Skip to content

Commit 1eb4204

Browse files
feat(components): use the React 19 syntax to declare components for React
https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript And update the React example to React 19.
1 parent f5c2c1c commit 1eb4204

18 files changed

+70
-82
lines changed

components/src/web-components/app.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { provide } from '@lit/context';
22
import { Task } from '@lit/task';
33
import { html, LitElement } from 'lit';
44
import { customElement, property } from 'lit/decorators.js';
5-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
65
import z from 'zod';
76

87
import { lapisContext } from './lapis-context';
@@ -88,11 +87,15 @@ declare global {
8887
}
8988
}
9089

91-
declare global {
90+
declare module 'react' {
9291
// eslint-disable-next-line @typescript-eslint/no-namespace
9392
namespace JSX {
9493
interface IntrinsicElements {
95-
'gs-app': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
94+
'gs-app': {
95+
lapis: string;
96+
// eslint-disable-next-line no-undef
97+
children: React.ReactNode;
98+
};
9699
}
97100
}
98101
}

components/src/web-components/input/gs-date-range-selector.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { DateRangeSelector, type DateRangeSelectorProps } from '../../preact/dateRangeSelector/date-range-selector';
54
import { type DateRangeOptionChangedEvent } from '../../preact/dateRangeSelector/dateRangeOption';
@@ -134,11 +133,11 @@ declare global {
134133
}
135134
}
136135

137-
declare global {
136+
declare module 'react' {
138137
// eslint-disable-next-line @typescript-eslint/no-namespace
139138
namespace JSX {
140139
interface IntrinsicElements {
141-
'gs-date-range-selector': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
140+
'gs-date-range-selector': Partial<DateRangeSelectorProps>;
142141
}
143142
}
144143
}

components/src/web-components/input/gs-lineage-filter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { type LineageFilterChangedEvent } from '../../preact/lineageFilter/LineageFilterChangedEvent';
54
import { LineageFilter, type LineageFilterProps } from '../../preact/lineageFilter/lineage-filter';
@@ -95,11 +94,11 @@ declare global {
9594
}
9695
}
9796

98-
declare global {
97+
declare module 'react' {
9998
// eslint-disable-next-line @typescript-eslint/no-namespace
10099
namespace JSX {
101100
interface IntrinsicElements {
102-
'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
101+
'gs-lineage-filter': Partial<LineageFilterProps>;
103102
}
104103
}
105104
}

components/src/web-components/input/gs-location-filter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { type LocationChangedEvent } from '../../preact/locationFilter/LocationChangedEvent';
54
import { LocationFilter, type LocationFilterProps } from '../../preact/locationFilter/location-filter';
@@ -99,11 +98,11 @@ declare global {
9998
}
10099
}
101100

102-
declare global {
101+
declare module 'react' {
103102
// eslint-disable-next-line @typescript-eslint/no-namespace
104103
namespace JSX {
105104
interface IntrinsicElements {
106-
'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
105+
'gs-location-filter': Partial<LocationFilterProps>;
107106
}
108107
}
109108
}

components/src/web-components/input/gs-mutation-filter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { ReferenceGenomesAwaiter } from '../../preact/components/ReferenceGenomesAwaiter';
54
import { MutationFilter, type MutationFilterProps } from '../../preact/mutationFilter/mutation-filter';
@@ -99,11 +98,11 @@ declare global {
9998
}
10099
}
101100

102-
declare global {
101+
declare module 'react' {
103102
// eslint-disable-next-line @typescript-eslint/no-namespace
104103
namespace JSX {
105104
interface IntrinsicElements {
106-
'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
105+
'gs-mutation-filter': Partial<MutationFilterProps>;
107106
}
108107
}
109108
}

components/src/web-components/input/gs-text-input.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { type TextInputChangedEvent } from '../../preact/textInput/TextInputChangedEvent';
54
import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
@@ -89,11 +88,11 @@ declare global {
8988
}
9089
}
9190

92-
declare global {
91+
declare module 'react' {
9392
// eslint-disable-next-line @typescript-eslint/no-namespace
9493
namespace JSX {
9594
interface IntrinsicElements {
96-
'gs-text-input': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
95+
'gs-text-input': Partial<TextInputProps>;
9796
}
9897
}
9998
}

components/src/web-components/visualization/gs-aggregate.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { Aggregate, type AggregateProps, type AggregateView } from '../../preact/aggregatedData/aggregate';
54
import { type Equals, type Expect } from '../../utils/typeAssertions';
@@ -126,11 +125,11 @@ declare global {
126125
}
127126
}
128127

129-
declare global {
128+
declare module 'react' {
130129
// eslint-disable-next-line @typescript-eslint/no-namespace
131130
namespace JSX {
132131
interface IntrinsicElements {
133-
'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
132+
'gs-aggregate': Partial<AggregateProps>;
134133
}
135134
}
136135
}

components/src/web-components/visualization/gs-mutation-comparison.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { MutationComparison, type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
54
import { type Equals, type Expect } from '../../utils/typeAssertions';
@@ -108,11 +107,11 @@ declare global {
108107
}
109108
}
110109

111-
declare global {
110+
declare module 'react' {
112111
// eslint-disable-next-line @typescript-eslint/no-namespace
113112
namespace JSX {
114113
interface IntrinsicElements {
115-
'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
114+
'gs-mutation-comparison': Partial<MutationComparisonProps>;
116115
}
117116
}
118117
}

components/src/web-components/visualization/gs-mutations-over-time.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { MutationsOverTime, type MutationsOverTimeProps } from '../../preact/mutationsOverTime/mutations-over-time';
54
import type { Equals, Expect } from '../../utils/typeAssertions';
@@ -108,11 +107,11 @@ declare global {
108107
}
109108
}
110109

111-
declare global {
110+
declare module 'react' {
112111
// eslint-disable-next-line @typescript-eslint/no-namespace
113112
namespace JSX {
114113
interface IntrinsicElements {
115-
'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
114+
'gs-mutations-over-time': Partial<MutationsOverTimeProps>;
116115
}
117116
}
118117
}

components/src/web-components/visualization/gs-mutations.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { customElement, property } from 'lit/decorators.js';
2-
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
32

43
import { Mutations, type MutationsProps } from '../../preact/mutations/mutations';
54
import type { Equals, Expect } from '../../utils/typeAssertions';
@@ -75,14 +74,14 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
7574
* If not provided, the Jaccard similarity is not computed.
7675
* For details, see the [Jaccard Similarity](#jaccard-similarity) section in the component description.
7776
*/
78-
@property({ type: Object })
77+
@property({type: Object})
7978
baselineLapisFilter:
8079
(Record<string, string | string[] | number | null | boolean | undefined> & {
81-
nucleotideMutations?: string[];
82-
aminoAcidMutations?: string[];
83-
nucleotideInsertions?: string[];
84-
aminoAcidInsertions?: string[];
85-
})
80+
nucleotideMutations?: string[];
81+
aminoAcidMutations?: string[];
82+
nucleotideInsertions?: string[];
83+
aminoAcidInsertions?: string[];
84+
})
8685
| undefined = undefined;
8786

8887
/**
@@ -141,11 +140,11 @@ declare global {
141140
}
142141
}
143142

144-
declare global {
143+
declare module 'react' {
145144
// eslint-disable-next-line @typescript-eslint/no-namespace
146145
namespace JSX {
147146
interface IntrinsicElements {
148-
'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
147+
'gs-mutations': Partial<MutationsProps>;
149148
}
150149
}
151150
}

0 commit comments

Comments
 (0)