@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.
- package/custom-elements.json +160 -10
- package/dist/{LineageFilterChangedEvent-ixHQkq8y.js → LineageFilterChangedEvent-b0iuroUL.js} +15 -5
- package/dist/LineageFilterChangedEvent-b0iuroUL.js.map +1 -0
- package/dist/assets/mutationOverTimeWorker-ChQTFL68.js.map +1 -1
- package/dist/components.d.ts +61 -15
- package/dist/components.js +9083 -8727
- package/dist/components.js.map +1 -1
- package/dist/util.d.ts +41 -15
- package/dist/util.js +2 -1
- package/package.json +1 -1
- package/src/componentsEntrypoint.ts +3 -1
- package/src/preact/components/downshift-combobox.tsx +31 -16
- package/src/preact/components/error-display.stories.tsx +2 -1
- package/src/preact/components/error-display.tsx +2 -3
- package/src/preact/components/resize-container.tsx +7 -10
- package/src/preact/components/tooltip.tsx +7 -4
- package/src/preact/dateRangeFilter/date-range-filter.stories.tsx +5 -4
- package/src/preact/dateRangeFilter/date-range-filter.tsx +2 -1
- package/src/preact/dateRangeFilter/dateRangeOption.ts +2 -1
- package/src/preact/genomeViewer/CDSPlot.tsx +219 -0
- package/src/preact/genomeViewer/genome-data-viewer.stories.tsx +113 -0
- package/src/preact/genomeViewer/genome-data-viewer.tsx +69 -0
- package/src/preact/genomeViewer/loadGff3.spec.ts +61 -0
- package/src/preact/genomeViewer/loadGff3.ts +174 -0
- package/src/preact/lineageFilter/LineageFilterChangedEvent.ts +3 -1
- package/src/preact/lineageFilter/lineage-filter.stories.tsx +3 -2
- package/src/preact/lineageFilter/lineage-filter.tsx +4 -4
- package/src/preact/locationFilter/LocationChangedEvent.ts +2 -1
- package/src/preact/locationFilter/location-filter.stories.tsx +3 -2
- package/src/preact/locationFilter/location-filter.tsx +5 -7
- package/src/preact/mutationFilter/mutation-filter.stories.tsx +3 -2
- package/src/preact/mutationFilter/mutation-filter.tsx +2 -1
- package/src/preact/shared/charts/colors.ts +1 -1
- package/src/preact/textFilter/TextFilterChangedEvent.ts +3 -1
- package/src/preact/textFilter/text-filter.stories.tsx +71 -10
- package/src/preact/textFilter/text-filter.tsx +5 -7
- package/src/utilEntrypoint.ts +2 -0
- package/src/utils/gsEventNames.ts +9 -0
- package/src/web-components/input/gs-date-range-filter.stories.ts +4 -3
- package/src/web-components/input/gs-date-range-filter.tsx +3 -2
- package/src/web-components/input/gs-lineage-filter.stories.ts +3 -2
- package/src/web-components/input/gs-lineage-filter.tsx +2 -1
- package/src/web-components/input/gs-location-filter.stories.ts +3 -2
- package/src/web-components/input/gs-location-filter.tsx +2 -1
- package/src/web-components/input/gs-mutation-filter.stories.ts +3 -2
- package/src/web-components/input/gs-mutation-filter.tsx +2 -1
- package/src/web-components/input/gs-text-filter.stories.ts +6 -12
- package/src/web-components/input/gs-text-filter.tsx +2 -1
- package/src/web-components/visualization/gs-genome-data-viewer.spec-d.ts +18 -0
- package/src/web-components/visualization/gs-genome-data-viewer.stories.ts +108 -0
- package/src/web-components/visualization/gs-genome-data-viewer.tsx +59 -0
- package/src/web-components/visualization/index.ts +1 -0
- package/standalone-bundle/assets/mutationOverTimeWorker-jChgWnwp.js.map +1 -1
- package/standalone-bundle/dashboard-components.js +32674 -32374
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/dist/LineageFilterChangedEvent-ixHQkq8y.js.map +0 -1
package/dist/util.d.ts
CHANGED
|
@@ -149,6 +149,16 @@ declare const dateRangeValueSchema: default_2.ZodNullable<default_2.ZodUnion<[de
|
|
|
149
149
|
dateTo?: string | undefined;
|
|
150
150
|
}>]>>;
|
|
151
151
|
|
|
152
|
+
export declare const gsEventNames: {
|
|
153
|
+
readonly error: "gs-error";
|
|
154
|
+
readonly dateRangeFilterChanged: "gs-date-range-filter-changed";
|
|
155
|
+
readonly dateRangeOptionChanged: "gs-date-range-option-changed";
|
|
156
|
+
readonly mutationFilterChanged: "gs-mutation-filter-changed";
|
|
157
|
+
readonly lineageFilterChanged: "gs-lineage-filter-changed";
|
|
158
|
+
readonly locationChanged: "gs-location-changed";
|
|
159
|
+
readonly textFilterChanged: "gs-text-filter-changed";
|
|
160
|
+
};
|
|
161
|
+
|
|
152
162
|
export declare type LapisFilter = default_2.infer<typeof lapisFilterSchema>;
|
|
153
163
|
|
|
154
164
|
declare const lapisFilterSchema: default_2.ZodIntersection<default_2.ZodRecord<default_2.ZodString, default_2.ZodUnion<[default_2.ZodString, default_2.ZodArray<default_2.ZodString, "many">, default_2.ZodNumber, default_2.ZodNull, default_2.ZodBoolean, default_2.ZodUndefined]>>, default_2.ZodObject<{
|
|
@@ -879,7 +889,7 @@ export { }
|
|
|
879
889
|
|
|
880
890
|
declare global {
|
|
881
891
|
interface HTMLElementEventMap {
|
|
882
|
-
|
|
892
|
+
[gsEventNames.error]: ErrorEvent;
|
|
883
893
|
}
|
|
884
894
|
}
|
|
885
895
|
|
|
@@ -902,7 +912,7 @@ declare global {
|
|
|
902
912
|
|
|
903
913
|
declare global {
|
|
904
914
|
interface HTMLElementTagNameMap {
|
|
905
|
-
'gs-
|
|
915
|
+
'gs-genome-data-viewer': GenomeDataViewerComponent;
|
|
906
916
|
}
|
|
907
917
|
}
|
|
908
918
|
|
|
@@ -910,7 +920,7 @@ declare global {
|
|
|
910
920
|
declare global {
|
|
911
921
|
namespace JSX {
|
|
912
922
|
interface IntrinsicElements {
|
|
913
|
-
'gs-
|
|
923
|
+
'gs-genome-data-viewer': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
914
924
|
}
|
|
915
925
|
}
|
|
916
926
|
}
|
|
@@ -950,7 +960,7 @@ declare global {
|
|
|
950
960
|
|
|
951
961
|
declare global {
|
|
952
962
|
interface HTMLElementTagNameMap {
|
|
953
|
-
'gs-
|
|
963
|
+
'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
|
|
954
964
|
}
|
|
955
965
|
}
|
|
956
966
|
|
|
@@ -958,7 +968,7 @@ declare global {
|
|
|
958
968
|
declare global {
|
|
959
969
|
namespace JSX {
|
|
960
970
|
interface IntrinsicElements {
|
|
961
|
-
'gs-
|
|
971
|
+
'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
962
972
|
}
|
|
963
973
|
}
|
|
964
974
|
}
|
|
@@ -966,7 +976,7 @@ declare global {
|
|
|
966
976
|
|
|
967
977
|
declare global {
|
|
968
978
|
interface HTMLElementTagNameMap {
|
|
969
|
-
'gs-
|
|
979
|
+
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
970
980
|
}
|
|
971
981
|
}
|
|
972
982
|
|
|
@@ -974,7 +984,7 @@ declare global {
|
|
|
974
984
|
declare global {
|
|
975
985
|
namespace JSX {
|
|
976
986
|
interface IntrinsicElements {
|
|
977
|
-
'gs-
|
|
987
|
+
'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
978
988
|
}
|
|
979
989
|
}
|
|
980
990
|
}
|
|
@@ -996,6 +1006,22 @@ declare global {
|
|
|
996
1006
|
}
|
|
997
1007
|
|
|
998
1008
|
|
|
1009
|
+
declare global {
|
|
1010
|
+
interface HTMLElementTagNameMap {
|
|
1011
|
+
'gs-aggregate': AggregateComponent;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
declare global {
|
|
1017
|
+
namespace JSX {
|
|
1018
|
+
interface IntrinsicElements {
|
|
1019
|
+
'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
|
|
999
1025
|
declare global {
|
|
1000
1026
|
interface HTMLElementTagNameMap {
|
|
1001
1027
|
'gs-mutations-over-time': MutationsOverTimeComponent;
|
|
@@ -1014,7 +1040,7 @@ declare global {
|
|
|
1014
1040
|
|
|
1015
1041
|
declare global {
|
|
1016
1042
|
interface HTMLElementTagNameMap {
|
|
1017
|
-
'gs-
|
|
1043
|
+
'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
|
|
1018
1044
|
}
|
|
1019
1045
|
}
|
|
1020
1046
|
|
|
@@ -1022,7 +1048,7 @@ declare global {
|
|
|
1022
1048
|
declare global {
|
|
1023
1049
|
namespace JSX {
|
|
1024
1050
|
interface IntrinsicElements {
|
|
1025
|
-
'gs-
|
|
1051
|
+
'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1026
1052
|
}
|
|
1027
1053
|
}
|
|
1028
1054
|
}
|
|
@@ -1065,8 +1091,8 @@ declare global {
|
|
|
1065
1091
|
'gs-date-range-filter': DateRangeFilterComponent;
|
|
1066
1092
|
}
|
|
1067
1093
|
interface HTMLElementEventMap {
|
|
1068
|
-
|
|
1069
|
-
|
|
1094
|
+
[gsEventNames.dateRangeFilterChanged]: CustomEvent<Record<string, string>>;
|
|
1095
|
+
[gsEventNames.dateRangeOptionChanged]: DateRangeOptionChangedEvent;
|
|
1070
1096
|
}
|
|
1071
1097
|
}
|
|
1072
1098
|
|
|
@@ -1085,7 +1111,7 @@ declare global {
|
|
|
1085
1111
|
'gs-location-filter': LocationFilterComponent;
|
|
1086
1112
|
}
|
|
1087
1113
|
interface HTMLElementEventMap {
|
|
1088
|
-
|
|
1114
|
+
[gsEventNames.locationChanged]: LocationChangedEvent;
|
|
1089
1115
|
}
|
|
1090
1116
|
}
|
|
1091
1117
|
|
|
@@ -1104,7 +1130,7 @@ declare global {
|
|
|
1104
1130
|
'gs-text-filter': TextFilterComponent;
|
|
1105
1131
|
}
|
|
1106
1132
|
interface HTMLElementEventMap {
|
|
1107
|
-
|
|
1133
|
+
[gsEventNames.textFilterChanged]: TextFilterChangedEvent;
|
|
1108
1134
|
}
|
|
1109
1135
|
}
|
|
1110
1136
|
|
|
@@ -1123,7 +1149,7 @@ declare global {
|
|
|
1123
1149
|
'gs-mutation-filter': MutationFilterComponent;
|
|
1124
1150
|
}
|
|
1125
1151
|
interface HTMLElementEventMap {
|
|
1126
|
-
|
|
1152
|
+
[gsEventNames.mutationFilterChanged]: CustomEvent<MutationsFilter>;
|
|
1127
1153
|
}
|
|
1128
1154
|
}
|
|
1129
1155
|
|
|
@@ -1142,7 +1168,7 @@ declare global {
|
|
|
1142
1168
|
'gs-lineage-filter': LineageFilterComponent;
|
|
1143
1169
|
}
|
|
1144
1170
|
interface HTMLElementEventMap {
|
|
1145
|
-
|
|
1171
|
+
[gsEventNames.lineageFilterChanged]: LineageFilterChangedEvent;
|
|
1146
1172
|
}
|
|
1147
1173
|
}
|
|
1148
1174
|
|
package/dist/util.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { D, a, L, T, d, v } from "./LineageFilterChangedEvent-
|
|
1
|
+
import { D, a, L, T, d, g, v } from "./LineageFilterChangedEvent-b0iuroUL.js";
|
|
2
2
|
export {
|
|
3
3
|
D as DateRangeOptionChangedEvent,
|
|
4
4
|
a as LineageFilterChangedEvent,
|
|
5
5
|
L as LocationChangedEvent,
|
|
6
6
|
T as TextFilterChangedEvent,
|
|
7
7
|
d as dateRangeOptionPresets,
|
|
8
|
+
g as gsEventNames,
|
|
8
9
|
v as views
|
|
9
10
|
};
|
|
10
11
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type gsEventNames } from './utils/gsEventNames';
|
|
2
|
+
|
|
1
3
|
export * from './web-components';
|
|
2
4
|
|
|
3
5
|
export { type ErrorEvent, UserFacingError } from './preact/components/error-display';
|
|
4
6
|
|
|
5
7
|
declare global {
|
|
6
8
|
interface HTMLElementEventMap {
|
|
7
|
-
|
|
9
|
+
[gsEventNames.error]: ErrorEvent;
|
|
8
10
|
}
|
|
9
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCombobox } from 'downshift/preact';
|
|
2
2
|
import { type ComponentChild } from 'preact';
|
|
3
|
-
import { useMemo, useRef, useState } from 'preact/hooks';
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
|
4
4
|
|
|
5
5
|
import { DeleteIcon } from '../shared/icons/DeleteIcon';
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ export function DownshiftCombobox<Item>({
|
|
|
15
15
|
inputClassName = '',
|
|
16
16
|
}: {
|
|
17
17
|
allItems: Item[];
|
|
18
|
-
value
|
|
18
|
+
value: Item | null;
|
|
19
19
|
filterItemsByInputValue: (item: Item, value: string) => boolean;
|
|
20
20
|
createEvent: (item: Item | null) => CustomEvent;
|
|
21
21
|
itemToString: (item: Item | undefined | null) => string;
|
|
@@ -23,12 +23,25 @@ export function DownshiftCombobox<Item>({
|
|
|
23
23
|
formatItemInList: (item: Item) => ComponentChild;
|
|
24
24
|
inputClassName?: string;
|
|
25
25
|
}) {
|
|
26
|
-
const [
|
|
26
|
+
const [selectedItem, setSelectedItem] = useState<Item | null>(() => value);
|
|
27
|
+
const [itemsFilter, setItemsFilter] = useState(() => itemToString(selectedItem));
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setSelectedItem(value);
|
|
31
|
+
setItemsFilter(itemToString(value));
|
|
32
|
+
}, [itemToString, value]);
|
|
33
|
+
|
|
27
34
|
const items = useMemo(
|
|
28
35
|
() => allItems.filter((item) => filterItemsByInputValue(item, itemsFilter)),
|
|
29
36
|
[allItems, filterItemsByInputValue, itemsFilter],
|
|
30
37
|
);
|
|
31
38
|
const divRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
const [inputIsInvalid, setInputIsInvalid] = useState(false);
|
|
40
|
+
|
|
41
|
+
const selectItem = (item: Item | null) => {
|
|
42
|
+
setSelectedItem(item);
|
|
43
|
+
divRef.current?.dispatchEvent(createEvent(item));
|
|
44
|
+
};
|
|
32
45
|
|
|
33
46
|
const shadowRoot = divRef.current?.shadowRoot ?? undefined;
|
|
34
47
|
|
|
@@ -49,39 +62,41 @@ export function DownshiftCombobox<Item>({
|
|
|
49
62
|
getInputProps,
|
|
50
63
|
highlightedIndex,
|
|
51
64
|
getItemProps,
|
|
52
|
-
selectedItem,
|
|
53
65
|
inputValue,
|
|
54
|
-
selectItem,
|
|
55
|
-
setInputValue,
|
|
56
66
|
closeMenu,
|
|
57
67
|
} = useCombobox({
|
|
58
68
|
onInputValueChange({ inputValue }) {
|
|
59
|
-
|
|
69
|
+
setInputIsInvalid(false);
|
|
70
|
+
setItemsFilter(inputValue.trim());
|
|
60
71
|
},
|
|
61
72
|
onSelectedItemChange({ selectedItem }) {
|
|
62
|
-
|
|
63
|
-
divRef.current?.dispatchEvent(createEvent(selectedItem));
|
|
64
|
-
}
|
|
73
|
+
selectItem(selectedItem);
|
|
65
74
|
},
|
|
66
75
|
items,
|
|
67
76
|
itemToString(item) {
|
|
68
77
|
return itemToString(item);
|
|
69
78
|
},
|
|
70
|
-
selectedItem
|
|
79
|
+
selectedItem,
|
|
71
80
|
environment,
|
|
72
81
|
});
|
|
73
82
|
|
|
74
83
|
const onInputBlur = () => {
|
|
75
84
|
if (inputValue === '') {
|
|
76
|
-
divRef.current?.dispatchEvent(createEvent(null));
|
|
77
85
|
selectItem(null);
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const trimmedInput = inputValue.trim();
|
|
90
|
+
const matchingItem = items.find((item) => itemToString(item) === trimmedInput);
|
|
91
|
+
if (matchingItem !== undefined) {
|
|
92
|
+
selectItem(matchingItem);
|
|
93
|
+
return;
|
|
80
94
|
}
|
|
95
|
+
|
|
96
|
+
setInputIsInvalid(true);
|
|
81
97
|
};
|
|
82
98
|
|
|
83
99
|
const clearInput = () => {
|
|
84
|
-
divRef.current?.dispatchEvent(createEvent(null));
|
|
85
100
|
selectItem(null);
|
|
86
101
|
};
|
|
87
102
|
|
|
@@ -91,7 +106,7 @@ export function DownshiftCombobox<Item>({
|
|
|
91
106
|
<div ref={divRef} className={'relative w-full'}>
|
|
92
107
|
<div className='w-full flex flex-col gap-1'>
|
|
93
108
|
<div
|
|
94
|
-
className={`flex gap-0.5 input min-w-32 w-full ${inputClassName}`}
|
|
109
|
+
className={`flex gap-0.5 input min-w-32 w-full ${inputClassName} ${inputIsInvalid ? 'input-error' : ''}`}
|
|
95
110
|
onBlur={(event) => {
|
|
96
111
|
if (event.relatedTarget != buttonRef.current) {
|
|
97
112
|
closeMenu();
|
|
@@ -3,6 +3,7 @@ import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
|
|
3
3
|
|
|
4
4
|
import { ErrorDisplay, UserFacingError } from './error-display';
|
|
5
5
|
import { ResizeContainer } from './resize-container';
|
|
6
|
+
import { gsEventNames } from '../../utils/gsEventNames';
|
|
6
7
|
|
|
7
8
|
const meta: Meta = {
|
|
8
9
|
title: 'Component/Error',
|
|
@@ -58,7 +59,7 @@ export const FiresEvent: StoryObj = {
|
|
|
58
59
|
|
|
59
60
|
play: async ({ canvasElement }) => {
|
|
60
61
|
const listenerMock = fn();
|
|
61
|
-
canvasElement.addEventListener(
|
|
62
|
+
canvasElement.addEventListener(gsEventNames.error, listenerMock);
|
|
62
63
|
|
|
63
64
|
await waitFor(async () => {
|
|
64
65
|
await expect(listenerMock.mock.calls.at(-1)![0].error.name).toStrictEqual('UserFacingError');
|
|
@@ -5,12 +5,11 @@ import { type ZodError } from 'zod';
|
|
|
5
5
|
import { InfoHeadline1, InfoParagraph } from './info';
|
|
6
6
|
import { Modal } from './modal';
|
|
7
7
|
import { LapisError, UnknownLapisError } from '../../lapisApi/lapisApi';
|
|
8
|
-
|
|
9
|
-
export const GS_ERROR_EVENT_TYPE = 'gs-error';
|
|
8
|
+
import { gsEventNames } from '../../utils/gsEventNames';
|
|
10
9
|
|
|
11
10
|
export class ErrorEvent extends Event {
|
|
12
11
|
constructor(public readonly error: Error) {
|
|
13
|
-
super(
|
|
12
|
+
super(gsEventNames.error, {
|
|
14
13
|
bubbles: true,
|
|
15
14
|
composed: true,
|
|
16
15
|
});
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentChildren } from 'preact';
|
|
2
|
+
import { forwardRef } from 'preact/compat';
|
|
2
3
|
|
|
3
4
|
export type Size = {
|
|
4
5
|
width: string;
|
|
5
6
|
height?: string;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
-
size
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ResizeContainer: FunctionComponent<ResizeContainerProps> = ({ children, size }) => {
|
|
13
|
-
return (
|
|
14
|
-
<div style={size} className='bg-white'>
|
|
9
|
+
export const ResizeContainer = forwardRef<HTMLDivElement, { size: Size; children: ComponentChildren }>(
|
|
10
|
+
({ size, children }, ref) => (
|
|
11
|
+
<div ref={ref} style={{ width: size.width, height: size.height, position: 'relative' }}>
|
|
15
12
|
{children}
|
|
16
13
|
</div>
|
|
17
|
-
)
|
|
18
|
-
|
|
14
|
+
),
|
|
15
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FunctionComponent } from 'preact';
|
|
2
|
+
import { type CSSProperties } from 'preact/compat';
|
|
2
3
|
import { type JSXInternal } from 'preact/src/jsx';
|
|
3
4
|
|
|
4
5
|
export type TooltipPosition =
|
|
@@ -14,6 +15,7 @@ export type TooltipPosition =
|
|
|
14
15
|
export type TooltipProps = {
|
|
15
16
|
content: string | JSXInternal.Element;
|
|
16
17
|
position?: TooltipPosition;
|
|
18
|
+
tooltipStyle?: CSSProperties;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
function getPositionCss(position?: TooltipPosition) {
|
|
@@ -39,12 +41,13 @@ function getPositionCss(position?: TooltipPosition) {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
const Tooltip: FunctionComponent<TooltipProps> = ({ children, content, position = 'bottom' }) => {
|
|
44
|
+
const Tooltip: FunctionComponent<TooltipProps> = ({ children, content, position = 'bottom', tooltipStyle }) => {
|
|
43
45
|
return (
|
|
44
|
-
<div className=
|
|
45
|
-
<div
|
|
46
|
+
<div className={`relative group`}>
|
|
47
|
+
<div>{children}</div>
|
|
46
48
|
<div
|
|
47
|
-
className={`absolute z-10 w-max bg-white p-4 border border-gray-200 rounded-md invisible
|
|
49
|
+
className={`absolute z-10 w-max bg-white p-4 border border-gray-200 rounded-md invisible group-hover:visible ${getPositionCss(position)}`}
|
|
50
|
+
style={{ ...tooltipStyle }}
|
|
48
51
|
>
|
|
49
52
|
{content}
|
|
50
53
|
</div>
|
|
@@ -7,6 +7,7 @@ import { useEffect, useRef, useState } from 'preact/hooks';
|
|
|
7
7
|
import { DateRangeFilter, type DateRangeFilterProps } from './date-range-filter';
|
|
8
8
|
import { previewHandles } from '../../../.storybook/preview';
|
|
9
9
|
import { LAPIS_URL } from '../../constants';
|
|
10
|
+
import { gsEventNames } from '../../utils/gsEventNames';
|
|
10
11
|
import { LapisUrlContextProvider } from '../LapisUrlContext';
|
|
11
12
|
import { dateRangeOptionPresets, type DateRangeValue } from './dateRangeOption';
|
|
12
13
|
import { expectInvalidAttributesErrorMessage } from '../shared/stories/expectErrorMessage';
|
|
@@ -27,7 +28,7 @@ const meta: Meta<DateRangeFilterProps> = {
|
|
|
27
28
|
component: DateRangeFilter,
|
|
28
29
|
parameters: {
|
|
29
30
|
actions: {
|
|
30
|
-
handles: [
|
|
31
|
+
handles: [gsEventNames.dateRangeFilterChanged, gsEventNames.dateRangeOptionChanged, ...previewHandles],
|
|
31
32
|
},
|
|
32
33
|
fetchMock: {},
|
|
33
34
|
},
|
|
@@ -198,7 +199,7 @@ export const ChangingTheValueProgrammatically: StoryObj<DateRangeFilterProps> =
|
|
|
198
199
|
const ref = useRef<HTMLDivElement>(null);
|
|
199
200
|
|
|
200
201
|
useEffect(() => {
|
|
201
|
-
ref.current?.addEventListener(
|
|
202
|
+
ref.current?.addEventListener(gsEventNames.dateRangeOptionChanged, (event) => {
|
|
202
203
|
setValue(event.detail);
|
|
203
204
|
});
|
|
204
205
|
}, []);
|
|
@@ -333,8 +334,8 @@ async function prepare(canvasElement: HTMLElement, step: StepFunction<PreactRend
|
|
|
333
334
|
const filterChangedListenerMock = fn();
|
|
334
335
|
const optionChangedListenerMock = fn();
|
|
335
336
|
await step('Setup event listener mock', () => {
|
|
336
|
-
canvasElement.addEventListener(
|
|
337
|
-
canvasElement.addEventListener(
|
|
337
|
+
canvasElement.addEventListener(gsEventNames.dateRangeFilterChanged, filterChangedListenerMock);
|
|
338
|
+
canvasElement.addEventListener(gsEventNames.dateRangeOptionChanged, optionChangedListenerMock);
|
|
338
339
|
});
|
|
339
340
|
|
|
340
341
|
return { canvas, filterChangedListenerMock, optionChangedListenerMock };
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
dateRangeOptionSchema,
|
|
11
11
|
dateRangeValueSchema,
|
|
12
12
|
} from './dateRangeOption';
|
|
13
|
+
import { gsEventNames } from '../../utils/gsEventNames';
|
|
13
14
|
import { ClearableSelect } from '../components/clearable-select';
|
|
14
15
|
import { ErrorBoundary } from '../components/error-boundary';
|
|
15
16
|
|
|
@@ -170,7 +171,7 @@ export const DateRangeFilterInner = ({
|
|
|
170
171
|
};
|
|
171
172
|
|
|
172
173
|
divRef.current?.dispatchEvent(
|
|
173
|
-
new CustomEvent(
|
|
174
|
+
new CustomEvent(gsEventNames.dateRangeFilterChanged, {
|
|
174
175
|
detail,
|
|
175
176
|
bubbles: true,
|
|
176
177
|
composed: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
|
|
3
3
|
import { toYYYYMMDD } from './dateConversion';
|
|
4
|
+
import { gsEventNames } from '../../utils/gsEventNames';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A date range option that can be used in the `gs-date-range-filter` component.
|
|
@@ -36,7 +37,7 @@ export type DateRangeValue = z.infer<typeof dateRangeValueSchema>;
|
|
|
36
37
|
|
|
37
38
|
export class DateRangeOptionChangedEvent extends CustomEvent<DateRangeValue> {
|
|
38
39
|
constructor(detail: DateRangeValue) {
|
|
39
|
-
super(
|
|
40
|
+
super(gsEventNames.dateRangeOptionChanged, {
|
|
40
41
|
detail,
|
|
41
42
|
bubbles: true,
|
|
42
43
|
composed: true,
|