Skip to content

Commit

Permalink
feat(components): use the React 19 syntax to declare components for R…
Browse files Browse the repository at this point in the history
  • Loading branch information
fengelniederhammer committed Jan 23, 2025
1 parent f5c2c1c commit 55f419b
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 82 deletions.
8 changes: 5 additions & 3 deletions components/src/web-components/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { provide } from '@lit/context';
import { Task } from '@lit/task';
import { html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
import z from 'zod';

import { lapisContext } from './lapis-context';
Expand Down Expand Up @@ -88,11 +87,14 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-app': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-app': {
lapis: string;
children: React.ReactNode;

Check failure on line 96 in components/src/web-components/app.ts

View workflow job for this annotation

GitHub Actions / Run checks and build

'React' is not defined
};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { DateRangeSelector, type DateRangeSelectorProps } from '../../preact/dateRangeSelector/date-range-selector';
import { type DateRangeOptionChangedEvent } from '../../preact/dateRangeSelector/dateRangeOption';
Expand Down Expand Up @@ -134,11 +133,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-date-range-selector': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-date-range-selector': Partial<DateRangeSelectorProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/input/gs-lineage-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { type LineageFilterChangedEvent } from '../../preact/lineageFilter/LineageFilterChangedEvent';
import { LineageFilter, type LineageFilterProps } from '../../preact/lineageFilter/lineage-filter';
Expand Down Expand Up @@ -95,11 +94,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-lineage-filter': Partial<LineageFilterProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/input/gs-location-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { type LocationChangedEvent } from '../../preact/locationFilter/LocationChangedEvent';
import { LocationFilter, type LocationFilterProps } from '../../preact/locationFilter/location-filter';
Expand Down Expand Up @@ -99,11 +98,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-location-filter': Partial<LocationFilterProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/input/gs-mutation-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { ReferenceGenomesAwaiter } from '../../preact/components/ReferenceGenomesAwaiter';
import { MutationFilter, type MutationFilterProps } from '../../preact/mutationFilter/mutation-filter';
Expand Down Expand Up @@ -99,11 +98,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-mutation-filter': Partial<MutationFilterProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/input/gs-text-input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { type TextInputChangedEvent } from '../../preact/textInput/TextInputChangedEvent';
import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
Expand Down Expand Up @@ -89,11 +88,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-text-input': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-text-input': Partial<TextInputProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/visualization/gs-aggregate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { Aggregate, type AggregateProps, type AggregateView } from '../../preact/aggregatedData/aggregate';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -126,11 +125,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-aggregate': Partial<AggregateProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { MutationComparison, type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -108,11 +107,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-mutation-comparison': Partial<MutationComparisonProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { MutationsOverTime, type MutationsOverTimeProps } from '../../preact/mutationsOverTime/mutations-over-time';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -108,11 +107,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-mutations-over-time': Partial<MutationsOverTimeProps>;
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions components/src/web-components/visualization/gs-mutations.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { Mutations, type MutationsProps } from '../../preact/mutations/mutations';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -75,14 +74,14 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
* If not provided, the Jaccard similarity is not computed.
* For details, see the [Jaccard Similarity](#jaccard-similarity) section in the component description.
*/
@property({ type: Object })
@property({type: Object})
baselineLapisFilter:
(Record<string, string | string[] | number | null | boolean | undefined> & {
nucleotideMutations?: string[];
aminoAcidMutations?: string[];
nucleotideInsertions?: string[];
aminoAcidInsertions?: string[];
})
nucleotideMutations?: string[];
aminoAcidMutations?: string[];
nucleotideInsertions?: string[];
aminoAcidInsertions?: string[];
})
| undefined = undefined;

/**
Expand Down Expand Up @@ -141,11 +140,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-mutations': Partial<MutationsProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import {
NumberSequencesOverTime,
Expand Down Expand Up @@ -121,11 +120,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-number-sequences-over-time': Partial<NumberSequencesOverTimeProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { PrevalenceOverTime, type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -188,11 +187,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-prevalence-over-time': Partial<PrevalenceOverTimeProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import {
RelativeGrowthAdvantage,
Expand Down Expand Up @@ -142,11 +141,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-relative-growth-advantage': Partial<RelativeGrowthAdvantageProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import leafletStyle from 'leaflet/dist/leaflet.css?inline';
import { unsafeCSS } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import leafletStyleModifications from '../../preact/map/leafletStyleModifications.css?inline';
import { SequencesByLocation, type SequencesByLocationProps } from '../../preact/map/sequences-by-location';
Expand Down Expand Up @@ -211,11 +210,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-sequences-by-location': Partial<SequencesByLocationProps>;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/src/web-components/visualization/gs-statistics.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { Statistics, type StatisticsProps } from '../../preact/statistic/statistics';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -71,11 +70,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-statistics': Partial<StatisticsProps>;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import {
WastewaterMutationsOverTime,
Expand Down Expand Up @@ -81,11 +80,11 @@ declare global {
}
}

declare global {
declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
'gs-wastewater-mutations-over-time': Partial<WastewaterMutationsOverTimeProps>;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/React/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
},
"dependencies": {
"@genspectrum/dashboard-components": "file:../../components/genspectrum-dashboard-components.tgz",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"typescript": "^5.2.2",
"vite": "^5.2.0"
"vite": "^6.0.11"
}
}
Loading

0 comments on commit 55f419b

Please sign in to comment.