@genspectrum/dashboard-components 0.14.2 → 0.15.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 (33) hide show
  1. package/custom-elements.json +81 -49
  2. package/dist/{LineageFilterChangedEvent-C9dXOxt6.js → LineageFilterChangedEvent-COWV-Y0k.js} +6 -6
  3. package/dist/LineageFilterChangedEvent-COWV-Y0k.js.map +1 -0
  4. package/dist/assets/{mutationOverTimeWorker-Dxnxrfe0.js.map → mutationOverTimeWorker-BL50C-yi.js.map} +1 -1
  5. package/dist/components.d.ts +31 -31
  6. package/dist/components.js +62 -51
  7. package/dist/components.js.map +1 -1
  8. package/dist/util.d.ts +29 -29
  9. package/dist/util.js +2 -2
  10. package/package.json +1 -1
  11. package/src/preact/{dateRangeSelector/date-range-selector.stories.tsx → dateRangeFilter/date-range-filter.stories.tsx} +15 -15
  12. package/src/preact/{dateRangeSelector/date-range-selector.tsx → dateRangeFilter/date-range-filter.tsx} +9 -9
  13. package/src/preact/{dateRangeSelector → dateRangeFilter}/dateRangeOption.ts +2 -2
  14. package/src/preact/{textInput/TextInputChangedEvent.ts → textFilter/TextFilterChangedEvent.ts} +2 -2
  15. package/src/preact/{textInput/text-input.stories.tsx → textFilter/text-filter.stories.tsx} +10 -10
  16. package/src/preact/{textInput/text-input.tsx → textFilter/text-filter.tsx} +10 -10
  17. package/src/utilEntrypoint.ts +2 -2
  18. package/src/web-components/input/{gs-date-range-selector.stories.ts → gs-date-range-filter.stories.ts} +59 -14
  19. package/src/web-components/input/{gs-date-range-selector.tsx → gs-date-range-filter.tsx} +28 -13
  20. package/src/web-components/input/{gs-text-input.stories.ts → gs-text-filter.stories.ts} +15 -15
  21. package/src/web-components/input/{gs-text-input.tsx → gs-text-filter.tsx} +16 -16
  22. package/src/web-components/input/index.ts +2 -2
  23. package/standalone-bundle/assets/{mutationOverTimeWorker-CmSrq4SZ.js.map → mutationOverTimeWorker-CFB5-Mdk.js.map} +1 -1
  24. package/standalone-bundle/dashboard-components.js +2167 -2161
  25. package/standalone-bundle/dashboard-components.js.map +1 -1
  26. package/dist/LineageFilterChangedEvent-C9dXOxt6.js.map +0 -1
  27. /package/src/preact/{dateRangeSelector → dateRangeFilter}/computeInitialValues.spec.ts +0 -0
  28. /package/src/preact/{dateRangeSelector → dateRangeFilter}/computeInitialValues.ts +0 -0
  29. /package/src/preact/{dateRangeSelector → dateRangeFilter}/dateConversion.ts +0 -0
  30. /package/src/preact/{dateRangeSelector → dateRangeFilter}/selectableOptions.ts +0 -0
  31. /package/src/preact/{textInput → textFilter}/__mockData__/aggregated_hosts.json +0 -0
  32. /package/src/preact/{textInput → textFilter}/fetchStringAutocompleteList.spec.ts +0 -0
  33. /package/src/preact/{textInput → textFilter}/fetchStringAutocompleteList.ts +0 -0
@@ -5,27 +5,27 @@ import { html } from 'lit';
5
5
  import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
6
6
  import { previewHandles } from '../../../.storybook/preview';
7
7
  import { LAPIS_URL } from '../../constants';
8
- import { type DateRangeSelectorProps } from '../../preact/dateRangeSelector/date-range-selector';
9
- import './gs-date-range-selector';
8
+ import { type DateRangeFilterProps } from '../../preact/dateRangeFilter/date-range-filter';
9
+ import './gs-date-range-filter';
10
10
  import '../gs-app';
11
- import { toYYYYMMDD } from '../../preact/dateRangeSelector/dateConversion';
12
- import { dateRangeOptionPresets } from '../../preact/dateRangeSelector/dateRangeOption';
11
+ import { toYYYYMMDD } from '../../preact/dateRangeFilter/dateConversion';
12
+ import { dateRangeOptionPresets } from '../../preact/dateRangeFilter/dateRangeOption';
13
13
  import { withinShadowRoot } from '../withinShadowRoot.story';
14
14
 
15
15
  const codeExample = String.raw`
16
- <gs-date-range-selector
16
+ <gs-date-range-filter
17
17
  dateRangeOptions='[{ "label": "Year 2021", "dateFrom": "2021-01-01", "dateTo": "2021-12-31" }]'
18
18
  earliestDate="1970-01-01"
19
19
  value="Year 2021"
20
20
  width="100%"
21
21
  lapisDateField="myDateColumn"
22
- ></gs-date-range-selector>`;
22
+ ></gs-date-range-filter>`;
23
23
 
24
24
  const customDateRange = { label: 'CustomDateRange', dateFrom: '2021-01-01', dateTo: '2021-12-31' };
25
25
 
26
- const meta: Meta<Required<DateRangeSelectorProps>> = {
27
- title: 'Input/DateRangeSelector',
28
- component: 'gs-date-range-selector',
26
+ const meta: Meta<Required<DateRangeFilterProps>> = {
27
+ title: 'Input/DateRangeFilter',
28
+ component: 'gs-date-range-filter',
29
29
  parameters: withComponentDocs({
30
30
  actions: {
31
31
  handles: ['gs-date-range-filter-changed', 'gs-date-range-option-changed', ...previewHandles],
@@ -65,6 +65,7 @@ const meta: Meta<Required<DateRangeSelectorProps>> = {
65
65
  dateRangeOptionPresets.lastMonth,
66
66
  dateRangeOptionPresets.last3Months,
67
67
  dateRangeOptionPresets.allTimes,
68
+ { label: '2021', dateFrom: '2021-01-01', dateTo: '2021-12-31' },
68
69
  customDateRange,
69
70
  ],
70
71
  earliestDate: '1970-01-01',
@@ -77,25 +78,69 @@ const meta: Meta<Required<DateRangeSelectorProps>> = {
77
78
 
78
79
  export default meta;
79
80
 
80
- export const Default: StoryObj<Required<DateRangeSelectorProps>> = {
81
+ export const Default: StoryObj<Required<DateRangeFilterProps>> = {
81
82
  render: (args) =>
82
83
  html` <gs-app lapis="${LAPIS_URL}">
83
84
  <div class="max-w-screen-lg">
84
- <gs-date-range-selector
85
+ <gs-date-range-filter
85
86
  .dateRangeOptions=${args.dateRangeOptions}
86
87
  .earliestDate=${args.earliestDate}
87
88
  .value=${args.value}
88
89
  .width=${args.width}
89
90
  .lapisDateField=${args.lapisDateField}
90
- ></gs-date-range-selector>
91
+ ></gs-date-range-filter>
91
92
  </div>
92
93
  </gs-app>`,
93
94
  };
94
95
 
95
- export const FiresEvents: StoryObj<Required<DateRangeSelectorProps>> = {
96
+ export const TestRenderAttributesInHtmlInsteadOfUsingPropertyExpression: StoryObj<Required<DateRangeFilterProps>> = {
97
+ render: (args) =>
98
+ html` <gs-app lapis="${LAPIS_URL}">
99
+ <div class="max-w-screen-lg">
100
+ <gs-date-range-filter
101
+ .dateRangeOptions=${args.dateRangeOptions}
102
+ earliestDate="${args.earliestDate}"
103
+ value="${args.value}"
104
+ width="${args.width}"
105
+ lapisDateField="${args.lapisDateField}"
106
+ ></gs-date-range-filter>
107
+ </div>
108
+ </gs-app>`,
109
+ play: async ({ canvasElement }) => {
110
+ const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-filter');
111
+
112
+ await waitFor(async () => {
113
+ await expect(selectField(canvas)).toHaveValue('Last month');
114
+ });
115
+ },
116
+ argTypes: {
117
+ value: {
118
+ control: {
119
+ type: 'text',
120
+ },
121
+ },
122
+ },
123
+ };
124
+
125
+ export const TestSettingANumericValueIsTreatedAsString: StoryObj<Required<DateRangeFilterProps>> = {
126
+ ...TestRenderAttributesInHtmlInsteadOfUsingPropertyExpression,
127
+ args: {
128
+ ...TestRenderAttributesInHtmlInsteadOfUsingPropertyExpression.args,
129
+ value: '2021',
130
+ },
131
+ play: async ({ canvasElement }) => {
132
+ const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-filter');
133
+
134
+ await waitFor(async () => {
135
+ await expect(selectField(canvas)).toHaveValue('2021');
136
+ });
137
+ },
138
+ };
139
+
140
+ export const FiresEvents: StoryObj<Required<DateRangeFilterProps>> = {
96
141
  ...Default,
97
142
  play: async ({ canvasElement, step }) => {
98
- const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-selector');
143
+ const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-filter');
99
144
 
100
145
  const filterChangedListenerMock = fn();
101
146
  const optionChangedListenerMock = fn();
@@ -1,8 +1,8 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
  import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
- import { DateRangeSelector, type DateRangeSelectorProps } from '../../preact/dateRangeSelector/date-range-selector';
5
- import { type DateRangeOptionChangedEvent } from '../../preact/dateRangeSelector/dateRangeOption';
4
+ import { DateRangeFilter, type DateRangeFilterProps } from '../../preact/dateRangeFilter/date-range-filter';
5
+ import { type DateRangeOptionChangedEvent } from '../../preact/dateRangeFilter/dateRangeOption';
6
6
  import { type Equals, type Expect } from '../../utils/typeAssertions';
7
7
  import { PreactLitAdapter } from '../PreactLitAdapter';
8
8
 
@@ -48,8 +48,8 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
48
48
  * Use this event, when you want to control this component in your JS application.
49
49
  * You can supply the `detail` of this event to the `value` attribute of this component.
50
50
  */
51
- @customElement('gs-date-range-selector')
52
- export class DateRangeSelectorComponent extends PreactLitAdapter {
51
+ @customElement('gs-date-range-filter')
52
+ export class DateRangeFilterComponent extends PreactLitAdapter {
53
53
  /**
54
54
  * An array of date range options that the select field should provide.
55
55
  * The `label` will be shown to the user, and it will be available as `value`.
@@ -78,7 +78,22 @@ export class DateRangeSelectorComponent extends PreactLitAdapter {
78
78
  * The `detail` of the `gs-date-range-option-changed` event can be used for this attribute,
79
79
  * if you want to control this component in your JS application.
80
80
  */
81
- @property({ type: Object })
81
+ @property({
82
+ converter: (value) => {
83
+ if (value === null) {
84
+ return undefined;
85
+ }
86
+ try {
87
+ const result = JSON.parse(value) as unknown;
88
+ if (typeof result !== 'object' && typeof result !== 'string') {
89
+ return value;
90
+ }
91
+ return result;
92
+ } catch (_) {
93
+ return value;
94
+ }
95
+ },
96
+ })
82
97
  value: string | { dateFrom?: string; dateTo?: string } | undefined = undefined;
83
98
 
84
99
  /**
@@ -97,7 +112,7 @@ export class DateRangeSelectorComponent extends PreactLitAdapter {
97
112
 
98
113
  override render() {
99
114
  return (
100
- <DateRangeSelector
115
+ <DateRangeFilter
101
116
  dateRangeOptions={this.dateRangeOptions}
102
117
  earliestDate={this.earliestDate}
103
118
  value={this.value}
@@ -110,7 +125,7 @@ export class DateRangeSelectorComponent extends PreactLitAdapter {
110
125
 
111
126
  declare global {
112
127
  interface HTMLElementTagNameMap {
113
- 'gs-date-range-selector': DateRangeSelectorComponent;
128
+ 'gs-date-range-filter': DateRangeFilterComponent;
114
129
  }
115
130
 
116
131
  interface HTMLElementEventMap {
@@ -123,21 +138,21 @@ declare global {
123
138
  // eslint-disable-next-line @typescript-eslint/no-namespace
124
139
  namespace JSX {
125
140
  interface IntrinsicElements {
126
- 'gs-date-range-selector': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
141
+ 'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
127
142
  }
128
143
  }
129
144
  }
130
145
 
131
146
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
132
147
  type CustomSelectOptionsMatches = Expect<
133
- Equals<typeof DateRangeSelectorComponent.prototype.dateRangeOptions, DateRangeSelectorProps['dateRangeOptions']>
148
+ Equals<typeof DateRangeFilterComponent.prototype.dateRangeOptions, DateRangeFilterProps['dateRangeOptions']>
134
149
  >;
135
150
  type EarliestDateMatches = Expect<
136
- Equals<typeof DateRangeSelectorComponent.prototype.earliestDate, DateRangeSelectorProps['earliestDate']>
151
+ Equals<typeof DateRangeFilterComponent.prototype.earliestDate, DateRangeFilterProps['earliestDate']>
137
152
  >;
138
- type ValueMatches = Expect<Equals<typeof DateRangeSelectorComponent.prototype.value, DateRangeSelectorProps['value']>>;
139
- type WidthMatches = Expect<Equals<typeof DateRangeSelectorComponent.prototype.width, DateRangeSelectorProps['width']>>;
153
+ type ValueMatches = Expect<Equals<typeof DateRangeFilterComponent.prototype.value, DateRangeFilterProps['value']>>;
154
+ type WidthMatches = Expect<Equals<typeof DateRangeFilterComponent.prototype.width, DateRangeFilterProps['width']>>;
140
155
  type DateColumnMatches = Expect<
141
- Equals<typeof DateRangeSelectorComponent.prototype.lapisDateField, DateRangeSelectorProps['lapisDateField']>
156
+ Equals<typeof DateRangeFilterComponent.prototype.lapisDateField, DateRangeFilterProps['lapisDateField']>
142
157
  >;
143
158
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -6,26 +6,26 @@ import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
6
6
  import { previewHandles } from '../../../.storybook/preview';
7
7
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
8
8
  import '../gs-app';
9
- import './gs-text-input';
10
- import data from '../../preact/textInput/__mockData__/aggregated_hosts.json';
11
- import type { TextInputProps } from '../../preact/textInput/text-input';
9
+ import './gs-text-filter';
10
+ import data from '../../preact/textFilter/__mockData__/aggregated_hosts.json';
11
+ import type { TextFilterProps } from '../../preact/textFilter/text-filter';
12
12
  import { withinShadowRoot } from '../withinShadowRoot.story';
13
13
 
14
14
  const codeExample = String.raw`
15
- <gs-text-input
15
+ <gs-text-filter
16
16
  lapisField="host"
17
17
  lapisFilter='{"country": "Germany"}'
18
18
  placeholderText="Enter host name"
19
19
  value="Homo sapiens"
20
20
  width="50%">
21
- </gs-text-input>`;
21
+ </gs-text-filter>`;
22
22
 
23
- const meta: Meta<Required<TextInputProps>> = {
24
- title: 'Input/Text input',
25
- component: 'gs-text-input',
23
+ const meta: Meta<Required<TextFilterProps>> = {
24
+ title: 'Input/Text filter',
25
+ component: 'gs-text-filter',
26
26
  parameters: withComponentDocs({
27
27
  actions: {
28
- handles: ['gs-text-input-changed', ...previewHandles],
28
+ handles: ['gs-text-filter-changed', ...previewHandles],
29
29
  },
30
30
  fetchMock: {
31
31
  mocks: [
@@ -83,17 +83,17 @@ const meta: Meta<Required<TextInputProps>> = {
83
83
 
84
84
  export default meta;
85
85
 
86
- export const Default: StoryObj<Required<TextInputProps>> = {
86
+ export const Default: StoryObj<Required<TextFilterProps>> = {
87
87
  render: (args) => {
88
88
  return html` <gs-app lapis="${LAPIS_URL}">
89
89
  <div class="max-w-screen-lg">
90
- <gs-text-input
90
+ <gs-text-filter
91
91
  .lapisField=${args.lapisField}
92
92
  .lapisFilter=${args.lapisFilter}
93
93
  .placeholderText=${args.placeholderText}
94
94
  .value=${args.value}
95
95
  .width=${args.width}
96
- ></gs-text-input>
96
+ ></gs-text-filter>
97
97
  </div>
98
98
  </gs-app>`;
99
99
  },
@@ -106,15 +106,15 @@ export const Default: StoryObj<Required<TextInputProps>> = {
106
106
  },
107
107
  };
108
108
 
109
- export const FiresEvents: StoryObj<Required<TextInputProps>> = {
109
+ export const FiresEvents: StoryObj<Required<TextFilterProps>> = {
110
110
  ...Default,
111
111
  play: async ({ canvasElement, step }) => {
112
- const canvas = await withinShadowRoot(canvasElement, 'gs-text-input');
112
+ const canvas = await withinShadowRoot(canvasElement, 'gs-text-filter');
113
113
 
114
114
  const inputField = () => canvas.getByPlaceholderText('Enter host name');
115
115
  const listenerMock = fn();
116
116
  await step('Setup event listener mock', () => {
117
- canvasElement.addEventListener('gs-text-input-changed', listenerMock);
117
+ canvasElement.addEventListener('gs-text-filter-changed', listenerMock);
118
118
  });
119
119
 
120
120
  await step('wait until data is loaded', async () => {
@@ -1,8 +1,8 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
  import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
- import { type TextInputChangedEvent } from '../../preact/textInput/TextInputChangedEvent';
5
- import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
4
+ import { type TextFilterChangedEvent } from '../../preact/textFilter/TextFilterChangedEvent';
5
+ import { TextFilter, type TextFilterProps } from '../../preact/textFilter/text-filter';
6
6
  import type { Equals, Expect } from '../../utils/typeAssertions';
7
7
  import { PreactLitAdapter } from '../PreactLitAdapter';
8
8
 
@@ -12,7 +12,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
12
12
  *
13
13
  * This component provides a text input field to specify filters for arbitrary fields of this LAPIS instance.
14
14
  *
15
- * @fires {CustomEvent<Record<string, string | undefined>>} gs-text-input-changed
15
+ * @fires {CustomEvent<Record<string, string | undefined>>} gs-text-filter-changed
16
16
  * Fired when the input field is changed.
17
17
  * The `details` of this event contain an object with the `lapisField` as key and the input value as value.
18
18
  * Example:
@@ -22,10 +22,10 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
22
22
  * }
23
23
  * ```
24
24
  */
25
- @customElement('gs-text-input')
26
- export class TextInputComponent extends PreactLitAdapter {
25
+ @customElement('gs-text-filter')
26
+ export class TextFilterComponent extends PreactLitAdapter {
27
27
  /**
28
- * The initial value to use for this text input.
28
+ * The initial value to use for this text filter.
29
29
  */
30
30
  @property()
31
31
  value: string | undefined = undefined;
@@ -33,7 +33,7 @@ export class TextInputComponent extends PreactLitAdapter {
33
33
  /**
34
34
  * Required.
35
35
  *
36
- * The LAPIS field name to use for this text input.
36
+ * The LAPIS field name to use for this text filter.
37
37
  * The field must exist on this LAPIS instance.
38
38
  */
39
39
  @property()
@@ -68,7 +68,7 @@ export class TextInputComponent extends PreactLitAdapter {
68
68
 
69
69
  override render() {
70
70
  return (
71
- <TextInput
71
+ <TextFilter
72
72
  lapisField={this.lapisField}
73
73
  lapisFilter={this.lapisFilter}
74
74
  placeholderText={this.placeholderText}
@@ -81,11 +81,11 @@ export class TextInputComponent extends PreactLitAdapter {
81
81
 
82
82
  declare global {
83
83
  interface HTMLElementTagNameMap {
84
- 'gs-text-input': TextInputComponent;
84
+ 'gs-text-filter': TextFilterComponent;
85
85
  }
86
86
 
87
87
  interface HTMLElementEventMap {
88
- 'gs-text-input-changed': TextInputChangedEvent;
88
+ 'gs-text-filter-changed': TextFilterChangedEvent;
89
89
  }
90
90
  }
91
91
 
@@ -93,19 +93,19 @@ declare global {
93
93
  // eslint-disable-next-line @typescript-eslint/no-namespace
94
94
  namespace JSX {
95
95
  interface IntrinsicElements {
96
- 'gs-text-input': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
96
+ 'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
97
97
  }
98
98
  }
99
99
  }
100
100
 
101
101
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
102
- type InitialValueMatches = Expect<Equals<typeof TextInputComponent.prototype.value, TextInputProps['value']>>;
103
- type LapisFieldMatches = Expect<Equals<typeof TextInputComponent.prototype.lapisField, TextInputProps['lapisField']>>;
102
+ type InitialValueMatches = Expect<Equals<typeof TextFilterComponent.prototype.value, TextFilterProps['value']>>;
103
+ type LapisFieldMatches = Expect<Equals<typeof TextFilterComponent.prototype.lapisField, TextFilterProps['lapisField']>>;
104
104
  type LapisFilterMatches = Expect<
105
- Equals<typeof TextInputComponent.prototype.lapisFilter, TextInputProps['lapisFilter']>
105
+ Equals<typeof TextFilterComponent.prototype.lapisFilter, TextFilterProps['lapisFilter']>
106
106
  >;
107
107
  type PlaceholderTextMatches = Expect<
108
- Equals<typeof TextInputComponent.prototype.placeholderText, TextInputProps['placeholderText']>
108
+ Equals<typeof TextFilterComponent.prototype.placeholderText, TextFilterProps['placeholderText']>
109
109
  >;
110
- type WidthMatches = Expect<Equals<typeof TextInputComponent.prototype.width, TextInputProps['width']>>;
110
+ type WidthMatches = Expect<Equals<typeof TextFilterComponent.prototype.width, TextFilterProps['width']>>;
111
111
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -1,5 +1,5 @@
1
- export { DateRangeSelectorComponent } from './gs-date-range-selector';
1
+ export { DateRangeFilterComponent } from './gs-date-range-filter';
2
2
  export { LocationFilterComponent } from './gs-location-filter';
3
- export { TextInputComponent } from './gs-text-input';
3
+ export { TextFilterComponent } from './gs-text-filter';
4
4
  export { MutationFilterComponent } from './gs-mutation-filter';
5
5
  export { LineageFilterComponent } from './gs-lineage-filter';