@genspectrum/dashboard-components 0.6.19 → 0.7.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.
Files changed (31) hide show
  1. package/custom-elements.json +18 -18
  2. package/dist/assets/mutationOverTimeWorker-BOCXtKzd.js.map +1 -0
  3. package/dist/dashboard-components.js +296 -302
  4. package/dist/dashboard-components.js.map +1 -1
  5. package/dist/genspectrum-components.d.ts +98 -48
  6. package/package.json +1 -3
  7. package/src/index.ts +1 -0
  8. package/src/preact/aggregatedData/aggregate.tsx +41 -33
  9. package/src/preact/dateRangeSelector/computeInitialValues.spec.ts +53 -38
  10. package/src/preact/dateRangeSelector/computeInitialValues.ts +17 -23
  11. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +46 -32
  12. package/src/preact/dateRangeSelector/date-range-selector.tsx +24 -26
  13. package/src/preact/dateRangeSelector/dateRangeOption.ts +65 -0
  14. package/src/preact/dateRangeSelector/selectableOptions.ts +17 -66
  15. package/src/preact/mutationComparison/mutation-comparison.tsx +32 -34
  16. package/src/preact/mutations/mutations.tsx +63 -56
  17. package/src/preact/mutationsOverTime/MutationOverTimeData.ts +20 -0
  18. package/src/preact/mutationsOverTime/getFilteredMutationsOverTime.spec.ts +2 -3
  19. package/src/preact/mutationsOverTime/getFilteredMutationsOverTimeData.ts +2 -2
  20. package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +3 -3
  21. package/src/preact/mutationsOverTime/mutations-over-time.tsx +40 -43
  22. package/src/preact/numberSequencesOverTime/number-sequences-over-time.tsx +46 -64
  23. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +29 -36
  24. package/src/query/queryMutationsOverTime.ts +3 -5
  25. package/src/utils/map2d.spec.ts +52 -13
  26. package/src/utils/map2d.ts +3 -4
  27. package/src/web-components/input/gs-date-range-selector.stories.ts +16 -28
  28. package/src/web-components/input/gs-date-range-selector.tsx +17 -32
  29. package/standalone-bundle/dashboard-components.js +14322 -15115
  30. package/standalone-bundle/dashboard-components.js.map +1 -1
  31. package/dist/assets/mutationOverTimeWorker-BdzqDqvO.js.map +0 -1
@@ -272,17 +272,17 @@
272
272
  "kind": "variable",
273
273
  "name": "meta",
274
274
  "type": {
275
- "text": "Meta<Required<DateRangeSelectorProps<'CustomDateRange'>>>"
275
+ "text": "Meta<Required<DateRangeSelectorProps>>"
276
276
  },
277
- "default": "{ title: 'Input/DateRangeSelector', component: 'gs-date-range-selector', parameters: withComponentDocs({ actions: { handles: ['gs-date-range-changed', ...previewHandles], }, fetchMock: {}, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { initialValue: { control: { type: 'select', }, options: [ PRESET_VALUE_CUSTOM, PRESET_VALUE_ALL_TIMES, PRESET_VALUE_LAST_2_WEEKS, PRESET_VALUE_LAST_MONTH, PRESET_VALUE_LAST_2_MONTHS, PRESET_VALUE_LAST_3_MONTHS, PRESET_VALUE_LAST_6_MONTHS, 'CustomDateRange', ], }, dateColumn: { control: { type: 'text' } }, customSelectOptions: { control: { type: 'object', }, }, earliestDate: { control: { type: 'text', }, }, width: { control: { type: 'text', }, }, }, args: { customSelectOptions: [{ label: 'CustomDateRange', dateFrom: '2021-01-01', dateTo: '2021-12-31' }], earliestDate: '1970-01-01', initialValue: PRESET_VALUE_LAST_6_MONTHS, dateColumn: 'aDateColumn', width: '100%', initialDateFrom: '', initialDateTo: '', }, tags: ['autodocs'], }"
277
+ "default": "{ title: 'Input/DateRangeSelector', component: 'gs-date-range-selector', parameters: withComponentDocs({ actions: { handles: ['gs-date-range-changed', ...previewHandles], }, fetchMock: {}, componentDocs: { opensShadowDom: true, expectsChildren: false, codeExample, }, }), argTypes: { initialValue: { control: { type: 'select', }, options: [dateRangeOptionPresets.lastMonth.label, dateRangeOptionPresets.allTimes.label, 'CustomDateRange'], }, dateColumn: { control: { type: 'text' } }, dateRangeOptions: { control: { type: 'object', }, }, earliestDate: { control: { type: 'text', }, }, width: { control: { type: 'text', }, }, }, args: { dateRangeOptions: [ dateRangeOptionPresets.lastMonth, dateRangeOptionPresets.last3Months, dateRangeOptionPresets.allTimes, { label: 'CustomDateRange', dateFrom: '2021-01-01', dateTo: '2021-12-31' }, ], earliestDate: '1970-01-01', initialValue: dateRangeOptionPresets.lastMonth.label, dateColumn: 'aDateColumn', width: '100%', initialDateFrom: '', initialDateTo: '', }, tags: ['autodocs'], }"
278
278
  },
279
279
  {
280
280
  "kind": "variable",
281
281
  "name": "DateRangeSelectorStory",
282
282
  "type": {
283
- "text": "StoryObj<Required<DateRangeSelectorProps<'CustomDateRange'>>>"
283
+ "text": "StoryObj<Required<DateRangeSelectorProps>>"
284
284
  },
285
- "default": "{ render: (args) => html` <gs-app lapis=\"${LAPIS_URL}\"> <div class=\"max-w-screen-lg\"> <gs-date-range-selector .customSelectOptions=${args.customSelectOptions} .earliestDate=${args.earliestDate} .initialValue=${args.initialValue} .initialDateFrom=${args.initialDateFrom} .initialDateTo=${args.initialDateTo} .width=${args.width} .dateColumn=${args.dateColumn} ></gs-date-range-selector> </div> </gs-app>`, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-selector'); const dateTo = () => canvas.getByPlaceholderText('Date to'); await step('Expect last 6 months to be selected', async () => { await expect(canvas.getByRole('combobox')).toHaveValue('last6Months'); await waitFor(() => { expect(dateTo()).toHaveValue(toYYYYMMDD(new Date())); }); }); // Due to the limitations of storybook testing which does not fire an event, // when selecting a value from the dropdown we can't test the fired event here. // An e2e test (using playwright) for that can be found in tests/dateRangeSelector.spec.ts }, }"
285
+ "default": "{ render: (args) => html` <gs-app lapis=\"${LAPIS_URL}\"> <div class=\"max-w-screen-lg\"> <gs-date-range-selector .dateRangeOptions=${args.dateRangeOptions} .earliestDate=${args.earliestDate} .initialValue=${args.initialValue} .initialDateFrom=${args.initialDateFrom} .initialDateTo=${args.initialDateTo} .width=${args.width} .dateColumn=${args.dateColumn} ></gs-date-range-selector> </div> </gs-app>`, play: async ({ canvasElement, step }) => { const canvas = await withinShadowRoot(canvasElement, 'gs-date-range-selector'); const dateTo = () => canvas.getByPlaceholderText('Date to'); await step('Expect last 6 months to be selected', async () => { await expect(canvas.getByRole('combobox')).toHaveValue('Last month'); await waitFor(() => { expect(dateTo()).toHaveValue(toYYYYMMDD(new Date())); }); }); // Due to the limitations of storybook testing which does not fire an event, // when selecting a value from the dropdown we can't test the fired event here. // An e2e test (using playwright) for that can be found in tests/dateRangeSelector.spec.ts }, }"
286
286
  }
287
287
  ],
288
288
  "exports": [
@@ -315,13 +315,13 @@
315
315
  "members": [
316
316
  {
317
317
  "kind": "field",
318
- "name": "customSelectOptions",
318
+ "name": "dateRangeOptions",
319
319
  "type": {
320
- "text": "{ label: string; dateFrom: string; dateTo: string }[]"
320
+ "text": "{ label: string; dateFrom?: string; dateTo?: string }[]"
321
321
  },
322
322
  "default": "[]",
323
- "description": "An array of custom options that the select field should provide,\nin addition to the predefined options.\nThe `label` will be shown to the user, and it will be available as `initialValue`.\nThe dates must be in the format `YYYY-MM-DD`.",
324
- "attribute": "customSelectOptions"
323
+ "description": "An array of date range options that the select field should provide.\nThe `label` will be shown to the user, and it will be available as `initialValue`.\nThe dates must be in the format `YYYY-MM-DD`.\n\nIf dateFrom or dateTo is not set, the component will default to the `earliestDate` or the current date.",
324
+ "attribute": "dateRangeOptions"
325
325
  },
326
326
  {
327
327
  "kind": "field",
@@ -337,10 +337,10 @@
337
337
  "kind": "field",
338
338
  "name": "initialValue",
339
339
  "type": {
340
- "text": "'custom'\n | 'allTimes'\n | 'last2Weeks'\n | 'lastMonth'\n | 'last2Months'\n | 'last3Months'\n | 'last6Months'\n | string"
340
+ "text": "string | undefined"
341
341
  },
342
- "default": "'last6Months'",
343
- "description": "The initial value to use for this date range selector.\nMust be a valid label from the preset labels or a `label` given in the `customSelectOptions`.\n\nIf the value is invalid, the component will default to `'last6Months'`.\n\nIt will be overwritten if `initialDateFrom` or `initialDateTo` is set.",
342
+ "default": "undefined",
343
+ "description": "The initial value to use for this date range selector.\nMust be a valid label from the `dateRangeOptions`.\n\nIf the value is not set, the component will default to the range `earliestDate` until today.\n\nIt will be overwritten if `initialDateFrom` or `initialDateTo` is set.\n\nWe provide some options in `dateRangeOptionPresets` for convenience.",
344
344
  "attribute": "initialValue"
345
345
  },
346
346
  {
@@ -395,13 +395,13 @@
395
395
  ],
396
396
  "attributes": [
397
397
  {
398
- "name": "customSelectOptions",
398
+ "name": "dateRangeOptions",
399
399
  "type": {
400
- "text": "{ label: string; dateFrom: string; dateTo: string }[]"
400
+ "text": "{ label: string; dateFrom?: string; dateTo?: string }[]"
401
401
  },
402
402
  "default": "[]",
403
- "description": "An array of custom options that the select field should provide,\nin addition to the predefined options.\nThe `label` will be shown to the user, and it will be available as `initialValue`.\nThe dates must be in the format `YYYY-MM-DD`.",
404
- "fieldName": "customSelectOptions"
403
+ "description": "An array of date range options that the select field should provide.\nThe `label` will be shown to the user, and it will be available as `initialValue`.\nThe dates must be in the format `YYYY-MM-DD`.\n\nIf dateFrom or dateTo is not set, the component will default to the `earliestDate` or the current date.",
404
+ "fieldName": "dateRangeOptions"
405
405
  },
406
406
  {
407
407
  "name": "earliestDate",
@@ -415,10 +415,10 @@
415
415
  {
416
416
  "name": "initialValue",
417
417
  "type": {
418
- "text": "'custom'\n | 'allTimes'\n | 'last2Weeks'\n | 'lastMonth'\n | 'last2Months'\n | 'last3Months'\n | 'last6Months'\n | string"
418
+ "text": "string | undefined"
419
419
  },
420
- "default": "'last6Months'",
421
- "description": "The initial value to use for this date range selector.\nMust be a valid label from the preset labels or a `label` given in the `customSelectOptions`.\n\nIf the value is invalid, the component will default to `'last6Months'`.\n\nIt will be overwritten if `initialDateFrom` or `initialDateTo` is set.",
420
+ "default": "undefined",
421
+ "description": "The initial value to use for this date range selector.\nMust be a valid label from the `dateRangeOptions`.\n\nIf the value is not set, the component will default to the range `earliestDate` until today.\n\nIt will be overwritten if `initialDateFrom` or `initialDateTo` is set.\n\nWe provide some options in `dateRangeOptionPresets` for convenience.",
422
422
  "fieldName": "initialValue"
423
423
  },
424
424
  {