@genspectrum/dashboard-components 0.1.3 → 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 (75) hide show
  1. package/custom-elements.json +311 -75
  2. package/dist/dashboard-components.js +622 -434
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/genspectrum-components.d.ts +229 -42
  5. package/dist/style.css +132 -139
  6. package/package.json +9 -5
  7. package/src/preact/aggregatedData/aggregate.stories.tsx +5 -5
  8. package/src/preact/aggregatedData/aggregate.tsx +8 -4
  9. package/src/preact/components/ReferenceGenomesAwaiter.tsx +25 -0
  10. package/src/preact/components/csv-download-button.tsx +8 -2
  11. package/src/preact/components/headline.tsx +16 -4
  12. package/src/preact/components/min-max-range-slider.tsx +4 -4
  13. package/src/preact/components/percent-intput.tsx +2 -3
  14. package/src/preact/components/resize-container.tsx +23 -0
  15. package/src/preact/components/table.tsx +1 -0
  16. package/src/preact/components/tabs.stories.tsx +2 -2
  17. package/src/preact/components/tabs.tsx +47 -24
  18. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +36 -4
  19. package/src/preact/dateRangeSelector/date-range-selector.tsx +57 -43
  20. package/src/preact/locationFilter/location-filter.tsx +2 -2
  21. package/src/preact/mutationComparison/getMutationComparisonTableData.spec.ts +5 -5
  22. package/src/preact/mutationComparison/getMutationComparisonTableData.ts +45 -10
  23. package/src/preact/mutationComparison/mutation-comparison-table.tsx +20 -22
  24. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +6 -3
  25. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +8 -1
  26. package/src/preact/mutationComparison/mutation-comparison.tsx +13 -4
  27. package/src/preact/mutationFilter/mutation-filter.stories.tsx +70 -31
  28. package/src/preact/mutationFilter/mutation-filter.tsx +62 -14
  29. package/src/preact/mutations/getInsertionsTableData.spec.ts +6 -4
  30. package/src/preact/mutations/getInsertionsTableData.ts +1 -1
  31. package/src/preact/mutations/getMutationsTableData.spec.ts +9 -19
  32. package/src/preact/mutations/getMutationsTableData.ts +1 -1
  33. package/src/preact/mutations/mutations-insertions-table.tsx +3 -1
  34. package/src/preact/mutations/mutations-table.tsx +3 -1
  35. package/src/preact/mutations/mutations.stories.tsx +8 -1
  36. package/src/preact/mutations/mutations.tsx +16 -5
  37. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +1 -0
  38. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +1 -0
  39. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +1 -0
  40. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +4 -0
  41. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +17 -9
  42. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +8 -5
  43. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +12 -0
  44. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +13 -8
  45. package/src/preact/shared/sort/sortInsertions.spec.ts +11 -10
  46. package/src/preact/shared/sort/sortInsertions.ts +10 -17
  47. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.spec.ts +19 -10
  48. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +45 -12
  49. package/src/preact/textInput/text-input.stories.tsx +22 -1
  50. package/src/preact/textInput/text-input.tsx +3 -1
  51. package/src/utils/typeAssertions.spec.ts +31 -0
  52. package/src/utils/typeAssertions.ts +16 -0
  53. package/src/web-components/PreactLitAdapter.tsx +0 -1
  54. package/src/web-components/app.stories.ts +129 -0
  55. package/src/web-components/app.ts +27 -6
  56. package/src/web-components/display/aggregate-component.stories.ts +21 -11
  57. package/src/web-components/display/aggregate-component.tsx +12 -5
  58. package/src/web-components/display/mutation-comparison-component.stories.ts +29 -11
  59. package/src/web-components/display/mutation-comparison-component.tsx +72 -4
  60. package/src/web-components/display/mutations-component.stories.ts +14 -13
  61. package/src/web-components/display/mutations-component.tsx +14 -1
  62. package/src/web-components/display/prevalence-over-time-component.stories.ts +20 -18
  63. package/src/web-components/display/prevalence-over-time-component.tsx +12 -0
  64. package/src/web-components/display/relative-growth-advantage-component.stories.ts +11 -10
  65. package/src/web-components/display/relative-growth-advantage-component.tsx +12 -0
  66. package/src/web-components/input/date-range-selector-component.stories.ts +35 -8
  67. package/src/web-components/input/date-range-selector-component.tsx +18 -5
  68. package/src/web-components/input/location-filter-component.stories.ts +15 -4
  69. package/src/web-components/input/location-filter-component.tsx +2 -6
  70. package/src/web-components/input/mutation-filter-component.stories.ts +20 -9
  71. package/src/web-components/input/mutation-filter-component.tsx +10 -2
  72. package/src/web-components/input/text-input-component.stories.ts +13 -4
  73. package/src/web-components/input/text-input-component.tsx +11 -2
  74. package/src/web-components/display/aggregate-component.mdx +0 -25
  75. package/src/web-components/input/location-filter.mdx +0 -25
@@ -8,10 +8,6 @@ import { ReactiveElement } from '@lit/reactive-element';
8
8
  import { TemplateResult } from 'lit-html';
9
9
 
10
10
  /**
11
- * ## Tag
12
- *
13
- * `gs-aggregate-component`
14
- *
15
11
  * ## Context
16
12
  *
17
13
  * This component displays aggregated data, which can provide an overview of the underlying data.
@@ -30,26 +26,57 @@ export declare class AggregateComponent extends PreactLitAdapterWithGridJsStyles
30
26
  * The proportion represents the ratio of the aggregated value to the total count of the data
31
27
  * (considering the applied filter).
32
28
  */
33
- views: View_5[];
29
+ views: View_4[];
34
30
  /**
35
31
  * The filter to apply to the data.
36
32
  */
37
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;
38
46
  render(): JSX_2.Element;
39
47
  }
40
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
+ */
41
65
  export declare class App extends LitElement {
66
+ /**
67
+ * The URL of the LAPIS instance that all children of this component will use.
68
+ */
42
69
  lapis: string;
43
- referenceGenome: ReferenceGenome;
44
- private updateReferenceGenome;
70
+ /* Excluded from this release type: referenceGenome */
71
+ /* Excluded from this release type: updateReferenceGenome */
45
72
  render(): TemplateResult<1> | undefined;
46
73
  createRenderRoot(): this;
47
74
  }
48
75
 
49
76
  declare type ConfidenceIntervalMethod = 'wilson' | 'none';
50
77
 
51
- declare type CustomSelectOption = {
52
- label: string;
78
+ declare type CustomSelectOption<CustomLabel extends string> = {
79
+ label: CustomLabel;
53
80
  dateFrom: string;
54
81
  dateTo: string;
55
82
  };
@@ -57,19 +84,38 @@ declare type CustomSelectOption = {
57
84
  /**
58
85
  * @fires {CustomEvent<{ dateFrom: string; dateTo: string; }>} gs-date-range-changed - When the date range has changed
59
86
  */
60
- export declare class DateRangeSelectorComponent extends PreactLitAdapter {
61
- customSelectOptions: CustomSelectOption[];
87
+ export declare class DateRangeSelectorComponent<CustomLabel extends string> extends PreactLitAdapter {
88
+ customSelectOptions: CustomSelectOption<CustomLabel>[];
62
89
  earliestDate: string | undefined;
90
+ initialValue: PresetOptionValues | CustomLabel | string | undefined;
63
91
  render(): JSX_2.Element;
64
92
  }
65
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
+
66
116
  declare type LapisFilter = Record<string, string | number | null | boolean>;
67
117
 
68
118
  /**
69
- * ## Tag
70
- *
71
- * `gs-location-filter`
72
- *
73
119
  * ## Context
74
120
  *
75
121
  * This component provides an input field to specify filters for locations.
@@ -101,7 +147,7 @@ export declare class LocationFilterComponent extends PreactLitAdapter {
101
147
  * The initial value to use for this location filter.
102
148
  * Must be of the form `valueForField1 / valueForField2 / ... / valueForFieldN`.
103
149
  */
104
- value: string;
150
+ initialValue: string;
105
151
  /**
106
152
  * The fields to display in the location filter, in hierarchical order.
107
153
  * The top-level field should be the first entry in the array.
@@ -112,16 +158,72 @@ export declare class LocationFilterComponent extends PreactLitAdapter {
112
158
  render(): JSX_2.Element;
113
159
  }
114
160
 
115
- export declare class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
116
- variants: MutationComparisonVariant[];
117
- sequenceType: SequenceType;
118
- views: View[];
119
- 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;
120
167
  }
121
168
 
122
- declare interface MutationComparisonVariant {
123
- lapisFilter: LapisFilter;
124
- 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;
125
227
  }
126
228
 
127
229
  /**
@@ -129,13 +231,26 @@ declare interface MutationComparisonVariant {
129
231
  * @fires {CustomEvent<SelectedMutationFilterStrings>} gs-mutation-filter-on-blur - When the mutation filter has lost focus
130
232
  */
131
233
  export declare class MutationFilterComponent extends PreactLitAdapter {
234
+ initialValue: SelectedMutationFilterStrings | string[] | undefined;
132
235
  render(): JSX_2.Element;
133
236
  }
134
237
 
135
238
  export declare class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
136
239
  variant: LapisFilter;
137
240
  sequenceType: SequenceType;
138
- 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;
139
254
  render(): JSX_2.Element;
140
255
  }
141
256
 
@@ -155,13 +270,51 @@ declare abstract class PreactLitAdapterWithGridJsStyles extends PreactLitAdapter
155
270
  static styles: CSSResult[];
156
271
  }
157
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
+
158
299
  export declare class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
159
300
  numerator: NamedLapisFilter | NamedLapisFilter[];
160
301
  denominator: NamedLapisFilter;
161
302
  granularity: TemporalGranularity;
162
303
  smoothingWindow: number;
163
- views: View_3[];
304
+ views: View_2[];
164
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;
165
318
  render(): JSX_2.Element;
166
319
  }
167
320
 
@@ -212,32 +365,66 @@ export declare class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
212
365
  numerator: LapisFilter;
213
366
  denominator: LapisFilter;
214
367
  generationTime: number;
215
- 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;
216
381
  render(): JSX_2.Element;
217
382
  }
218
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
+
219
395
  declare type SequenceType = 'nucleotide' | 'amino acid';
220
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
+
221
409
  declare type TemporalGranularity = 'day' | 'week' | 'month' | 'year';
222
410
 
223
411
  /**
224
412
  * @fires {CustomEvent<Record<string, string>>} gs-text-input-changed - When the text input has changed
225
413
  */
226
414
  export declare class TextInputComponent extends PreactLitAdapter {
415
+ initialValue: string | undefined;
227
416
  lapisField: string;
228
- placeholderText: string;
417
+ placeholderText: string | undefined;
229
418
  render(): JSX_2.Element;
230
419
  }
231
420
 
232
- declare type View = 'table' | 'venn';
421
+ declare type View = 'table' | 'grid' | 'insertions';
233
422
 
234
- declare type View_2 = 'table' | 'grid' | 'insertions';
423
+ declare type View_2 = 'bar' | 'line' | 'bubble' | 'table';
235
424
 
236
- declare type View_3 = 'bar' | 'line' | 'bubble' | 'table';
425
+ declare type View_3 = 'line';
237
426
 
238
- declare type View_4 = 'line';
239
-
240
- declare type View_5 = 'table';
427
+ declare type View_4 = 'table';
241
428
 
242
429
  export { }
243
430
 
@@ -286,7 +473,7 @@ declare global {
286
473
 
287
474
  declare global {
288
475
  interface HTMLElementTagNameMap {
289
- 'gs-date-range-selector': DateRangeSelectorComponent;
476
+ 'gs-date-range-selector': DateRangeSelectorComponent<string>;
290
477
  }
291
478
  interface HTMLElementEventMap {
292
479
  'gs-date-range-changed': CustomEvent<{
@@ -299,31 +486,31 @@ declare global {
299
486
 
300
487
  declare global {
301
488
  interface HTMLElementTagNameMap {
302
- 'gs-mutation-filter': TextInputComponent;
489
+ 'gs-location-filter': LocationFilterComponent;
303
490
  }
304
491
  interface HTMLElementEventMap {
305
- 'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
306
- 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
492
+ 'gs-location-changed': CustomEvent<Record<string, string>>;
307
493
  }
308
494
  }
309
495
 
310
496
 
311
497
  declare global {
312
498
  interface HTMLElementTagNameMap {
313
- 'gs-location-filter': LocationFilterComponent;
499
+ 'gs-text-input': TextInputComponent;
314
500
  }
315
501
  interface HTMLElementEventMap {
316
- 'gs-location-changed': CustomEvent<Record<string, string>>;
502
+ 'gs-text-input-changed': CustomEvent<Record<string, string>>;
317
503
  }
318
504
  }
319
505
 
320
506
 
321
507
  declare global {
322
508
  interface HTMLElementTagNameMap {
323
- 'gs-text-input': TextInputComponent;
509
+ 'gs-mutation-filter': TextInputComponent;
324
510
  }
325
511
  interface HTMLElementEventMap {
326
- 'gs-text-input-changed': CustomEvent<Record<string, string>>;
512
+ 'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
513
+ 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
327
514
  }
328
515
  }
329
516