@genspectrum/dashboard-components 0.7.2 → 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.
@@ -887,7 +887,7 @@
887
887
  "type": {
888
888
  "text": "Meta<MutationFilterProps>"
889
889
  },
890
- "default": "{ title: 'Input/Mutation filter', component: 'gs-mutation-filter', parameters: withComponentDocs({ actions: { handles: ['gs-mutation-filter-changed', 'gs-mutation-filter-on-blur', ...previewHandles], }, fetchMock: {}, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { initialValue: { control: { type: 'object', }, }, width: { control: 'text' }, }, tags: ['autodocs'], }"
890
+ "default": "{ title: 'Input/Mutation filter', component: 'gs-mutation-filter', parameters: withComponentDocs({ actions: { handles: ['gs-mutation-filter-changed', ...previewHandles], }, fetchMock: {}, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { initialValue: { control: { type: 'object', }, }, width: { control: 'text' }, }, tags: ['autodocs'], }"
891
891
  },
892
892
  {
893
893
  "kind": "variable",
@@ -905,14 +905,6 @@
905
905
  },
906
906
  "default": "{ ...Template, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-filter'); const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false }); const submitButton = () => canvas.getByRole('button', { name: '+' }); const listenerMock = fn(); await step('Setup event listener mock', async () => { canvasElement.addEventListener('gs-mutation-filter-changed', listenerMock); }); await step('wait until data is loaded', async () => { await waitFor(() => { return expect(inputField()).toBeEnabled(); }); }); await step('Enter a valid mutation', async () => { await userEvent.type(inputField(), 'A123T'); await waitFor(() => submitButton().click()); await waitFor(() => expect(listenerMock).toHaveBeenCalledWith( expect.objectContaining({ detail: { nucleotideMutations: ['A123T'], aminoAcidMutations: [], nucleotideInsertions: [], aminoAcidInsertions: [], }, }), ), ); }); }, }"
907
907
  },
908
- {
909
- "kind": "variable",
910
- "name": "FiresFilterOnBlurEvent",
911
- "type": {
912
- "text": "StoryObj<MutationFilterProps>"
913
- },
914
- "default": "{ ...Template, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-filter'); const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false }); const listenerMock = fn(); await step('Setup event listener mock', async () => { canvasElement.addEventListener('gs-mutation-filter-on-blur', listenerMock); }); await step('wait until data is loaded', async () => { await waitFor(() => { return expect(inputField()).toBeEnabled(); }); }); await step('Move outside of input', async () => { await userEvent.type(inputField(), 'A123T'); await userEvent.tab(); await expect(listenerMock).toHaveBeenCalled(); }); }, }"
915
- },
916
908
  {
917
909
  "kind": "variable",
918
910
  "name": "MultiSegmentedReferenceGenomes",
@@ -947,14 +939,6 @@
947
939
  "module": "src/web-components/input/gs-mutation-filter.stories.ts"
948
940
  }
949
941
  },
950
- {
951
- "kind": "js",
952
- "name": "FiresFilterOnBlurEvent",
953
- "declaration": {
954
- "name": "FiresFilterOnBlurEvent",
955
- "module": "src/web-components/input/gs-mutation-filter.stories.ts"
956
- }
957
- },
958
942
  {
959
943
  "kind": "js",
960
944
  "name": "MultiSegmentedReferenceGenomes",
@@ -1002,13 +986,6 @@
1002
986
  },
1003
987
  "description": "Fired when: - The user has submitted a valid mutation or insertion - The user has removed a mutation or insertion",
1004
988
  "name": "gs-mutation-filter-changed"
1005
- },
1006
- {
1007
- "type": {
1008
- "text": "CustomEvent<{nucleotideMutations: string[],aminoAcidMutations: string[],nucleotideInsertions: string[],aminoAcidInsertions: string[]}>"
1009
- },
1010
- "description": "Fired when: - the mutation filter has lost focus Contains the selected mutations in the format",
1011
- "name": "gs-mutation-filter-on-blur"
1012
989
  }
1013
990
  ],
1014
991
  "attributes": [
@@ -8900,13 +8900,10 @@ function useWebWorker(messageToWorker, worker) {
8900
8900
  setError(new Error(`Worker received a message that it cannot deserialize: ${event.data}`));
8901
8901
  setIsLoading(false);
8902
8902
  };
8903
- return () => {
8904
- worker.terminate();
8905
- };
8906
- }, []);
8907
- T(() => {
8903
+ }, [worker]);
8904
+ y(() => {
8908
8905
  worker.postMessage(messageToWorker);
8909
- }, [messageToWorker]);
8906
+ }, [messageToWorker, worker]);
8910
8907
  return { data, error, isLoading };
8911
8908
  }
8912
8909
  const MutationsOverTime = (componentProps) => {
@@ -8917,15 +8914,19 @@ const MutationsOverTime = (componentProps) => {
8917
8914
  const MutationsOverTimeInner = (componentProps) => {
8918
8915
  const lapis = x(LapisUrlContext);
8919
8916
  const { lapisFilter, sequenceType, granularity, lapisDateField } = componentProps;
8920
- const { data, error, isLoading } = useWebWorker(
8921
- {
8917
+ const messageToWorker = T(() => {
8918
+ return {
8922
8919
  lapisFilter,
8923
8920
  sequenceType,
8924
8921
  granularity,
8925
8922
  lapisDateField,
8926
8923
  lapis
8927
- },
8928
- new WorkerWrapper()
8924
+ };
8925
+ }, [granularity, lapis, lapisDateField, lapisFilter, sequenceType]);
8926
+ const worker = T(() => new WorkerWrapper(), []);
8927
+ const { data, error, isLoading } = useWebWorker(
8928
+ messageToWorker,
8929
+ worker
8929
8930
  );
8930
8931
  if (isLoading) {
8931
8932
  return /* @__PURE__ */ u$1(LoadingDisplay, {});
@@ -9972,17 +9973,6 @@ const MutationFilterInner = ({ initialValue }) => {
9972
9973
  })
9973
9974
  );
9974
9975
  };
9975
- const handleOnBlur = () => {
9976
- var _a;
9977
- const detail = mapToMutationFilterStrings(selectedFilters);
9978
- (_a = formRef.current) == null ? void 0 : _a.dispatchEvent(
9979
- new CustomEvent("gs-mutation-filter-on-blur", {
9980
- detail,
9981
- bubbles: true,
9982
- composed: true
9983
- })
9984
- );
9985
- };
9986
9976
  const handleInputChange = (event) => {
9987
9977
  setInputValue(event.target.value);
9988
9978
  setIsError(false);
@@ -10010,8 +10000,7 @@ const MutationFilterInner = ({ initialValue }) => {
10010
10000
  type: "text",
10011
10001
  value: inputValue,
10012
10002
  onInput: handleInputChange,
10013
- placeholder: getPlaceholder(referenceGenome),
10014
- onBlur: handleOnBlur
10003
+ placeholder: getPlaceholder(referenceGenome)
10015
10004
  }
10016
10005
  ),
10017
10006
  /* @__PURE__ */ u$1("button", { type: "submit", className: "btn btn-xs m-1", children: "+" })