@genspectrum/dashboard-components 0.1.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 (186) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +109 -0
  3. package/custom-elements.json +1587 -0
  4. package/dist/dashboard-components.js +7322 -0
  5. package/dist/dashboard-components.js.map +1 -0
  6. package/dist/genspectrum-components.d.ts +298 -0
  7. package/dist/style.css +2930 -0
  8. package/package.json +109 -0
  9. package/src/constants.ts +6 -0
  10. package/src/index.ts +1 -0
  11. package/src/lapisApi/ReferenceGenome.ts +30 -0
  12. package/src/lapisApi/__mockData__/referenceGenome.json +58 -0
  13. package/src/lapisApi/lapisApi.ts +99 -0
  14. package/src/lapisApi/lapisTypes.ts +51 -0
  15. package/src/operator/Dataset.ts +3 -0
  16. package/src/operator/DivisionOperator.spec.ts +27 -0
  17. package/src/operator/DivisionOperator.ts +60 -0
  18. package/src/operator/FetchAggregatedOperator.ts +44 -0
  19. package/src/operator/FetchInsertionsOperator.ts +24 -0
  20. package/src/operator/FetchSubstitutionsOrDeletionsOperator.ts +49 -0
  21. package/src/operator/FillMissingOperator.spec.ts +26 -0
  22. package/src/operator/FillMissingOperator.ts +30 -0
  23. package/src/operator/GroupByAndSumOperator.spec.ts +26 -0
  24. package/src/operator/GroupByAndSumOperator.ts +26 -0
  25. package/src/operator/GroupByOperator.spec.ts +43 -0
  26. package/src/operator/GroupByOperator.ts +32 -0
  27. package/src/operator/MapOperator.spec.ts +13 -0
  28. package/src/operator/MapOperator.ts +16 -0
  29. package/src/operator/MockOperator.spec.ts +11 -0
  30. package/src/operator/MockOperator.ts +12 -0
  31. package/src/operator/Operator.ts +5 -0
  32. package/src/operator/SlidingOperator.spec.ts +52 -0
  33. package/src/operator/SlidingOperator.ts +23 -0
  34. package/src/operator/SortOperator.spec.ts +13 -0
  35. package/src/operator/SortOperator.ts +16 -0
  36. package/src/preact/LapisUrlContext.ts +3 -0
  37. package/src/preact/ReferenceGenomeContext.ts +5 -0
  38. package/src/preact/components/SegmentSelector.tsx +62 -0
  39. package/src/preact/components/chart.stories.tsx +42 -0
  40. package/src/preact/components/chart.tsx +32 -0
  41. package/src/preact/components/checkbox-selector.stories.tsx +56 -0
  42. package/src/preact/components/checkbox-selector.tsx +46 -0
  43. package/src/preact/components/confidence-interval-selector.tsx +45 -0
  44. package/src/preact/components/csv-download-button.stories.tsx +25 -0
  45. package/src/preact/components/csv-download-button.tsx +51 -0
  46. package/src/preact/components/error-display.stories.tsx +22 -0
  47. package/src/preact/components/error-display.tsx +5 -0
  48. package/src/preact/components/headline.stories.tsx +29 -0
  49. package/src/preact/components/headline.tsx +16 -0
  50. package/src/preact/components/info.stories.tsx +22 -0
  51. package/src/preact/components/info.tsx +16 -0
  52. package/src/preact/components/loading-display.stories.tsx +20 -0
  53. package/src/preact/components/loading-display.tsx +5 -0
  54. package/src/preact/components/min-max-percent-slider.css +40 -0
  55. package/src/preact/components/min-max-range-slider.tsx +95 -0
  56. package/src/preact/components/mutation-type-selector.tsx +30 -0
  57. package/src/preact/components/no-data-display.stories.tsx +20 -0
  58. package/src/preact/components/no-data-display.tsx +5 -0
  59. package/src/preact/components/percent-intput.tsx +49 -0
  60. package/src/preact/components/proportion-selector-dropdown.stories.tsx +66 -0
  61. package/src/preact/components/proportion-selector-dropdown.tsx +33 -0
  62. package/src/preact/components/proportion-selector.stories.tsx +81 -0
  63. package/src/preact/components/proportion-selector.tsx +43 -0
  64. package/src/preact/components/scaling-selector.stories.tsx +25 -0
  65. package/src/preact/components/scaling-selector.tsx +36 -0
  66. package/src/preact/components/select.stories.tsx +42 -0
  67. package/src/preact/components/select.tsx +21 -0
  68. package/src/preact/components/table.stories.tsx +24 -0
  69. package/src/preact/components/table.tsx +51 -0
  70. package/src/preact/components/tabs.stories.tsx +60 -0
  71. package/src/preact/components/tabs.tsx +49 -0
  72. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +32 -0
  73. package/src/preact/dateRangeSelector/date-range-selector.tsx +228 -0
  74. package/src/preact/dateRangeSelector/dateConversion.ts +8 -0
  75. package/src/preact/locationFilter/__mockData__/aggregated.json +775 -0
  76. package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +36 -0
  77. package/src/preact/locationFilter/fetchAutocompletionList.ts +43 -0
  78. package/src/preact/locationFilter/location-filter.stories.tsx +50 -0
  79. package/src/preact/locationFilter/location-filter.tsx +112 -0
  80. package/src/preact/mutationComparison/__mockData__/nucleotideMutationsOtherVariant.json +295 -0
  81. package/src/preact/mutationComparison/__mockData__/nucleotideMutationsSomeVariant.json +304 -0
  82. package/src/preact/mutationComparison/fetchMutationData.spec.ts +118 -0
  83. package/src/preact/mutationComparison/getMutationComparisonTableData.spec.ts +125 -0
  84. package/src/preact/mutationComparison/getMutationComparisonTableData.ts +40 -0
  85. package/src/preact/mutationComparison/mutation-comparison-table.tsx +43 -0
  86. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +122 -0
  87. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +152 -0
  88. package/src/preact/mutationComparison/mutation-comparison.tsx +179 -0
  89. package/src/preact/mutationComparison/queryMutationData.ts +53 -0
  90. package/src/preact/mutationFilter/mutation-filter.stories.tsx +164 -0
  91. package/src/preact/mutationFilter/mutation-filter.tsx +268 -0
  92. package/src/preact/mutationFilter/parseAndValidateMutation.ts +54 -0
  93. package/src/preact/mutationFilter/parseMutation.spec.ts +150 -0
  94. package/src/preact/mutationFilter/sequenceTypeFromSegment.spec.ts +66 -0
  95. package/src/preact/mutationFilter/sequenceTypeFromSegment.ts +20 -0
  96. package/src/preact/mutations/__mockData__/nucleotideInsertions.json +252 -0
  97. package/src/preact/mutations/__mockData__/nucleotideMutations.json +880 -0
  98. package/src/preact/mutations/getInsertionsTableData.spec.ts +36 -0
  99. package/src/preact/mutations/getInsertionsTableData.ts +10 -0
  100. package/src/preact/mutations/getMutationsGridData.spec.ts +135 -0
  101. package/src/preact/mutations/getMutationsGridData.ts +92 -0
  102. package/src/preact/mutations/getMutationsTableData.spec.ts +94 -0
  103. package/src/preact/mutations/getMutationsTableData.ts +17 -0
  104. package/src/preact/mutations/mutations-grid.tsx +84 -0
  105. package/src/preact/mutations/mutations-insertions-table.tsx +33 -0
  106. package/src/preact/mutations/mutations-table.tsx +47 -0
  107. package/src/preact/mutations/mutations.stories.tsx +95 -0
  108. package/src/preact/mutations/mutations.tsx +192 -0
  109. package/src/preact/mutations/queryMutations.ts +55 -0
  110. package/src/preact/prevalenceOverTime/__mockData__/denominator.json +1700 -0
  111. package/src/preact/prevalenceOverTime/__mockData__/denominatorOneVariant.json +608 -0
  112. package/src/preact/prevalenceOverTime/__mockData__/numeratorEG.json +1560 -0
  113. package/src/preact/prevalenceOverTime/__mockData__/numeratorJN1.json +592 -0
  114. package/src/preact/prevalenceOverTime/__mockData__/numeratorOneVariant.json +604 -0
  115. package/src/preact/prevalenceOverTime/getPrevalenceOverTimeTableData.spec.ts +67 -0
  116. package/src/preact/prevalenceOverTime/getPrevalenceOverTimeTableData.ts +18 -0
  117. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +105 -0
  118. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +86 -0
  119. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +141 -0
  120. package/src/preact/prevalenceOverTime/prevalence-over-time-table.tsx +46 -0
  121. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +165 -0
  122. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +202 -0
  123. package/src/preact/relativeGrowthAdvantage/__mockData__/denominator.json +376 -0
  124. package/src/preact/relativeGrowthAdvantage/__mockData__/numerator.json +332 -0
  125. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +138 -0
  126. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +71 -0
  127. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +136 -0
  128. package/src/preact/shared/charts/LogitScale.ts +48 -0
  129. package/src/preact/shared/charts/colors.ts +26 -0
  130. package/src/preact/shared/charts/confideceInterval.ts +29 -0
  131. package/src/preact/shared/charts/getYAxisScale.ts +16 -0
  132. package/src/preact/shared/charts/scales.ts +16 -0
  133. package/src/preact/shared/icons/DeleteIcon.tsx +17 -0
  134. package/src/preact/shared/sort/sortInsertions.spec.ts +47 -0
  135. package/src/preact/shared/sort/sortInsertions.ts +21 -0
  136. package/src/preact/shared/sort/sortMutationPositions.spec.ts +31 -0
  137. package/src/preact/shared/sort/sortMutationPositions.ts +14 -0
  138. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.spec.ts +47 -0
  139. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +17 -0
  140. package/src/preact/shared/table/formatProportion.ts +3 -0
  141. package/src/preact/textInput/__mockData__/aggregated_hosts.json +24 -0
  142. package/src/preact/textInput/fetchAutocompleteList.ts +9 -0
  143. package/src/preact/textInput/text-input.stories.tsx +49 -0
  144. package/src/preact/textInput/text-input.tsx +73 -0
  145. package/src/preact/useQuery.ts +27 -0
  146. package/src/query/queryInsertions.ts +14 -0
  147. package/src/query/queryPrevalenceOverTime.ts +126 -0
  148. package/src/query/queryRelativeGrowthAdvantage.ts +131 -0
  149. package/src/query/querySubstitutionsOrDeletions.ts +19 -0
  150. package/src/styles/tailwind.css +3 -0
  151. package/src/styles/tailwind.d.ts +3 -0
  152. package/src/types.ts +23 -0
  153. package/src/utils/mutations.spec.ts +64 -0
  154. package/src/utils/mutations.ts +165 -0
  155. package/src/utils/temporal.spec.ts +97 -0
  156. package/src/utils/temporal.ts +348 -0
  157. package/src/utils/test-utils.ts +5 -0
  158. package/src/utils/type-utils.ts +15 -0
  159. package/src/utils/utils.spec.ts +16 -0
  160. package/src/utils/utils.ts +38 -0
  161. package/src/web-components/PreactLitAdapter.tsx +62 -0
  162. package/src/web-components/PreactLitAdapterWithGridJsStyles.tsx +12 -0
  163. package/src/web-components/app.ts +51 -0
  164. package/src/web-components/display/index.ts +4 -0
  165. package/src/web-components/display/mutation-comparison-component.stories.ts +138 -0
  166. package/src/web-components/display/mutation-comparison-component.tsx +31 -0
  167. package/src/web-components/display/mutations-component.stories.ts +107 -0
  168. package/src/web-components/display/mutations-component.tsx +27 -0
  169. package/src/web-components/display/prevalence-over-time-component.stories.ts +205 -0
  170. package/src/web-components/display/prevalence-over-time-component.tsx +46 -0
  171. package/src/web-components/display/relative-growth-advantage-component.stories.ts +89 -0
  172. package/src/web-components/display/relative-growth-advantage-component.tsx +37 -0
  173. package/src/web-components/index.ts +3 -0
  174. package/src/web-components/input/date-range-selector-component.stories.ts +53 -0
  175. package/src/web-components/input/date-range-selector-component.tsx +33 -0
  176. package/src/web-components/input/index.ts +4 -0
  177. package/src/web-components/input/location-filter-component.stories.ts +184 -0
  178. package/src/web-components/input/location-filter-component.tsx +68 -0
  179. package/src/web-components/input/location-filter.mdx +25 -0
  180. package/src/web-components/input/mutation-filter-component.stories.ts +97 -0
  181. package/src/web-components/input/mutation-filter-component.tsx +27 -0
  182. package/src/web-components/input/text-input-component.stories.ts +92 -0
  183. package/src/web-components/input/text-input-component.tsx +30 -0
  184. package/src/web-components/lapis-context.ts +3 -0
  185. package/src/web-components/reference-genome-context.ts +5 -0
  186. package/src/web-components/withinShadowRoot.story.ts +34 -0
@@ -0,0 +1,298 @@
1
+ import { CSSResult } from 'lit';
2
+ import { default as default_2 } from 'zod';
3
+ import { JSX as JSX_2 } from 'preact';
4
+ import { JSXInternal } from 'preact/src/jsx';
5
+ import { LitElement } from 'lit';
6
+ import { PropertyValues } from '@lit/reactive-element';
7
+ import { ReactiveElement } from '@lit/reactive-element';
8
+ import { TemplateResult } from 'lit-html';
9
+
10
+ export declare class App extends LitElement {
11
+ lapis: string;
12
+ referenceGenome: ReferenceGenome;
13
+ private updateReferenceGenome;
14
+ render(): TemplateResult<1> | undefined;
15
+ createRenderRoot(): this;
16
+ }
17
+
18
+ declare type ConfidenceIntervalMethod = 'wilson' | 'none';
19
+
20
+ declare type CustomSelectOption = {
21
+ label: string;
22
+ dateFrom: string;
23
+ dateTo: string;
24
+ };
25
+
26
+ /**
27
+ * @fires {CustomEvent<{ dateFrom: string; dateTo: string; }>} gs-date-range-changed - When the date range has changed
28
+ */
29
+ export declare class DateRangeSelectorComponent extends PreactLitAdapter {
30
+ customSelectOptions: CustomSelectOption[];
31
+ earliestDate: string | undefined;
32
+ render(): JSX_2.Element;
33
+ }
34
+
35
+ declare type LapisFilter = Record<string, string | number | null | boolean>;
36
+
37
+ /**
38
+ * ## Tag
39
+ *
40
+ * `gs-location-filter`
41
+ *
42
+ * ## Context
43
+ *
44
+ * This component provides an input field to specify filters for locations.
45
+ *
46
+ * It expects a list of fields that form a strict hierarchical order, such as continent, country, and city.
47
+ * The component retrieves a list of all possible values for these fields from the Lapis instance.
48
+ * This list is then utilized to display autocomplete suggestions and to validate the input.
49
+ *
50
+ * Given `fields` are `['field1', 'field2', ..., 'fieldN']`,
51
+ * then valid values for the location filter must be in the form `valueForField1 / valueForField2 / ... / valueForFieldK`,
52
+ * where `1 <= K <= N`.
53
+ * Values for the fields `i > K` are considered `undefined`.
54
+ *
55
+ * @fires {CustomEvent<Record<string, string>>} gs-location-changed
56
+ * Fired when the field is submitted with a valid location value.
57
+ * The `details` of this event contain an object with all `fields` as keys
58
+ * and the corresponding values as values, if they are not `undefined`.
59
+ * Example:
60
+ * ```
61
+ * {
62
+ * continent: "Asia",
63
+ * country: "China",
64
+ * city: "Beijing"
65
+ * }
66
+ * ```
67
+ */
68
+ export declare class LocationFilterComponent extends PreactLitAdapter {
69
+ /**
70
+ * The initial value to use for this location filter.
71
+ * Must be of the form `valueForField1 / valueForField2 / ... / valueForFieldN`.
72
+ */
73
+ value: string;
74
+ /**
75
+ * The fields to display in the location filter, in hierarchical order.
76
+ * The top-level field should be the first entry in the array.
77
+ * This component assumes that the values for each field form a strict hierarchy
78
+ * (e.g., `fields = ['continent', 'country', 'city']`).
79
+ */
80
+ fields: string[];
81
+ render(): JSX_2.Element;
82
+ }
83
+
84
+ export declare class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
85
+ variants: MutationComparisonVariant[];
86
+ sequenceType: SequenceType;
87
+ views: View[];
88
+ render(): JSX_2.Element;
89
+ }
90
+
91
+ declare interface MutationComparisonVariant {
92
+ lapisFilter: LapisFilter;
93
+ displayName: string;
94
+ }
95
+
96
+ /**
97
+ * @fires {CustomEvent<SelectedMutationFilterStrings>} gs-mutation-filter-changed - When the mutation filter values have changed
98
+ * @fires {CustomEvent<SelectedMutationFilterStrings>} gs-mutation-filter-on-blur - When the mutation filter has lost focus
99
+ */
100
+ export declare class MutationFilterComponent extends PreactLitAdapter {
101
+ render(): JSX_2.Element;
102
+ }
103
+
104
+ export declare class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
105
+ variant: LapisFilter;
106
+ sequenceType: SequenceType;
107
+ views: View_2[];
108
+ render(): JSX_2.Element;
109
+ }
110
+
111
+ declare type NamedLapisFilter = LapisFilter & {
112
+ displayName: string;
113
+ };
114
+
115
+ declare abstract class PreactLitAdapter extends ReactiveElement {
116
+ static styles: CSSResult[];
117
+ /* Excluded from this release type: lapis */
118
+ /* Excluded from this release type: referenceGenome */
119
+ update(changedProperties: PropertyValues): void;
120
+ protected abstract render(): JSXInternal.Element;
121
+ }
122
+
123
+ declare abstract class PreactLitAdapterWithGridJsStyles extends PreactLitAdapter {
124
+ static styles: CSSResult[];
125
+ }
126
+
127
+ export declare class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
128
+ numerator: NamedLapisFilter | NamedLapisFilter[];
129
+ denominator: NamedLapisFilter;
130
+ granularity: TemporalGranularity;
131
+ smoothingWindow: number;
132
+ views: View_3[];
133
+ confidenceIntervalMethods: ConfidenceIntervalMethod[];
134
+ render(): JSX_2.Element;
135
+ }
136
+
137
+ declare type ReferenceGenome = default_2.infer<typeof referenceGenomeResponse>;
138
+
139
+ declare const referenceGenomeResponse: default_2.ZodObject<{
140
+ nucleotideSequences: default_2.ZodArray<default_2.ZodObject<{
141
+ name: default_2.ZodString;
142
+ sequence: default_2.ZodString;
143
+ }, "strip", default_2.ZodTypeAny, {
144
+ name: string;
145
+ sequence: string;
146
+ }, {
147
+ name: string;
148
+ sequence: string;
149
+ }>, "many">;
150
+ genes: default_2.ZodArray<default_2.ZodObject<{
151
+ name: default_2.ZodString;
152
+ sequence: default_2.ZodString;
153
+ }, "strip", default_2.ZodTypeAny, {
154
+ name: string;
155
+ sequence: string;
156
+ }, {
157
+ name: string;
158
+ sequence: string;
159
+ }>, "many">;
160
+ }, "strip", default_2.ZodTypeAny, {
161
+ nucleotideSequences: {
162
+ name: string;
163
+ sequence: string;
164
+ }[];
165
+ genes: {
166
+ name: string;
167
+ sequence: string;
168
+ }[];
169
+ }, {
170
+ nucleotideSequences: {
171
+ name: string;
172
+ sequence: string;
173
+ }[];
174
+ genes: {
175
+ name: string;
176
+ sequence: string;
177
+ }[];
178
+ }>;
179
+
180
+ export declare class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
181
+ numerator: LapisFilter;
182
+ denominator: LapisFilter;
183
+ generationTime: number;
184
+ views: View_4[];
185
+ render(): JSX_2.Element;
186
+ }
187
+
188
+ declare type SequenceType = 'nucleotide' | 'amino acid';
189
+
190
+ declare type TemporalGranularity = 'day' | 'week' | 'month' | 'year';
191
+
192
+ /**
193
+ * @fires {CustomEvent<Record<string, string>>} gs-text-input-changed - When the text input has changed
194
+ */
195
+ export declare class TextInputComponent extends PreactLitAdapter {
196
+ lapisField: string;
197
+ placeholderText: string;
198
+ render(): JSX_2.Element;
199
+ }
200
+
201
+ declare type View = 'table' | 'venn';
202
+
203
+ declare type View_2 = 'table' | 'grid' | 'insertions';
204
+
205
+ declare type View_3 = 'bar' | 'line' | 'bubble' | 'table';
206
+
207
+ declare type View_4 = 'line';
208
+
209
+ export { }
210
+
211
+
212
+ declare global {
213
+ interface HTMLElementTagNameMap {
214
+ 'gs-app': App;
215
+ }
216
+ }
217
+
218
+
219
+ declare global {
220
+ 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
+ }>;
228
+ }
229
+ }
230
+
231
+
232
+ declare global {
233
+ 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>;
239
+ }
240
+ }
241
+
242
+
243
+ declare global {
244
+ interface HTMLElementTagNameMap {
245
+ 'gs-text-input': TextInputComponent;
246
+ }
247
+ interface HTMLElementEventMap {
248
+ 'gs-text-input-changed': CustomEvent<Record<string, string>>;
249
+ }
250
+ }
251
+
252
+
253
+ declare global {
254
+ interface HTMLElementTagNameMap {
255
+ 'gs-location-filter': LocationFilterComponent;
256
+ }
257
+ interface HTMLElementEventMap {
258
+ 'gs-location-changed': CustomEvent<Record<string, string>>;
259
+ }
260
+ }
261
+
262
+
263
+ declare global {
264
+ interface HTMLElementTagNameMap {
265
+ 'gs-mutation-comparison-component': MutationComparisonComponent;
266
+ }
267
+ }
268
+
269
+
270
+ declare global {
271
+ interface HTMLElementTagNameMap {
272
+ 'gs-mutations-component': MutationsComponent;
273
+ }
274
+ }
275
+
276
+
277
+ declare global {
278
+ interface HTMLElementTagNameMap {
279
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
280
+ }
281
+ }
282
+
283
+
284
+ declare global {
285
+ interface HTMLElementTagNameMap {
286
+ 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
287
+ }
288
+ }
289
+
290
+
291
+ declare module 'chart.js' {
292
+ interface CartesianScaleTypeRegistry {
293
+ logit: {
294
+ options: CoreScaleOptions;
295
+ };
296
+ }
297
+ }
298
+