@genspectrum/dashboard-components 0.6.0 → 0.6.1
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 +181 -1
- package/dist/dashboard-components.js +1 -5
- package/dist/dashboard-components.js.map +1 -1
- package/dist/genspectrum-components.d.ts +10 -0
- package/package.json +1 -1
- package/src/preact/lineageFilter/__mockData__/aggregated.json +14510 -0
- package/src/preact/lineageFilter/fetchLineageAutocompleteList.spec.ts +14 -0
- package/src/preact/lineageFilter/fetchLineageAutocompleteList.ts +9 -0
- package/src/preact/lineageFilter/lineage-filter.stories.tsx +56 -0
- package/src/preact/lineageFilter/lineage-filter.tsx +100 -0
- package/src/preact/numberSequencesOverTime/__mockData__/twoVariantsEG.json +0 -8
- package/src/preact/textInput/text-input.tsx +1 -5
- package/src/web-components/input/gs-lineage-filter.stories.ts +137 -0
- package/src/web-components/input/gs-lineage-filter.tsx +79 -0
- package/src/web-components/visualization/gs-number-sequences-over-time.stories.ts +1 -0
package/custom-elements.json
CHANGED
|
@@ -479,6 +479,186 @@
|
|
|
479
479
|
}
|
|
480
480
|
]
|
|
481
481
|
},
|
|
482
|
+
{
|
|
483
|
+
"kind": "javascript-module",
|
|
484
|
+
"path": "src/web-components/input/gs-lineage-filter.stories.ts",
|
|
485
|
+
"declarations": [
|
|
486
|
+
{
|
|
487
|
+
"kind": "variable",
|
|
488
|
+
"name": "meta",
|
|
489
|
+
"type": {
|
|
490
|
+
"text": "Meta<Required<LineageFilterProps>>"
|
|
491
|
+
},
|
|
492
|
+
"default": "{ title: 'Input/Lineage filter', component: 'gs-lineage-filter', parameters: withComponentDocs({ actions: { handles: ['gs-lineage-filter-changed'], }, fetchMock: { mocks: [ { matcher: { name: 'pangoLineage', url: AGGREGATED_ENDPOINT, body: { fields: ['pangoLineage'], }, }, response: { status: 200, body: aggregatedData, }, }, ], }, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), decorators: [withActions], tags: ['autodocs'], }"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"kind": "variable",
|
|
496
|
+
"name": "Default",
|
|
497
|
+
"type": {
|
|
498
|
+
"text": "StoryObj<Required<LineageFilterProps>>"
|
|
499
|
+
},
|
|
500
|
+
"default": "{ render: (args) => { return html` <gs-app lapis=\"${LAPIS_URL}\"> <div class=\"max-w-screen-lg\"> <gs-lineage-filter .lapisField=${args.lapisField} .placeholderText=${args.placeholderText} .initialValue=${args.initialValue} .width=${args.width} ></gs-lineage-filter> </div> </gs-app>`; }, args: { lapisField: 'pangoLineage', placeholderText: 'Enter lineage', initialValue: 'B.1.1.7', width: '100%', }, }"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"kind": "variable",
|
|
504
|
+
"name": "FiresEvent",
|
|
505
|
+
"type": {
|
|
506
|
+
"text": "StoryObj<Required<LineageFilterProps>>"
|
|
507
|
+
},
|
|
508
|
+
"default": "{ ...Default, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-lineage-filter'); const inputField = () => canvas.getByPlaceholderText('Enter lineage'); const listenerMock = fn(); await step('Setup event listener mock', async () => { canvasElement.addEventListener('gs-lineage-filter-changed', listenerMock); }); await step('wait until data is loaded', async () => { await waitFor(() => { return expect(inputField()).toBeEnabled(); }); }); await step('Enters an invalid lineage value', async () => { await userEvent.type(inputField(), 'notInList'); await expect(listenerMock).not.toHaveBeenCalled(); }); await step('Empty input', async () => { await userEvent.type(inputField(), '{backspace>9/}'); await expect(listenerMock.mock.calls.at(-1)[0].detail).toStrictEqual({ pangoLineage: undefined, }); }); await step('Enter a valid lineage value', async () => { await userEvent.type(inputField(), 'B.1.1.7'); await expect(listenerMock).toHaveBeenCalledWith( expect.objectContaining({ detail: { pangoLineage: 'B.1.1.7', }, }), ); }); await step('Enter a valid lineage value', async () => { await userEvent.type(inputField(), '{backspace>9/}'); await userEvent.type(inputField(), 'B.1.1.7*'); await expect(listenerMock).toHaveBeenCalledWith( expect.objectContaining({ detail: { pangoLineage: 'B.1.1.7*', }, }), ); }); }, args: { ...Default.args, initialValue: '', }, }"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
"exports": [
|
|
512
|
+
{
|
|
513
|
+
"kind": "js",
|
|
514
|
+
"name": "default",
|
|
515
|
+
"declaration": {
|
|
516
|
+
"name": "meta",
|
|
517
|
+
"module": "src/web-components/input/gs-lineage-filter.stories.ts"
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"kind": "js",
|
|
522
|
+
"name": "Default",
|
|
523
|
+
"declaration": {
|
|
524
|
+
"name": "Default",
|
|
525
|
+
"module": "src/web-components/input/gs-lineage-filter.stories.ts"
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"kind": "js",
|
|
530
|
+
"name": "FiresEvent",
|
|
531
|
+
"declaration": {
|
|
532
|
+
"name": "FiresEvent",
|
|
533
|
+
"module": "src/web-components/input/gs-lineage-filter.stories.ts"
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
]
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"kind": "javascript-module",
|
|
540
|
+
"path": "src/web-components/input/gs-lineage-filter.tsx",
|
|
541
|
+
"declarations": [
|
|
542
|
+
{
|
|
543
|
+
"kind": "class",
|
|
544
|
+
"description": "\n## Context\n\nThis component provides a text input field to filter by lineages.\nCurrently, it is designed to work well with Pango Lineages,\nbut it may also be used for other lineage types, if suitable.\n\nIt fetches all available values of the `lapisField` from the LAPIS instance\nand provides an autocomplete list with the available values of the lineage and sublineage queries\n(a `*` appended to the lineage value).",
|
|
545
|
+
"name": "LineageFilterComponent",
|
|
546
|
+
"members": [
|
|
547
|
+
{
|
|
548
|
+
"kind": "field",
|
|
549
|
+
"name": "initialValue",
|
|
550
|
+
"type": {
|
|
551
|
+
"text": "string"
|
|
552
|
+
},
|
|
553
|
+
"default": "''",
|
|
554
|
+
"description": "The initial value to use for this lineage filter.",
|
|
555
|
+
"attribute": "initialValue"
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"kind": "field",
|
|
559
|
+
"name": "lapisField",
|
|
560
|
+
"type": {
|
|
561
|
+
"text": "string"
|
|
562
|
+
},
|
|
563
|
+
"default": "''",
|
|
564
|
+
"description": "Required.\n\nThe LAPIS field name to use for this lineage filter.\nThe field must exist on this LAPIS instance.",
|
|
565
|
+
"attribute": "lapisField"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"kind": "field",
|
|
569
|
+
"name": "placeholderText",
|
|
570
|
+
"type": {
|
|
571
|
+
"text": "string"
|
|
572
|
+
},
|
|
573
|
+
"default": "''",
|
|
574
|
+
"description": "The placeholder text to display in the input field.",
|
|
575
|
+
"attribute": "placeholderText"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"kind": "field",
|
|
579
|
+
"name": "width",
|
|
580
|
+
"type": {
|
|
581
|
+
"text": "string"
|
|
582
|
+
},
|
|
583
|
+
"default": "'100%'",
|
|
584
|
+
"description": "The width of the component.\n\nVisit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.",
|
|
585
|
+
"attribute": "width"
|
|
586
|
+
}
|
|
587
|
+
],
|
|
588
|
+
"events": [
|
|
589
|
+
{
|
|
590
|
+
"type": {
|
|
591
|
+
"text": "CustomEvent<Record<string, string>>"
|
|
592
|
+
},
|
|
593
|
+
"description": "Fired when the input field is changed. The `details` of this event contain an object with the `lapisField` as key and the input value as value. Example: ``` { \"pangoLineage\": \"B.1.1.7\" } ```",
|
|
594
|
+
"name": "gs-lineage-filter-changed"
|
|
595
|
+
}
|
|
596
|
+
],
|
|
597
|
+
"attributes": [
|
|
598
|
+
{
|
|
599
|
+
"name": "initialValue",
|
|
600
|
+
"type": {
|
|
601
|
+
"text": "string"
|
|
602
|
+
},
|
|
603
|
+
"default": "''",
|
|
604
|
+
"description": "The initial value to use for this lineage filter.",
|
|
605
|
+
"fieldName": "initialValue"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"name": "lapisField",
|
|
609
|
+
"type": {
|
|
610
|
+
"text": "string"
|
|
611
|
+
},
|
|
612
|
+
"default": "''",
|
|
613
|
+
"description": "Required.\n\nThe LAPIS field name to use for this lineage filter.\nThe field must exist on this LAPIS instance.",
|
|
614
|
+
"fieldName": "lapisField"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"name": "placeholderText",
|
|
618
|
+
"type": {
|
|
619
|
+
"text": "string"
|
|
620
|
+
},
|
|
621
|
+
"default": "''",
|
|
622
|
+
"description": "The placeholder text to display in the input field.",
|
|
623
|
+
"fieldName": "placeholderText"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"name": "width",
|
|
627
|
+
"type": {
|
|
628
|
+
"text": "string"
|
|
629
|
+
},
|
|
630
|
+
"default": "'100%'",
|
|
631
|
+
"description": "The width of the component.\n\nVisit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.",
|
|
632
|
+
"fieldName": "width"
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
"superclass": {
|
|
636
|
+
"name": "PreactLitAdapter",
|
|
637
|
+
"module": "/src/web-components/PreactLitAdapter"
|
|
638
|
+
},
|
|
639
|
+
"tagName": "gs-lineage-filter",
|
|
640
|
+
"customElement": true
|
|
641
|
+
}
|
|
642
|
+
],
|
|
643
|
+
"exports": [
|
|
644
|
+
{
|
|
645
|
+
"kind": "js",
|
|
646
|
+
"name": "LineageFilterComponent",
|
|
647
|
+
"declaration": {
|
|
648
|
+
"name": "LineageFilterComponent",
|
|
649
|
+
"module": "src/web-components/input/gs-lineage-filter.tsx"
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"kind": "custom-element-definition",
|
|
654
|
+
"name": "gs-lineage-filter",
|
|
655
|
+
"declaration": {
|
|
656
|
+
"name": "LineageFilterComponent",
|
|
657
|
+
"module": "src/web-components/input/gs-lineage-filter.tsx"
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
]
|
|
661
|
+
},
|
|
482
662
|
{
|
|
483
663
|
"kind": "javascript-module",
|
|
484
664
|
"path": "src/web-components/input/gs-location-filter.stories.ts",
|
|
@@ -1856,7 +2036,7 @@
|
|
|
1856
2036
|
"type": {
|
|
1857
2037
|
"text": "StoryObj<NumberSequencesOverTimeProps>"
|
|
1858
2038
|
},
|
|
1859
|
-
"default": "{ ...Template, args: { ...Template.args, lapisFilter: [ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2022-10-01' }, }, { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } }, ], }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'aggregatedEG', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'EG*', fields: ['date'], }, }, response: { status: 200, body: twoVariantsEG, }, }, { matcher: { name: 'aggregatedJN.1', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: twoVariantsJN1, }, }, ], }, }, }"
|
|
2039
|
+
"default": "{ ...Template, args: { ...Template.args, lapisFilter: [ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2022-10-01' }, }, { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } }, ], }, parameters: { fetchMock: { mocks: [ { matcher: { name: 'aggregatedEG', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2022-10-01', fields: ['date'], }, }, response: { status: 200, body: twoVariantsEG, }, }, { matcher: { name: 'aggregatedJN.1', url: AGGREGATED_ENDPOINT, body: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01', fields: ['date'], }, }, response: { status: 200, body: twoVariantsJN1, }, }, ], }, }, }"
|
|
1860
2040
|
},
|
|
1861
2041
|
{
|
|
1862
2042
|
"kind": "variable",
|
|
@@ -8318,11 +8318,7 @@ const TextInput = ({ width, ...innerProps }) => {
|
|
|
8318
8318
|
const size2 = { width, height: "3rem" };
|
|
8319
8319
|
return /* @__PURE__ */ u$1(ErrorBoundary, { size: size2, children: /* @__PURE__ */ u$1(ResizeContainer, { size: size2, children: /* @__PURE__ */ u$1(TextInputInner, { ...innerProps }) }) });
|
|
8320
8320
|
};
|
|
8321
|
-
const TextInputInner = ({
|
|
8322
|
-
lapisField,
|
|
8323
|
-
placeholderText,
|
|
8324
|
-
initialValue
|
|
8325
|
-
}) => {
|
|
8321
|
+
const TextInputInner = ({ lapisField, placeholderText, initialValue }) => {
|
|
8326
8322
|
const lapis = x(LapisUrlContext);
|
|
8327
8323
|
const inputRef = A(null);
|
|
8328
8324
|
const { data, error, isLoading } = useQuery(() => fetchAutocompleteList(lapis, lapisField), [lapisField, lapis]);
|