@genspectrum/dashboard-components 0.7.1 → 0.8.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.
@@ -1,3 +1,5 @@
1
+ import { type StoryObj } from '@storybook/preact';
2
+
1
3
  import denominator from './__mockData__/denominatorFilter.json';
2
4
  import numerator from './__mockData__/numeratorFilter.json';
3
5
  import { RelativeGrowthAdvantage, type RelativeGrowthAdvantageProps } from './relative-growth-advantage';
@@ -11,8 +13,8 @@ export default {
11
13
  fetchMock: {},
12
14
  },
13
15
  argTypes: {
14
- numerator: { control: 'object' },
15
- denominator: { control: 'object' },
16
+ numeratorFilter: { control: 'object' },
17
+ denominatorFilter: { control: 'object' },
16
18
  generationTime: { control: 'number' },
17
19
  views: {
18
20
  options: ['line'],
@@ -24,7 +26,7 @@ export default {
24
26
  },
25
27
  };
26
28
 
27
- export const Primary = {
29
+ export const Primary: StoryObj<RelativeGrowthAdvantageProps> = {
28
30
  render: (args: RelativeGrowthAdvantageProps) => (
29
31
  <LapisUrlContext.Provider value={LAPIS_URL}>
30
32
  <RelativeGrowthAdvantage
@@ -40,8 +42,13 @@ export const Primary = {
40
42
  </LapisUrlContext.Provider>
41
43
  ),
42
44
  args: {
43
- numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
44
- denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
45
+ numeratorFilter: {
46
+ country: 'Switzerland',
47
+ pangoLineage: 'B.1.1.7',
48
+ dateFrom: '2020-12-01',
49
+ dateTo: '2021-03-01',
50
+ },
51
+ denominatorFilter: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
45
52
  generationTime: 7,
46
53
  views: ['line'],
47
54
  width: '100%',
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from 'preact/hooks';
1
+ import { useEffect, useState } from 'preact/hooks';
2
2
 
3
3
  export function useWebWorker<Request, Response>(messageToWorker: Request, worker: Worker) {
4
4
  const [data, setData] = useState<Response | undefined>(undefined);
@@ -37,15 +37,11 @@ export function useWebWorker<Request, Response>(messageToWorker: Request, worker
37
37
  setError(new Error(`Worker received a message that it cannot deserialize: ${event.data}`));
38
38
  setIsLoading(false);
39
39
  };
40
+ }, [worker]);
40
41
 
41
- return () => {
42
- worker.terminate();
43
- };
44
- }, []);
45
-
46
- useMemo(() => {
42
+ useEffect(() => {
47
43
  worker.postMessage(messageToWorker);
48
- }, [messageToWorker]);
44
+ }, [messageToWorker, worker]);
49
45
 
50
46
  return { data, error, isLoading };
51
47
  }
@@ -21,7 +21,7 @@ const meta: Meta<MutationFilterProps> = {
21
21
  component: 'gs-mutation-filter',
22
22
  parameters: withComponentDocs({
23
23
  actions: {
24
- handles: ['gs-mutation-filter-changed', 'gs-mutation-filter-on-blur', ...previewHandles],
24
+ handles: ['gs-mutation-filter-changed', ...previewHandles],
25
25
  },
26
26
  fetchMock: {},
27
27
  componentDocs: {
@@ -102,32 +102,6 @@ export const FiresFilterChangedEvent: StoryObj<MutationFilterProps> = {
102
102
  },
103
103
  };
104
104
 
105
- export const FiresFilterOnBlurEvent: StoryObj<MutationFilterProps> = {
106
- ...Template,
107
- play: async ({ canvasElement, step }) => {
108
- const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-filter');
109
-
110
- const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false });
111
- const listenerMock = fn();
112
- await step('Setup event listener mock', async () => {
113
- canvasElement.addEventListener('gs-mutation-filter-on-blur', listenerMock);
114
- });
115
-
116
- await step('wait until data is loaded', async () => {
117
- await waitFor(() => {
118
- return expect(inputField()).toBeEnabled();
119
- });
120
- });
121
-
122
- await step('Move outside of input', async () => {
123
- await userEvent.type(inputField(), 'A123T');
124
- await userEvent.tab();
125
-
126
- await expect(listenerMock).toHaveBeenCalled();
127
- });
128
- },
129
- };
130
-
131
105
  export const MultiSegmentedReferenceGenomes: StoryObj<MutationFilterProps> = {
132
106
  ...Template,
133
107
  args: {
@@ -53,16 +53,6 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
53
53
  * Fired when:
54
54
  * - The user has submitted a valid mutation or insertion
55
55
  * - The user has removed a mutation or insertion
56
- *
57
- * @fires {CustomEvent<{
58
- * nucleotideMutations: string[],
59
- * aminoAcidMutations: string[],
60
- * nucleotideInsertions: string[],
61
- * aminoAcidInsertions: string[]
62
- * }>} gs-mutation-filter-on-blur
63
- * Fired when:
64
- * - the mutation filter has lost focus
65
- * Contains the selected mutations in the format
66
56
  */
67
57
  @customElement('gs-mutation-filter')
68
58
  export class MutationFilterComponent extends PreactLitAdapter {
@@ -108,7 +98,6 @@ declare global {
108
98
 
109
99
  interface HTMLElementEventMap {
110
100
  'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
111
- 'gs-mutation-filter-on-blur': CustomEvent<SelectedMutationFilterStrings>;
112
101
  }
113
102
  }
114
103