@genspectrum/dashboard-components 0.11.6 → 0.12.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.
- package/custom-elements.json +50 -15
- package/dist/{dateRangeOption-Bh2p78z0.js → LocationChangedEvent-CORvQvXv.js} +11 -1
- package/dist/LocationChangedEvent-CORvQvXv.js.map +1 -0
- package/dist/assets/{mutationOverTimeWorker-CWneD7i5.js.map → mutationOverTimeWorker-DTv93Ere.js.map} +1 -1
- package/dist/components.d.ts +79 -51
- package/dist/components.js +3951 -621
- package/dist/components.js.map +1 -1
- package/dist/style.css +151 -4
- package/dist/util.d.ts +78 -44
- package/dist/util.js +2 -1
- package/package.json +2 -1
- package/src/preact/components/csv-download-button.tsx +2 -2
- package/src/preact/downshift_types.d.ts +3 -0
- package/src/preact/locationFilter/LocationChangedEvent.ts +11 -0
- package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +5 -5
- package/src/preact/locationFilter/fetchAutocompletionList.ts +9 -2
- package/src/preact/locationFilter/location-filter.stories.tsx +94 -10
- package/src/preact/locationFilter/location-filter.tsx +183 -62
- package/src/preact/mutationFilter/mutation-filter-info.tsx +73 -10
- package/src/preact/mutations/__mockData__/baselineNucleotideMutations.json +337412 -0
- package/src/preact/mutations/__mockData__/overallVariantCount.json +14 -0
- package/src/preact/mutations/getMutationsTableData.spec.ts +20 -3
- package/src/preact/mutations/getMutationsTableData.ts +37 -2
- package/src/preact/mutations/mutations-table.tsx +47 -27
- package/src/preact/mutations/mutations.stories.tsx +41 -9
- package/src/preact/mutations/mutations.tsx +22 -6
- package/src/preact/mutations/queryMutations.ts +28 -8
- package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutationsByDay.ts +11077 -3062
- package/src/preact/mutationsOverTime/__mockData__/byWeek.ts +3883 -6606
- package/src/preact/mutationsOverTime/__mockData__/defaultMockData.ts +17624 -2203
- package/src/preact/mutationsOverTime/mutations-over-time.tsx +1 -1
- package/src/query/queryMutationsOverTime.spec.ts +144 -4
- package/src/query/queryMutationsOverTime.ts +17 -1
- package/src/utilEntrypoint.ts +2 -0
- package/src/web-components/input/gs-location-filter.stories.ts +34 -29
- package/src/web-components/input/gs-location-filter.tsx +6 -13
- package/src/web-components/visualization/gs-mutations.stories.ts +62 -4
- package/src/web-components/visualization/gs-mutations.tsx +44 -0
- package/standalone-bundle/assets/{mutationOverTimeWorker-x1ipPFL0.js.map → mutationOverTimeWorker-DEybsZ5r.js.map} +1 -1
- package/standalone-bundle/dashboard-components.js +11021 -8621
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/standalone-bundle/style.css +1 -1
- package/dist/dateRangeOption-Bh2p78z0.js.map +0 -1
package/custom-elements.json
CHANGED
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
"type": {
|
|
715
715
|
"text": "Meta"
|
|
716
716
|
},
|
|
717
|
-
"default": "{ title: 'Input/Location filter', component: 'gs-location-filter', parameters: withComponentDocs({ actions: { handles: ['gs-location-changed', ...previewHandles], }, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { fields: { control: { type: 'object', }, },
|
|
717
|
+
"default": "{ title: 'Input/Location filter', component: 'gs-location-filter', parameters: withComponentDocs({ actions: { handles: ['gs-location-changed', ...previewHandles], }, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { fields: { control: { type: 'object', }, }, value: { control: { type: 'object', }, }, width: { control: { type: 'text', }, }, placeholderText: { control: { type: 'text', }, }, }, tags: ['autodocs'], }"
|
|
718
718
|
},
|
|
719
719
|
{
|
|
720
720
|
"kind": "variable",
|
|
@@ -722,7 +722,7 @@
|
|
|
722
722
|
"type": {
|
|
723
723
|
"text": "StoryObj<LocationFilterProps>"
|
|
724
724
|
},
|
|
725
|
-
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: aggregatedEndpointMatcher, response: { status: 200, body: data, }, }, ], }, }, play: async ({ canvasElement }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-location-filter'); await waitFor(() => { return expect(canvas.
|
|
725
|
+
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: aggregatedEndpointMatcher, response: { status: 200, body: data, }, }, ], }, }, play: async ({ canvasElement }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-location-filter'); await waitFor(() => { return expect(canvas.getByPlaceholderText('Enter a location')).toBeVisible(); }); }, }"
|
|
726
726
|
},
|
|
727
727
|
{
|
|
728
728
|
"kind": "variable",
|
|
@@ -746,7 +746,7 @@
|
|
|
746
746
|
"type": {
|
|
747
747
|
"text": "StoryObj<LocationFilterProps>"
|
|
748
748
|
},
|
|
749
|
-
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: aggregatedEndpointMatcher, response: { status: 200, body: data, }, }, ], }, }, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-location-filter'); const inputField = () => canvas.getByRole('combobox'); const listenerMock = fn(); await step('Setup event listener mock', async () => { canvasElement.addEventListener('gs-location-changed', listenerMock); }); await step('wait until data is loaded', async () => { await waitFor(() => { return expect(inputField()).toBeEnabled(); }); }); await step('Input invalid location', async () => { await userEvent.type(inputField(), 'Not / A / Location'); await expect(listenerMock).not.toHaveBeenCalled(); }); await step('Empty input', async () => { await userEvent.type(inputField(), '{backspace>18/}'); await expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ region: undefined, country: undefined, division: undefined, location: undefined, }); }); await step('Select Asia', async () => { await userEvent.type(inputField(), 'Asia'); await expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ region: 'Asia', country: undefined, division: undefined, location: undefined, }); }); await step('Select Asia / Bangladesh / Rajshahi / Chapainawabgonj', async () => { await userEvent.type(inputField(), ' / Bangladesh / Rajshahi / Chapainawabgonj'); await
|
|
749
|
+
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: aggregatedEndpointMatcher, response: { status: 200, body: data, }, }, ], }, }, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-location-filter'); const inputField = () => canvas.getByRole('combobox'); const listenerMock = fn(); await step('Setup event listener mock', async () => { canvasElement.addEventListener('gs-location-changed', listenerMock); }); await step('wait until data is loaded', async () => { await waitFor(() => { return expect(inputField()).toBeEnabled(); }); }); await step('Input invalid location', async () => { await userEvent.type(inputField(), 'Not / A / Location'); await expect(listenerMock).not.toHaveBeenCalled(); }); await step('Empty input', async () => { await userEvent.type(inputField(), '{backspace>18/}'); await userEvent.click(canvas.getByLabelText('toggle menu')); await waitFor(() => { return expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ region: undefined, country: undefined, division: undefined, location: undefined, }); }); }); await step('Select Asia', async () => { await userEvent.type(inputField(), 'Asia'); await userEvent.click(canvas.getByRole('option', { name: 'Asia Asia' })); await waitFor(() => { return expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ region: 'Asia', country: undefined, division: undefined, location: undefined, }); }); }); await step('Select Asia / Bangladesh / Rajshahi / Chapainawabgonj', async () => { await userEvent.type(inputField(), ' / Bangladesh / Rajshahi / Chapainawabgonj'); await userEvent.click(canvas.getByText('Asia / Bangladesh / Rajshahi / Chapainawabgonj')); await waitFor(() => { return expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ region: 'Asia', country: 'Bangladesh', division: 'Rajshahi', location: 'Chapainawabgonj', }); }); }); }, }"
|
|
750
750
|
}
|
|
751
751
|
],
|
|
752
752
|
"exports": [
|
|
@@ -798,18 +798,18 @@
|
|
|
798
798
|
"declarations": [
|
|
799
799
|
{
|
|
800
800
|
"kind": "class",
|
|
801
|
-
"description": "## Context\n\nThis component provides an input field to specify filters for locations.\n\nIt expects a list of fields that form a strict hierarchical order, such as continent, country, and city.\nThe component retrieves a list of all possible values for these fields from the Lapis instance.\nThis list is then utilized to display autocomplete suggestions and to validate the input
|
|
801
|
+
"description": "## Context\n\nThis component provides an input field to specify filters for locations.\n\nIt expects a list of fields that form a strict hierarchical order, such as continent, country, and city.\nThe component retrieves a list of all possible values for these fields from the Lapis instance.\nThis list is then utilized to display autocomplete suggestions and to validate the input.",
|
|
802
802
|
"name": "LocationFilterComponent",
|
|
803
803
|
"members": [
|
|
804
804
|
{
|
|
805
805
|
"kind": "field",
|
|
806
|
-
"name": "
|
|
806
|
+
"name": "value",
|
|
807
807
|
"type": {
|
|
808
|
-
"text": "string | undefined"
|
|
808
|
+
"text": "Record<string, string | null | undefined> | undefined"
|
|
809
809
|
},
|
|
810
810
|
"default": "undefined",
|
|
811
|
-
"description": "The initial value to use for this location filter
|
|
812
|
-
"attribute": "
|
|
811
|
+
"description": "The initial value to use for this location filter.",
|
|
812
|
+
"attribute": "value"
|
|
813
813
|
},
|
|
814
814
|
{
|
|
815
815
|
"kind": "field",
|
|
@@ -853,13 +853,13 @@
|
|
|
853
853
|
],
|
|
854
854
|
"attributes": [
|
|
855
855
|
{
|
|
856
|
-
"name": "
|
|
856
|
+
"name": "value",
|
|
857
857
|
"type": {
|
|
858
|
-
"text": "string | undefined"
|
|
858
|
+
"text": "Record<string, string | null | undefined> | undefined"
|
|
859
859
|
},
|
|
860
860
|
"default": "undefined",
|
|
861
|
-
"description": "The initial value to use for this location filter
|
|
862
|
-
"fieldName": "
|
|
861
|
+
"description": "The initial value to use for this location filter.",
|
|
862
|
+
"fieldName": "value"
|
|
863
863
|
},
|
|
864
864
|
{
|
|
865
865
|
"name": "fields",
|
|
@@ -2120,7 +2120,7 @@
|
|
|
2120
2120
|
"type": {
|
|
2121
2121
|
"text": "Meta<Required<MutationsProps>>"
|
|
2122
2122
|
},
|
|
2123
|
-
"default": "{ title: 'Visualization/Mutations', component: 'gs-mutations', argTypes: { lapisFilter: { control: 'object' }, sequenceType: { options: ['nucleotide', 'amino acid'], control: { type: 'radio' }, }, views: { options: ['table', 'grid', 'insertions'], control: { type: 'check' }, }, width: { control: 'text' }, height: { control: 'text' }, pageSize: { control: 'object' }, }, args: { lapisFilter: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' }, sequenceType: 'nucleotide', views: ['grid', 'table', 'insertions'], width: '100%', height: '700px', pageSize: 10, }, parameters: withComponentDocs({ componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), tags: ['autodocs'], }"
|
|
2123
|
+
"default": "{ title: 'Visualization/Mutations', component: 'gs-mutations', argTypes: { lapisFilter: { control: 'object' }, baselineLapisFilter: { control: 'object' }, sequenceType: { options: ['nucleotide', 'amino acid'], control: { type: 'radio' }, }, views: { options: ['table', 'grid', 'insertions'], control: { type: 'check' }, }, width: { control: 'text' }, height: { control: 'text' }, pageSize: { control: 'object' }, }, args: { lapisFilter: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' }, baselineLapisFilter: { country: 'Switzerland', dateTo: '2022-01-01' }, sequenceType: 'nucleotide', views: ['grid', 'table', 'insertions'], width: '100%', height: '700px', pageSize: 10, }, parameters: withComponentDocs({ componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), tags: ['autodocs'], }"
|
|
2124
2124
|
},
|
|
2125
2125
|
{
|
|
2126
2126
|
"kind": "variable",
|
|
@@ -2128,7 +2128,7 @@
|
|
|
2128
2128
|
"type": {
|
|
2129
2129
|
"text": "StoryObj<Required<MutationsProps>>"
|
|
2130
2130
|
},
|
|
2131
|
-
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: { name: 'nucleotideMutations', url: NUCLEOTIDE_MUTATIONS_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01', minProportion: 0, }, }, response: { status: 200, body: nucleotideMutations, }, }, { matcher: { name: 'nucleotideInsertions', url: NUCLEOTIDE_INSERTIONS_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' }, }, response: { status: 200, body: nucleotideInsertions, }, }, ], }, }, }"
|
|
2131
|
+
"default": "{ ...Template, parameters: { fetchMock: { mocks: [ { matcher: { name: 'nucleotideMutations', url: NUCLEOTIDE_MUTATIONS_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01', minProportion: 0, }, }, response: { status: 200, body: nucleotideMutations, }, }, { matcher: { name: 'baselineNucleotideMutations', url: NUCLEOTIDE_MUTATIONS_ENDPOINT, body: { country: 'Switzerland', dateTo: '2022-01-01', minProportion: 0, }, }, response: { status: 200, body: baselineNucleotideMutations, }, }, { matcher: { name: 'overallVariantCount', url: AGGREGATED_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01', fields: [], }, }, response: { status: 200, body: overallVariantCount, }, }, { matcher: { name: 'nucleotideInsertions', url: NUCLEOTIDE_INSERTIONS_ENDPOINT, body: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' }, }, response: { status: 200, body: nucleotideInsertions, }, }, ], }, }, }"
|
|
2132
2132
|
},
|
|
2133
2133
|
{
|
|
2134
2134
|
"kind": "variable",
|
|
@@ -2138,6 +2138,14 @@
|
|
|
2138
2138
|
},
|
|
2139
2139
|
"default": "{ ...Default, play: async ({ canvasElement }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-mutations'); await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument()); await fireEvent.click(canvas.getByRole('button', { name: 'Table' })); }, }"
|
|
2140
2140
|
},
|
|
2141
|
+
{
|
|
2142
|
+
"kind": "variable",
|
|
2143
|
+
"name": "OnTableTabWithoutJaccardSimilarity",
|
|
2144
|
+
"type": {
|
|
2145
|
+
"text": "StoryObj<Required<MutationsProps>>"
|
|
2146
|
+
},
|
|
2147
|
+
"default": "{ ...Default, args: { ...Default.args, baselineLapisFilter: undefined, }, play: async ({ canvasElement }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-mutations'); await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument()); await fireEvent.click(canvas.getByRole('button', { name: 'Table' })); }, }"
|
|
2148
|
+
},
|
|
2141
2149
|
{
|
|
2142
2150
|
"kind": "variable",
|
|
2143
2151
|
"name": "OnInsertionsTab",
|
|
@@ -2172,6 +2180,14 @@
|
|
|
2172
2180
|
"module": "src/web-components/visualization/gs-mutations.stories.ts"
|
|
2173
2181
|
}
|
|
2174
2182
|
},
|
|
2183
|
+
{
|
|
2184
|
+
"kind": "js",
|
|
2185
|
+
"name": "OnTableTabWithoutJaccardSimilarity",
|
|
2186
|
+
"declaration": {
|
|
2187
|
+
"name": "OnTableTabWithoutJaccardSimilarity",
|
|
2188
|
+
"module": "src/web-components/visualization/gs-mutations.stories.ts"
|
|
2189
|
+
}
|
|
2190
|
+
},
|
|
2175
2191
|
{
|
|
2176
2192
|
"kind": "js",
|
|
2177
2193
|
"name": "OnInsertionsTab",
|
|
@@ -2188,7 +2204,7 @@
|
|
|
2188
2204
|
"declarations": [
|
|
2189
2205
|
{
|
|
2190
2206
|
"kind": "class",
|
|
2191
|
-
"description": "## Context\n\nThis component displays mutations (substitutions, deletions and insertions) for a dataset selected by a LAPIS filter.\n\n## Views\n\n### Table View\n\nThe table view shows all substitutions and deletions for the dataset.\nIt shows the type (substitution or deletion), the total count of the mutation\nand the proportion of the mutation in the dataset.\nThe proportion is relative to the total number of sequences matching\nthe specified sequence filters with non-ambiguous reads at that position.\n\nThe proportion interval filter can be used to filter the displayed mutations on client side.\n\n### Grid View\n\nThe grid view shows the proportion of each sequence symbol (nucleotide or amino acid) for each position that has a mutation.\nOnly positions with at least one mutation in the selected proportion interval are shown.\n\n### Insertions View\n\nThe insertions view shows the count of all insertions for the dataset.",
|
|
2207
|
+
"description": "## Context\n\nThis component displays mutations (substitutions, deletions and insertions) for a dataset selected by a LAPIS filter.\n\n## Views\n\n### Table View\n\nThe table view shows all substitutions and deletions for the dataset.\nIt shows the type (substitution or deletion), the total count of the mutation\nand the proportion of the mutation in the dataset.\nThe proportion is relative to the total number of sequences matching\nthe specified sequence filters with non-ambiguous reads at that position.\n\nThe proportion interval filter can be used to filter the displayed mutations on client side.\n\n#### Jaccard Similarity\n\nIf the `baselineLapisFilter` attribute is set,\nthe [Jaccard similarity](https://en.wikipedia.org/wiki/Jaccard_index) is computed for each mutation.\nIt is computed as `variantWithMutationCount / (variantCount + mutationCount - variantWithMutationCount)`,\n- `variantCount` is the number of sequences of the variant (i.e. the number of sequences that match the `lapisFilter`),\n- `mutationCount` is the number of sequences with the mutation\n (i.e. the number of sequences matching the `baselineLapisFilter` that have the mutation),\n- `variantWithMutationCount` is the number of sequences that belong to the variant and have the mutation\n (i.e. the `count` value that is shown in the table).\n\nTypically, this is useful when you query mutations of a certain \"variant\"\n(i.e. a certain lineage or a certain set of mutations).\nThen the `baselineLapisFilter` should be the `lapisFilter` but without the lineage or mutations.\n\nFor example:\nYou are interested in a certain lineage in a certain country: `lapisFilter={country: 'Switzerland', linage: 'XY.1.2.3'}`.\nThen the \"baseline\" should be the same filter but without the lineage: `baselineLapisFilter={country: 'Switzerland'}`.\n\nComputing the Jaccard similarity is not always meaningful, because you might not have a \"variant\"\n(e.g. when you only query for a certain country).\nIn this case you can simply omit the `baselineLapisFilter`.\n\n### Grid View\n\nThe grid view shows the proportion of each sequence symbol (nucleotide or amino acid) for each position that has a mutation.\nOnly positions with at least one mutation in the selected proportion interval are shown.\n\n### Insertions View\n\nThe insertions view shows the count of all insertions for the dataset.",
|
|
2192
2208
|
"name": "MutationsComponent",
|
|
2193
2209
|
"members": [
|
|
2194
2210
|
{
|
|
@@ -2201,6 +2217,16 @@
|
|
|
2201
2217
|
"description": "LAPIS filter to select the displayed data. If not provided, all data is displayed.",
|
|
2202
2218
|
"attribute": "lapisFilter"
|
|
2203
2219
|
},
|
|
2220
|
+
{
|
|
2221
|
+
"kind": "field",
|
|
2222
|
+
"name": "baselineLapisFilter",
|
|
2223
|
+
"type": {
|
|
2224
|
+
"text": "(Record<string, string | string[] | number | null | boolean | undefined> & {\n nucleotideMutations?: string[];\n aminoAcidMutations?: string[];\n nucleotideInsertions?: string[];\n aminoAcidInsertions?: string[];\n })\n | undefined"
|
|
2225
|
+
},
|
|
2226
|
+
"default": "undefined",
|
|
2227
|
+
"description": "LAPIS filter to select the mutation counts that are used to compute the Jaccard similarity.\nIf not provided, the Jaccard similarity is not computed.\nFor details, see the [Jaccard Similarity](#jaccard-similarity) section in the component description.",
|
|
2228
|
+
"attribute": "baselineLapisFilter"
|
|
2229
|
+
},
|
|
2204
2230
|
{
|
|
2205
2231
|
"kind": "field",
|
|
2206
2232
|
"name": "sequenceType",
|
|
@@ -2262,6 +2288,15 @@
|
|
|
2262
2288
|
"description": "LAPIS filter to select the displayed data. If not provided, all data is displayed.",
|
|
2263
2289
|
"fieldName": "lapisFilter"
|
|
2264
2290
|
},
|
|
2291
|
+
{
|
|
2292
|
+
"name": "baselineLapisFilter",
|
|
2293
|
+
"type": {
|
|
2294
|
+
"text": "(Record<string, string | string[] | number | null | boolean | undefined> & {\n nucleotideMutations?: string[];\n aminoAcidMutations?: string[];\n nucleotideInsertions?: string[];\n aminoAcidInsertions?: string[];\n })\n | undefined"
|
|
2295
|
+
},
|
|
2296
|
+
"default": "undefined",
|
|
2297
|
+
"description": "LAPIS filter to select the mutation counts that are used to compute the Jaccard similarity.\nIf not provided, the Jaccard similarity is not computed.\nFor details, see the [Jaccard Similarity](#jaccard-similarity) section in the component description.",
|
|
2298
|
+
"fieldName": "baselineLapisFilter"
|
|
2299
|
+
},
|
|
2265
2300
|
{
|
|
2266
2301
|
"name": "sequenceType",
|
|
2267
2302
|
"type": {
|
|
@@ -96,8 +96,18 @@ const dateRangeOptionPresets = {
|
|
|
96
96
|
label: "All times"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
+
class LocationChangedEvent extends CustomEvent {
|
|
100
|
+
constructor(detail) {
|
|
101
|
+
super("gs-location-changed", {
|
|
102
|
+
detail,
|
|
103
|
+
bubbles: true,
|
|
104
|
+
composed: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
99
108
|
export {
|
|
100
109
|
DateRangeOptionChangedEvent as D,
|
|
110
|
+
LocationChangedEvent as L,
|
|
101
111
|
dateRangeOptionSchema as a,
|
|
102
112
|
toYYYYMMDD as b,
|
|
103
113
|
dateRangeOptionPresets as d,
|
|
@@ -108,4 +118,4 @@ export {
|
|
|
108
118
|
temporalGranularitySchema as t,
|
|
109
119
|
views as v
|
|
110
120
|
};
|
|
111
|
-
//# sourceMappingURL=
|
|
121
|
+
//# sourceMappingURL=LocationChangedEvent-CORvQvXv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationChangedEvent-CORvQvXv.js","sources":["../src/types.ts","../src/preact/dateRangeSelector/dateConversion.ts","../src/preact/dateRangeSelector/dateRangeOption.ts","../src/preact/locationFilter/LocationChangedEvent.ts"],"sourcesContent":["import z from 'zod';\n\nimport {\n type Deletion,\n type DeletionClass,\n type Insertion,\n type InsertionClass,\n type Substitution,\n type SubstitutionClass,\n} from './utils/mutations';\n\nexport const mutationsFilterSchema = z.object({\n nucleotideMutations: z.array(z.string()),\n aminoAcidMutations: z.array(z.string()),\n nucleotideInsertions: z.array(z.string()),\n aminoAcidInsertions: z.array(z.string()),\n});\nexport type MutationsFilter = z.infer<typeof mutationsFilterSchema>;\n\nexport const lapisFilterSchema = z\n .record(z.union([z.string(), z.array(z.string()), z.number(), z.null(), z.boolean(), z.undefined()]))\n .and(mutationsFilterSchema.partial());\nexport type LapisFilter = z.infer<typeof lapisFilterSchema>;\n\nexport const namedLapisFilterSchema = z.object({\n lapisFilter: lapisFilterSchema,\n displayName: z.string(),\n});\nexport type NamedLapisFilter = z.infer<typeof namedLapisFilterSchema>;\n\nexport const temporalGranularitySchema = z.union([\n z.literal('day'),\n z.literal('week'),\n z.literal('month'),\n z.literal('year'),\n]);\nexport type TemporalGranularity = z.infer<typeof temporalGranularitySchema>;\n\nexport const sequenceTypeSchema = z.union([z.literal('nucleotide'), z.literal('amino acid')]);\nexport type SequenceType = z.infer<typeof sequenceTypeSchema>;\n\nexport type SubstitutionOrDeletion = 'substitution' | 'deletion';\n\nexport type MutationType = SubstitutionOrDeletion | 'insertion';\n\nexport type SubstitutionEntry<T extends Substitution = SubstitutionClass> = {\n type: 'substitution';\n mutation: T;\n count: number;\n proportion: number;\n};\n\nexport type DeletionEntry<T extends Deletion = DeletionClass> = {\n type: 'deletion';\n mutation: T;\n count: number;\n proportion: number;\n};\n\nexport type InsertionEntry<T extends Insertion = InsertionClass> = { type: 'insertion'; mutation: T; count: number };\n\nexport type SubstitutionOrDeletionEntry<\n S extends Substitution = SubstitutionClass,\n D extends Deletion = DeletionClass,\n> = SubstitutionEntry<S> | DeletionEntry<D>;\n\nexport type MutationEntry = SubstitutionEntry | DeletionEntry | InsertionEntry;\n\nexport const views = {\n table: 'table',\n venn: 'venn',\n grid: 'grid',\n insertions: 'insertions',\n bar: 'bar',\n line: 'line',\n bubble: 'bubble',\n map: 'map',\n} as const;\n","export const toYYYYMMDD = (date: Date) => {\n const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: '2-digit', day: '2-digit' };\n return date.toLocaleDateString('en-CA', options);\n};\n","import z from 'zod';\n\nimport { toYYYYMMDD } from './dateConversion';\n\n/**\n * A date range option that can be used in the `gs-date-range-selector` component.\n */\nexport const dateRangeOptionSchema = z.object({\n /** The label of the date range option that will be shown to the user */\n label: z.string(),\n /**\n * The start date of the date range in the format `YYYY-MM-DD`.\n * If not set, the date range selector will default to the `earliestDate` property.\n */\n dateFrom: z.string().date().optional(),\n /**\n * The end date of the date range in the format `YYYY-MM-DD`.\n * If not set, the date range selector will default to the current date.\n */\n dateTo: z.string().date().optional(),\n});\n\nexport type DateRangeOption = z.infer<typeof dateRangeOptionSchema>;\n\nexport type DateRangeSelectOption = string | { dateFrom: string; dateTo: string };\n\nexport class DateRangeOptionChangedEvent extends CustomEvent<DateRangeSelectOption> {\n constructor(detail: DateRangeSelectOption) {\n super('gs-date-range-option-changed', {\n detail,\n bubbles: true,\n composed: true,\n });\n }\n}\n\nconst today = new Date();\n\nconst twoWeeksAgo = new Date();\ntwoWeeksAgo.setDate(today.getDate() - 14);\n\nconst lastMonth = new Date(today);\nlastMonth.setMonth(today.getMonth() - 1);\n\nconst last2Months = new Date(today);\nlast2Months.setMonth(today.getMonth() - 2);\n\nconst last3Months = new Date(today);\nlast3Months.setMonth(today.getMonth() - 3);\n\nconst last6Months = new Date(today);\nlast6Months.setMonth(today.getMonth() - 6);\n\nconst lastYear = new Date(today);\nlastYear.setFullYear(today.getFullYear() - 1);\n\n/**\n * Presets for the `gs-date-range-selector` component that can be used as `dateRangeOptions`.\n */\nexport const dateRangeOptionPresets = {\n last2Weeks: {\n label: 'Last 2 weeks',\n dateFrom: toYYYYMMDD(twoWeeksAgo),\n },\n lastMonth: {\n label: 'Last month',\n dateFrom: toYYYYMMDD(lastMonth),\n },\n last2Months: {\n label: 'Last 2 months',\n dateFrom: toYYYYMMDD(last2Months),\n },\n last3Months: {\n label: 'Last 3 months',\n dateFrom: toYYYYMMDD(last3Months),\n },\n last6Months: {\n label: 'Last 6 months',\n dateFrom: toYYYYMMDD(last6Months),\n },\n lastYear: {\n label: 'Last year',\n dateFrom: toYYYYMMDD(lastYear),\n },\n allTimes: {\n label: 'All times',\n },\n} satisfies Record<string, DateRangeOption>;\n","export type LapisLocationFilter = Record<string, string | null | undefined>;\n\nexport class LocationChangedEvent extends CustomEvent<LapisLocationFilter> {\n constructor(detail: LapisLocationFilter) {\n super('gs-location-changed', {\n detail,\n bubbles: true,\n composed: true,\n });\n }\n}\n"],"names":[],"mappings":";AAWa,MAAA,wBAAwB,EAAE,OAAO;AAAA,EAC1C,qBAAqB,EAAE,MAAM,EAAE,QAAQ;AAAA,EACvC,oBAAoB,EAAE,MAAM,EAAE,QAAQ;AAAA,EACtC,sBAAsB,EAAE,MAAM,EAAE,QAAQ;AAAA,EACxC,qBAAqB,EAAE,MAAM,EAAE,OAAQ,CAAA;AAC3C,CAAC;AAGM,MAAM,oBAAoB,EAC5B,OA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