@genspectrum/dashboard-components 0.1.5 → 0.3.0

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 (69) hide show
  1. package/custom-elements.json +1161 -928
  2. package/dist/dashboard-components.js +663 -237
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/genspectrum-components.d.ts +177 -140
  5. package/dist/style.css +247 -50
  6. package/package.json +2 -3
  7. package/src/constants.ts +1 -1
  8. package/src/lapisApi/lapisApi.ts +46 -2
  9. package/src/lapisApi/lapisTypes.ts +14 -0
  10. package/src/preact/aggregatedData/aggregate.stories.tsx +4 -2
  11. package/src/preact/aggregatedData/aggregate.tsx +31 -29
  12. package/src/preact/components/error-boundary.stories.tsx +54 -0
  13. package/src/preact/components/error-boundary.tsx +22 -0
  14. package/src/preact/components/error-display.stories.tsx +32 -4
  15. package/src/preact/components/error-display.tsx +48 -1
  16. package/src/preact/components/loading-display.stories.tsx +6 -6
  17. package/src/preact/components/loading-display.tsx +1 -1
  18. package/src/preact/components/no-data-display.tsx +5 -1
  19. package/src/preact/components/resize-container.tsx +5 -14
  20. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +19 -0
  21. package/src/preact/dateRangeSelector/date-range-selector.tsx +38 -7
  22. package/src/preact/locationFilter/fetchAutocompletionList.ts +15 -1
  23. package/src/preact/locationFilter/location-filter.stories.tsx +23 -6
  24. package/src/preact/locationFilter/location-filter.tsx +28 -18
  25. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +6 -3
  26. package/src/preact/mutationComparison/mutation-comparison.tsx +33 -32
  27. package/src/preact/mutationComparison/queryMutationData.ts +2 -3
  28. package/src/preact/mutationFilter/mutation-filter.stories.tsx +18 -3
  29. package/src/preact/mutationFilter/mutation-filter.tsx +26 -7
  30. package/src/preact/mutations/mutations.stories.tsx +6 -3
  31. package/src/preact/mutations/mutations.tsx +28 -26
  32. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +14 -7
  33. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +50 -32
  34. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +6 -3
  35. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +46 -32
  36. package/src/preact/textInput/text-input.stories.tsx +26 -0
  37. package/src/preact/textInput/text-input.tsx +25 -3
  38. package/src/query/queryPrevalenceOverTime.ts +4 -10
  39. package/src/types.ts +4 -1
  40. package/src/web-components/ResizeContainer.mdx +13 -0
  41. package/src/web-components/app.stories.ts +1 -2
  42. package/src/web-components/app.ts +7 -3
  43. package/src/web-components/index.ts +1 -1
  44. package/src/web-components/input/{date-range-selector-component.stories.ts → gs-date-range-selector.stories.ts} +29 -4
  45. package/src/web-components/input/{date-range-selector-component.tsx → gs-date-range-selector.tsx} +32 -10
  46. package/src/web-components/input/{location-filter-component.stories.ts → gs-location-filter.stories.ts} +32 -5
  47. package/src/web-components/input/{location-filter-component.tsx → gs-location-filter.tsx} +11 -1
  48. package/src/web-components/input/{mutation-filter-component.stories.ts → gs-mutation-filter.stories.ts} +23 -4
  49. package/src/web-components/input/gs-mutation-filter.tsx +126 -0
  50. package/src/web-components/input/{text-input-component.stories.ts → gs-text-input.stories.ts} +34 -6
  51. package/src/web-components/input/{text-input-component.tsx → gs-text-input.tsx} +16 -4
  52. package/src/web-components/input/index.ts +4 -4
  53. package/src/web-components/input/introduction.mdx +11 -0
  54. package/src/web-components/introduction.mdx +15 -0
  55. package/src/web-components/visualization/data_visualization_statistical_analysis.mdx +26 -0
  56. package/src/web-components/{display/aggregate-component.stories.ts → visualization/gs-aggregate.stories.ts} +23 -11
  57. package/src/web-components/visualization/gs-aggregate.tsx +88 -0
  58. package/src/web-components/{display/mutation-comparison-component.stories.ts → visualization/gs-mutation-comparison.stories.ts} +21 -16
  59. package/src/web-components/{display/mutation-comparison-component.tsx → visualization/gs-mutation-comparison.tsx} +27 -18
  60. package/src/web-components/{display/mutations-component.stories.ts → visualization/gs-mutations.stories.ts} +20 -15
  61. package/src/web-components/{display/mutations-component.tsx → visualization/gs-mutations.tsx} +20 -10
  62. package/src/web-components/{display/prevalence-over-time-component.stories.ts → visualization/gs-prevalence-over-time.stories.ts} +29 -20
  63. package/src/web-components/{display/prevalence-over-time-component.tsx → visualization/gs-prevalence-over-time.tsx} +47 -22
  64. package/src/web-components/{display/relative-growth-advantage-component.stories.ts → visualization/gs-relative-growth-advantage.stories.ts} +12 -7
  65. package/src/web-components/{display/relative-growth-advantage-component.tsx → visualization/gs-relative-growth-advantage.tsx} +21 -9
  66. package/src/web-components/visualization/index.ts +5 -0
  67. package/src/web-components/display/aggregate-component.tsx +0 -72
  68. package/src/web-components/display/index.ts +0 -5
  69. package/src/web-components/input/mutation-filter-component.tsx +0 -83
@@ -1,15 +1,12 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
 
3
- import {
4
- MutationComparison,
5
- type MutationComparisonVariant,
6
- type View,
7
- } from '../../preact/mutationComparison/mutation-comparison';
8
- import { type SequenceType } from '../../types';
3
+ import { MutationComparison, type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
9
4
  import { type Equals, type Expect } from '../../utils/typeAssertions';
10
5
  import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
11
6
 
12
7
  /**
8
+ * ## Context
9
+ *
13
10
  * This component allows to compare mutations between different variants.
14
11
  * A variant is defined by its LAPIS filter.
15
12
  *
@@ -32,9 +29,11 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
32
29
  * Thus, changing the proportion interval may change a mutations from being "common" between variant
33
30
  * to being "for one variant only".
34
31
  */
35
- @customElement('gs-mutation-comparison-component')
32
+ @customElement('gs-mutation-comparison')
36
33
  export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
37
34
  /**
35
+ * Required.
36
+ *
38
37
  * An array of variants to compare.
39
38
  *
40
39
  * The `lapisFilter` will be sent as is to LAPIS to filter the mutation data.
@@ -62,21 +61,26 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
62
61
  views: ('table' | 'venn')[] = ['table'];
63
62
 
64
63
  /**
65
- * The size of the component.
64
+ * The width of the component.
66
65
  *
67
- * If not set, the component will take the full width of its container with height 700px.
66
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
67
+ */
68
+ @property({ type: String })
69
+ width: string = '100%';
70
+
71
+ /**
72
+ * The height of the component.
68
73
  *
69
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
70
- * If the unit is %, the size will be relative to the container of the component.
74
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
71
75
  */
72
- @property({ type: Object })
73
- size: { width?: string; height?: string } | undefined = undefined;
76
+ @property({ type: String })
77
+ height: string = '700px';
74
78
 
75
79
  /**
76
80
  * The headline of the component. Set to an empty string to hide the headline.
77
81
  */
78
82
  @property({ type: String })
79
- headline: string | undefined = 'Mutation comparison';
83
+ headline: string = 'Mutation comparison';
80
84
 
81
85
  override render() {
82
86
  return (
@@ -84,7 +88,8 @@ export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyle
84
88
  variants={this.variants}
85
89
  sequenceType={this.sequenceType}
86
90
  views={this.views}
87
- size={this.size}
91
+ width={this.width}
92
+ height={this.height}
88
93
  headline={this.headline}
89
94
  />
90
95
  );
@@ -99,8 +104,12 @@ declare global {
99
104
 
100
105
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
101
106
  type VariantsMatches = Expect<
102
- Equals<typeof MutationComparisonComponent.prototype.variants, MutationComparisonVariant[]>
107
+ Equals<typeof MutationComparisonComponent.prototype.variants, MutationComparisonProps['variants']>
108
+ >;
109
+ type SequenceTypeMatches = Expect<
110
+ Equals<typeof MutationComparisonComponent.prototype.sequenceType, MutationComparisonProps['sequenceType']>
111
+ >;
112
+ type ViewsMatches = Expect<
113
+ Equals<typeof MutationComparisonComponent.prototype.views, MutationComparisonProps['views']>
103
114
  >;
104
- type SequenceTypeMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.sequenceType, SequenceType>>;
105
- type ViewsMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.views, View[]>>;
106
115
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -2,7 +2,7 @@ import { expect, fireEvent, waitFor } from '@storybook/test';
2
2
  import type { Meta, StoryObj } from '@storybook/web-components';
3
3
  import { html } from 'lit';
4
4
 
5
- import './mutations-component';
5
+ import './gs-mutations';
6
6
  import '../app';
7
7
  import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
8
8
  import { LAPIS_URL, NUCLEOTIDE_INSERTIONS_ENDPOINT, NUCLEOTIDE_MUTATIONS_ENDPOINT } from '../../constants';
@@ -16,11 +16,14 @@ const codeExample = String.raw`
16
16
  variant='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateTo": "2022-01-01" }'
17
17
  sequenceType="nucleotide"
18
18
  views='["grid", "table", "insertions"]'
19
+ headline="Mutations"
20
+ width='100%'
21
+ height='700px'
19
22
  ></gs-mutations>`;
20
23
 
21
- const meta: Meta<MutationsProps> = {
24
+ const meta: Meta<Required<MutationsProps>> = {
22
25
  title: 'Visualization/Mutations',
23
- component: 'gs-mutations-component',
26
+ component: 'gs-mutations',
24
27
  argTypes: {
25
28
  variant: { control: 'object' },
26
29
  sequenceType: {
@@ -31,19 +34,20 @@ const meta: Meta<MutationsProps> = {
31
34
  options: ['table', 'grid', 'insertions'],
32
35
  control: { type: 'check' },
33
36
  },
34
- size: { control: 'object' },
37
+ width: { control: 'text' },
38
+ height: { control: 'text' },
35
39
  headline: { control: 'text' },
36
40
  },
37
41
  args: {
38
42
  variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
39
43
  sequenceType: 'nucleotide',
40
44
  views: ['grid', 'table', 'insertions'],
41
- size: { width: '100%', height: '700px' },
45
+ width: '100%',
46
+ height: '700px',
42
47
  headline: 'Mutations',
43
48
  },
44
49
  parameters: withComponentDocs({
45
50
  componentDocs: {
46
- tag: 'gs-mutations-component',
47
51
  opensShadowDom: true,
48
52
  expectsChildren: false,
49
53
  codeExample,
@@ -54,21 +58,22 @@ const meta: Meta<MutationsProps> = {
54
58
 
55
59
  export default meta;
56
60
 
57
- const Template: StoryObj<MutationsProps> = {
61
+ const Template: StoryObj<Required<MutationsProps>> = {
58
62
  render: (args) => html`
59
63
  <gs-app lapis="${LAPIS_URL}">
60
- <gs-mutations-component
64
+ <gs-mutations
61
65
  .variant=${args.variant}
62
66
  .sequenceType=${args.sequenceType}
63
67
  .views=${args.views}
64
- .size=${args.size}
68
+ .width=${args.width}
69
+ .height=${args.height}
65
70
  .headline=${args.headline}
66
- ></gs-mutations-component>
71
+ ></gs-mutations>
67
72
  </gs-app>
68
73
  `,
69
74
  };
70
75
 
71
- export const Default: StoryObj<MutationsProps> = {
76
+ export const Default: StoryObj<Required<MutationsProps>> = {
72
77
  ...Template,
73
78
  parameters: {
74
79
  fetchMock: {
@@ -105,10 +110,10 @@ export const Default: StoryObj<MutationsProps> = {
105
110
  },
106
111
  };
107
112
 
108
- export const OnTableTab: StoryObj<MutationsProps> = {
113
+ export const OnTableTab: StoryObj<Required<MutationsProps>> = {
109
114
  ...Default,
110
115
  play: async ({ canvasElement }) => {
111
- const canvas = await withinShadowRoot(canvasElement, 'gs-mutations-component');
116
+ const canvas = await withinShadowRoot(canvasElement, 'gs-mutations');
112
117
 
113
118
  await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument());
114
119
 
@@ -116,10 +121,10 @@ export const OnTableTab: StoryObj<MutationsProps> = {
116
121
  },
117
122
  };
118
123
 
119
- export const OnInsertionsTab: StoryObj<MutationsProps> = {
124
+ export const OnInsertionsTab: StoryObj<Required<MutationsProps>> = {
120
125
  ...Default,
121
126
  play: async ({ canvasElement }) => {
122
- const canvas = await withinShadowRoot(canvasElement, 'gs-mutations-component');
127
+ const canvas = await withinShadowRoot(canvasElement, 'gs-mutations');
123
128
 
124
129
  await waitFor(() => expect(canvas.getByRole('button', { name: 'Insertions' })).toBeInTheDocument());
125
130
 
@@ -6,6 +6,8 @@ import type { Equals, Expect } from '../../utils/typeAssertions';
6
6
  import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
7
7
 
8
8
  /**
9
+ * ## Context
10
+ *
9
11
  * This component displays mutations (substitutions, deletions and insertions) for a given variant.
10
12
  *
11
13
  * ## Views
@@ -30,14 +32,16 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
30
32
  * The insertions view shows the count of all insertions for the given variant.
31
33
  *
32
34
  */
33
- @customElement('gs-mutations-component')
35
+ @customElement('gs-mutations')
34
36
  export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
35
37
  /**
38
+ * Required.
39
+ *
36
40
  * The `variant` will be sent as is to LAPIS to filter the mutation data.
37
41
  * It must be a valid LAPIS filter object.
38
42
  */
39
43
  @property({ type: Object })
40
- variant: Record<string, string | number | null | boolean> = { displayName: '' };
44
+ variant: Record<string, string | number | null | boolean> = {};
41
45
 
42
46
  /**
43
47
  * The type of the sequence for which the mutations should be shown.
@@ -52,21 +56,26 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
52
56
  views: ('table' | 'grid' | 'insertions')[] = ['table', 'grid'];
53
57
 
54
58
  /**
55
- * The size of the component.
59
+ * The width of the component.
56
60
  *
57
- * If not set, the component will take the full width of its container with height 700px.
61
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
62
+ */
63
+ @property({ type: String })
64
+ width: string = '100%';
65
+
66
+ /**
67
+ * The height of the component.
58
68
  *
59
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
60
- * If the unit is %, the size will be relative to the container of the component.
69
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
61
70
  */
62
- @property({ type: Object })
63
- size: { width?: string; height?: string } | undefined = undefined;
71
+ @property({ type: String })
72
+ height: string = '700px';
64
73
 
65
74
  /**
66
75
  * The headline of the component. Set to an empty string to hide the headline.
67
76
  */
68
77
  @property({ type: String })
69
- headline: string | undefined = 'Mutations';
78
+ headline: string = 'Mutations';
70
79
 
71
80
  override render() {
72
81
  return (
@@ -74,7 +83,8 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
74
83
  variant={this.variant}
75
84
  sequenceType={this.sequenceType}
76
85
  views={this.views}
77
- size={this.size}
86
+ width={this.width}
87
+ height={this.height}
78
88
  headline={this.headline}
79
89
  />
80
90
  );
@@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/web-components';
3
3
  import { html } from 'lit';
4
4
 
5
5
  import '../app';
6
- import './prevalence-over-time-component';
6
+ import './gs-prevalence-over-time';
7
7
  import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
8
8
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
9
9
  import denominator from '../../preact/prevalenceOverTime/__mockData__/denominator.json';
@@ -16,15 +16,18 @@ import { withinShadowRoot } from '../withinShadowRoot.story';
16
16
 
17
17
  const codeExample = String.raw`
18
18
  <gs-prevalence-over-time
19
- numerator='[{ "displayName": "EG", "country": "USA", "pangoLineage": "EG*" }, { "displayName": "JN.1", "country": "USA", "pangoLineage": "JN.1*" }]'
20
- denominator='{ "country": "USA", "displayName": "All" }'
19
+ numerator='[{ "displayName": "EG", "lapisFilter": { "country": "USA", "pangoLineage": "EG*" }}, { "displayName": "JN.1", "lapisFilter": { "country": "USA", "pangoLineage": "JN.1*" }}]'
20
+ denominator='{ "country": "USA"}'
21
21
  granularity="month"
22
22
  smoothingWindow="0"
23
23
  views='["bar", "line", "bubble", "table"]'
24
24
  confidenceIntervalMethods='["wilson"]'
25
+ headline="Prevalence over time"
26
+ width='100%'
27
+ height='700px'
25
28
  ></gs-prevalence-over-time>`;
26
29
 
27
- const meta: Meta<PrevalenceOverTimeProps> = {
30
+ const meta: Meta<Required<PrevalenceOverTimeProps>> = {
28
31
  title: 'Visualization/Prevalence over time',
29
32
  component: 'gs-prevalence-over-time',
30
33
  argTypes: {
@@ -43,12 +46,12 @@ const meta: Meta<PrevalenceOverTimeProps> = {
43
46
  options: ['wilson'],
44
47
  control: { type: 'check' },
45
48
  },
46
- size: [{ control: 'object' }],
49
+ width: { control: 'text' },
50
+ height: { control: 'text' },
47
51
  headline: { control: 'text' },
48
52
  },
49
53
  parameters: withComponentDocs({
50
54
  componentDocs: {
51
- tag: 'gs-prevalence-over-time',
52
55
  opensShadowDom: true,
53
56
  expectsChildren: false,
54
57
  codeExample,
@@ -59,7 +62,7 @@ const meta: Meta<PrevalenceOverTimeProps> = {
59
62
 
60
63
  export default meta;
61
64
 
62
- const Template: StoryObj<PrevalenceOverTimeProps> = {
65
+ const Template: StoryObj<Required<PrevalenceOverTimeProps>> = {
63
66
  render: (args) => html`
64
67
  <gs-app lapis="${LAPIS_URL}">
65
68
  <gs-prevalence-over-time
@@ -69,26 +72,28 @@ const Template: StoryObj<PrevalenceOverTimeProps> = {
69
72
  .smoothingWindow=${args.smoothingWindow}
70
73
  .views=${args.views}
71
74
  .confidenceIntervalMethods=${args.confidenceIntervalMethods}
72
- .size=${args.size}
75
+ .width=${args.width}
76
+ .height=${args.height}
73
77
  .headline=${args.headline}
74
78
  ></gs-prevalence-over-time>
75
79
  </gs-app>
76
80
  `,
77
81
  };
78
82
 
79
- export const TwoVariants: StoryObj<PrevalenceOverTimeProps> = {
83
+ export const TwoVariants: StoryObj<Required<PrevalenceOverTimeProps>> = {
80
84
  ...Template,
81
85
  args: {
82
86
  numerator: [
83
- { displayName: 'EG', country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' },
84
- { displayName: 'JN.1', country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' },
87
+ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } },
88
+ { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } },
85
89
  ],
86
- denominator: { country: 'USA', dateFrom: '2023-01-01', displayName: 'All' },
90
+ denominator: { country: 'USA', dateFrom: '2023-01-01' },
87
91
  granularity: 'month',
88
92
  smoothingWindow: 0,
89
93
  views: ['bar', 'line', 'bubble', 'table'],
90
94
  confidenceIntervalMethods: ['wilson'],
91
- size: { width: '100%', height: '700px' },
95
+ width: '100%',
96
+ height: '700px',
92
97
  headline: 'Prevalence over time',
93
98
  },
94
99
  parameters: {
@@ -146,16 +151,20 @@ export const TwoVariants: StoryObj<PrevalenceOverTimeProps> = {
146
151
  },
147
152
  };
148
153
 
149
- export const OneVariant: StoryObj<PrevalenceOverTimeProps> = {
154
+ export const OneVariant: StoryObj<Required<PrevalenceOverTimeProps>> = {
150
155
  ...Template,
151
156
  args: {
152
- numerator: { displayName: 'EG', country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
153
- denominator: { country: 'USA', dateFrom: '2023-10-01', displayName: 'All' },
157
+ numerator: {
158
+ displayName: 'EG',
159
+ lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
160
+ },
161
+ denominator: { country: 'USA', dateFrom: '2023-10-01' },
154
162
  granularity: 'day',
155
163
  smoothingWindow: 7,
156
164
  views: ['bar', 'line', 'bubble', 'table'],
157
165
  confidenceIntervalMethods: ['wilson'],
158
- size: { width: '100%', height: '700px' },
166
+ width: '100%',
167
+ height: '700px',
159
168
  headline: 'Prevalence over time',
160
169
  },
161
170
  parameters: {
@@ -197,7 +206,7 @@ export const OneVariant: StoryObj<PrevalenceOverTimeProps> = {
197
206
  },
198
207
  };
199
208
 
200
- export const OneVariantOnLineTab: StoryObj<PrevalenceOverTimeProps> = {
209
+ export const OneVariantOnLineTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
201
210
  ...OneVariant,
202
211
  play: async ({ canvasElement }) => {
203
212
  const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
@@ -208,7 +217,7 @@ export const OneVariantOnLineTab: StoryObj<PrevalenceOverTimeProps> = {
208
217
  },
209
218
  };
210
219
 
211
- export const OneVariantOnBubbleTab: StoryObj<PrevalenceOverTimeProps> = {
220
+ export const OneVariantOnBubbleTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
212
221
  ...OneVariant,
213
222
  play: async ({ canvasElement }) => {
214
223
  const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
@@ -219,7 +228,7 @@ export const OneVariantOnBubbleTab: StoryObj<PrevalenceOverTimeProps> = {
219
228
  },
220
229
  };
221
230
 
222
- export const OneVariantOnTableTab: StoryObj<PrevalenceOverTimeProps> = {
231
+ export const OneVariantOnTableTab: StoryObj<Required<PrevalenceOverTimeProps>> = {
223
232
  ...OneVariant,
224
233
  play: async ({ canvasElement }) => {
225
234
  const canvas = await withinShadowRoot(canvasElement, 'gs-prevalence-over-time');
@@ -1,12 +1,12 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
 
3
- import PrevalenceOverTime, { type View } from '../../preact/prevalenceOverTime/prevalence-over-time';
4
- import { type ConfidenceIntervalMethod } from '../../preact/shared/charts/confideceInterval';
5
- import { type NamedLapisFilter, type TemporalGranularity } from '../../types';
3
+ import PrevalenceOverTime, { type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
6
4
  import { type Equals, type Expect } from '../../utils/typeAssertions';
7
5
  import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
8
6
 
9
7
  /**
8
+ * ## Context
9
+ *
10
10
  * This component displays the prevalence over time of one or more variants.
11
11
  * The prevalence is calculated as the ratio of the number of cases of each variant given as `numerator`
12
12
  * to the number of cases of the variant given as `denominator`.
@@ -43,24 +43,34 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
43
43
  */
44
44
  @customElement('gs-prevalence-over-time')
45
45
  export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyles {
46
+ // prettier-ignore
47
+ // The multiline union type must not start with `|` because it looks weird in the Storybook docs
46
48
  /**
49
+ * Required.
50
+ *
47
51
  * Either a single variant or an array of variants to compare.
48
52
  * This must be a valid LAPIS filter object with an additional `displayName` property
49
53
  * which will be used as the label for the variant in the views,
50
54
  * or an array of such objects.
51
55
  */
52
- @property({ type: Object })
56
+ @property({type: Object})
53
57
  numerator:
54
- | (Record<string, string | number | null | boolean> & { displayName: string })
55
- | (Record<string, string | number | null | boolean> & {
56
- displayName: string;
57
- })[] = { displayName: '' };
58
+ {
59
+ lapisFilter: Record<string, string | number | null | boolean>;
60
+ displayName: string;
61
+ }
62
+ | {
63
+ lapisFilter: Record<string, string | number | null | boolean>;
64
+ displayName: string;
65
+ }[] = { displayName: '', lapisFilter: {} };
58
66
 
59
67
  /**
68
+ * Required.
69
+ *
60
70
  * The variant that the variants in `numerator` are compared to.
61
71
  */
62
72
  @property({ type: Object })
63
- denominator: Record<string, string | number | null | boolean> & { displayName: string } = { displayName: '' };
73
+ denominator: Record<string, string | number | null | boolean> = {};
64
74
 
65
75
  /**
66
76
  * The granularity of the time axis.
@@ -98,18 +108,23 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
98
108
  * The headline of the component. Set to an empty string to hide the headline.
99
109
  */
100
110
  @property({ type: String })
101
- headline: string | undefined = 'Prevalence over time';
111
+ headline: string = 'Prevalence over time';
102
112
 
103
113
  /**
104
- * The size of the component.
114
+ * The width of the component.
105
115
  *
106
- * If not set, the component will take the full width of its container with height 700px.
116
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
117
+ */
118
+ @property({ type: String })
119
+ width: string = '100%';
120
+
121
+ /**
122
+ * The height of the component.
107
123
  *
108
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
109
- * If the unit is %, the size will be relative to the container of the component.
124
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
110
125
  */
111
- @property({ type: Object })
112
- size: { width?: string; height?: string } | undefined = undefined;
126
+ @property({ type: String })
127
+ height: string = '700px';
113
128
 
114
129
  override render() {
115
130
  return (
@@ -120,7 +135,8 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
120
135
  smoothingWindow={this.smoothingWindow}
121
136
  views={this.views}
122
137
  confidenceIntervalMethods={this.confidenceIntervalMethods}
123
- size={this.size}
138
+ width={this.width}
139
+ height={this.height}
124
140
  headline={this.headline}
125
141
  />
126
142
  );
@@ -135,12 +151,21 @@ declare global {
135
151
 
136
152
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
137
153
  type NumeratorMatches = Expect<
138
- Equals<typeof PrevalenceOverTimeComponent.prototype.numerator, NamedLapisFilter | NamedLapisFilter[]>
154
+ Equals<typeof PrevalenceOverTimeComponent.prototype.numerator, PrevalenceOverTimeProps['numerator']>
155
+ >;
156
+ type DenominatorMatches = Expect<
157
+ Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, PrevalenceOverTimeProps['denominator']>
158
+ >;
159
+ type GranularityMatches = Expect<
160
+ Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, PrevalenceOverTimeProps['granularity']>
161
+ >;
162
+ type ViewsMatches = Expect<
163
+ Equals<typeof PrevalenceOverTimeComponent.prototype.views, PrevalenceOverTimeProps['views']>
139
164
  >;
140
- type DenominatorMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, NamedLapisFilter>>;
141
- type GranularityMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, TemporalGranularity>>;
142
- type ViewsMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.views, View[]>>;
143
165
  type ConfidenceIntervalMethodsMatches = Expect<
144
- Equals<typeof PrevalenceOverTimeComponent.prototype.confidenceIntervalMethods, ConfidenceIntervalMethod[]>
166
+ Equals<
167
+ typeof PrevalenceOverTimeComponent.prototype.confidenceIntervalMethods,
168
+ PrevalenceOverTimeProps['confidenceIntervalMethods']
169
+ >
145
170
  >;
146
171
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/web-components';
2
2
  import { html } from 'lit';
3
3
 
4
- import './relative-growth-advantage-component';
4
+ import './gs-relative-growth-advantage';
5
5
  import '../app';
6
6
  import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
7
7
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
@@ -15,6 +15,9 @@ const codeExample = String.raw`
15
15
  denominator='{ "country": "Switzerland", "dateFrom": "2020-12-01" }'
16
16
  generationTime="7"
17
17
  views='["line"]'
18
+ width='100%'
19
+ height='700px'
20
+ headline="Relative growth advantage"
18
21
  ></gs-relative-growth-advantage>`;
19
22
 
20
23
  const meta: Meta<RelativeGrowthAdvantageProps> = {
@@ -28,12 +31,12 @@ const meta: Meta<RelativeGrowthAdvantageProps> = {
28
31
  options: ['line'],
29
32
  control: { type: 'check' },
30
33
  },
31
- size: [{ control: 'object' }],
34
+ width: { control: 'text' },
35
+ height: { control: 'text' },
32
36
  headline: { control: 'text' },
33
37
  },
34
38
  parameters: withComponentDocs({
35
39
  componentDocs: {
36
- tag: 'gs-relative-growth-advantage',
37
40
  opensShadowDom: true,
38
41
  expectsChildren: false,
39
42
  codeExample,
@@ -44,7 +47,7 @@ const meta: Meta<RelativeGrowthAdvantageProps> = {
44
47
 
45
48
  export default meta;
46
49
 
47
- const Template: StoryObj<RelativeGrowthAdvantageProps> = {
50
+ const Template: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
48
51
  render: (args) => html`
49
52
  <gs-app lapis="${LAPIS_URL}">
50
53
  <gs-relative-growth-advantage
@@ -52,21 +55,23 @@ const Template: StoryObj<RelativeGrowthAdvantageProps> = {
52
55
  .denominator=${args.denominator}
53
56
  .generationTime=${args.generationTime}
54
57
  .views=${args.views}
55
- .size=${args.size}
58
+ .width=${args.width}
59
+ .height=${args.height}
56
60
  .headline=${args.headline}
57
61
  ></gs-relative-growth-advantage>
58
62
  </gs-app>
59
63
  `,
60
64
  };
61
65
 
62
- export const Default: StoryObj<RelativeGrowthAdvantageProps> = {
66
+ export const Default: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
63
67
  ...Template,
64
68
  args: {
65
69
  numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
66
70
  denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
67
71
  generationTime: 7,
68
72
  views: ['line'],
69
- size: { width: '100%', height: '700px' },
73
+ width: '100%',
74
+ height: '700px',
70
75
  headline: 'Relative growth advantage',
71
76
  },
72
77
  parameters: {