@genspectrum/dashboard-components 0.12.1 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/custom-elements.json +292 -25
  2. package/dist/{LocationChangedEvent-CORvQvXv.js → LineageFilterChangedEvent-GedKNGFI.js} +25 -3
  3. package/dist/LineageFilterChangedEvent-GedKNGFI.js.map +1 -0
  4. package/dist/assets/mutationOverTimeWorker-B1-WrM4b.js.map +1 -0
  5. package/dist/components.d.ts +124 -25
  6. package/dist/components.js +765 -572
  7. package/dist/components.js.map +1 -1
  8. package/dist/style.css +3 -0
  9. package/dist/util.d.ts +48 -18
  10. package/dist/util.js +3 -1
  11. package/package.json +2 -2
  12. package/src/constants.ts +6 -0
  13. package/src/lapisApi/__mockData__/wiseReferenceGenome.json +9 -0
  14. package/src/lapisApi/lapisApi.ts +17 -0
  15. package/src/lapisApi/lapisTypes.ts +7 -1
  16. package/src/operator/FetchDetailsOperator.ts +28 -0
  17. package/src/preact/components/downshift-combobox.tsx +145 -0
  18. package/src/preact/components/tabs.tsx +1 -1
  19. package/src/preact/lineageFilter/LineageFilterChangedEvent.ts +11 -0
  20. package/src/preact/lineageFilter/fetchLineageAutocompleteList.spec.ts +16 -2
  21. package/src/preact/lineageFilter/fetchLineageAutocompleteList.ts +13 -2
  22. package/src/preact/lineageFilter/lineage-filter.stories.tsx +110 -9
  23. package/src/preact/lineageFilter/lineage-filter.tsx +40 -50
  24. package/src/preact/locationFilter/LocationChangedEvent.ts +1 -1
  25. package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +6 -2
  26. package/src/preact/locationFilter/fetchAutocompletionList.ts +16 -6
  27. package/src/preact/locationFilter/location-filter.stories.tsx +33 -30
  28. package/src/preact/locationFilter/location-filter.tsx +47 -144
  29. package/src/preact/mutationsOverTime/MutationOverTimeData.ts +9 -5
  30. package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +5 -3
  31. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +4 -7
  32. package/src/preact/textInput/TextInputChangedEvent.ts +1 -1
  33. package/src/preact/textInput/fetchStringAutocompleteList.ts +20 -0
  34. package/src/preact/textInput/text-input.stories.tsx +14 -11
  35. package/src/preact/textInput/text-input.tsx +39 -140
  36. package/src/preact/wastewater/mutationsOverTime/__mockData__/details.json +88 -0
  37. package/src/preact/wastewater/mutationsOverTime/computeWastewaterMutationsOverTimeDataPerLocation.spec.ts +159 -0
  38. package/src/preact/wastewater/mutationsOverTime/computeWastewaterMutationsOverTimeDataPerLocation.ts +51 -0
  39. package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.stories.tsx +71 -0
  40. package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.tsx +151 -0
  41. package/src/query/queryMutationsOverTime.ts +6 -14
  42. package/src/query/queryWastewaterMutationsOverTime.spec.ts +94 -0
  43. package/src/query/queryWastewaterMutationsOverTime.ts +55 -0
  44. package/src/types.ts +3 -0
  45. package/src/utilEntrypoint.ts +2 -0
  46. package/src/utils/map2d.ts +39 -0
  47. package/src/web-components/index.ts +1 -0
  48. package/src/web-components/input/gs-lineage-filter.stories.ts +120 -31
  49. package/src/web-components/input/gs-lineage-filter.tsx +24 -8
  50. package/src/web-components/input/gs-location-filter.stories.ts +9 -0
  51. package/src/web-components/input/gs-location-filter.tsx +21 -3
  52. package/src/web-components/input/gs-text-input.stories.ts +14 -5
  53. package/src/web-components/input/gs-text-input.tsx +23 -7
  54. package/src/web-components/wastewaterVisualization/gs-wastewater-mutations-over-time.stories.ts +82 -0
  55. package/src/web-components/wastewaterVisualization/gs-wastewater-mutations-over-time.tsx +112 -0
  56. package/src/web-components/wastewaterVisualization/index.ts +1 -0
  57. package/standalone-bundle/assets/{mutationOverTimeWorker-DEybsZ5r.js.map → mutationOverTimeWorker-Cls1J0cl.js.map} +1 -1
  58. package/standalone-bundle/dashboard-components.js +6972 -6796
  59. package/standalone-bundle/dashboard-components.js.map +1 -1
  60. package/standalone-bundle/style.css +1 -1
  61. package/dist/LocationChangedEvent-CORvQvXv.js.map +0 -1
  62. package/dist/assets/mutationOverTimeWorker-DTv93Ere.js.map +0 -1
  63. package/src/preact/textInput/fetchAutocompleteList.ts +0 -9
@@ -1,6 +1,7 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
  import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
+ import { type TextInputChangedEvent } from '../../preact/textInput/TextInputChangedEvent';
4
5
  import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
5
6
  import type { Equals, Expect } from '../../utils/typeAssertions';
6
7
  import { PreactLitAdapter } from '../PreactLitAdapter';
@@ -11,7 +12,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
11
12
  *
12
13
  * This component provides a text input field to specify filters for arbitrary fields of this LAPIS instance.
13
14
  *
14
- * @fires {CustomEvent<Record<string, string>>} gs-text-input-changed
15
+ * @fires {CustomEvent<Record<string, string | undefined>>} gs-text-input-changed
15
16
  * Fired when the input field is changed.
16
17
  * The `details` of this event contain an object with the `lapisField` as key and the input value as value.
17
18
  * Example:
@@ -27,7 +28,7 @@ export class TextInputComponent extends PreactLitAdapter {
27
28
  * The initial value to use for this text input.
28
29
  */
29
30
  @property()
30
- initialValue: string | undefined = undefined;
31
+ value: string | undefined = undefined;
31
32
 
32
33
  /**
33
34
  * Required.
@@ -38,6 +39,19 @@ export class TextInputComponent extends PreactLitAdapter {
38
39
  @property()
39
40
  lapisField = '';
40
41
 
42
+ /**
43
+ * The filter that is used to fetch the available the autocomplete options.
44
+ * If not set it fetches all available options.
45
+ * It must be a valid LAPIS filter object.
46
+ */
47
+ @property({ type: Object })
48
+ lapisFilter: Record<string, string | string[] | number | null | boolean | undefined> & {
49
+ nucleotideMutations?: string[];
50
+ aminoAcidMutations?: string[];
51
+ nucleotideInsertions?: string[];
52
+ aminoAcidInsertions?: string[];
53
+ } = {};
54
+
41
55
  /**
42
56
  * The placeholder text to display in the input field.
43
57
  */
@@ -56,8 +70,9 @@ export class TextInputComponent extends PreactLitAdapter {
56
70
  return (
57
71
  <TextInput
58
72
  lapisField={this.lapisField}
73
+ lapisFilter={this.lapisFilter}
59
74
  placeholderText={this.placeholderText}
60
- initialValue={this.initialValue}
75
+ value={this.value}
61
76
  width={this.width}
62
77
  />
63
78
  );
@@ -70,7 +85,7 @@ declare global {
70
85
  }
71
86
 
72
87
  interface HTMLElementEventMap {
73
- 'gs-text-input-changed': CustomEvent<Record<string, string>>;
88
+ 'gs-text-input-changed': TextInputChangedEvent;
74
89
  }
75
90
  }
76
91
 
@@ -84,10 +99,11 @@ declare global {
84
99
  }
85
100
 
86
101
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
87
- type InitialValueMatches = Expect<
88
- Equals<typeof TextInputComponent.prototype.initialValue, TextInputProps['initialValue']>
89
- >;
102
+ type InitialValueMatches = Expect<Equals<typeof TextInputComponent.prototype.value, TextInputProps['value']>>;
90
103
  type LapisFieldMatches = Expect<Equals<typeof TextInputComponent.prototype.lapisField, TextInputProps['lapisField']>>;
104
+ type LapisFilterMatches = Expect<
105
+ Equals<typeof TextInputComponent.prototype.lapisFilter, TextInputProps['lapisFilter']>
106
+ >;
91
107
  type PlaceholderTextMatches = Expect<
92
108
  Equals<typeof TextInputComponent.prototype.placeholderText, TextInputProps['placeholderText']>
93
109
  >;
@@ -0,0 +1,82 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+ import { html } from 'lit';
3
+
4
+ import './gs-wastewater-mutations-over-time';
5
+ import '../app';
6
+ import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
7
+ import { WISE_DETAILS_ENDPOINT, WISE_LAPIS_URL } from '../../constants';
8
+ import details from '../../preact/wastewater/mutationsOverTime/__mockData__/details.json';
9
+ import { type WastewaterMutationsOverTimeProps } from '../../preact/wastewater/mutationsOverTime/wastewater-mutations-over-time';
10
+
11
+ const codeExample = String.raw`
12
+ <gs-wastewater-mutations-over-time
13
+ lapisFilter='{ "dateFrom": "2024-01-01" }'
14
+ sequenceType='nucleotide'
15
+ width='100%'
16
+ height='700px'
17
+ ></gs-wastewater-mutations-over-time>`;
18
+
19
+ const meta: Meta<Required<WastewaterMutationsOverTimeProps>> = {
20
+ title: 'Wastewater visualization/Wastewater mutations over time',
21
+ component: 'gs-wastewater-mutations-over-time',
22
+ argTypes: {
23
+ lapisFilter: { control: 'object' },
24
+ sequenceType: {
25
+ options: ['nucleotide', 'amino acid'],
26
+ control: { type: 'radio' },
27
+ },
28
+ width: { control: 'text' },
29
+ height: { control: 'text' },
30
+ },
31
+ args: {
32
+ lapisFilter: { versionStatus: 'LATEST_VERSION', isRevocation: false },
33
+ sequenceType: 'nucleotide',
34
+ width: '100%',
35
+ height: '700px',
36
+ },
37
+ parameters: withComponentDocs({
38
+ componentDocs: {
39
+ opensShadowDom: true,
40
+ expectsChildren: false,
41
+ codeExample,
42
+ },
43
+ fetchMock: {},
44
+ }),
45
+ tags: ['autodocs'],
46
+ };
47
+
48
+ export default meta;
49
+
50
+ export const WastewaterMutationsOverTime: StoryObj<Required<WastewaterMutationsOverTimeProps>> = {
51
+ render: (args) => html`
52
+ <gs-app lapis="${WISE_LAPIS_URL}">
53
+ <gs-wastewater-mutations-over-time
54
+ .lapisFilter=${args.lapisFilter}
55
+ .sequenceType=${args.sequenceType}
56
+ .width=${args.width}
57
+ .height=${args.height}
58
+ ></gs-wastewater-mutations-over-time>
59
+ </gs-app>
60
+ `,
61
+ parameters: {
62
+ fetchMock: {
63
+ mocks: [
64
+ {
65
+ matcher: {
66
+ name: 'details',
67
+ url: WISE_DETAILS_ENDPOINT,
68
+ body: {
69
+ fields: ['date', 'location', 'nucleotideMutationFrequency', 'aminoAcidMutationFrequency'],
70
+ versionStatus: 'LATEST_VERSION',
71
+ isRevocation: false,
72
+ },
73
+ },
74
+ response: {
75
+ status: 200,
76
+ body: details,
77
+ },
78
+ },
79
+ ],
80
+ },
81
+ },
82
+ };
@@ -0,0 +1,112 @@
1
+ import { customElement, property } from 'lit/decorators.js';
2
+ import { type DetailedHTMLProps, type HTMLAttributes } from 'react';
3
+
4
+ import {
5
+ WastewaterMutationsOverTime,
6
+ type WastewaterMutationsOverTimeProps,
7
+ } from '../../preact/wastewater/mutationsOverTime/wastewater-mutations-over-time';
8
+ import { type Equals, type Expect } from '../../utils/typeAssertions';
9
+ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
10
+
11
+ /**
12
+ * ## Context
13
+ *
14
+ * This component displays mutations for Swiss wastewater data generated within the WISE consortium. It is designed
15
+ * only for this purpose and is not designed to be reused outside the WISE project.
16
+ *
17
+ * It relies on a LAPIS instance that has the fields `nucleotideMutationFrequency` and `aminoAcidMutationFrequency`.
18
+ * Those fields are expected to be JSON strings of the format `{ [mutation]: frequency | null }`
19
+ * (e.g. `{ "A123T": 0.5, "C456G": 0.7, "T789G": null }`).
20
+ *
21
+ * The component will stratify by `location`.
22
+ * Every location will be rendered in a separate tab.
23
+ * The content of the tab is a "mutations over time" grid, similar to the one used in the `gs-mutations-over-time` component.
24
+ *
25
+ * This component also assumes that the LAPIS instance has the field `date` which can be used for the time axis.
26
+ */
27
+ @customElement('gs-wastewater-mutations-over-time')
28
+ export class WastewaterMutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
29
+ /**
30
+ * Required.
31
+ *
32
+ * LAPIS filter to select the displayed data.
33
+ */
34
+ @property({ type: Object })
35
+ lapisFilter: Record<string, string | string[] | number | null | boolean | undefined> & {
36
+ nucleotideMutations?: string[];
37
+ aminoAcidMutations?: string[];
38
+ nucleotideInsertions?: string[];
39
+ aminoAcidInsertions?: string[];
40
+ } = {};
41
+
42
+ /**
43
+ * Required.
44
+ *
45
+ * Whether to display nucleotide or amino acid mutations.
46
+ */
47
+ @property({ type: String })
48
+ sequenceType: 'nucleotide' | 'amino acid' = 'nucleotide';
49
+
50
+ /**
51
+ * The width of the component.
52
+ *
53
+ * Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
54
+ */
55
+ @property({ type: String })
56
+ width: string = '100%';
57
+
58
+ /**
59
+ * The height of the component.
60
+ *
61
+ * Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
62
+ */
63
+ @property({ type: String })
64
+ height: string = '700px';
65
+
66
+ override render() {
67
+ return (
68
+ <WastewaterMutationsOverTime
69
+ lapisFilter={this.lapisFilter}
70
+ sequenceType={this.sequenceType}
71
+ width={this.width}
72
+ height={this.height}
73
+ />
74
+ );
75
+ }
76
+ }
77
+
78
+ declare global {
79
+ interface HTMLElementTagNameMap {
80
+ 'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
81
+ }
82
+ }
83
+
84
+ declare global {
85
+ // eslint-disable-next-line @typescript-eslint/no-namespace
86
+ namespace JSX {
87
+ interface IntrinsicElements {
88
+ 'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
89
+ }
90
+ }
91
+ }
92
+
93
+ /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
94
+ type LapisFilterMatches = Expect<
95
+ Equals<
96
+ typeof WastewaterMutationsOverTimeComponent.prototype.lapisFilter,
97
+ WastewaterMutationsOverTimeProps['lapisFilter']
98
+ >
99
+ >;
100
+ type SequenceTypeMatches = Expect<
101
+ Equals<
102
+ typeof WastewaterMutationsOverTimeComponent.prototype.sequenceType,
103
+ WastewaterMutationsOverTimeProps['sequenceType']
104
+ >
105
+ >;
106
+ type WidthMatches = Expect<
107
+ Equals<typeof WastewaterMutationsOverTimeComponent.prototype.width, WastewaterMutationsOverTimeProps['width']>
108
+ >;
109
+ type HeightMatches = Expect<
110
+ Equals<typeof WastewaterMutationsOverTimeComponent.prototype.height, WastewaterMutationsOverTimeProps['height']>
111
+ >;
112
+ /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -0,0 +1 @@
1
+ export { WastewaterMutationsOverTimeComponent } from './gs-wastewater-mutations-over-time';