@genspectrum/dashboard-components 0.19.1 → 0.19.3

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 (56) hide show
  1. package/custom-elements.json +160 -10
  2. package/dist/{LineageFilterChangedEvent-ixHQkq8y.js → LineageFilterChangedEvent-b0iuroUL.js} +15 -5
  3. package/dist/LineageFilterChangedEvent-b0iuroUL.js.map +1 -0
  4. package/dist/assets/mutationOverTimeWorker-ChQTFL68.js.map +1 -1
  5. package/dist/components.d.ts +61 -15
  6. package/dist/components.js +9083 -8727
  7. package/dist/components.js.map +1 -1
  8. package/dist/util.d.ts +41 -15
  9. package/dist/util.js +2 -1
  10. package/package.json +1 -1
  11. package/src/componentsEntrypoint.ts +3 -1
  12. package/src/preact/components/downshift-combobox.tsx +31 -16
  13. package/src/preact/components/error-display.stories.tsx +2 -1
  14. package/src/preact/components/error-display.tsx +2 -3
  15. package/src/preact/components/resize-container.tsx +7 -10
  16. package/src/preact/components/tooltip.tsx +7 -4
  17. package/src/preact/dateRangeFilter/date-range-filter.stories.tsx +5 -4
  18. package/src/preact/dateRangeFilter/date-range-filter.tsx +2 -1
  19. package/src/preact/dateRangeFilter/dateRangeOption.ts +2 -1
  20. package/src/preact/genomeViewer/CDSPlot.tsx +219 -0
  21. package/src/preact/genomeViewer/genome-data-viewer.stories.tsx +113 -0
  22. package/src/preact/genomeViewer/genome-data-viewer.tsx +69 -0
  23. package/src/preact/genomeViewer/loadGff3.spec.ts +61 -0
  24. package/src/preact/genomeViewer/loadGff3.ts +174 -0
  25. package/src/preact/lineageFilter/LineageFilterChangedEvent.ts +3 -1
  26. package/src/preact/lineageFilter/lineage-filter.stories.tsx +3 -2
  27. package/src/preact/lineageFilter/lineage-filter.tsx +4 -4
  28. package/src/preact/locationFilter/LocationChangedEvent.ts +2 -1
  29. package/src/preact/locationFilter/location-filter.stories.tsx +3 -2
  30. package/src/preact/locationFilter/location-filter.tsx +5 -7
  31. package/src/preact/mutationFilter/mutation-filter.stories.tsx +3 -2
  32. package/src/preact/mutationFilter/mutation-filter.tsx +2 -1
  33. package/src/preact/shared/charts/colors.ts +1 -1
  34. package/src/preact/textFilter/TextFilterChangedEvent.ts +3 -1
  35. package/src/preact/textFilter/text-filter.stories.tsx +71 -10
  36. package/src/preact/textFilter/text-filter.tsx +5 -7
  37. package/src/utilEntrypoint.ts +2 -0
  38. package/src/utils/gsEventNames.ts +9 -0
  39. package/src/web-components/input/gs-date-range-filter.stories.ts +4 -3
  40. package/src/web-components/input/gs-date-range-filter.tsx +3 -2
  41. package/src/web-components/input/gs-lineage-filter.stories.ts +3 -2
  42. package/src/web-components/input/gs-lineage-filter.tsx +2 -1
  43. package/src/web-components/input/gs-location-filter.stories.ts +3 -2
  44. package/src/web-components/input/gs-location-filter.tsx +2 -1
  45. package/src/web-components/input/gs-mutation-filter.stories.ts +3 -2
  46. package/src/web-components/input/gs-mutation-filter.tsx +2 -1
  47. package/src/web-components/input/gs-text-filter.stories.ts +6 -12
  48. package/src/web-components/input/gs-text-filter.tsx +2 -1
  49. package/src/web-components/visualization/gs-genome-data-viewer.spec-d.ts +18 -0
  50. package/src/web-components/visualization/gs-genome-data-viewer.stories.ts +108 -0
  51. package/src/web-components/visualization/gs-genome-data-viewer.tsx +59 -0
  52. package/src/web-components/visualization/index.ts +1 -0
  53. package/standalone-bundle/assets/mutationOverTimeWorker-jChgWnwp.js.map +1 -1
  54. package/standalone-bundle/dashboard-components.js +32674 -32374
  55. package/standalone-bundle/dashboard-components.js.map +1 -1
  56. package/dist/LineageFilterChangedEvent-ixHQkq8y.js.map +0 -1
@@ -77,16 +77,16 @@ const LineageSelector = ({
77
77
  allItems={data}
78
78
  value={value}
79
79
  filterItemsByInputValue={filterByInputValue}
80
- createEvent={(item: string | null) => new LineageFilterChangedEvent({ [lapisField]: item ?? undefined })}
81
- itemToString={(item: string | undefined | null) => item ?? ''}
80
+ createEvent={(item) => new LineageFilterChangedEvent({ [lapisField]: item ?? undefined })}
81
+ itemToString={(item) => item ?? ''}
82
82
  placeholderText={placeholderText}
83
83
  formatItemInList={(item: string) => item}
84
84
  />
85
85
  );
86
86
  };
87
87
 
88
- function filterByInputValue(item: string, inputValue: string | undefined | null) {
89
- if (inputValue === undefined || inputValue === null || inputValue === '') {
88
+ function filterByInputValue(item: string, inputValue: string | null) {
89
+ if (inputValue === null || inputValue === '') {
90
90
  return true;
91
91
  }
92
92
  return item?.toLowerCase().includes(inputValue?.toLowerCase() || '');
@@ -1,8 +1,9 @@
1
1
  import { type LapisLocationFilter } from '../../types';
2
+ import { gsEventNames } from '../../utils/gsEventNames';
2
3
 
3
4
  export class LocationChangedEvent extends CustomEvent<LapisLocationFilter> {
4
5
  constructor(detail: LapisLocationFilter) {
5
- super('gs-location-changed', {
6
+ super(gsEventNames.locationChanged, {
6
7
  detail,
7
8
  bubbles: true,
8
9
  composed: true,
@@ -6,6 +6,7 @@ import data from './__mockData__/aggregated.json';
6
6
  import { LocationFilter, type LocationFilterProps } from './location-filter';
7
7
  import { previewHandles } from '../../../.storybook/preview';
8
8
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
9
+ import { gsEventNames } from '../../utils/gsEventNames';
9
10
  import { LapisUrlContextProvider } from '../LapisUrlContext';
10
11
  import { expectInvalidAttributesErrorMessage } from '../shared/stories/expectErrorMessage';
11
12
 
@@ -32,7 +33,7 @@ const meta: Meta<LocationFilterProps> = {
32
33
  ],
33
34
  },
34
35
  actions: {
35
- handles: ['gs-location-changed', ...previewHandles],
36
+ handles: [gsEventNames.locationChanged, ...previewHandles],
36
37
  },
37
38
  },
38
39
  args: {
@@ -152,7 +153,7 @@ async function prepare(canvasElement: HTMLElement, step: StepFunction<PreactRend
152
153
 
153
154
  const locationChangedListenerMock = fn();
154
155
  await step('Setup event listener mock', () => {
155
- canvasElement.addEventListener('gs-location-changed', locationChangedListenerMock);
156
+ canvasElement.addEventListener(gsEventNames.locationChanged, locationChangedListenerMock);
156
157
  });
157
158
 
158
159
  await step('location filter is rendered with value', async () => {
@@ -87,12 +87,10 @@ const LocationSelector = ({
87
87
  return (
88
88
  <DownshiftCombobox
89
89
  allItems={allItems}
90
- value={selectedItem}
90
+ value={selectedItem ?? null}
91
91
  filterItemsByInputValue={filterByInputValue}
92
- createEvent={(item: SelectItem | null) =>
93
- new LocationChangedEvent(item?.lapisFilter ?? emptyLocationFilter(fields))
94
- }
95
- itemToString={(item: SelectItem | undefined | null) => item?.label ?? ''}
92
+ createEvent={(item) => new LocationChangedEvent(item?.lapisFilter ?? emptyLocationFilter(fields))}
93
+ itemToString={(item) => item?.label ?? ''}
96
94
  placeholderText={placeholderText}
97
95
  formatItemInList={(item: SelectItem) => (
98
96
  <>
@@ -107,8 +105,8 @@ const LocationSelector = ({
107
105
  );
108
106
  };
109
107
 
110
- function filterByInputValue(item: SelectItem, inputValue: string | undefined | null) {
111
- if (inputValue === undefined || inputValue === null) {
108
+ function filterByInputValue(item: SelectItem, inputValue: string | null) {
109
+ if (inputValue === null) {
112
110
  return true;
113
111
  }
114
112
  return (
@@ -6,6 +6,7 @@ import { MutationFilter, type MutationFilterProps } from './mutation-filter';
6
6
  import { previewHandles } from '../../../.storybook/preview';
7
7
  import { LAPIS_URL } from '../../constants';
8
8
  import referenceGenome from '../../lapisApi/__mockData__/referenceGenome.json';
9
+ import { gsEventNames } from '../../utils/gsEventNames';
9
10
  import { LapisUrlContextProvider } from '../LapisUrlContext';
10
11
  import { ReferenceGenomeContext } from '../ReferenceGenomeContext';
11
12
  import { playThatExpectsErrorMessage } from '../shared/stories/expectErrorMessage';
@@ -15,7 +16,7 @@ const meta: Meta<MutationFilterProps> = {
15
16
  component: MutationFilter,
16
17
  parameters: {
17
18
  actions: {
18
- handles: ['gs-mutation-filter-changed', ...previewHandles],
19
+ handles: [gsEventNames.mutationFilterChanged, ...previewHandles],
19
20
  },
20
21
  fetchMock: {},
21
22
  },
@@ -357,7 +358,7 @@ async function prepare(canvasElement: HTMLElement, step: StepFunction<PreactRend
357
358
 
358
359
  const changedListenerMock = fn();
359
360
  await step('Setup event listener mock', () => {
360
- canvasElement.addEventListener('gs-mutation-filter-changed', changedListenerMock);
361
+ canvasElement.addEventListener(gsEventNames.mutationFilterChanged, changedListenerMock);
361
362
  });
362
363
 
363
364
  await step('wait until data is loaded', async () => {
@@ -8,6 +8,7 @@ import { MutationFilterInfo } from './mutation-filter-info';
8
8
  import { parseAndValidateMutation } from './parseAndValidateMutation';
9
9
  import { type ReferenceGenome } from '../../lapisApi/ReferenceGenome';
10
10
  import { type MutationsFilter, mutationsFilterSchema } from '../../types';
11
+ import { gsEventNames } from '../../utils/gsEventNames';
11
12
  import { type DeletionClass, type InsertionClass, type SubstitutionClass } from '../../utils/mutations';
12
13
  import { ReferenceGenomeContext } from '../ReferenceGenomeContext';
13
14
  import { ErrorBoundary } from '../components/error-boundary';
@@ -86,7 +87,7 @@ function MutationFilterInner({ initialValue }: MutationFilterInnerProps) {
86
87
  const detail = mapToMutationFilterStrings(selectedFilters);
87
88
 
88
89
  filterRef.current?.dispatchEvent(
89
- new CustomEvent<MutationsFilter>('gs-mutation-filter-changed', {
90
+ new CustomEvent<MutationsFilter>(gsEventNames.mutationFilterChanged, {
90
91
  detail,
91
92
  bubbles: true,
92
93
  composed: true,
@@ -1,6 +1,6 @@
1
1
  // colorblind friendly colors taken from https://personal.sron.nl/~pault/
2
2
 
3
- const ColorsRGB = {
3
+ export const ColorsRGB = {
4
4
  indigo: [51, 34, 136],
5
5
  green: [17, 119, 51],
6
6
  cyan: [136, 204, 238],
@@ -1,8 +1,10 @@
1
+ import { gsEventNames } from '../../utils/gsEventNames';
2
+
1
3
  type LapisTextFilter = Record<string, string | undefined>;
2
4
 
3
5
  export class TextFilterChangedEvent extends CustomEvent<LapisTextFilter> {
4
6
  constructor(detail: LapisTextFilter) {
5
- super('gs-text-filter-changed', {
7
+ super(gsEventNames.textFilterChanged, {
6
8
  detail,
7
9
  bubbles: true,
8
10
  composed: true,
@@ -1,10 +1,11 @@
1
1
  import { type Meta, type StoryObj } from '@storybook/preact';
2
- import { expect, fireEvent, fn, waitFor, within } from '@storybook/test';
2
+ import { expect, fireEvent, fn, userEvent, waitFor, within } from '@storybook/test';
3
3
 
4
4
  import data from './__mockData__/aggregated_hosts.json';
5
5
  import { TextFilter, type TextFilterProps } from './text-filter';
6
6
  import { previewHandles } from '../../../.storybook/preview';
7
7
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
8
+ import { gsEventNames } from '../../utils/gsEventNames';
8
9
  import { LapisUrlContextProvider } from '../LapisUrlContext';
9
10
  import { expectInvalidAttributesErrorMessage } from '../shared/stories/expectErrorMessage';
10
11
 
@@ -13,7 +14,7 @@ const meta: Meta<TextFilterProps> = {
13
14
  component: TextFilter,
14
15
  parameters: {
15
16
  actions: {
16
- handles: ['gs-text-filter-changed', ...previewHandles],
17
+ handles: [gsEventNames.textFilterChanged, ...previewHandles],
17
18
  },
18
19
  fetchMock: {
19
20
  mocks: [
@@ -93,7 +94,7 @@ export const RemoveInitialValue: StoryObj<TextFilterProps> = {
93
94
 
94
95
  const changedListenerMock = fn();
95
96
  await step('Setup event listener mock', () => {
96
- canvasElement.addEventListener('gs-text-filter-changed', changedListenerMock);
97
+ canvasElement.addEventListener(gsEventNames.textFilterChanged, changedListenerMock);
97
98
  });
98
99
 
99
100
  await waitFor(async () => {
@@ -104,13 +105,73 @@ export const RemoveInitialValue: StoryObj<TextFilterProps> = {
104
105
  await step('Remove initial value', async () => {
105
106
  await fireEvent.click(canvas.getByRole('button', { name: 'clear selection' }));
106
107
 
107
- await expect(changedListenerMock).toHaveBeenCalledWith(
108
- expect.objectContaining({
109
- detail: {
110
- host: undefined,
111
- },
112
- }),
113
- );
108
+ await waitFor(async () => {
109
+ await expect(changedListenerMock).toHaveBeenCalledWith(
110
+ expect.objectContaining({
111
+ detail: {
112
+ host: undefined,
113
+ },
114
+ }),
115
+ );
116
+ });
117
+ });
118
+ },
119
+ };
120
+
121
+ export const KeepsPartialInputInInputField: StoryObj<TextFilterProps> = {
122
+ ...Default,
123
+ render: (args) => (
124
+ <>
125
+ <button data-testid='focusHelper'>Focus helper</button>
126
+ <LapisUrlContextProvider value={LAPIS_URL}>
127
+ <TextFilter {...args} />
128
+ </LapisUrlContextProvider>
129
+ </>
130
+ ),
131
+ args: {
132
+ ...Default.args,
133
+ value: '',
134
+ },
135
+ play: async ({ canvasElement, step }) => {
136
+ const canvas = within(canvasElement);
137
+
138
+ const changedListenerMock = fn();
139
+ await step('Setup event listener mock', () => {
140
+ canvasElement.addEventListener(gsEventNames.textFilterChanged, changedListenerMock);
141
+ });
142
+ const inputField = () => canvas.getByPlaceholderText('Enter a host name', { exact: false });
143
+ async function typeAndBlur(input: string) {
144
+ await userEvent.click(inputField());
145
+ await userEvent.type(inputField(), input);
146
+ await userEvent.click(canvas.getByTestId('focusHelper'));
147
+ }
148
+
149
+ await waitFor(async () => {
150
+ await expect(inputField()).toHaveValue('');
151
+ });
152
+
153
+ await step('Type a value that it not valid yet and focus out', async () => {
154
+ await typeAndBlur('Homo sapi');
155
+ await waitFor(async () => {
156
+ await expect(inputField()).toHaveValue('Homo sapi');
157
+ });
158
+ await expect(changedListenerMock).not.toHaveBeenCalled();
159
+ });
160
+
161
+ await step('Complete the input value and expect an event', async () => {
162
+ await typeAndBlur('ens');
163
+ await waitFor(async () => {
164
+ await expect(inputField()).toHaveValue('Homo sapiens');
165
+ });
166
+ await waitFor(async () => {
167
+ await expect(changedListenerMock).toHaveBeenLastCalledWith(
168
+ expect.objectContaining({
169
+ detail: {
170
+ host: 'Homo sapiens',
171
+ },
172
+ }),
173
+ );
174
+ });
114
175
  });
115
176
  },
116
177
  };
@@ -85,12 +85,10 @@ const TextSelector = ({
85
85
  return (
86
86
  <DownshiftCombobox
87
87
  allItems={data}
88
- value={initialSelectedItem}
88
+ value={initialSelectedItem ?? null}
89
89
  filterItemsByInputValue={filterByInputValue}
90
- createEvent={(item: SelectItem | null) =>
91
- new TextFilterChangedEvent({ [lapisField]: item?.value ?? undefined })
92
- }
93
- itemToString={(item: SelectItem | undefined | null) => item?.value ?? ''}
90
+ createEvent={(item) => new TextFilterChangedEvent({ [lapisField]: item?.value ?? undefined })}
91
+ itemToString={(item) => item?.value ?? ''}
94
92
  placeholderText={placeholderText}
95
93
  formatItemInList={(item: SelectItem) => {
96
94
  return (
@@ -104,8 +102,8 @@ const TextSelector = ({
104
102
  );
105
103
  };
106
104
 
107
- function filterByInputValue(item: SelectItem, inputValue: string | undefined | null) {
108
- if (inputValue === undefined || inputValue === null || inputValue === '') {
105
+ function filterByInputValue(item: SelectItem, inputValue: string | null) {
106
+ if (inputValue === null || inputValue === '') {
109
107
  return true;
110
108
  }
111
109
  return item.value?.toLowerCase().includes(inputValue?.toLowerCase() || '');
@@ -38,3 +38,5 @@ export { LineageFilterChangedEvent } from './preact/lineageFilter/LineageFilterC
38
38
  export { TextFilterChangedEvent } from './preact/textFilter/TextFilterChangedEvent';
39
39
 
40
40
  export type { MutationAnnotations, MutationAnnotation } from './web-components/mutation-annotations-context';
41
+
42
+ export { gsEventNames } from './utils/gsEventNames';
@@ -0,0 +1,9 @@
1
+ export const gsEventNames = {
2
+ error: 'gs-error',
3
+ dateRangeFilterChanged: 'gs-date-range-filter-changed',
4
+ dateRangeOptionChanged: 'gs-date-range-option-changed',
5
+ mutationFilterChanged: 'gs-mutation-filter-changed',
6
+ lineageFilterChanged: 'gs-lineage-filter-changed',
7
+ locationChanged: 'gs-location-changed',
8
+ textFilterChanged: 'gs-text-filter-changed',
9
+ } as const;
@@ -10,6 +10,7 @@ import './gs-date-range-filter';
10
10
  import '../gs-app';
11
11
  import { toYYYYMMDD } from '../../preact/dateRangeFilter/dateConversion';
12
12
  import { dateRangeOptionPresets } from '../../preact/dateRangeFilter/dateRangeOption';
13
+ import { gsEventNames } from '../../utils/gsEventNames';
13
14
  import { withinShadowRoot } from '../withinShadowRoot.story';
14
15
 
15
16
  const codeExample = String.raw`
@@ -29,7 +30,7 @@ const meta: Meta<Required<DateRangeFilterProps>> = {
29
30
  component: 'gs-date-range-filter',
30
31
  parameters: withComponentDocs({
31
32
  actions: {
32
- handles: ['gs-date-range-filter-changed', 'gs-date-range-option-changed', ...previewHandles],
33
+ handles: [gsEventNames.dateRangeFilterChanged, gsEventNames.dateRangeOptionChanged, ...previewHandles],
33
34
  },
34
35
  fetchMock: {},
35
36
  componentDocs: {
@@ -144,8 +145,8 @@ export const FiresEvents: StoryObj<Required<DateRangeFilterProps>> = {
144
145
  const filterChangedListenerMock = fn();
145
146
  const optionChangedListenerMock = fn();
146
147
  await step('Setup event listener mock', () => {
147
- canvasElement.addEventListener('gs-date-range-filter-changed', filterChangedListenerMock);
148
- canvasElement.addEventListener('gs-date-range-option-changed', optionChangedListenerMock);
148
+ canvasElement.addEventListener(gsEventNames.dateRangeFilterChanged, filterChangedListenerMock);
149
+ canvasElement.addEventListener(gsEventNames.dateRangeOptionChanged, optionChangedListenerMock);
149
150
  });
150
151
 
151
152
  await step('Expect last 6 months to be selected', async () => {
@@ -5,6 +5,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
5
5
 
6
6
  import { DateRangeFilter, type DateRangeFilterProps } from '../../preact/dateRangeFilter/date-range-filter';
7
7
  import { type DateRangeOptionChangedEvent } from '../../preact/dateRangeFilter/dateRangeOption';
8
+ import { type gsEventNames } from '../../utils/gsEventNames';
8
9
  import { type Equals, type Expect } from '../../utils/typeAssertions';
9
10
  import { PreactLitAdapter } from '../PreactLitAdapter';
10
11
 
@@ -143,8 +144,8 @@ declare global {
143
144
  }
144
145
 
145
146
  interface HTMLElementEventMap {
146
- 'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
147
- 'gs-date-range-option-changed': DateRangeOptionChangedEvent;
147
+ [gsEventNames.dateRangeFilterChanged]: CustomEvent<Record<string, string>>;
148
+ [gsEventNames.dateRangeOptionChanged]: DateRangeOptionChangedEvent;
148
149
  }
149
150
  }
150
151
 
@@ -9,6 +9,7 @@ import '../gs-app';
9
9
  import './gs-lineage-filter';
10
10
  import aggregatedData from '../../preact/lineageFilter/__mockData__/aggregated.json';
11
11
  import { type LineageFilterProps } from '../../preact/lineageFilter/lineage-filter';
12
+ import { gsEventNames } from '../../utils/gsEventNames';
12
13
  import { withinShadowRoot } from '../withinShadowRoot.story';
13
14
 
14
15
  const codeExample = String.raw`
@@ -25,7 +26,7 @@ const meta: Meta<Required<LineageFilterProps>> = {
25
26
  component: 'gs-lineage-filter',
26
27
  parameters: withComponentDocs({
27
28
  actions: {
28
- handles: ['gs-lineage-filter-changed', ...previewHandles],
29
+ handles: [gsEventNames.lineageFilterChanged, ...previewHandles],
29
30
  },
30
31
  fetchMock: {
31
32
  mocks: [
@@ -182,7 +183,7 @@ export const FiresEvent: StoryObj<Required<LineageFilterProps>> = {
182
183
  const inputField = () => canvas.getByPlaceholderText('Enter a lineage');
183
184
  const listenerMock = fn();
184
185
  await step('Setup event listener mock', () => {
185
- canvasElement.addEventListener('gs-lineage-filter-changed', listenerMock);
186
+ canvasElement.addEventListener(gsEventNames.lineageFilterChanged, listenerMock);
186
187
  });
187
188
 
188
189
  await step('wait until data is loaded', async () => {
@@ -3,6 +3,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
4
  import { type LineageFilterChangedEvent } from '../../preact/lineageFilter/LineageFilterChangedEvent';
5
5
  import { LineageFilter, type LineageFilterProps } from '../../preact/lineageFilter/lineage-filter';
6
+ import { type gsEventNames } from '../../utils/gsEventNames';
6
7
  import type { Equals, Expect } from '../../utils/typeAssertions';
7
8
  import { PreactLitAdapter } from '../PreactLitAdapter';
8
9
 
@@ -91,7 +92,7 @@ declare global {
91
92
  }
92
93
 
93
94
  interface HTMLElementEventMap {
94
- 'gs-lineage-filter-changed': LineageFilterChangedEvent;
95
+ [gsEventNames.lineageFilterChanged]: LineageFilterChangedEvent;
95
96
  }
96
97
  }
97
98
 
@@ -10,6 +10,7 @@ import '../gs-app';
10
10
  import './gs-location-filter';
11
11
  import data from '../../preact/locationFilter/__mockData__/aggregated.json';
12
12
  import { type LocationFilterProps } from '../../preact/locationFilter/location-filter';
13
+ import { gsEventNames } from '../../utils/gsEventNames';
13
14
  import { withinShadowRoot } from '../withinShadowRoot.story';
14
15
 
15
16
  const codeExample = String.raw`
@@ -26,7 +27,7 @@ const meta: Meta = {
26
27
  component: 'gs-location-filter',
27
28
  parameters: withComponentDocs({
28
29
  actions: {
29
- handles: ['gs-location-changed', ...previewHandles],
30
+ handles: [gsEventNames.locationChanged, ...previewHandles],
30
31
  },
31
32
  componentDocs: {
32
33
  opensShadowDom: true,
@@ -189,7 +190,7 @@ export const FiresEvent: StoryObj<LocationFilterProps> = {
189
190
 
190
191
  const listenerMock = fn();
191
192
  await step('Setup event listener mock', () => {
192
- canvasElement.addEventListener('gs-location-changed', listenerMock);
193
+ canvasElement.addEventListener(gsEventNames.locationChanged, listenerMock);
193
194
  });
194
195
 
195
196
  await step('wait until data is loaded', async () => {
@@ -3,6 +3,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
4
  import { type LocationChangedEvent } from '../../preact/locationFilter/LocationChangedEvent';
5
5
  import { LocationFilter, type LocationFilterProps } from '../../preact/locationFilter/location-filter';
6
+ import { type gsEventNames } from '../../utils/gsEventNames';
6
7
  import type { Equals, Expect } from '../../utils/typeAssertions';
7
8
  import { PreactLitAdapter } from '../PreactLitAdapter';
8
9
 
@@ -95,7 +96,7 @@ declare global {
95
96
  }
96
97
 
97
98
  interface HTMLElementEventMap {
98
- 'gs-location-changed': LocationChangedEvent;
99
+ [gsEventNames.locationChanged]: LocationChangedEvent;
99
100
  }
100
101
  }
101
102
 
@@ -7,6 +7,7 @@ import { previewHandles } from '../../../.storybook/preview';
7
7
  import { LAPIS_URL, REFERENCE_GENOME_ENDPOINT } from '../../constants';
8
8
  import '../gs-app';
9
9
  import { type MutationFilterProps } from '../../preact/mutationFilter/mutation-filter';
10
+ import { gsEventNames } from '../../utils/gsEventNames';
10
11
  import { withinShadowRoot } from '../withinShadowRoot.story';
11
12
  import './gs-mutation-filter';
12
13
 
@@ -21,7 +22,7 @@ const meta: Meta<MutationFilterProps> = {
21
22
  component: 'gs-mutation-filter',
22
23
  parameters: withComponentDocs({
23
24
  actions: {
24
- handles: ['gs-mutation-filter-changed', ...previewHandles],
25
+ handles: [gsEventNames.mutationFilterChanged, ...previewHandles],
25
26
  },
26
27
  fetchMock: {},
27
28
  componentDocs: {
@@ -73,7 +74,7 @@ export const FiresFilterChangedEvent: StoryObj<MutationFilterProps> = {
73
74
  const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false });
74
75
  const listenerMock = fn();
75
76
  await step('Setup event listener mock', () => {
76
- canvasElement.addEventListener('gs-mutation-filter-changed', listenerMock);
77
+ canvasElement.addEventListener(gsEventNames.mutationFilterChanged, listenerMock);
77
78
  });
78
79
 
79
80
  await step('wait until data is loaded', async () => {
@@ -4,6 +4,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
4
4
  import { ReferenceGenomesAwaiter } from '../../preact/components/ReferenceGenomesAwaiter';
5
5
  import { MutationFilter, type MutationFilterProps } from '../../preact/mutationFilter/mutation-filter';
6
6
  import type { MutationsFilter } from '../../types';
7
+ import { type gsEventNames } from '../../utils/gsEventNames';
7
8
  import type { Equals, Expect } from '../../utils/typeAssertions';
8
9
  import { PreactLitAdapter } from '../PreactLitAdapter';
9
10
 
@@ -95,7 +96,7 @@ declare global {
95
96
  }
96
97
 
97
98
  interface HTMLElementEventMap {
98
- 'gs-mutation-filter-changed': CustomEvent<MutationsFilter>;
99
+ [gsEventNames.mutationFilterChanged]: CustomEvent<MutationsFilter>;
99
100
  }
100
101
  }
101
102
 
@@ -1,4 +1,4 @@
1
- import { expect, fireEvent, fn, userEvent, waitFor } from '@storybook/test';
1
+ import { expect, fn, userEvent, waitFor } from '@storybook/test';
2
2
  import type { Meta, StoryObj } from '@storybook/web-components';
3
3
  import { html } from 'lit';
4
4
 
@@ -9,6 +9,7 @@ import '../gs-app';
9
9
  import './gs-text-filter';
10
10
  import data from '../../preact/textFilter/__mockData__/aggregated_hosts.json';
11
11
  import type { TextFilterProps } from '../../preact/textFilter/text-filter';
12
+ import { gsEventNames } from '../../utils/gsEventNames';
12
13
  import { withinShadowRoot } from '../withinShadowRoot.story';
13
14
 
14
15
  const codeExample = String.raw`
@@ -25,7 +26,7 @@ const meta: Meta<Required<TextFilterProps>> = {
25
26
  component: 'gs-text-filter',
26
27
  parameters: withComponentDocs({
27
28
  actions: {
28
- handles: ['gs-text-filter-changed', ...previewHandles],
29
+ handles: [gsEventNames.textFilterChanged, ...previewHandles],
29
30
  },
30
31
  fetchMock: {
31
32
  mocks: [
@@ -114,7 +115,7 @@ export const FiresEvents: StoryObj<Required<TextFilterProps>> = {
114
115
  const inputField = () => canvas.getByPlaceholderText('Enter host name');
115
116
  const listenerMock = fn();
116
117
  await step('Setup event listener mock', () => {
117
- canvasElement.addEventListener('gs-text-filter-changed', listenerMock);
118
+ canvasElement.addEventListener(gsEventNames.textFilterChanged, listenerMock);
118
119
  });
119
120
 
120
121
  await step('wait until data is loaded', async () => {
@@ -152,9 +153,9 @@ export const FiresEvents: StoryObj<Required<TextFilterProps>> = {
152
153
  });
153
154
 
154
155
  await step('Remove initial value', async () => {
155
- await fireEvent.click(canvas.getByRole('button', { name: 'clear selection' }));
156
+ await userEvent.click(canvas.getByRole('button', { name: 'clear selection' }));
156
157
 
157
- await expect(listenerMock).toHaveBeenCalledWith(
158
+ await expect(listenerMock).toHaveBeenLastCalledWith(
158
159
  expect.objectContaining({
159
160
  detail: {
160
161
  host: undefined,
@@ -162,13 +163,6 @@ export const FiresEvents: StoryObj<Required<TextFilterProps>> = {
162
163
  }),
163
164
  );
164
165
  });
165
-
166
- await step('Empty input', async () => {
167
- inputField().blur();
168
- await expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({
169
- host: undefined,
170
- });
171
- });
172
166
  },
173
167
  args: {
174
168
  ...Default.args,
@@ -3,6 +3,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
3
3
 
4
4
  import { type TextFilterChangedEvent } from '../../preact/textFilter/TextFilterChangedEvent';
5
5
  import { TextFilter, type TextFilterProps } from '../../preact/textFilter/text-filter';
6
+ import { type gsEventNames } from '../../utils/gsEventNames';
6
7
  import type { Equals, Expect } from '../../utils/typeAssertions';
7
8
  import { PreactLitAdapter } from '../PreactLitAdapter';
8
9
 
@@ -85,7 +86,7 @@ declare global {
85
86
  }
86
87
 
87
88
  interface HTMLElementEventMap {
88
- 'gs-text-filter-changed': TextFilterChangedEvent;
89
+ [gsEventNames.textFilterChanged]: TextFilterChangedEvent;
89
90
  }
90
91
  }
91
92
 
@@ -0,0 +1,18 @@
1
+ import { describe, expectTypeOf, test } from 'vitest';
2
+
3
+ import { GenomeDataViewerComponent } from './gs-genome-data-viewer';
4
+ import type { GenomeDataViewerProps } from '../../preact/genomeViewer/genome-data-viewer';
5
+
6
+ describe('gs-app types', () => {
7
+ test('mutationAnnotations type should match', ({}) => {
8
+ expectTypeOf(GenomeDataViewerComponent.prototype)
9
+ .toHaveProperty('gff3Source')
10
+ .toEqualTypeOf<GenomeDataViewerProps['gff3Source']>();
11
+ expectTypeOf(GenomeDataViewerComponent.prototype)
12
+ .toHaveProperty('genomeLength')
13
+ .toEqualTypeOf<GenomeDataViewerProps['genomeLength']>();
14
+ expectTypeOf(GenomeDataViewerComponent.prototype)
15
+ .toHaveProperty('width')
16
+ .toEqualTypeOf<GenomeDataViewerProps['width']>();
17
+ });
18
+ });