@genspectrum/dashboard-components 0.19.5 → 0.19.7

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 (57) hide show
  1. package/README.md +24 -8
  2. package/custom-elements.json +101 -2
  3. package/dist/{LineageFilterChangedEvent-GgkxoF3X.js → NumberRangeFilterChangedEvent-RZ8haPHq.js} +31 -5
  4. package/dist/NumberRangeFilterChangedEvent-RZ8haPHq.js.map +1 -0
  5. package/dist/assets/mutationOverTimeWorker-DQGh08AS.js.map +1 -0
  6. package/dist/components.d.ts +43 -12
  7. package/dist/components.js +78 -63
  8. package/dist/components.js.map +1 -1
  9. package/dist/util.d.ts +21 -10
  10. package/dist/util.js +3 -1
  11. package/package.json +1 -1
  12. package/src/preact/aggregatedData/aggregate.stories.tsx +6 -0
  13. package/src/preact/aggregatedData/aggregate.tsx +10 -1
  14. package/src/preact/components/tabs.tsx +4 -4
  15. package/src/preact/genomeViewer/CDSPlot.tsx +4 -1
  16. package/src/preact/genomeViewer/genome-data-viewer.stories.tsx +6 -0
  17. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +6 -0
  18. package/src/preact/mutationComparison/mutation-comparison.tsx +4 -0
  19. package/src/preact/mutations/mutations.stories.tsx +6 -0
  20. package/src/preact/mutations/mutations.tsx +4 -1
  21. package/src/preact/mutationsOverTime/mutations-over-time.stories.tsx +6 -0
  22. package/src/preact/mutationsOverTime/mutations-over-time.tsx +4 -1
  23. package/src/preact/numberRangeFilter/NumberRangeFilterChangedEvent.ts +1 -1
  24. package/src/preact/numberSequencesOverTime/number-sequences-over-time.stories.tsx +3 -1
  25. package/src/preact/numberSequencesOverTime/number-sequences-over-time.tsx +4 -0
  26. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +6 -0
  27. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +4 -1
  28. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +6 -0
  29. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +4 -1
  30. package/src/preact/sequencesByLocation/sequences-by-location.stories.tsx +6 -0
  31. package/src/preact/sequencesByLocation/sequences-by-location.tsx +4 -0
  32. package/src/preact/shared/stories/expectFinishedLoadingEvent.ts +12 -0
  33. package/src/preact/statistic/statistics.stories.tsx +6 -0
  34. package/src/preact/statistic/statistics.tsx +4 -1
  35. package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.stories.tsx +2 -0
  36. package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.tsx +4 -1
  37. package/src/utilEntrypoint.ts +6 -1
  38. package/src/utils/gsEventNames.ts +1 -0
  39. package/src/utils/useDispatchFinishedLoadingEvent.ts +19 -0
  40. package/src/web-components/input/gs-number-range-filter.tsx +2 -2
  41. package/src/web-components/visualization/gs-aggregate.tsx +3 -0
  42. package/src/web-components/visualization/gs-genome-data-viewer.tsx +2 -0
  43. package/src/web-components/visualization/gs-mutation-comparison.tsx +3 -0
  44. package/src/web-components/visualization/gs-mutations-over-time.tsx +3 -0
  45. package/src/web-components/visualization/gs-mutations.tsx +2 -0
  46. package/src/web-components/visualization/gs-number-sequences-over-time.tsx +3 -0
  47. package/src/web-components/visualization/gs-prevalence-over-time.tsx +3 -0
  48. package/src/web-components/visualization/gs-relative-growth-advantage.tsx +3 -0
  49. package/src/web-components/visualization/gs-sequences-by-location.tsx +3 -0
  50. package/src/web-components/visualization/gs-statistics.tsx +3 -0
  51. package/src/web-components/wastewaterVisualization/gs-wastewater-mutations-over-time.tsx +3 -0
  52. package/standalone-bundle/assets/mutationOverTimeWorker-DAf2_NiP.js.map +1 -0
  53. package/standalone-bundle/dashboard-components.js +6980 -6945
  54. package/standalone-bundle/dashboard-components.js.map +1 -1
  55. package/dist/LineageFilterChangedEvent-GgkxoF3X.js.map +0 -1
  56. package/dist/assets/mutationOverTimeWorker-ChQTFL68.js.map +0 -1
  57. package/standalone-bundle/assets/mutationOverTimeWorker-jChgWnwp.js.map +0 -1
@@ -3,6 +3,7 @@ import z from 'zod';
3
3
 
4
4
  import { queryGeneralStatistics } from '../../query/queryGeneralStatistics';
5
5
  import { lapisFilterSchema } from '../../types';
6
+ import { useDispatchFinishedLoadingEvent } from '../../utils/useDispatchFinishedLoadingEvent';
6
7
  import { useLapisUrl } from '../LapisUrlContext';
7
8
  import { ErrorBoundary } from '../components/error-boundary';
8
9
  import { LoadingDisplay } from '../components/loading-display';
@@ -60,9 +61,11 @@ type MetricDataTabsProps = {
60
61
  };
61
62
 
62
63
  const MetricDataTabs: FunctionComponent<MetricDataTabsProps> = ({ data }) => {
64
+ const ref = useDispatchFinishedLoadingEvent();
65
+
63
66
  const { count, proportion } = data;
64
67
  return (
65
- <div className='flex flex-col sm:flex-row rounded-md border-2 border-gray-100 min-w-[180px]'>
68
+ <div ref={ref} className='flex flex-col sm:flex-row rounded-md border-2 border-gray-100 min-w-[180px]'>
66
69
  <div className='stat'>
67
70
  <div className='stat-title'>Sequences</div>
68
71
  <div className='stat-value text-2xl sm:text-4xl'>{count.toLocaleString('en-us')}</div>
@@ -9,6 +9,7 @@ import { LapisUrlContextProvider } from '../../LapisUrlContext';
9
9
  import { ReferenceGenomeContext } from '../../ReferenceGenomeContext';
10
10
  import details from './__mockData__/details.json';
11
11
  import type { MutationsOverTimeProps } from '../../mutationsOverTime/mutations-over-time';
12
+ import { playThatExpectsFinishedLoadingEvent } from '../../shared/stories/expectFinishedLoadingEvent';
12
13
 
13
14
  const meta: Meta<WastewaterMutationsOverTimeProps> = {
14
15
  title: 'Wastewater visualization/Wastewater mutations over time',
@@ -67,6 +68,7 @@ export const Default: StoryObj<WastewaterMutationsOverTimeProps> = {
67
68
  ],
68
69
  },
69
70
  },
71
+ play: playThatExpectsFinishedLoadingEvent(),
70
72
  };
71
73
 
72
74
  export const ChangingRowsPerPageChangesItForEveryTag: StoryObj<WastewaterMutationsOverTimeProps> = {
@@ -5,6 +5,7 @@ import z from 'zod';
5
5
  import { computeWastewaterMutationsOverTimeDataPerLocation } from './computeWastewaterMutationsOverTimeDataPerLocation';
6
6
  import { lapisFilterSchema, type SequenceType, sequenceTypeSchema } from '../../../types';
7
7
  import { Map2dView } from '../../../utils/map2d';
8
+ import { useDispatchFinishedLoadingEvent } from '../../../utils/useDispatchFinishedLoadingEvent';
8
9
  import { useLapisUrl } from '../../LapisUrlContext';
9
10
  import { useMutationAnnotationsProvider } from '../../MutationAnnotationsContext';
10
11
  import { type ColorScale } from '../../components/color-scale-selector';
@@ -145,6 +146,8 @@ const MutationsOverTimeTabs: FunctionComponent<MutationOverTimeTabsProps> = ({
145
146
  mutationOverTimeDataPerLocation,
146
147
  originalComponentProps,
147
148
  }) => {
149
+ const tabsRef = useDispatchFinishedLoadingEvent();
150
+
148
151
  const [mutationFilterValue, setMutationFilterValue] = useState('');
149
152
  const annotationProvider = useMutationAnnotationsProvider();
150
153
 
@@ -196,7 +199,7 @@ const MutationsOverTimeTabs: FunctionComponent<MutationOverTimeTabsProps> = ({
196
199
 
197
200
  return (
198
201
  <PageSizeContextProvider pageSizes={originalComponentProps.pageSizes}>
199
- <Tabs tabs={tabs} toolbar={toolbar} />
202
+ <Tabs ref={tabsRef} tabs={tabs} toolbar={toolbar} />
200
203
  </PageSizeContextProvider>
201
204
  );
202
205
  };
@@ -41,4 +41,9 @@ export type { MutationAnnotations, MutationAnnotation } from './web-components/m
41
41
 
42
42
  export { gsEventNames } from './utils/gsEventNames';
43
43
 
44
- export { type NumberRange } from './preact/numberRangeFilter/NumberRangeFilterChangedEvent';
44
+ export {
45
+ type NumberRange,
46
+ type LapisNumberFilter,
47
+ NumberRangeFilterChangedEvent,
48
+ NumberRangeValueChangedEvent,
49
+ } from './preact/numberRangeFilter/NumberRangeFilterChangedEvent';
@@ -1,5 +1,6 @@
1
1
  export const gsEventNames = {
2
2
  error: 'gs-error',
3
+ componentFinishedLoading: 'gs-component-finished-loading',
3
4
  dateRangeFilterChanged: 'gs-date-range-filter-changed',
4
5
  dateRangeOptionChanged: 'gs-date-range-option-changed',
5
6
  mutationFilterChanged: 'gs-mutation-filter-changed',
@@ -0,0 +1,19 @@
1
+ import { useEffect, useRef } from 'preact/hooks';
2
+
3
+ import { gsEventNames } from './gsEventNames';
4
+
5
+ export function useDispatchFinishedLoadingEvent() {
6
+ const ref = useRef<HTMLDivElement>(null);
7
+
8
+ useEffect(() => {
9
+ if (ref.current === null) {
10
+ return;
11
+ }
12
+
13
+ ref.current.dispatchEvent(
14
+ new CustomEvent(gsEventNames.componentFinishedLoading, { bubbles: true, composed: true }),
15
+ );
16
+ }, [ref]);
17
+
18
+ return ref;
19
+ }
@@ -19,7 +19,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
19
19
  * The slider must be restricted to a certain range.
20
20
  * Users can however still enter values outside of this range in the text input fields.
21
21
  *
22
- * @fires {CustomEvent<Record<string, string | undefined>>} gs-number-range-filter-changed
22
+ * @fires {CustomEvent<Record<string, number | undefined>>} gs-number-range-filter-changed
23
23
  * Fired when the slider is released,
24
24
  * `onBlur` on the input fields after the user has typed a valid range in the input fields,
25
25
  * or when one of the input fields is cleared.
@@ -39,7 +39,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
39
39
  * }
40
40
  * ```
41
41
  *
42
- * @fires {CustomEvent<Record<string, string | undefined>>} gs-number-range-value-changed
42
+ * @fires {CustomEvent<Record<string, number | undefined>>} gs-number-range-value-changed
43
43
  * Similar to the `gs-number-range-filter-changed` event,
44
44
  * but contains an `event.detail` that has a fixed format:
45
45
  * ```
@@ -30,6 +30,9 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
30
30
  *
31
31
  * The chart shows the bars with the highest aggregated `count`.
32
32
  * The number of bars can be adjusted with the `maxNumberOfBars` property.
33
+ *
34
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
35
+ * Fired when the component has finished loading the required data from LAPIS.
33
36
  */
34
37
  @customElement('gs-aggregate')
35
38
  export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
@@ -10,6 +10,8 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
10
10
  * This component shows the Coding Sequence (CDS) of a genome using a gff3 file as input.
11
11
  * The CDS shows which parts of the genome are translated into proteins.
12
12
  *
13
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
14
+ * Fired when the component has finished loading the required data.
13
15
  */
14
16
  @customElement('gs-genome-data-viewer')
15
17
  export class GenomeDataViewerComponent extends PreactLitAdapter {
@@ -34,6 +34,9 @@ import { type MutationAnnotations, mutationAnnotationsContext } from '../mutatio
34
34
  * selected proportion interval.
35
35
  * Thus, changing the proportion interval may change a mutations from being "common" between the datasets
36
36
  * to being "for one dataset only".
37
+ *
38
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
39
+ * Fired when the component has finished loading the required data from LAPIS.
37
40
  */
38
41
  @customElement('gs-mutation-comparison')
39
42
  export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
@@ -38,6 +38,9 @@ import { type MutationAnnotations, mutationAnnotationsContext } from '../mutatio
38
38
  * Users can filter the displayed rows by mean proportion via a slider in the toolbar.
39
39
  * The mean proportion of each row is calculated by LAPIS over the whole data range that the component displays.
40
40
  * The initial mean proportion can be set via `initialMeanProportionInterval`.
41
+ *
42
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
43
+ * Fired when the component has finished loading the required data from LAPIS.
41
44
  */
42
45
  @customElement('gs-mutations-over-time')
43
46
  export class MutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
@@ -60,6 +60,8 @@ import { type MutationAnnotations, mutationAnnotationsContext } from '../mutatio
60
60
  *
61
61
  * The insertions view shows the count of all insertions for the dataset.
62
62
  *
63
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
64
+ * Fired when the component has finished loading the required data from LAPIS.
63
65
  */
64
66
  @customElement('gs-mutations')
65
67
  export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
@@ -19,6 +19,9 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
19
19
  * Thus, the `lapisFilter` implicitly also defines the range that is shown on the x-axis.
20
20
  * If you want to restrict the x-axis to a smaller date range,
21
21
  * then you need to set appropriate filter values in the `lapisFilter`.
22
+ *
23
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
24
+ * Fired when the component has finished loading the required data from LAPIS.
22
25
  */
23
26
  @customElement('gs-number-sequences-over-time')
24
27
  export class NumberSequencesOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
@@ -41,6 +41,9 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
41
41
  * ### Table View
42
42
  *
43
43
  * Displays the prevalence over time as a table with one row per time point.
44
+ *
45
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
46
+ * Fired when the component has finished loading the required data from LAPIS.
44
47
  */
45
48
  @customElement('gs-prevalence-over-time')
46
49
  export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
@@ -33,6 +33,9 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
33
33
  * The dots in the plot show the proportions of the focal variant (defined by the `numeratorFilter`) to the baseline variant (defined by the `denominatorFilter`)
34
34
  * for every day as observed in the data.
35
35
  * The line shows a logistic curve fitted to the data points, including a 95% confidence interval.
36
+ *
37
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
38
+ * Fired when the component has finished loading the required data from LAPIS.
36
39
  */
37
40
  @customElement('gs-relative-growth-advantage')
38
41
  export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
@@ -94,6 +94,9 @@ const leafletModificationsCss = unsafeCSS(leafletStyleModifications);
94
94
  * - `lapisLocationField`,
95
95
  * - `count` (the number of samples in this location matching the `lapisFilter`),
96
96
  * - `proportion` (`count` / sum of the `count` of all locations).
97
+ *
98
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
99
+ * Fired when the component has finished loading the required data from LAPIS.
97
100
  */
98
101
  @customElement('gs-sequences-by-location')
99
102
  export class SequencesByLocationComponent extends PreactLitAdapterWithGridJsStyles {
@@ -10,6 +10,9 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
10
10
  *
11
11
  * This component displays general statistics (number of sequences, overall proportion)
12
12
  * for a given numerator and denominator filter.
13
+ *
14
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
15
+ * Fired when the component has finished loading the required data from LAPIS.
13
16
  */
14
17
  @customElement('gs-statistics')
15
18
  export class StatisticsComponent extends PreactLitAdapterWithGridJsStyles {
@@ -24,6 +24,9 @@ import { type MutationAnnotations, mutationAnnotationsContext } from '../mutatio
24
24
  * This component also assumes that the LAPIS instance has the field `date` which can be used for the time axis.
25
25
  *
26
26
  * @slot infoText - Additional information text to be shown in the info modal (the "?" button).
27
+ *
28
+ * @fires {CustomEvent<undefined>} gs-component-finished-loading
29
+ * Fired when the component has finished loading the required data from LAPIS.
27
30
  */
28
31
  @customElement('gs-wastewater-mutations-over-time')
29
32
  export class WastewaterMutationsOverTimeComponent extends PreactLitAdapterWithGridJsStyles {