@genspectrum/dashboard-components 0.14.2 → 0.15.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 +81 -49
- package/dist/{LineageFilterChangedEvent-C9dXOxt6.js → LineageFilterChangedEvent-COWV-Y0k.js} +6 -6
- package/dist/LineageFilterChangedEvent-COWV-Y0k.js.map +1 -0
- package/dist/assets/{mutationOverTimeWorker-Dxnxrfe0.js.map → mutationOverTimeWorker-BL50C-yi.js.map} +1 -1
- package/dist/components.d.ts +31 -31
- package/dist/components.js +62 -51
- package/dist/components.js.map +1 -1
- package/dist/util.d.ts +29 -29
- package/dist/util.js +2 -2
- package/package.json +1 -1
- package/src/preact/{dateRangeSelector/date-range-selector.stories.tsx → dateRangeFilter/date-range-filter.stories.tsx} +15 -15
- package/src/preact/{dateRangeSelector/date-range-selector.tsx → dateRangeFilter/date-range-filter.tsx} +9 -9
- package/src/preact/{dateRangeSelector → dateRangeFilter}/dateRangeOption.ts +2 -2
- package/src/preact/{textInput/TextInputChangedEvent.ts → textFilter/TextFilterChangedEvent.ts} +2 -2
- package/src/preact/{textInput/text-input.stories.tsx → textFilter/text-filter.stories.tsx} +10 -10
- package/src/preact/{textInput/text-input.tsx → textFilter/text-filter.tsx} +10 -10
- package/src/utilEntrypoint.ts +2 -2
- package/src/web-components/input/{gs-date-range-selector.stories.ts → gs-date-range-filter.stories.ts} +59 -14
- package/src/web-components/input/{gs-date-range-selector.tsx → gs-date-range-filter.tsx} +28 -13
- package/src/web-components/input/{gs-text-input.stories.ts → gs-text-filter.stories.ts} +15 -15
- package/src/web-components/input/{gs-text-input.tsx → gs-text-filter.tsx} +16 -16
- package/src/web-components/input/index.ts +2 -2
- package/standalone-bundle/assets/{mutationOverTimeWorker-CmSrq4SZ.js.map → mutationOverTimeWorker-CFB5-Mdk.js.map} +1 -1
- package/standalone-bundle/dashboard-components.js +2167 -2161
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/dist/LineageFilterChangedEvent-C9dXOxt6.js.map +0 -1
- /package/src/preact/{dateRangeSelector → dateRangeFilter}/computeInitialValues.spec.ts +0 -0
- /package/src/preact/{dateRangeSelector → dateRangeFilter}/computeInitialValues.ts +0 -0
- /package/src/preact/{dateRangeSelector → dateRangeFilter}/dateConversion.ts +0 -0
- /package/src/preact/{dateRangeSelector → dateRangeFilter}/selectableOptions.ts +0 -0
- /package/src/preact/{textInput → textFilter}/__mockData__/aggregated_hosts.json +0 -0
- /package/src/preact/{textInput → textFilter}/fetchStringAutocompleteList.spec.ts +0 -0
- /package/src/preact/{textInput → textFilter}/fetchStringAutocompleteList.ts +0 -0
package/dist/util.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export declare class DateRangeOptionChangedEvent extends CustomEvent<DateRangeSe
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Presets for the `gs-date-range-
|
|
81
|
+
* Presets for the `gs-date-range-filter` component that can be used as `dateRangeOptions`.
|
|
82
82
|
*/
|
|
83
83
|
export declare const dateRangeOptionPresets: {
|
|
84
84
|
last2Weeks: {
|
|
@@ -111,7 +111,7 @@ export declare const dateRangeOptionPresets: {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* A date range option that can be used in the `gs-date-range-
|
|
114
|
+
* A date range option that can be used in the `gs-date-range-filter` component.
|
|
115
115
|
*/
|
|
116
116
|
declare const dateRangeOptionSchema: default_2.ZodObject<{
|
|
117
117
|
/** The label of the date range option that will be shown to the user */
|
|
@@ -792,7 +792,7 @@ export declare type TemporalGranularity = default_2.infer<typeof temporalGranula
|
|
|
792
792
|
|
|
793
793
|
declare const temporalGranularitySchema: default_2.ZodUnion<[default_2.ZodLiteral<"day">, default_2.ZodLiteral<"week">, default_2.ZodLiteral<"month">, default_2.ZodLiteral<"year">]>;
|
|
794
794
|
|
|
795
|
-
export declare class
|
|
795
|
+
export declare class TextFilterChangedEvent extends CustomEvent<LapisTextFilter> {
|
|
796
796
|
constructor(detail: LapisTextFilter);
|
|
797
797
|
}
|
|
798
798
|
|
|
@@ -848,7 +848,7 @@ declare global {
|
|
|
848
848
|
|
|
849
849
|
declare global {
|
|
850
850
|
interface HTMLElementTagNameMap {
|
|
851
|
-
'gs-mutations-
|
|
851
|
+
'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
|
|
@@ -856,7 +856,7 @@ declare global {
|
|
|
856
856
|
declare global {
|
|
857
857
|
namespace JSX {
|
|
858
858
|
interface IntrinsicElements {
|
|
859
|
-
'gs-mutations-
|
|
859
|
+
'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
}
|
|
@@ -880,7 +880,7 @@ declare global {
|
|
|
880
880
|
|
|
881
881
|
declare global {
|
|
882
882
|
interface HTMLElementTagNameMap {
|
|
883
|
-
'gs-
|
|
883
|
+
'gs-mutations-component': MutationsComponent;
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
|
|
@@ -888,7 +888,7 @@ declare global {
|
|
|
888
888
|
declare global {
|
|
889
889
|
namespace JSX {
|
|
890
890
|
interface IntrinsicElements {
|
|
891
|
-
'gs-
|
|
891
|
+
'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
894
|
}
|
|
@@ -896,7 +896,7 @@ declare global {
|
|
|
896
896
|
|
|
897
897
|
declare global {
|
|
898
898
|
interface HTMLElementTagNameMap {
|
|
899
|
-
'gs-
|
|
899
|
+
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
|
|
@@ -904,7 +904,7 @@ declare global {
|
|
|
904
904
|
declare global {
|
|
905
905
|
namespace JSX {
|
|
906
906
|
interface IntrinsicElements {
|
|
907
|
-
'gs-
|
|
907
|
+
'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
}
|
|
@@ -912,7 +912,7 @@ declare global {
|
|
|
912
912
|
|
|
913
913
|
declare global {
|
|
914
914
|
interface HTMLElementTagNameMap {
|
|
915
|
-
'gs-
|
|
915
|
+
'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
|
|
@@ -920,7 +920,7 @@ declare global {
|
|
|
920
920
|
declare global {
|
|
921
921
|
namespace JSX {
|
|
922
922
|
interface IntrinsicElements {
|
|
923
|
-
'gs-
|
|
923
|
+
'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
}
|
|
@@ -928,7 +928,7 @@ declare global {
|
|
|
928
928
|
|
|
929
929
|
declare global {
|
|
930
930
|
interface HTMLElementTagNameMap {
|
|
931
|
-
'gs-
|
|
931
|
+
'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
|
|
932
932
|
}
|
|
933
933
|
}
|
|
934
934
|
|
|
@@ -936,7 +936,7 @@ declare global {
|
|
|
936
936
|
declare global {
|
|
937
937
|
namespace JSX {
|
|
938
938
|
interface IntrinsicElements {
|
|
939
|
-
'gs-
|
|
939
|
+
'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
942
|
}
|
|
@@ -944,7 +944,7 @@ declare global {
|
|
|
944
944
|
|
|
945
945
|
declare global {
|
|
946
946
|
interface HTMLElementTagNameMap {
|
|
947
|
-
'gs-
|
|
947
|
+
'gs-aggregate': AggregateComponent;
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
|
|
@@ -952,7 +952,7 @@ declare global {
|
|
|
952
952
|
declare global {
|
|
953
953
|
namespace JSX {
|
|
954
954
|
interface IntrinsicElements {
|
|
955
|
-
'gs-
|
|
955
|
+
'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
958
|
}
|
|
@@ -960,7 +960,7 @@ declare global {
|
|
|
960
960
|
|
|
961
961
|
declare global {
|
|
962
962
|
interface HTMLElementTagNameMap {
|
|
963
|
-
'gs-
|
|
963
|
+
'gs-mutations-over-time': MutationsOverTimeComponent;
|
|
964
964
|
}
|
|
965
965
|
}
|
|
966
966
|
|
|
@@ -968,7 +968,7 @@ declare global {
|
|
|
968
968
|
declare global {
|
|
969
969
|
namespace JSX {
|
|
970
970
|
interface IntrinsicElements {
|
|
971
|
-
'gs-
|
|
971
|
+
'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
}
|
|
@@ -976,7 +976,7 @@ declare global {
|
|
|
976
976
|
|
|
977
977
|
declare global {
|
|
978
978
|
interface HTMLElementTagNameMap {
|
|
979
|
-
'gs-
|
|
979
|
+
'gs-sequences-by-location': SequencesByLocationComponent;
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
982
|
|
|
@@ -984,7 +984,7 @@ declare global {
|
|
|
984
984
|
declare global {
|
|
985
985
|
namespace JSX {
|
|
986
986
|
interface IntrinsicElements {
|
|
987
|
-
'gs-
|
|
987
|
+
'gs-sequences-by-location': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
988
988
|
}
|
|
989
989
|
}
|
|
990
990
|
}
|
|
@@ -992,7 +992,7 @@ declare global {
|
|
|
992
992
|
|
|
993
993
|
declare global {
|
|
994
994
|
interface HTMLElementTagNameMap {
|
|
995
|
-
'gs-
|
|
995
|
+
'gs-statistics': StatisticsComponent;
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
998
|
|
|
@@ -1000,7 +1000,7 @@ declare global {
|
|
|
1000
1000
|
declare global {
|
|
1001
1001
|
namespace JSX {
|
|
1002
1002
|
interface IntrinsicElements {
|
|
1003
|
-
'gs-
|
|
1003
|
+
'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1004
1004
|
}
|
|
1005
1005
|
}
|
|
1006
1006
|
}
|
|
@@ -1008,7 +1008,7 @@ declare global {
|
|
|
1008
1008
|
|
|
1009
1009
|
declare global {
|
|
1010
1010
|
interface HTMLElementTagNameMap {
|
|
1011
|
-
'gs-date-range-
|
|
1011
|
+
'gs-date-range-filter': DateRangeFilterComponent;
|
|
1012
1012
|
}
|
|
1013
1013
|
interface HTMLElementEventMap {
|
|
1014
1014
|
'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
|
|
@@ -1020,7 +1020,7 @@ declare global {
|
|
|
1020
1020
|
declare global {
|
|
1021
1021
|
namespace JSX {
|
|
1022
1022
|
interface IntrinsicElements {
|
|
1023
|
-
'gs-date-range-
|
|
1023
|
+
'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
@@ -1028,10 +1028,10 @@ declare global {
|
|
|
1028
1028
|
|
|
1029
1029
|
declare global {
|
|
1030
1030
|
interface HTMLElementTagNameMap {
|
|
1031
|
-
'gs-
|
|
1031
|
+
'gs-location-filter': LocationFilterComponent;
|
|
1032
1032
|
}
|
|
1033
1033
|
interface HTMLElementEventMap {
|
|
1034
|
-
'gs-
|
|
1034
|
+
'gs-location-changed': LocationChangedEvent;
|
|
1035
1035
|
}
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
@@ -1039,7 +1039,7 @@ declare global {
|
|
|
1039
1039
|
declare global {
|
|
1040
1040
|
namespace JSX {
|
|
1041
1041
|
interface IntrinsicElements {
|
|
1042
|
-
'gs-
|
|
1042
|
+
'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
@@ -1047,10 +1047,10 @@ declare global {
|
|
|
1047
1047
|
|
|
1048
1048
|
declare global {
|
|
1049
1049
|
interface HTMLElementTagNameMap {
|
|
1050
|
-
'gs-
|
|
1050
|
+
'gs-text-filter': TextFilterComponent;
|
|
1051
1051
|
}
|
|
1052
1052
|
interface HTMLElementEventMap {
|
|
1053
|
-
'gs-
|
|
1053
|
+
'gs-text-filter-changed': TextFilterChangedEvent;
|
|
1054
1054
|
}
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
@@ -1058,7 +1058,7 @@ declare global {
|
|
|
1058
1058
|
declare global {
|
|
1059
1059
|
namespace JSX {
|
|
1060
1060
|
interface IntrinsicElements {
|
|
1061
|
-
'gs-
|
|
1061
|
+
'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
package/dist/util.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { D, a, L, T, d, v } from "./LineageFilterChangedEvent-
|
|
1
|
+
import { D, a, L, T, d, v } from "./LineageFilterChangedEvent-COWV-Y0k.js";
|
|
2
2
|
export {
|
|
3
3
|
D as DateRangeOptionChangedEvent,
|
|
4
4
|
a as LineageFilterChangedEvent,
|
|
5
5
|
L as LocationChangedEvent,
|
|
6
|
-
T as
|
|
6
|
+
T as TextFilterChangedEvent,
|
|
7
7
|
d as dateRangeOptionPresets,
|
|
8
8
|
v as views
|
|
9
9
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type { StepFunction } from '@storybook/types';
|
|
|
4
4
|
import dayjs from 'dayjs/esm';
|
|
5
5
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { DateRangeFilter, type DateRangeFilterProps } from './date-range-filter';
|
|
8
8
|
import { previewHandles } from '../../../.storybook/preview';
|
|
9
9
|
import { LAPIS_URL } from '../../constants';
|
|
10
10
|
import { LapisUrlContextProvider } from '../LapisUrlContext';
|
|
@@ -19,9 +19,9 @@ const customDateRange = {
|
|
|
19
19
|
dateTo: '2021-12-31',
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const meta: Meta<
|
|
23
|
-
title: 'Input/
|
|
24
|
-
component:
|
|
22
|
+
const meta: Meta<DateRangeFilterProps> = {
|
|
23
|
+
title: 'Input/DateRangeFilter',
|
|
24
|
+
component: DateRangeFilter,
|
|
25
25
|
parameters: {
|
|
26
26
|
actions: {
|
|
27
27
|
handles: ['gs-date-range-filter-changed', 'gs-date-range-option-changed', ...previewHandles],
|
|
@@ -61,15 +61,15 @@ const meta: Meta<DateRangeSelectorProps> = {
|
|
|
61
61
|
|
|
62
62
|
export default meta;
|
|
63
63
|
|
|
64
|
-
const Primary: StoryObj<
|
|
64
|
+
const Primary: StoryObj<DateRangeFilterProps> = {
|
|
65
65
|
render: (args) => (
|
|
66
66
|
<LapisUrlContextProvider value={LAPIS_URL}>
|
|
67
|
-
<
|
|
67
|
+
<DateRangeFilter {...args} />
|
|
68
68
|
</LapisUrlContextProvider>
|
|
69
69
|
),
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
export const SetCorrectInitialValues: StoryObj<
|
|
72
|
+
export const SetCorrectInitialValues: StoryObj<DateRangeFilterProps> = {
|
|
73
73
|
...Primary,
|
|
74
74
|
args: {
|
|
75
75
|
...Primary.args,
|
|
@@ -88,7 +88,7 @@ export const SetCorrectInitialValues: StoryObj<DateRangeSelectorProps> = {
|
|
|
88
88
|
|
|
89
89
|
const initialDateFrom = '2000-01-01';
|
|
90
90
|
|
|
91
|
-
export const SetCorrectInitialDateFrom: StoryObj<
|
|
91
|
+
export const SetCorrectInitialDateFrom: StoryObj<DateRangeFilterProps> = {
|
|
92
92
|
...Primary,
|
|
93
93
|
args: {
|
|
94
94
|
...Primary.args,
|
|
@@ -107,7 +107,7 @@ export const SetCorrectInitialDateFrom: StoryObj<DateRangeSelectorProps> = {
|
|
|
107
107
|
|
|
108
108
|
const initialDateTo = '2000-01-01';
|
|
109
109
|
|
|
110
|
-
export const SetCorrectInitialDateTo: StoryObj<
|
|
110
|
+
export const SetCorrectInitialDateTo: StoryObj<DateRangeFilterProps> = {
|
|
111
111
|
...Primary,
|
|
112
112
|
args: {
|
|
113
113
|
...Primary.args,
|
|
@@ -124,7 +124,7 @@ export const SetCorrectInitialDateTo: StoryObj<DateRangeSelectorProps> = {
|
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
export const ChangingDateSetsOptionToCustom: StoryObj<
|
|
127
|
+
export const ChangingDateSetsOptionToCustom: StoryObj<DateRangeFilterProps> = {
|
|
128
128
|
...Primary,
|
|
129
129
|
args: {
|
|
130
130
|
...Primary.args,
|
|
@@ -167,7 +167,7 @@ export const ChangingDateSetsOptionToCustom: StoryObj<DateRangeSelectorProps> =
|
|
|
167
167
|
},
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
export const ChangingTheValueProgrammatically: StoryObj<
|
|
170
|
+
export const ChangingTheValueProgrammatically: StoryObj<DateRangeFilterProps> = {
|
|
171
171
|
...Primary,
|
|
172
172
|
render: (args) => {
|
|
173
173
|
const StatefulWrapper = () => {
|
|
@@ -183,7 +183,7 @@ export const ChangingTheValueProgrammatically: StoryObj<DateRangeSelectorProps>
|
|
|
183
183
|
return (
|
|
184
184
|
<div ref={ref}>
|
|
185
185
|
<LapisUrlContextProvider value={LAPIS_URL}>
|
|
186
|
-
<
|
|
186
|
+
<DateRangeFilter {...args} value={value} />
|
|
187
187
|
</LapisUrlContextProvider>
|
|
188
188
|
<button className='btn' onClick={() => setValue(customDateRange.label)}>
|
|
189
189
|
Set to Custom
|
|
@@ -230,7 +230,7 @@ export const ChangingTheValueProgrammatically: StoryObj<DateRangeSelectorProps>
|
|
|
230
230
|
},
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
-
export const ChangingDateOption: StoryObj<
|
|
233
|
+
export const ChangingDateOption: StoryObj<DateRangeFilterProps> = {
|
|
234
234
|
...Primary,
|
|
235
235
|
play: async ({ canvasElement, step }) => {
|
|
236
236
|
const { canvas, filterChangedListenerMock, optionChangedListenerMock } = await prepare(canvasElement, step);
|
|
@@ -263,7 +263,7 @@ export const ChangingDateOption: StoryObj<DateRangeSelectorProps> = {
|
|
|
263
263
|
},
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
-
export const HandlesInvalidInitialDateFrom: StoryObj<
|
|
266
|
+
export const HandlesInvalidInitialDateFrom: StoryObj<DateRangeFilterProps> = {
|
|
267
267
|
...Primary,
|
|
268
268
|
args: {
|
|
269
269
|
...Primary.args,
|
|
@@ -278,7 +278,7 @@ export const HandlesInvalidInitialDateFrom: StoryObj<DateRangeSelectorProps> = {
|
|
|
278
278
|
},
|
|
279
279
|
};
|
|
280
280
|
|
|
281
|
-
export const WithNoDateColumn: StoryObj<
|
|
281
|
+
export const WithNoDateColumn: StoryObj<DateRangeFilterProps> = {
|
|
282
282
|
...Primary,
|
|
283
283
|
args: {
|
|
284
284
|
...Primary.args,
|
|
@@ -18,39 +18,39 @@ import type { ScaleType } from '../shared/charts/getYAxisScale';
|
|
|
18
18
|
|
|
19
19
|
const customOption = 'Custom';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const dateRangeFilterInnerPropsSchema = z.object({
|
|
22
22
|
dateRangeOptions: z.array(dateRangeOptionSchema),
|
|
23
23
|
earliestDate: z.string().date(),
|
|
24
24
|
value: dateRangeValueSchema.optional(),
|
|
25
25
|
lapisDateField: z.string().min(1),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const dateRangeFilterPropsSchema = dateRangeFilterInnerPropsSchema.extend({
|
|
29
29
|
width: z.string(),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export type
|
|
33
|
-
export type
|
|
32
|
+
export type DateRangeFilterProps = z.infer<typeof dateRangeFilterPropsSchema>;
|
|
33
|
+
export type DateRangeFilterInnerProps = z.infer<typeof dateRangeFilterInnerPropsSchema>;
|
|
34
34
|
|
|
35
|
-
export const
|
|
35
|
+
export const DateRangeFilter = (props: DateRangeFilterProps) => {
|
|
36
36
|
const { width, ...innerProps } = props;
|
|
37
37
|
const size = { width, height: '3rem' };
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<ErrorBoundary size={size} layout='horizontal' componentProps={props} schema={
|
|
40
|
+
<ErrorBoundary size={size} layout='horizontal' componentProps={props} schema={dateRangeFilterPropsSchema}>
|
|
41
41
|
<div style={{ width }}>
|
|
42
|
-
<
|
|
42
|
+
<DateRangeFilterInner {...innerProps} />
|
|
43
43
|
</div>
|
|
44
44
|
</ErrorBoundary>
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const
|
|
48
|
+
export const DateRangeFilterInner = ({
|
|
49
49
|
dateRangeOptions,
|
|
50
50
|
earliestDate = '1900-01-01',
|
|
51
51
|
value,
|
|
52
52
|
lapisDateField,
|
|
53
|
-
}:
|
|
53
|
+
}: DateRangeFilterInnerProps) => {
|
|
54
54
|
const initialValues = useMemo(
|
|
55
55
|
() => computeInitialValues(value, earliestDate, dateRangeOptions),
|
|
56
56
|
[value, earliestDate, dateRangeOptions],
|
|
@@ -3,7 +3,7 @@ import z from 'zod';
|
|
|
3
3
|
import { toYYYYMMDD } from './dateConversion';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A date range option that can be used in the `gs-date-range-
|
|
6
|
+
* A date range option that can be used in the `gs-date-range-filter` component.
|
|
7
7
|
*/
|
|
8
8
|
export const dateRangeOptionSchema = z.object({
|
|
9
9
|
/** The label of the date range option that will be shown to the user */
|
|
@@ -65,7 +65,7 @@ const lastYear = new Date(today);
|
|
|
65
65
|
lastYear.setFullYear(today.getFullYear() - 1);
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* Presets for the `gs-date-range-
|
|
68
|
+
* Presets for the `gs-date-range-filter` component that can be used as `dateRangeOptions`.
|
|
69
69
|
*/
|
|
70
70
|
export const dateRangeOptionPresets = {
|
|
71
71
|
last2Weeks: {
|
package/src/preact/{textInput/TextInputChangedEvent.ts → textFilter/TextFilterChangedEvent.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type LapisTextFilter = Record<string, string | undefined>;
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class TextFilterChangedEvent extends CustomEvent<LapisTextFilter> {
|
|
4
4
|
constructor(detail: LapisTextFilter) {
|
|
5
|
-
super('gs-text-
|
|
5
|
+
super('gs-text-filter-changed', {
|
|
6
6
|
detail,
|
|
7
7
|
bubbles: true,
|
|
8
8
|
composed: true,
|
|
@@ -2,18 +2,18 @@ import { type Meta, type StoryObj } from '@storybook/preact';
|
|
|
2
2
|
import { expect, fireEvent, fn, waitFor, within } from '@storybook/test';
|
|
3
3
|
|
|
4
4
|
import data from './__mockData__/aggregated_hosts.json';
|
|
5
|
-
import {
|
|
5
|
+
import { TextFilter, type TextFilterProps } from './text-filter';
|
|
6
6
|
import { previewHandles } from '../../../.storybook/preview';
|
|
7
7
|
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
8
8
|
import { LapisUrlContextProvider } from '../LapisUrlContext';
|
|
9
9
|
import { expectInvalidAttributesErrorMessage } from '../shared/stories/expectErrorMessage';
|
|
10
10
|
|
|
11
|
-
const meta: Meta<
|
|
12
|
-
title: 'Input/
|
|
13
|
-
component:
|
|
11
|
+
const meta: Meta<TextFilterProps> = {
|
|
12
|
+
title: 'Input/TextFilter',
|
|
13
|
+
component: TextFilter,
|
|
14
14
|
parameters: {
|
|
15
15
|
actions: {
|
|
16
|
-
handles: ['gs-text-
|
|
16
|
+
handles: ['gs-text-filter-changed', ...previewHandles],
|
|
17
17
|
},
|
|
18
18
|
fetchMock: {
|
|
19
19
|
mocks: [
|
|
@@ -65,10 +65,10 @@ const meta: Meta<TextInputProps> = {
|
|
|
65
65
|
|
|
66
66
|
export default meta;
|
|
67
67
|
|
|
68
|
-
export const Default: StoryObj<
|
|
68
|
+
export const Default: StoryObj<TextFilterProps> = {
|
|
69
69
|
render: (args) => (
|
|
70
70
|
<LapisUrlContextProvider value={LAPIS_URL}>
|
|
71
|
-
<
|
|
71
|
+
<TextFilter {...args} />
|
|
72
72
|
</LapisUrlContextProvider>
|
|
73
73
|
),
|
|
74
74
|
args: {
|
|
@@ -82,7 +82,7 @@ export const Default: StoryObj<TextInputProps> = {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const RemoveInitialValue: StoryObj<
|
|
85
|
+
export const RemoveInitialValue: StoryObj<TextFilterProps> = {
|
|
86
86
|
...Default,
|
|
87
87
|
args: {
|
|
88
88
|
...Default.args,
|
|
@@ -93,7 +93,7 @@ export const RemoveInitialValue: StoryObj<TextInputProps> = {
|
|
|
93
93
|
|
|
94
94
|
const changedListenerMock = fn();
|
|
95
95
|
await step('Setup event listener mock', () => {
|
|
96
|
-
canvasElement.addEventListener('gs-text-
|
|
96
|
+
canvasElement.addEventListener('gs-text-filter-changed', changedListenerMock);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
await waitFor(async () => {
|
|
@@ -115,7 +115,7 @@ export const RemoveInitialValue: StoryObj<TextInputProps> = {
|
|
|
115
115
|
},
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
export const WithNoLapisField: StoryObj<
|
|
118
|
+
export const WithNoLapisField: StoryObj<TextFilterProps> = {
|
|
119
119
|
...Default,
|
|
120
120
|
args: {
|
|
121
121
|
...Default.args,
|
|
@@ -2,7 +2,7 @@ import { type FunctionComponent } from 'preact';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
|
|
4
4
|
import { useLapisUrl } from '../LapisUrlContext';
|
|
5
|
-
import {
|
|
5
|
+
import { TextFilterChangedEvent } from './TextFilterChangedEvent';
|
|
6
6
|
import { fetchStringAutocompleteList } from './fetchStringAutocompleteList';
|
|
7
7
|
import { lapisFilterSchema } from '../../types';
|
|
8
8
|
import { DownshiftCombobox } from '../components/downshift-combobox';
|
|
@@ -17,29 +17,29 @@ const textSelectorPropsSchema = z.object({
|
|
|
17
17
|
placeholderText: z.string().optional(),
|
|
18
18
|
value: z.string().optional(),
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const textFilterInnerPropsSchema = textSelectorPropsSchema.extend({ lapisFilter: lapisFilterSchema });
|
|
21
|
+
const textFilterPropsSchema = textFilterInnerPropsSchema.extend({
|
|
22
22
|
width: z.string(),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
25
|
+
export type TextFilterInnerProps = z.infer<typeof textFilterInnerPropsSchema>;
|
|
26
|
+
export type TextFilterProps = z.infer<typeof textFilterPropsSchema>;
|
|
27
27
|
type TextSelectorProps = z.infer<typeof textSelectorPropsSchema>;
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const TextFilter: FunctionComponent<TextFilterProps> = (props) => {
|
|
30
30
|
const { width, ...innerProps } = props;
|
|
31
31
|
const size = { width, height: '3rem' };
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<ErrorBoundary size={size} layout='horizontal' componentProps={props} schema={
|
|
34
|
+
<ErrorBoundary size={size} layout='horizontal' componentProps={props} schema={textFilterPropsSchema}>
|
|
35
35
|
<ResizeContainer size={size}>
|
|
36
|
-
<
|
|
36
|
+
<TextFilterInner {...innerProps} />
|
|
37
37
|
</ResizeContainer>
|
|
38
38
|
</ErrorBoundary>
|
|
39
39
|
);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const TextFilterInner: FunctionComponent<TextFilterInnerProps> = ({
|
|
43
43
|
value,
|
|
44
44
|
lapisField,
|
|
45
45
|
placeholderText,
|
|
@@ -88,7 +88,7 @@ const TextSelector = ({
|
|
|
88
88
|
value={initialSelectedItem}
|
|
89
89
|
filterItemsByInputValue={filterByInputValue}
|
|
90
90
|
createEvent={(item: SelectItem | null) =>
|
|
91
|
-
new
|
|
91
|
+
new TextFilterChangedEvent({ [lapisField]: item?.value ?? undefined })
|
|
92
92
|
}
|
|
93
93
|
itemToString={(item: SelectItem | undefined | null) => item?.value ?? ''}
|
|
94
94
|
placeholderText={placeholderText}
|
package/src/utilEntrypoint.ts
CHANGED
|
@@ -3,7 +3,7 @@ export {
|
|
|
3
3
|
type DateRangeSelectOption,
|
|
4
4
|
dateRangeOptionPresets,
|
|
5
5
|
DateRangeOptionChangedEvent,
|
|
6
|
-
} from './preact/
|
|
6
|
+
} from './preact/dateRangeFilter/dateRangeOption';
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
type NamedLapisFilter,
|
|
@@ -35,4 +35,4 @@ export type { AxisMax, YAxisMaxConfig } from './preact/shared/charts/getYAxisMax
|
|
|
35
35
|
|
|
36
36
|
export { LocationChangedEvent } from './preact/locationFilter/LocationChangedEvent';
|
|
37
37
|
export { LineageFilterChangedEvent } from './preact/lineageFilter/LineageFilterChangedEvent';
|
|
38
|
-
export {
|
|
38
|
+
export { TextFilterChangedEvent } from './preact/textFilter/TextFilterChangedEvent';
|