@genspectrum/dashboard-components 0.20.0 → 0.21.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 +8 -27
- package/dist/{NumberRangeFilterChangedEvent-RqWinxhE.js → NumberRangeFilterChangedEvent-B64OQZjX.js} +1 -6
- package/dist/NumberRangeFilterChangedEvent-B64OQZjX.js.map +1 -0
- package/dist/components.d.ts +16 -20
- package/dist/components.js +39 -80
- package/dist/components.js.map +1 -1
- package/dist/util.d.ts +14 -17
- package/dist/util.js +1 -1
- package/package.json +2 -2
- package/src/preact/dateRangeFilter/computeInitialValues.spec.ts +18 -29
- package/src/preact/dateRangeFilter/computeInitialValues.ts +29 -27
- package/src/preact/dateRangeFilter/date-range-filter.stories.tsx +6 -13
- package/src/preact/dateRangeFilter/date-range-filter.tsx +16 -35
- package/src/preact/dateRangeFilter/dateRangeOption.ts +0 -6
- package/src/preact/dateRangeFilter/selectableOptions.ts +0 -23
- package/src/preact/statistic/statistics.stories.tsx +67 -0
- package/src/preact/statistic/statistics.tsx +3 -1
- package/src/web-components/input/gs-date-range-filter.stories.ts +1 -10
- package/src/web-components/input/gs-date-range-filter.tsx +2 -12
- package/standalone-bundle/dashboard-components.js +6470 -6451
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/dist/NumberRangeFilterChangedEvent-RqWinxhE.js.map +0 -1
|
@@ -80,6 +80,73 @@ export const Default: StoryObj<StatisticsProps> = {
|
|
|
80
80
|
},
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
export const ValuesAre0: StoryObj<StatisticsProps> = {
|
|
84
|
+
...Default,
|
|
85
|
+
parameters: {
|
|
86
|
+
fetchMock: {
|
|
87
|
+
mocks: [
|
|
88
|
+
{
|
|
89
|
+
matcher: {
|
|
90
|
+
name: 'denominatorData',
|
|
91
|
+
url: AGGREGATED_ENDPOINT,
|
|
92
|
+
body: {
|
|
93
|
+
fields: [],
|
|
94
|
+
country: 'USA',
|
|
95
|
+
division: 'Alabama',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
response: {
|
|
99
|
+
status: 200,
|
|
100
|
+
body: {
|
|
101
|
+
data: [
|
|
102
|
+
{
|
|
103
|
+
count: 0,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
info: {
|
|
107
|
+
dataVersion: '1712315293',
|
|
108
|
+
requestId: '4603a85e-ae5e-495d-aee5-778a3af862c1',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
matcher: {
|
|
115
|
+
name: 'numeratorData',
|
|
116
|
+
url: AGGREGATED_ENDPOINT,
|
|
117
|
+
body: {
|
|
118
|
+
fields: [],
|
|
119
|
+
country: 'USA',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
response: {
|
|
123
|
+
status: 200,
|
|
124
|
+
body: {
|
|
125
|
+
data: [
|
|
126
|
+
{
|
|
127
|
+
count: 0,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
info: {
|
|
131
|
+
dataVersion: '1712315293',
|
|
132
|
+
requestId: '4603a85e-ae5e-495d-aee5-778a3af862c1',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
play: async ({ canvasElement }) => {
|
|
141
|
+
const canvas = within(canvasElement);
|
|
142
|
+
|
|
143
|
+
await waitFor(async () => {
|
|
144
|
+
await expect(canvas.getByText('0')).toBeInTheDocument();
|
|
145
|
+
await expect(canvas.getByText('-%')).toBeInTheDocument();
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
83
150
|
export const FiresFinishedLoadingEvent: StoryObj<StatisticsProps> = {
|
|
84
151
|
...Default,
|
|
85
152
|
play: playThatExpectsFinishedLoadingEvent(),
|
|
@@ -74,7 +74,9 @@ const MetricDataTabs: FunctionComponent<MetricDataTabsProps> = ({ data }) => {
|
|
|
74
74
|
|
|
75
75
|
<div className='stat'>
|
|
76
76
|
<div className='stat-title'>Overall proportion</div>
|
|
77
|
-
<div className='stat-value text-2xl sm:text-4xl'>
|
|
77
|
+
<div className='stat-value text-2xl sm:text-4xl'>
|
|
78
|
+
{Number.isFinite(proportion) ? formatProportion(proportion) : '-%'}
|
|
79
|
+
</div>
|
|
78
80
|
<div className='stat-desc text-wrap'>The proportion among all sequenced samples</div>
|
|
79
81
|
</div>
|
|
80
82
|
</div>
|
|
@@ -8,7 +8,6 @@ import { LAPIS_URL } from '../../constants';
|
|
|
8
8
|
import { type DateRangeFilterProps } from '../../preact/dateRangeFilter/date-range-filter';
|
|
9
9
|
import './gs-date-range-filter';
|
|
10
10
|
import '../gs-app';
|
|
11
|
-
import { toYYYYMMDD } from '../../preact/dateRangeFilter/dateConversion';
|
|
12
11
|
import { dateRangeOptionPresets } from '../../preact/dateRangeFilter/dateRangeOption';
|
|
13
12
|
import { gsEventNames } from '../../utils/gsEventNames';
|
|
14
13
|
import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
@@ -16,7 +15,6 @@ import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
|
16
15
|
const codeExample = String.raw`
|
|
17
16
|
<gs-date-range-filter
|
|
18
17
|
dateRangeOptions='[{ "label": "Year 2021", "dateFrom": "2021-01-01", "dateTo": "2021-12-31" }]'
|
|
19
|
-
earliestDate="1970-01-01"
|
|
20
18
|
value="Year 2021"
|
|
21
19
|
width="100%"
|
|
22
20
|
lapisDateField="myDateColumn"
|
|
@@ -47,9 +45,6 @@ const meta: Meta<Required<DateRangeFilterProps>> = {
|
|
|
47
45
|
dateRangeOptions: {
|
|
48
46
|
control: { type: 'object' },
|
|
49
47
|
},
|
|
50
|
-
earliestDate: {
|
|
51
|
-
control: { type: 'text' },
|
|
52
|
-
},
|
|
53
48
|
width: {
|
|
54
49
|
control: { type: 'text' },
|
|
55
50
|
},
|
|
@@ -61,11 +56,9 @@ const meta: Meta<Required<DateRangeFilterProps>> = {
|
|
|
61
56
|
dateRangeOptions: [
|
|
62
57
|
dateRangeOptionPresets().lastMonth,
|
|
63
58
|
dateRangeOptionPresets().last3Months,
|
|
64
|
-
dateRangeOptionPresets().allTimes,
|
|
65
59
|
{ label: '2021', dateFrom: '2021-01-01', dateTo: '2021-12-31' },
|
|
66
60
|
customDateRange,
|
|
67
61
|
],
|
|
68
|
-
earliestDate: '1970-01-01',
|
|
69
62
|
value: dateRangeOptionPresets().lastMonth.label,
|
|
70
63
|
lapisDateField: 'aDateColumn',
|
|
71
64
|
width: '100%',
|
|
@@ -82,7 +75,6 @@ export const Default: StoryObj<Required<DateRangeFilterProps>> = {
|
|
|
82
75
|
<div class="max-w-(--breakpoint-lg)">
|
|
83
76
|
<gs-date-range-filter
|
|
84
77
|
.dateRangeOptions=${args.dateRangeOptions}
|
|
85
|
-
.earliestDate=${args.earliestDate}
|
|
86
78
|
.value=${args.value}
|
|
87
79
|
.width=${args.width}
|
|
88
80
|
.lapisDateField=${args.lapisDateField}
|
|
@@ -98,7 +90,6 @@ export const TestRenderAttributesInHtmlInsteadOfUsingPropertyExpression: StoryOb
|
|
|
98
90
|
<div class="max-w-(--breakpoint-lg)">
|
|
99
91
|
<gs-date-range-filter
|
|
100
92
|
.dateRangeOptions=${args.dateRangeOptions}
|
|
101
|
-
earliestDate="${args.earliestDate}"
|
|
102
93
|
value="${args.value ?? 'null'}"
|
|
103
94
|
width="${args.width}"
|
|
104
95
|
lapisDateField="${args.lapisDateField}"
|
|
@@ -155,7 +146,7 @@ export const FiresEvents: StoryObj<Required<DateRangeFilterProps>> = {
|
|
|
155
146
|
await expect(placeholderOption).toHaveTextContent('Last month');
|
|
156
147
|
});
|
|
157
148
|
await waitFor(async () => {
|
|
158
|
-
await expect(dateToPicker(canvas)).toHaveValue(
|
|
149
|
+
await expect(dateToPicker(canvas)).toHaveValue('');
|
|
159
150
|
});
|
|
160
151
|
});
|
|
161
152
|
|
|
@@ -64,24 +64,18 @@ export class DateRangeFilterComponent extends PreactLitAdapter {
|
|
|
64
64
|
* The `label` will be shown to the user, and it will be available as `value`.
|
|
65
65
|
* The dates must be in the format `YYYY-MM-DD`.
|
|
66
66
|
*
|
|
67
|
-
* If dateFrom or dateTo is not set, the component will
|
|
67
|
+
* If dateFrom or dateTo is not set, the component will leave the corresponding input field empty.
|
|
68
68
|
*
|
|
69
69
|
* We provide some options in `dateRangeOptionPresets` for convenience.
|
|
70
70
|
*/
|
|
71
71
|
@property({ type: Array })
|
|
72
72
|
dateRangeOptions: { label: string; dateFrom?: string; dateTo?: string }[] = [];
|
|
73
73
|
|
|
74
|
-
/**
|
|
75
|
-
* The `dateFrom` value to use in the `allTimes` preset in the format `YYYY-MM-DD`.
|
|
76
|
-
*/
|
|
77
|
-
@property({ type: String })
|
|
78
|
-
earliestDate: string = '1900-01-01';
|
|
79
|
-
|
|
80
74
|
/**
|
|
81
75
|
* The value to use for this date range selector.
|
|
82
76
|
* - If it is a string, then it must be a valid label from the `dateRangeOptions`.
|
|
83
77
|
* - If it is an object, then it accepts dates in the format `YYYY-MM-DD` for the keys `dateFrom` and `dateTo`.
|
|
84
|
-
* Keys that are not set will
|
|
78
|
+
* Keys that are not set will leave the corresponding input field empty.
|
|
85
79
|
*
|
|
86
80
|
* The `detail` of the `gs-date-range-option-changed` event can be used for this attribute,
|
|
87
81
|
* if you want to control this component in your JS application.
|
|
@@ -128,7 +122,6 @@ export class DateRangeFilterComponent extends PreactLitAdapter {
|
|
|
128
122
|
return (
|
|
129
123
|
<DateRangeFilter
|
|
130
124
|
dateRangeOptions={this.dateRangeOptions}
|
|
131
|
-
earliestDate={this.earliestDate}
|
|
132
125
|
value={this.value}
|
|
133
126
|
lapisDateField={this.lapisDateField}
|
|
134
127
|
width={this.width}
|
|
@@ -162,9 +155,6 @@ declare global {
|
|
|
162
155
|
type CustomSelectOptionsMatches = Expect<
|
|
163
156
|
Equals<typeof DateRangeFilterComponent.prototype.dateRangeOptions, DateRangeFilterProps['dateRangeOptions']>
|
|
164
157
|
>;
|
|
165
|
-
type EarliestDateMatches = Expect<
|
|
166
|
-
Equals<typeof DateRangeFilterComponent.prototype.earliestDate, DateRangeFilterProps['earliestDate']>
|
|
167
|
-
>;
|
|
168
158
|
type ValueMatches = Expect<Equals<typeof DateRangeFilterComponent.prototype.value, DateRangeFilterProps['value']>>;
|
|
169
159
|
type WidthMatches = Expect<Equals<typeof DateRangeFilterComponent.prototype.width, DateRangeFilterProps['width']>>;
|
|
170
160
|
type DateColumnMatches = Expect<
|