@genspectrum/dashboard-components 0.1.2 → 0.1.4

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 (81) hide show
  1. package/README.md +1 -1
  2. package/custom-elements.json +453 -67
  3. package/dist/dashboard-components.js +778 -488
  4. package/dist/dashboard-components.js.map +1 -1
  5. package/dist/genspectrum-components.d.ts +277 -50
  6. package/dist/style.css +132 -139
  7. package/package.json +9 -5
  8. package/src/lapisApi/lapisApi.ts +1 -1
  9. package/src/preact/aggregatedData/__mockData__/aggregated.json +585 -0
  10. package/src/preact/aggregatedData/aggregate-table.tsx +32 -0
  11. package/src/preact/aggregatedData/aggregate.stories.tsx +53 -0
  12. package/src/preact/aggregatedData/aggregate.tsx +102 -0
  13. package/src/preact/components/ReferenceGenomesAwaiter.tsx +25 -0
  14. package/src/preact/components/csv-download-button.tsx +8 -2
  15. package/src/preact/components/headline.tsx +16 -4
  16. package/src/preact/components/min-max-range-slider.tsx +4 -4
  17. package/src/preact/components/percent-intput.tsx +2 -3
  18. package/src/preact/components/resize-container.tsx +23 -0
  19. package/src/preact/components/table.tsx +1 -0
  20. package/src/preact/components/tabs.stories.tsx +2 -2
  21. package/src/preact/components/tabs.tsx +47 -24
  22. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +36 -4
  23. package/src/preact/dateRangeSelector/date-range-selector.tsx +57 -43
  24. package/src/preact/locationFilter/location-filter.tsx +2 -2
  25. package/src/preact/mutationComparison/getMutationComparisonTableData.spec.ts +5 -5
  26. package/src/preact/mutationComparison/getMutationComparisonTableData.ts +45 -10
  27. package/src/preact/mutationComparison/mutation-comparison-table.tsx +20 -22
  28. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +6 -3
  29. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +8 -1
  30. package/src/preact/mutationComparison/mutation-comparison.tsx +13 -4
  31. package/src/preact/mutationFilter/mutation-filter.stories.tsx +70 -31
  32. package/src/preact/mutationFilter/mutation-filter.tsx +62 -14
  33. package/src/preact/mutations/getInsertionsTableData.spec.ts +6 -4
  34. package/src/preact/mutations/getInsertionsTableData.ts +1 -1
  35. package/src/preact/mutations/getMutationsTableData.spec.ts +9 -19
  36. package/src/preact/mutations/getMutationsTableData.ts +1 -1
  37. package/src/preact/mutations/mutations-insertions-table.tsx +3 -1
  38. package/src/preact/mutations/mutations-table.tsx +3 -1
  39. package/src/preact/mutations/mutations.stories.tsx +8 -1
  40. package/src/preact/mutations/mutations.tsx +16 -5
  41. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +1 -0
  42. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +1 -0
  43. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +1 -0
  44. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +4 -0
  45. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +17 -9
  46. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +8 -5
  47. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +12 -0
  48. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +13 -8
  49. package/src/preact/shared/sort/sortInsertions.spec.ts +11 -10
  50. package/src/preact/shared/sort/sortInsertions.ts +10 -17
  51. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.spec.ts +19 -10
  52. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +45 -12
  53. package/src/preact/textInput/text-input.stories.tsx +22 -1
  54. package/src/preact/textInput/text-input.tsx +3 -1
  55. package/src/query/queryAggregateData.spec.ts +32 -0
  56. package/src/query/queryAggregateData.ts +25 -0
  57. package/src/utils/typeAssertions.spec.ts +31 -0
  58. package/src/utils/typeAssertions.ts +16 -0
  59. package/src/web-components/PreactLitAdapter.tsx +0 -1
  60. package/src/web-components/app.stories.ts +129 -0
  61. package/src/web-components/app.ts +27 -6
  62. package/src/web-components/display/aggregate-component.stories.ts +73 -0
  63. package/src/web-components/display/aggregate-component.tsx +58 -0
  64. package/src/web-components/display/index.ts +1 -0
  65. package/src/web-components/display/mutation-comparison-component.stories.ts +29 -11
  66. package/src/web-components/display/mutation-comparison-component.tsx +72 -4
  67. package/src/web-components/display/mutations-component.stories.ts +14 -13
  68. package/src/web-components/display/mutations-component.tsx +14 -1
  69. package/src/web-components/display/prevalence-over-time-component.stories.ts +20 -18
  70. package/src/web-components/display/prevalence-over-time-component.tsx +12 -0
  71. package/src/web-components/display/relative-growth-advantage-component.stories.ts +11 -10
  72. package/src/web-components/display/relative-growth-advantage-component.tsx +12 -0
  73. package/src/web-components/input/date-range-selector-component.stories.ts +35 -8
  74. package/src/web-components/input/date-range-selector-component.tsx +18 -5
  75. package/src/web-components/input/location-filter-component.stories.ts +17 -8
  76. package/src/web-components/input/location-filter-component.tsx +2 -6
  77. package/src/web-components/input/mutation-filter-component.stories.ts +20 -9
  78. package/src/web-components/input/mutation-filter-component.tsx +10 -2
  79. package/src/web-components/input/text-input-component.stories.ts +13 -4
  80. package/src/web-components/input/text-input-component.tsx +11 -2
  81. package/src/web-components/input/location-filter.mdx +0 -25
@@ -7,18 +7,76 @@ import { PropertyValues } from '@lit/reactive-element';
7
7
  import { ReactiveElement } from '@lit/reactive-element';
8
8
  import { TemplateResult } from 'lit-html';
9
9
 
10
+ /**
11
+ * ## Context
12
+ *
13
+ * This component displays aggregated data, which can provide an overview of the underlying data.
14
+ *
15
+ * It expects a list of fields to aggregate by and a filter to apply to the data.
16
+ */
17
+ export declare class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
18
+ /**
19
+ * The fields to aggregate by.
20
+ */
21
+ fields: string[];
22
+ /**
23
+ * The views are used to display the aggregated data.
24
+ * In the table view, the data is presented in a table format where each field is a column,
25
+ * along with the aggregated value and its proportion.
26
+ * The proportion represents the ratio of the aggregated value to the total count of the data
27
+ * (considering the applied filter).
28
+ */
29
+ views: View_4[];
30
+ /**
31
+ * The filter to apply to the data.
32
+ */
33
+ filter: LapisFilter;
34
+ /**
35
+ * The size of the component.
36
+ *
37
+ * If not set, the component will take the full width of its container with height 700px.
38
+ *
39
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
40
+ * If the unit is %, the size will be relative to the container of the component.
41
+ */
42
+ size: {
43
+ width?: string;
44
+ height?: string;
45
+ } | undefined;
46
+ render(): JSX_2.Element;
47
+ }
48
+
49
+ /**
50
+ * ## Context
51
+ *
52
+ * This component provides the main application context.
53
+ * All other `gs-*` components must be (possibly nested) children of this component.
54
+ * It makes use of the [Lit Context](https://lit.dev/docs/data/context/) to
55
+ * - provide the URL to the LAPIS instance to all its children
56
+ * - fetch the reference genomes from LAPIS and provide it to all its children
57
+ *
58
+ * This will show an error message if the reference genome cannot be fetched
59
+ * (e.g., due to an invalid LAPIS URL).
60
+ *
61
+ * ## Shadow DOM
62
+ *
63
+ * This component does __not__ use a shadow DOM. Children of this component will be rendered directly in the light DOM.
64
+ */
10
65
  export declare class App extends LitElement {
66
+ /**
67
+ * The URL of the LAPIS instance that all children of this component will use.
68
+ */
11
69
  lapis: string;
12
- referenceGenome: ReferenceGenome;
13
- private updateReferenceGenome;
70
+ /* Excluded from this release type: referenceGenome */
71
+ /* Excluded from this release type: updateReferenceGenome */
14
72
  render(): TemplateResult<1> | undefined;
15
73
  createRenderRoot(): this;
16
74
  }
17
75
 
18
76
  declare type ConfidenceIntervalMethod = 'wilson' | 'none';
19
77
 
20
- declare type CustomSelectOption = {
21
- label: string;
78
+ declare type CustomSelectOption<CustomLabel extends string> = {
79
+ label: CustomLabel;
22
80
  dateFrom: string;
23
81
  dateTo: string;
24
82
  };
@@ -26,19 +84,38 @@ declare type CustomSelectOption = {
26
84
  /**
27
85
  * @fires {CustomEvent<{ dateFrom: string; dateTo: string; }>} gs-date-range-changed - When the date range has changed
28
86
  */
29
- export declare class DateRangeSelectorComponent extends PreactLitAdapter {
30
- customSelectOptions: CustomSelectOption[];
87
+ export declare class DateRangeSelectorComponent<CustomLabel extends string> extends PreactLitAdapter {
88
+ customSelectOptions: CustomSelectOption<CustomLabel>[];
31
89
  earliestDate: string | undefined;
90
+ initialValue: PresetOptionValues | CustomLabel | string | undefined;
32
91
  render(): JSX_2.Element;
33
92
  }
34
93
 
94
+ declare class Deletion implements Mutation {
95
+ readonly segment: string | undefined;
96
+ readonly valueAtReference: string | undefined;
97
+ readonly position: number;
98
+ readonly code: string;
99
+ constructor(segment: string | undefined, valueAtReference: string | undefined, position: number);
100
+ equals(other: Mutation): boolean;
101
+ toString(): string;
102
+ static parse(mutationStr: string): Deletion | null;
103
+ }
104
+
105
+ declare class Insertion implements Mutation {
106
+ readonly segment: string | undefined;
107
+ readonly position: number;
108
+ readonly insertedSymbols: string;
109
+ readonly code: string;
110
+ constructor(segment: string | undefined, position: number, insertedSymbols: string);
111
+ equals(other: Mutation): boolean;
112
+ toString(): string;
113
+ static parse(mutationStr: string): Insertion | null;
114
+ }
115
+
35
116
  declare type LapisFilter = Record<string, string | number | null | boolean>;
36
117
 
37
118
  /**
38
- * ## Tag
39
- *
40
- * `gs-location-filter`
41
- *
42
119
  * ## Context
43
120
  *
44
121
  * This component provides an input field to specify filters for locations.
@@ -70,7 +147,7 @@ export declare class LocationFilterComponent extends PreactLitAdapter {
70
147
  * The initial value to use for this location filter.
71
148
  * Must be of the form `valueForField1 / valueForField2 / ... / valueForFieldN`.
72
149
  */
73
- value: string;
150
+ initialValue: string;
74
151
  /**
75
152
  * The fields to display in the location filter, in hierarchical order.
76
153
  * The top-level field should be the first entry in the array.
@@ -81,16 +158,72 @@ export declare class LocationFilterComponent extends PreactLitAdapter {
81
158
  render(): JSX_2.Element;
82
159
  }
83
160
 
84
- export declare class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
85
- variants: MutationComparisonVariant[];
86
- sequenceType: SequenceType;
87
- views: View[];
88
- render(): JSX_2.Element;
161
+ declare interface Mutation {
162
+ readonly segment: string | undefined;
163
+ readonly position: number;
164
+ readonly code: string;
165
+ equals(other: Mutation): boolean;
166
+ toString(): string;
89
167
  }
90
168
 
91
- declare interface MutationComparisonVariant {
92
- lapisFilter: LapisFilter;
93
- displayName: string;
169
+ /**
170
+ * This component allows to compare mutations between different variants.
171
+ * A variant is defined by its LAPIS filter.
172
+ *
173
+ * It only shows substitutions and deletions, it does not show insertions.
174
+ *
175
+ * ## Views
176
+ *
177
+ * ### Table View
178
+ *
179
+ * The table view shows mutations
180
+ * and the proportions with which the mutation occurs in the respective variant.
181
+ * It only shows mutations that are present in at least one of the variants
182
+ * and where the proportion is within the selected proportion interval for at least one variant.
183
+ *
184
+ * ### Venn View
185
+ *
186
+ * The Venn view shows the overlap of mutations between the variants in a Venn diagram.
187
+ * A variant is considered to have a certain mutation,
188
+ * if the proportion of the mutation in the variant is within the selected proportion interval.
189
+ * Thus, changing the proportion interval may change a mutations from being "common" between variant
190
+ * to being "for one variant only".
191
+ */
192
+ export declare class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
193
+ /**
194
+ * An array of variants to compare.
195
+ *
196
+ * The `lapisFilter` will be sent as is to LAPIS to filter the mutation data.
197
+ * It must be a valid LAPIS filter object.
198
+ *
199
+ * The `displayName` will be used as the label for the variant in the views.
200
+ * It should be human-readable.
201
+ */
202
+ variants: {
203
+ lapisFilter: Record<string, string | number | null | boolean>;
204
+ displayName: string;
205
+ }[];
206
+ /**
207
+ * The type of the sequence for which the mutations should be shown.
208
+ */
209
+ sequenceType: 'nucleotide' | 'amino acid';
210
+ /**
211
+ * A list of tabs with views that this component should provide.
212
+ */
213
+ views: ('table' | 'venn')[];
214
+ /**
215
+ * The size of the component.
216
+ *
217
+ * If not set, the component will take the full width of its container with height 700px.
218
+ *
219
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
220
+ * If the unit is %, the size will be relative to the container of the component.
221
+ */
222
+ size: {
223
+ width?: string;
224
+ height?: string;
225
+ } | undefined;
226
+ render(): JSX_2.Element;
94
227
  }
95
228
 
96
229
  /**
@@ -98,13 +231,26 @@ declare interface MutationComparisonVariant {
98
231
  * @fires {CustomEvent<SelectedMutationFilterStrings>} gs-mutation-filter-on-blur - When the mutation filter has lost focus
99
232
  */
100
233
  export declare class MutationFilterComponent extends PreactLitAdapter {
234
+ initialValue: SelectedMutationFilterStrings | string[] | undefined;
101
235
  render(): JSX_2.Element;
102
236
  }
103
237
 
104
238
  export declare class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
105
239
  variant: LapisFilter;
106
240
  sequenceType: SequenceType;
107
- views: View_2[];
241
+ views: View[];
242
+ /**
243
+ * The size of the component.
244
+ *
245
+ * If not set, the component will take the full width of its container with height 700px.
246
+ *
247
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
248
+ * If the unit is %, the size will be relative to the container of the component.
249
+ */
250
+ size: {
251
+ width?: string;
252
+ height?: string;
253
+ } | undefined;
108
254
  render(): JSX_2.Element;
109
255
  }
110
256
 
@@ -124,13 +270,51 @@ declare abstract class PreactLitAdapterWithGridJsStyles extends PreactLitAdapter
124
270
  static styles: CSSResult[];
125
271
  }
126
272
 
273
+ declare type PresetOptionValues = keyof typeof presets;
274
+
275
+ declare const presets: {
276
+ custom: {
277
+ label: string;
278
+ };
279
+ allTimes: {
280
+ label: string;
281
+ };
282
+ last2Weeks: {
283
+ label: string;
284
+ };
285
+ lastMonth: {
286
+ label: string;
287
+ };
288
+ last2Months: {
289
+ label: string;
290
+ };
291
+ last3Months: {
292
+ label: string;
293
+ };
294
+ last6Months: {
295
+ label: string;
296
+ };
297
+ };
298
+
127
299
  export declare class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
128
300
  numerator: NamedLapisFilter | NamedLapisFilter[];
129
301
  denominator: NamedLapisFilter;
130
302
  granularity: TemporalGranularity;
131
303
  smoothingWindow: number;
132
- views: View_3[];
304
+ views: View_2[];
133
305
  confidenceIntervalMethods: ConfidenceIntervalMethod[];
306
+ /**
307
+ * The size of the component.
308
+ *
309
+ * If not set, the component will take the full width of its container with height 700px.
310
+ *
311
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
312
+ * If the unit is %, the size will be relative to the container of the component.
313
+ */
314
+ size: {
315
+ width?: string;
316
+ height?: string;
317
+ } | undefined;
134
318
  render(): JSX_2.Element;
135
319
  }
136
320
 
@@ -181,30 +365,66 @@ export declare class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
181
365
  numerator: LapisFilter;
182
366
  denominator: LapisFilter;
183
367
  generationTime: number;
184
- views: View_4[];
368
+ views: View_3[];
369
+ /**
370
+ * The size of the component.
371
+ *
372
+ * If not set, the component will take the full width of its container with height 700px.
373
+ *
374
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
375
+ * If the unit is %, the size will be relative to the container of the component.
376
+ */
377
+ size: {
378
+ width?: string;
379
+ height?: string;
380
+ } | undefined;
185
381
  render(): JSX_2.Element;
186
382
  }
187
383
 
384
+ declare type SelectedFilters = {
385
+ nucleotideMutations: (Substitution | Deletion)[];
386
+ aminoAcidMutations: (Substitution | Deletion)[];
387
+ nucleotideInsertions: Insertion[];
388
+ aminoAcidInsertions: Insertion[];
389
+ };
390
+
391
+ declare type SelectedMutationFilterStrings = {
392
+ [Key in keyof SelectedFilters]: string[];
393
+ };
394
+
188
395
  declare type SequenceType = 'nucleotide' | 'amino acid';
189
396
 
397
+ declare class Substitution implements Mutation {
398
+ readonly segment: string | undefined;
399
+ readonly valueAtReference: string | undefined;
400
+ readonly substitutionValue: string | undefined;
401
+ readonly position: number;
402
+ readonly code: string;
403
+ constructor(segment: string | undefined, valueAtReference: string | undefined, substitutionValue: string | undefined, position: number);
404
+ equals(other: Mutation): boolean;
405
+ toString(): string;
406
+ static parse(mutationStr: string): Substitution | null;
407
+ }
408
+
190
409
  declare type TemporalGranularity = 'day' | 'week' | 'month' | 'year';
191
410
 
192
411
  /**
193
412
  * @fires {CustomEvent<Record<string, string>>} gs-text-input-changed - When the text input has changed
194
413
  */
195
414
  export declare class TextInputComponent extends PreactLitAdapter {
415
+ initialValue: string | undefined;
196
416
  lapisField: string;
197
- placeholderText: string;
417
+ placeholderText: string | undefined;
198
418
  render(): JSX_2.Element;
199
419
  }
200
420
 
201
- declare type View = 'table' | 'venn';
421
+ declare type View = 'table' | 'grid' | 'insertions';
202
422
 
203
- declare type View_2 = 'table' | 'grid' | 'insertions';
423
+ declare type View_2 = 'bar' | 'line' | 'bubble' | 'table';
204
424
 
205
- declare type View_3 = 'bar' | 'line' | 'bubble' | 'table';
425
+ declare type View_3 = 'line';
206
426
 
207
- declare type View_4 = 'line';
427
+ declare type View_4 = 'table';
208
428
 
209
429
  export { }
210
430
 
@@ -218,72 +438,79 @@ declare global {
218
438
 
219
439
  declare global {
220
440
  interface HTMLElementTagNameMap {
221
- 'gs-date-range-selector': DateRangeSelectorComponent;
222
- }
223
- interface HTMLElementEventMap {
224
- 'gs-date-range-changed': CustomEvent<{
225
- dateFrom: string;
226
- dateTo: string;
227
- }>;
441
+ 'gs-mutation-comparison-component': MutationComparisonComponent;
228
442
  }
229
443
  }
230
444
 
231
445
 
232
446
  declare global {
233
447
  interface HTMLElementTagNameMap {
234
- 'gs-mutation-filter': TextInputComponent;
235
- }
236
- interface HTMLElementEventMap {
237
- 'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
238
- 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
448
+ 'gs-mutations-component': MutationsComponent;
239
449
  }
240
450
  }
241
451
 
242
452
 
243
453
  declare global {
244
454
  interface HTMLElementTagNameMap {
245
- 'gs-text-input': TextInputComponent;
246
- }
247
- interface HTMLElementEventMap {
248
- 'gs-text-input-changed': CustomEvent<Record<string, string>>;
455
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
249
456
  }
250
457
  }
251
458
 
252
459
 
253
460
  declare global {
254
461
  interface HTMLElementTagNameMap {
255
- 'gs-location-filter': LocationFilterComponent;
462
+ 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
256
463
  }
257
- interface HTMLElementEventMap {
258
- 'gs-location-changed': CustomEvent<Record<string, string>>;
464
+ }
465
+
466
+
467
+ declare global {
468
+ interface HTMLElementTagNameMap {
469
+ 'gs-aggregate-component': AggregateComponent;
259
470
  }
260
471
  }
261
472
 
262
473
 
263
474
  declare global {
264
475
  interface HTMLElementTagNameMap {
265
- 'gs-mutation-comparison-component': MutationComparisonComponent;
476
+ 'gs-date-range-selector': DateRangeSelectorComponent<string>;
477
+ }
478
+ interface HTMLElementEventMap {
479
+ 'gs-date-range-changed': CustomEvent<{
480
+ dateFrom: string;
481
+ dateTo: string;
482
+ }>;
266
483
  }
267
484
  }
268
485
 
269
486
 
270
487
  declare global {
271
488
  interface HTMLElementTagNameMap {
272
- 'gs-mutations-component': MutationsComponent;
489
+ 'gs-location-filter': LocationFilterComponent;
490
+ }
491
+ interface HTMLElementEventMap {
492
+ 'gs-location-changed': CustomEvent<Record<string, string>>;
273
493
  }
274
494
  }
275
495
 
276
496
 
277
497
  declare global {
278
498
  interface HTMLElementTagNameMap {
279
- 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
499
+ 'gs-text-input': TextInputComponent;
500
+ }
501
+ interface HTMLElementEventMap {
502
+ 'gs-text-input-changed': CustomEvent<Record<string, string>>;
280
503
  }
281
504
  }
282
505
 
283
506
 
284
507
  declare global {
285
508
  interface HTMLElementTagNameMap {
286
- 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
509
+ 'gs-mutation-filter': TextInputComponent;
510
+ }
511
+ interface HTMLElementEventMap {
512
+ 'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
513
+ 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
287
514
  }
288
515
  }
289
516