@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
@@ -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
  );
@@ -0,0 +1,5 @@
1
+ export { MutationComparisonComponent } from './gs-mutation-comparison';
2
+ export { MutationsComponent } from './gs-mutations';
3
+ export { PrevalenceOverTimeComponent } from './gs-prevalence-over-time';
4
+ export { RelativeGrowthAdvantageComponent } from './gs-relative-growth-advantage';
5
+ export { AggregateComponent } from './gs-aggregate';
@@ -1,72 +0,0 @@
1
- import { customElement, property } from 'lit/decorators.js';
2
-
3
- import { Aggregate, type View } from '../../preact/aggregatedData/aggregate';
4
- import { type LapisFilter } from '../../types';
5
- import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
6
-
7
- /**
8
- * ## Context
9
- *
10
- * This component displays aggregated data, which can provide an overview of the underlying data.
11
- *
12
- * It expects a list of fields to aggregate by and a filter to apply to the data.
13
- */
14
- @customElement('gs-aggregate-component')
15
- export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
16
- /**
17
- * The fields to aggregate by.
18
- */
19
- @property({ type: Array })
20
- fields: string[] = [];
21
-
22
- /**
23
- * The views are used to display the aggregated data.
24
- * In the table view, the data is presented in a table format where each field is a column,
25
- * along with the aggregated value and its proportion.
26
- * The proportion represents the ratio of the aggregated value to the total count of the data
27
- * (considering the applied filter).
28
- */
29
- @property({ type: Array })
30
- views: View[] = ['table'];
31
-
32
- /**
33
- * The filter to apply to the data.
34
- */
35
- @property({ type: Object })
36
- filter: LapisFilter = {};
37
-
38
- /**
39
- * The size of the component.
40
- *
41
- * If not set, the component will take the full width of its container with height 700px.
42
- *
43
- * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
44
- * If the unit is %, the size will be relative to the container of the component.
45
- */
46
- @property({ type: Object })
47
- size: { width?: string; height?: string } | undefined = undefined;
48
-
49
- /**
50
- * The headline of the component. Set to an empty string to hide the headline.
51
- */
52
- @property({ type: String })
53
- headline: string | undefined = 'Aggregate';
54
-
55
- override render() {
56
- return (
57
- <Aggregate
58
- fields={this.fields}
59
- views={this.views}
60
- filter={this.filter}
61
- size={this.size}
62
- headline={this.headline}
63
- />
64
- );
65
- }
66
- }
67
-
68
- declare global {
69
- interface HTMLElementTagNameMap {
70
- 'gs-aggregate-component': AggregateComponent;
71
- }
72
- }
@@ -1,5 +0,0 @@
1
- export { MutationComparisonComponent } from './mutation-comparison-component';
2
- export { MutationsComponent } from './mutations-component';
3
- export { PrevalenceOverTimeComponent } from './prevalence-over-time-component';
4
- export { RelativeGrowthAdvantageComponent } from './relative-growth-advantage-component';
5
- export { AggregateComponent } from './aggregate-component';
@@ -1,83 +0,0 @@
1
- import { customElement, property } from 'lit/decorators.js';
2
-
3
- import { type TextInputComponent } from './text-input-component';
4
- import { ReferenceGenomesAwaiter } from '../../preact/components/ReferenceGenomesAwaiter';
5
- import { MutationFilter, type SelectedMutationFilterStrings } from '../../preact/mutationFilter/mutation-filter';
6
- import { PreactLitAdapter } from '../PreactLitAdapter';
7
-
8
- /**
9
- * ## Context
10
- * This component provides an input field to specify filters for nucleotide and amino acid mutations and insertions.
11
- *
12
- * Input values have to be provided one at a time and submitted by pressing the Enter key or by clicking the '+' button.
13
- * After submission, the component validates the input and fires an event with the selected mutations.
14
- * All previously selected mutations are displayed at the input field and added to the event.
15
- * Users can remove a mutation by clicking the 'x' button next to the mutation.
16
- *
17
- * Validation of the input is performed according to the following rules:
18
- *
19
- * Mutations have to conform to the following format: `<gene/segment>:<symbol at reference><position><Substituted symbol/Deletion>`
20
- * - Gene/segment: The gene or segment where the mutation occurs. Must be contained in the reference genome
21
- * (Optional for elements with only one gene/segment)
22
- * - Symbol at reference: The symbol at the reference position. (Optional)
23
- * - Position: The position of the mutation. (Required)
24
- * - Substituted symbol/Deletion: The substituted symbol or '-' for a deletion. (Required)
25
- * Example: S:614G, 614G, 614- or 614G
26
- *
27
- * Insertions have to conform to the following format: `ins_<gene/segment>:<position>:<Inserted symbols>`
28
- * - Gene/segment: The gene or segment where the insertion occurs. Must be contained in the reference genome
29
- * (Optional for elements with only one gene/segment)
30
- * - Position: The position of the insertion. (Required)
31
- * - Inserted symbols: The symbols that are inserted. (Required)
32
- * Example: ins_S:614:G, ins_614:G
33
- *
34
- * @fires {CustomEvent<{
35
- * nucleotideMutations: string[],
36
- * aminoAcidMutations: string[],
37
- * nucleotideInsertions: string[],
38
- * aminoAcidInsertions: string[]
39
- * }>} gs-mutation-filter-changed
40
- * Fired when:
41
- * - The user has submitted a valid mutation or insertion
42
- * - The user has removed a mutation or insertion
43
- *
44
- * @fires {CustomEvent<{
45
- * nucleotideMutations: string[],
46
- * aminoAcidMutations: string[],
47
- * nucleotideInsertions: string[],
48
- * aminoAcidInsertions: string[]
49
- * }>} gs-mutation-filter-on-blur
50
- * Fired when:
51
- * - the mutation filter has lost focus
52
- * Contains the selected mutations in the format
53
- */
54
- @customElement('gs-mutation-filter')
55
- export class MutationFilterComponent extends PreactLitAdapter {
56
- /**
57
- * The initial value to use for this mutation filter.
58
- * Must be either
59
- * - an array of strings of valid mutations.
60
- * - an object with the keys `nucleotideMutations`, `aminoAcidMutations`, `nucleotideInsertions` and `aminoAcidInsertions` and corresponding string arrays.
61
- */
62
- @property()
63
- initialValue: SelectedMutationFilterStrings | string[] | undefined = undefined;
64
-
65
- override render() {
66
- return (
67
- <ReferenceGenomesAwaiter>
68
- <MutationFilter initialValue={this.initialValue} />
69
- </ReferenceGenomesAwaiter>
70
- );
71
- }
72
- }
73
-
74
- declare global {
75
- interface HTMLElementTagNameMap {
76
- 'gs-mutation-filter': TextInputComponent;
77
- }
78
-
79
- interface HTMLElementEventMap {
80
- 'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
81
- 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
82
- }
83
- }