@genspectrum/dashboard-components 0.2.0 → 0.3.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 (59) hide show
  1. package/custom-elements.json +330 -179
  2. package/dist/dashboard-components.js +379 -187
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/genspectrum-components.d.ts +160 -114
  5. package/dist/style.css +171 -71
  6. package/package.json +1 -2
  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 +8 -6
  12. package/src/preact/components/error-boundary.stories.tsx +6 -14
  13. package/src/preact/components/error-boundary.tsx +2 -11
  14. package/src/preact/components/error-display.stories.tsx +12 -5
  15. package/src/preact/components/error-display.tsx +37 -3
  16. package/src/preact/components/loading-display.stories.tsx +1 -1
  17. package/src/preact/components/resize-container.tsx +5 -14
  18. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +2 -0
  19. package/src/preact/dateRangeSelector/date-range-selector.tsx +11 -8
  20. package/src/preact/locationFilter/fetchAutocompletionList.ts +15 -1
  21. package/src/preact/locationFilter/location-filter.stories.tsx +1 -1
  22. package/src/preact/locationFilter/location-filter.tsx +16 -30
  23. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +6 -3
  24. package/src/preact/mutationComparison/mutation-comparison.tsx +10 -13
  25. package/src/preact/mutationComparison/queryMutationData.ts +2 -3
  26. package/src/preact/mutationFilter/mutation-filter.stories.tsx +8 -8
  27. package/src/preact/mutationFilter/mutation-filter.tsx +7 -6
  28. package/src/preact/mutations/mutations.stories.tsx +6 -3
  29. package/src/preact/mutations/mutations.tsx +8 -6
  30. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +14 -7
  31. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +10 -8
  32. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +6 -3
  33. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +9 -7
  34. package/src/preact/textInput/text-input.stories.tsx +26 -0
  35. package/src/preact/textInput/text-input.tsx +4 -5
  36. package/src/query/queryPrevalenceOverTime.ts +4 -10
  37. package/src/types.ts +4 -1
  38. package/src/web-components/ResizeContainer.mdx +13 -0
  39. package/src/web-components/app.ts +3 -1
  40. package/src/web-components/input/gs-date-range-selector.stories.ts +10 -2
  41. package/src/web-components/input/gs-date-range-selector.tsx +26 -16
  42. package/src/web-components/input/gs-location-filter.stories.ts +5 -7
  43. package/src/web-components/input/gs-location-filter.tsx +6 -7
  44. package/src/web-components/input/gs-mutation-filter.stories.ts +11 -8
  45. package/src/web-components/input/gs-mutation-filter.tsx +38 -26
  46. package/src/web-components/input/gs-text-input.stories.ts +3 -3
  47. package/src/web-components/input/gs-text-input.tsx +10 -10
  48. package/src/web-components/input/introduction.mdx +11 -0
  49. package/src/web-components/introduction.mdx +15 -0
  50. package/src/web-components/visualization/gs-aggregate.stories.ts +19 -6
  51. package/src/web-components/visualization/gs-aggregate.tsx +31 -15
  52. package/src/web-components/visualization/gs-mutation-comparison.stories.ts +13 -7
  53. package/src/web-components/visualization/gs-mutation-comparison.tsx +26 -17
  54. package/src/web-components/visualization/gs-mutations.stories.ts +14 -8
  55. package/src/web-components/visualization/gs-mutations.tsx +18 -8
  56. package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +28 -18
  57. package/src/web-components/visualization/gs-prevalence-over-time.tsx +45 -22
  58. package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +11 -5
  59. package/src/web-components/visualization/gs-relative-growth-advantage.tsx +21 -9
@@ -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`.
@@ -46,23 +46,31 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
46
46
  // prettier-ignore
47
47
  // The multiline union type must not start with `|` because it looks weird in the Storybook docs
48
48
  /**
49
+ * Required.
50
+ *
49
51
  * Either a single variant or an array of variants to compare.
50
52
  * This must be a valid LAPIS filter object with an additional `displayName` property
51
53
  * which will be used as the label for the variant in the views,
52
54
  * or an array of such objects.
53
55
  */
54
- @property({ type: Object })
56
+ @property({type: Object})
55
57
  numerator:
56
- (Record<string, string | number | null | boolean> & { displayName: string })
57
- | (Record<string, string | number | null | boolean> & {
58
- displayName: string;
59
- })[] = { 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: {} };
60
66
 
61
67
  /**
68
+ * Required.
69
+ *
62
70
  * The variant that the variants in `numerator` are compared to.
63
71
  */
64
72
  @property({ type: Object })
65
- denominator: Record<string, string | number | null | boolean> & { displayName: string } = { displayName: '' };
73
+ denominator: Record<string, string | number | null | boolean> = {};
66
74
 
67
75
  /**
68
76
  * The granularity of the time axis.
@@ -100,18 +108,23 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
100
108
  * The headline of the component. Set to an empty string to hide the headline.
101
109
  */
102
110
  @property({ type: String })
103
- headline: string | undefined = 'Prevalence over time';
111
+ headline: string = 'Prevalence over time';
104
112
 
105
113
  /**
106
- * The size of the component.
114
+ * The width of the component.
107
115
  *
108
- * 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.
109
123
  *
110
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
111
- * 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.
112
125
  */
113
- @property({ type: Object })
114
- size: { width?: string; height?: string } | undefined = undefined;
126
+ @property({ type: String })
127
+ height: string = '700px';
115
128
 
116
129
  override render() {
117
130
  return (
@@ -122,7 +135,8 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
122
135
  smoothingWindow={this.smoothingWindow}
123
136
  views={this.views}
124
137
  confidenceIntervalMethods={this.confidenceIntervalMethods}
125
- size={this.size}
138
+ width={this.width}
139
+ height={this.height}
126
140
  headline={this.headline}
127
141
  />
128
142
  );
@@ -137,12 +151,21 @@ declare global {
137
151
 
138
152
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
139
153
  type NumeratorMatches = Expect<
140
- 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']>
141
164
  >;
142
- type DenominatorMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.denominator, NamedLapisFilter>>;
143
- type GranularityMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.granularity, TemporalGranularity>>;
144
- type ViewsMatches = Expect<Equals<typeof PrevalenceOverTimeComponent.prototype.views, View[]>>;
145
165
  type ConfidenceIntervalMethodsMatches = Expect<
146
- Equals<typeof PrevalenceOverTimeComponent.prototype.confidenceIntervalMethods, ConfidenceIntervalMethod[]>
166
+ Equals<
167
+ typeof PrevalenceOverTimeComponent.prototype.confidenceIntervalMethods,
168
+ PrevalenceOverTimeProps['confidenceIntervalMethods']
169
+ >
147
170
  >;
148
171
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -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,7 +31,8 @@ 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({
@@ -43,7 +47,7 @@ const meta: Meta<RelativeGrowthAdvantageProps> = {
43
47
 
44
48
  export default meta;
45
49
 
46
- const Template: StoryObj<RelativeGrowthAdvantageProps> = {
50
+ const Template: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
47
51
  render: (args) => html`
48
52
  <gs-app lapis="${LAPIS_URL}">
49
53
  <gs-relative-growth-advantage
@@ -51,21 +55,23 @@ const Template: StoryObj<RelativeGrowthAdvantageProps> = {
51
55
  .denominator=${args.denominator}
52
56
  .generationTime=${args.generationTime}
53
57
  .views=${args.views}
54
- .size=${args.size}
58
+ .width=${args.width}
59
+ .height=${args.height}
55
60
  .headline=${args.headline}
56
61
  ></gs-relative-growth-advantage>
57
62
  </gs-app>
58
63
  `,
59
64
  };
60
65
 
61
- export const Default: StoryObj<RelativeGrowthAdvantageProps> = {
66
+ export const Default: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
62
67
  ...Template,
63
68
  args: {
64
69
  numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
65
70
  denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
66
71
  generationTime: 7,
67
72
  views: ['line'],
68
- size: { width: '100%', height: '700px' },
73
+ width: '100%',
74
+ height: '700px',
69
75
  headline: 'Relative growth advantage',
70
76
  },
71
77
  parameters: {
@@ -6,7 +6,9 @@ import { type Equals, type Expect } from '../../utils/typeAssertions';
6
6
  import { PreactLitAdapter } from '../PreactLitAdapter';
7
7
 
8
8
  /**
9
- * We assume a discrete time model, where new infections happen exactly every `generationTime` days.
9
+ * ## Context
10
+ *
11
+ * For this component, we assume a discrete time model, where new infections happen exactly every `generationTime` days.
10
12
  * This is what we call a "generation".
11
13
  *
12
14
  * This component estimates the relative growth advantage of a variant by performing a logistic regression.
@@ -32,12 +34,16 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
32
34
  @customElement('gs-relative-growth-advantage')
33
35
  export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
34
36
  /**
37
+ * Required.
38
+ *
35
39
  * The LAPIS filter for the focal variant.
36
40
  */
37
41
  @property({ type: Object })
38
42
  numerator: Record<string, string | number | null | boolean> = {};
39
43
 
40
44
  /**
45
+ * Required.
46
+ *
41
47
  * The LAPIS filter for the variant that the focal variant (`numerator`) should be compared to.
42
48
  */
43
49
  @property({ type: Object })
@@ -60,18 +66,23 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
60
66
  * The headline of the component. Set to an empty string to hide the headline.
61
67
  */
62
68
  @property({ type: String })
63
- headline: string | undefined = 'Relative growth advantage';
69
+ headline: string = 'Relative growth advantage';
64
70
 
65
71
  /**
66
- * The size of the component.
72
+ * The width of the component.
67
73
  *
68
- * If not set, the component will take the full width of its container with height 700px.
74
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
75
+ */
76
+ @property({ type: String })
77
+ width: string = '100%';
78
+
79
+ /**
80
+ * The height of the component.
69
81
  *
70
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
71
- * If the unit is %, the size will be relative to the container of the component.
82
+ * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
72
83
  */
73
- @property({ type: Object })
74
- size: { width?: string; height?: string } | undefined = undefined;
84
+ @property({ type: String })
85
+ height: string = '700px';
75
86
 
76
87
  override render() {
77
88
  return (
@@ -80,7 +91,8 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
80
91
  denominator={this.denominator}
81
92
  generationTime={this.generationTime}
82
93
  views={this.views}
83
- size={this.size}
94
+ width={this.width}
95
+ height={this.height}
84
96
  headline={this.headline}
85
97
  />
86
98
  );