@genspectrum/dashboard-components 0.10.2 → 0.10.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/README.md +19 -19
- package/custom-elements.json +49 -33
- package/dist/assets/{mutationOverTimeWorker-Di6yP1e6.js.map → mutationOverTimeWorker-CNg_ztNp.js.map} +1 -1
- package/dist/components.d.ts +49 -60
- package/dist/components.js +203 -45
- package/dist/components.js.map +1 -1
- package/dist/{dateRangeOption-du8H7LWu.js → dateRangeOption-DjtcAEWq.js} +16 -3
- package/dist/dateRangeOption-DjtcAEWq.js.map +1 -0
- package/dist/style.css +11 -5
- package/dist/util.d.ts +91 -42
- package/dist/util.js +1 -1
- package/package.json +2 -2
- package/src/preact/aggregatedData/aggregate.stories.tsx +14 -0
- package/src/preact/aggregatedData/aggregate.tsx +17 -15
- package/src/preact/components/error-boundary.stories.tsx +24 -3
- package/src/preact/components/error-boundary.tsx +3 -4
- package/src/preact/components/error-display.tsx +38 -17
- package/src/preact/components/tabs.tsx +2 -2
- package/src/preact/mutationFilter/mutation-filter.tsx +26 -13
- package/src/preact/mutations/mutations.tsx +16 -12
- package/src/preact/mutationsOverTime/mutations-over-time.stories.tsx +14 -0
- package/src/preact/mutationsOverTime/mutations-over-time.tsx +18 -14
- package/src/preact/numberSequencesOverTime/number-sequences-over-time.stories.tsx +14 -0
- package/src/preact/numberSequencesOverTime/number-sequences-over-time.tsx +22 -14
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +14 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +28 -19
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +14 -0
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +18 -15
- package/src/preact/shared/charts/confideceInterval.ts +10 -8
- package/src/preact/shared/charts/getYAxisMax.ts +10 -5
- package/src/preact/statistic/statistics.tsx +10 -8
- package/src/preact/textInput/text-input.stories.tsx +14 -0
- package/src/preact/textInput/text-input.tsx +16 -11
- package/src/query/queryAggregateData.ts +2 -1
- package/src/types.ts +12 -1
- package/src/utilEntrypoint.ts +7 -0
- package/src/web-components/app.stories.ts +17 -2
- package/src/web-components/app.ts +17 -5
- package/src/web-components/input/gs-mutation-filter.stories.ts +2 -0
- package/src/web-components/input/gs-text-input.tsx +2 -2
- package/src/web-components/introduction.mdx +4 -4
- package/src/web-components/visualization/data_visualization_statistical_analysis.mdx +3 -3
- package/src/web-components/visualization/gs-mutations-over-time.tsx +1 -3
- package/src/web-components/visualization/gs-mutations.tsx +1 -3
- package/src/web-components/visualization/gs-number-sequences-over-time.tsx +1 -3
- package/src/web-components/visualization/gs-prevalence-over-time.tsx +3 -6
- package/src/web-components/visualization/gs-relative-growth-advantage.tsx +1 -5
- package/standalone-bundle/assets/mutationOverTimeWorker-cIyshfj_.js.map +1 -1
- package/standalone-bundle/dashboard-components.js +6079 -5944
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/standalone-bundle/style.css +1 -1
- package/dist/dateRangeOption-du8H7LWu.js.map +0 -1
|
@@ -4,10 +4,21 @@ const namedLapisFilterSchema = z.object({
|
|
|
4
4
|
lapisFilter: lapisFilterSchema,
|
|
5
5
|
displayName: z.string()
|
|
6
6
|
});
|
|
7
|
+
const temporalGranularitySchema = z.union([
|
|
8
|
+
z.literal("day"),
|
|
9
|
+
z.literal("week"),
|
|
10
|
+
z.literal("month"),
|
|
11
|
+
z.literal("year")
|
|
12
|
+
]);
|
|
7
13
|
const sequenceTypeSchema = z.union([z.literal("nucleotide"), z.literal("amino acid")]);
|
|
8
14
|
const views = {
|
|
9
15
|
table: "table",
|
|
10
|
-
venn: "venn"
|
|
16
|
+
venn: "venn",
|
|
17
|
+
grid: "grid",
|
|
18
|
+
insertions: "insertions",
|
|
19
|
+
bar: "bar",
|
|
20
|
+
line: "line",
|
|
21
|
+
bubble: "bubble"
|
|
11
22
|
};
|
|
12
23
|
const mutationComparisonViewSchema = z.union([z.literal(views.table), z.literal(views.venn)]);
|
|
13
24
|
const toYYYYMMDD = (date) => {
|
|
@@ -82,11 +93,13 @@ const dateRangeOptionPresets = {
|
|
|
82
93
|
export {
|
|
83
94
|
DateRangeOptionChangedEvent as D,
|
|
84
95
|
dateRangeOptionSchema as a,
|
|
96
|
+
toYYYYMMDD as b,
|
|
85
97
|
dateRangeOptionPresets as d,
|
|
98
|
+
lapisFilterSchema as l,
|
|
86
99
|
mutationComparisonViewSchema as m,
|
|
87
100
|
namedLapisFilterSchema as n,
|
|
88
101
|
sequenceTypeSchema as s,
|
|
89
|
-
|
|
102
|
+
temporalGranularitySchema as t,
|
|
90
103
|
views as v
|
|
91
104
|
};
|
|
92
|
-
//# sourceMappingURL=dateRangeOption-
|
|
105
|
+
//# sourceMappingURL=dateRangeOption-DjtcAEWq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateRangeOption-DjtcAEWq.js","sources":["../src/types.ts","../src/preact/dateRangeSelector/dateConversion.ts","../src/preact/dateRangeSelector/dateRangeOption.ts"],"sourcesContent":["import z from 'zod';\n\nimport {\n type Deletion,\n type DeletionClass,\n type Insertion,\n type InsertionClass,\n type Substitution,\n type SubstitutionClass,\n} from './utils/mutations';\n\nexport const lapisFilterSchema = z.record(z.union([z.string(), z.number(), z.null(), z.boolean()]));\nexport type LapisFilter = z.infer<typeof lapisFilterSchema>;\n\nexport const namedLapisFilterSchema = z.object({\n lapisFilter: lapisFilterSchema,\n displayName: z.string(),\n});\nexport type NamedLapisFilter = z.infer<typeof namedLapisFilterSchema>;\n\nexport const temporalGranularitySchema = z.union([\n z.literal('day'),\n z.literal('week'),\n z.literal('month'),\n z.literal('year'),\n]);\nexport type TemporalGranularity = z.infer<typeof temporalGranularitySchema>;\n\nexport const sequenceTypeSchema = z.union([z.literal('nucleotide'), z.literal('amino acid')]);\nexport type SequenceType = z.infer<typeof sequenceTypeSchema>;\n\nexport type SubstitutionOrDeletion = 'substitution' | 'deletion';\n\nexport type MutationType = SubstitutionOrDeletion | 'insertion';\n\nexport type SubstitutionEntry<T extends Substitution = SubstitutionClass> = {\n type: 'substitution';\n mutation: T;\n count: number;\n proportion: number;\n};\n\nexport type DeletionEntry<T extends Deletion = DeletionClass> = {\n type: 'deletion';\n mutation: T;\n count: number;\n proportion: number;\n};\n\nexport type InsertionEntry<T extends Insertion = InsertionClass> = { type: 'insertion'; mutation: T; count: number };\n\nexport type SubstitutionOrDeletionEntry<\n S extends Substitution = SubstitutionClass,\n D extends Deletion = DeletionClass,\n> = SubstitutionEntry<S> | DeletionEntry<D>;\n\nexport type MutationEntry = SubstitutionEntry | DeletionEntry | InsertionEntry;\n\nexport const views = {\n table: 'table',\n venn: 'venn',\n grid: 'grid',\n insertions: 'insertions',\n bar: 'bar',\n line: 'line',\n bubble: 'bubble',\n} as const;\n\nexport const mutationComparisonViewSchema = z.union([z.literal(views.table), z.literal(views.venn)]);\nexport type MutationComparisonView = z.infer<typeof mutationComparisonViewSchema>;\n","export const toYYYYMMDD = (date: Date) => {\n const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: '2-digit', day: '2-digit' };\n return date.toLocaleDateString('en-CA', options);\n};\n","import z from 'zod';\n\nimport { toYYYYMMDD } from './dateConversion';\n\n/**\n * A date range option that can be used in the `gs-date-range-selector` component.\n */\nexport const dateRangeOptionSchema = z.object({\n /** The label of the date range option that will be shown to the user */\n label: z.string(),\n /**\n * The start date of the date range in the format `YYYY-MM-DD`.\n * If not set, the date range selector will default to the `earliestDate` property.\n */\n dateFrom: z.string().date().optional(),\n /**\n * The end date of the date range in the format `YYYY-MM-DD`.\n * If not set, the date range selector will default to the current date.\n */\n dateTo: z.string().date().optional(),\n});\n\nexport type DateRangeOption = z.infer<typeof dateRangeOptionSchema>;\n\nexport type DateRangeSelectOption = string | { dateFrom: string; dateTo: string };\n\nexport class DateRangeOptionChangedEvent extends CustomEvent<DateRangeSelectOption> {\n constructor(detail: DateRangeSelectOption) {\n super('gs-date-range-option-changed', {\n detail,\n bubbles: true,\n composed: true,\n });\n }\n}\n\nconst today = new Date();\n\nconst twoWeeksAgo = new Date();\ntwoWeeksAgo.setDate(today.getDate() - 14);\n\nconst lastMonth = new Date(today);\nlastMonth.setMonth(today.getMonth() - 1);\n\nconst last2Months = new Date(today);\nlast2Months.setMonth(today.getMonth() - 2);\n\nconst last3Months = new Date(today);\nlast3Months.setMonth(today.getMonth() - 3);\n\nconst last6Months = new Date(today);\nlast6Months.setMonth(today.getMonth() - 6);\n\nconst lastYear = new Date(today);\nlastYear.setFullYear(today.getFullYear() - 1);\n\n/**\n * Presets for the `gs-date-range-selector` component that can be used as `dateRangeOptions`.\n */\nexport const dateRangeOptionPresets = {\n last2Weeks: {\n label: 'Last 2 weeks',\n dateFrom: toYYYYMMDD(twoWeeksAgo),\n },\n lastMonth: {\n label: 'Last month',\n dateFrom: toYYYYMMDD(lastMonth),\n },\n last2Months: {\n label: 'Last 2 months',\n dateFrom: toYYYYMMDD(last2Months),\n },\n last3Months: {\n label: 'Last 3 months',\n dateFrom: toYYYYMMDD(last3Months),\n },\n last6Months: {\n label: 'Last 6 months',\n dateFrom: toYYYYMMDD(last6Months),\n },\n lastYear: {\n label: 'Last year',\n dateFrom: toYYYYMMDD(lastYear),\n },\n allTimes: {\n label: 'All times',\n },\n} satisfies Record<string, DateRangeOption>;\n"],"names":[],"mappings":";AAWO,MAAM,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,QAAS,CAAA,CAAC,CAAC;AAGrF,MAAA,yBAAyB,EAAE,OAAO;AAAA,EAC3C,aAAa;AAAA,EACb,aAAa,EAAE,OAAO;AAC1B,CAAC;AAGY,MAAA,4BAA4B,EAAE,MAAM;AAAA,EAC7C,EAAE,QAAQ,KAAK;AAAA,EACf,EAAE,QAAQ,MAAM;AAAA,EAChB,EAAE,QAAQ,OAAO;AAAA,EACjB,EAAE,QAAQ,MAAM;AACpB,CAAC;AAGM,MAAM,qBAAqB,EAAE,MAAM,CAAC,EAAE,QAAQ,YAAY,GAAG,EAAE,QAAQ,YAAY,CAAC,CAAC;AA8BrF,MAAM,QAAQ;AAAA,EACjB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AACZ;AAEO,MAAM,+BAA+B,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,KAAK,GAAG,EAAE,QAAQ,MAAM,IAAI,CAAC,CAAC;ACpEtF,MAAA,aAAa,CAAC,SAAe;AACtC,QAAM,UAAsC,EAAE,MAAM,WAAW,OAAO,WAAW,KAAK;AAC/E,SAAA,KAAK,mBAAmB,SAAS,OAAO;AACnD;ACIa,MAAA,wBAAwB,EAAE,OAAO;AAAA;AAAA,EAE1C,OAAO,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhB,UAAU,EAAE,OAAS,EAAA,KAAA,EAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,QAAQ,EAAE,OAAS,EAAA,KAAA,EAAO,SAAS;AACvC,CAAC;AAMM,MAAM,oCAAoC,YAAmC;AAAA,EAChF,YAAY,QAA+B;AACvC,UAAM,gCAAgC;AAAA,MAClC;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACb;AAAA,EACL;AACJ;AAEA,MAAM,4BAAY;AAElB,MAAM,kCAAkB;AACxB,YAAY,QAAQ,MAAM,QAAQ,IAAI,EAAE;AAExC,MAAM,YAAY,IAAI,KAAK,KAAK;AAChC,UAAU,SAAS,MAAM,SAAS,IAAI,CAAC;AAEvC,MAAM,cAAc,IAAI,KAAK,KAAK;AAClC,YAAY,SAAS,MAAM,SAAS,IAAI,CAAC;AAEzC,MAAM,cAAc,IAAI,KAAK,KAAK;AAClC,YAAY,SAAS,MAAM,SAAS,IAAI,CAAC;AAEzC,MAAM,cAAc,IAAI,KAAK,KAAK;AAClC,YAAY,SAAS,MAAM,SAAS,IAAI,CAAC;AAEzC,MAAM,WAAW,IAAI,KAAK,KAAK;AAC/B,SAAS,YAAY,MAAM,YAAY,IAAI,CAAC;AAKrC,MAAM,yBAAyB;AAAA,EAClC,YAAY;AAAA,IACR,OAAO;AAAA,IACP,UAAU,WAAW,WAAW;AAAA,EACpC;AAAA,EACA,WAAW;AAAA,IACP,OAAO;AAAA,IACP,UAAU,WAAW,SAAS;AAAA,EAClC;AAAA,EACA,aAAa;AAAA,IACT,OAAO;AAAA,IACP,UAAU,WAAW,WAAW;AAAA,EACpC;AAAA,EACA,aAAa;AAAA,IACT,OAAO;AAAA,IACP,UAAU,WAAW,WAAW;AAAA,EACpC;AAAA,EACA,aAAa;AAAA,IACT,OAAO;AAAA,IACP,UAAU,WAAW,WAAW;AAAA,EACpC;AAAA,EACA,UAAU;AAAA,IACN,OAAO;AAAA,IACP,UAAU,WAAW,QAAQ;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,IACN,OAAO;AAAA,EACX;AACJ;"}
|
package/dist/style.css
CHANGED
|
@@ -482,7 +482,7 @@ input[type="range"] {
|
|
|
482
482
|
--tw-contain-paint: ;
|
|
483
483
|
--tw-contain-style: ;
|
|
484
484
|
}/*
|
|
485
|
-
! tailwindcss v3.4.
|
|
485
|
+
! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com
|
|
486
486
|
*//*
|
|
487
487
|
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
488
488
|
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
@@ -1981,12 +1981,12 @@ input.tab:checked + .tab-content,
|
|
|
1981
1981
|
mask-repeat: no-repeat;
|
|
1982
1982
|
-webkit-mask-position: center;
|
|
1983
1983
|
mask-position: center;
|
|
1984
|
-
-webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='
|
|
1985
|
-
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='
|
|
1984
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
|
|
1985
|
+
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
|
|
1986
1986
|
}
|
|
1987
1987
|
.loading-spinner {
|
|
1988
|
-
-webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='
|
|
1989
|
-
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='
|
|
1988
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
|
|
1989
|
+
mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' stroke='black' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform-origin='center'%3E%3Ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dasharray' values='0,150;42,150;42,150' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='stroke-dashoffset' values='0;-16;-59' keyTimes='0;0.475;1' dur='1.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
|
|
1990
1990
|
}
|
|
1991
1991
|
.loading-md {
|
|
1992
1992
|
width: 1.5rem;
|
|
@@ -2083,6 +2083,9 @@ input.tab:checked + .tab-content,
|
|
|
2083
2083
|
margin-right: calc(0.5rem * var(--tw-space-x-reverse));
|
|
2084
2084
|
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
|
|
2085
2085
|
}
|
|
2086
|
+
.modal-action:where([dir="rtl"], [dir="rtl"] *) > :not([hidden]) ~ :not([hidden]) {
|
|
2087
|
+
--tw-space-x-reverse: 1;
|
|
2088
|
+
}
|
|
2086
2089
|
@keyframes modal-pop {
|
|
2087
2090
|
|
|
2088
2091
|
0% {
|
|
@@ -3148,6 +3151,9 @@ input.tab:checked + .tab-content,
|
|
|
3148
3151
|
.list-inside {
|
|
3149
3152
|
list-style-position: inside;
|
|
3150
3153
|
}
|
|
3154
|
+
.list-outside {
|
|
3155
|
+
list-style-position: outside;
|
|
3156
|
+
}
|
|
3151
3157
|
.list-disc {
|
|
3152
3158
|
list-style-type: disc;
|
|
3153
3159
|
}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { default as default_2 } from 'zod';
|
|
2
2
|
|
|
3
|
+
export declare type AxisMax = default_2.infer<typeof axisMaxSchema>;
|
|
4
|
+
|
|
5
|
+
declare const axisMaxSchema: default_2.ZodUnion<[default_2.ZodLiteral<"maxInData">, default_2.ZodLiteral<"limitTo1">, default_2.ZodNumber]>;
|
|
6
|
+
|
|
7
|
+
export declare type ConfidenceIntervalMethod = default_2.infer<typeof confidenceIntervalMethodSchema>;
|
|
8
|
+
|
|
9
|
+
declare const confidenceIntervalMethodSchema: default_2.ZodUnion<[default_2.ZodLiteral<"wilson">, default_2.ZodLiteral<"none">]>;
|
|
10
|
+
|
|
3
11
|
export declare type DateRangeOption = default_2.infer<typeof dateRangeOptionSchema>;
|
|
4
12
|
|
|
5
13
|
export declare class DateRangeOptionChangedEvent extends CustomEvent<DateRangeSelectOption> {
|
|
@@ -91,15 +99,56 @@ declare const namedLapisFilterSchema: default_2.ZodObject<{
|
|
|
91
99
|
displayName: string;
|
|
92
100
|
}>;
|
|
93
101
|
|
|
102
|
+
export declare type SelectedMutationFilterStrings = default_2.infer<typeof selectedMutationFilterStringsSchema>;
|
|
103
|
+
|
|
104
|
+
declare const selectedMutationFilterStringsSchema: default_2.ZodObject<{
|
|
105
|
+
nucleotideMutations: default_2.ZodArray<default_2.ZodString, "many">;
|
|
106
|
+
aminoAcidMutations: default_2.ZodArray<default_2.ZodString, "many">;
|
|
107
|
+
nucleotideInsertions: default_2.ZodArray<default_2.ZodString, "many">;
|
|
108
|
+
aminoAcidInsertions: default_2.ZodArray<default_2.ZodString, "many">;
|
|
109
|
+
}, "strip", default_2.ZodTypeAny, {
|
|
110
|
+
nucleotideMutations: string[];
|
|
111
|
+
aminoAcidMutations: string[];
|
|
112
|
+
nucleotideInsertions: string[];
|
|
113
|
+
aminoAcidInsertions: string[];
|
|
114
|
+
}, {
|
|
115
|
+
nucleotideMutations: string[];
|
|
116
|
+
aminoAcidMutations: string[];
|
|
117
|
+
nucleotideInsertions: string[];
|
|
118
|
+
aminoAcidInsertions: string[];
|
|
119
|
+
}>;
|
|
120
|
+
|
|
94
121
|
export declare type SequenceType = default_2.infer<typeof sequenceTypeSchema>;
|
|
95
122
|
|
|
96
123
|
declare const sequenceTypeSchema: default_2.ZodUnion<[default_2.ZodLiteral<"nucleotide">, default_2.ZodLiteral<"amino acid">]>;
|
|
97
124
|
|
|
125
|
+
export declare type TemporalGranularity = default_2.infer<typeof temporalGranularitySchema>;
|
|
126
|
+
|
|
127
|
+
declare const temporalGranularitySchema: default_2.ZodUnion<[default_2.ZodLiteral<"day">, default_2.ZodLiteral<"week">, default_2.ZodLiteral<"month">, default_2.ZodLiteral<"year">]>;
|
|
128
|
+
|
|
98
129
|
export declare const views: {
|
|
99
130
|
readonly table: "table";
|
|
100
131
|
readonly venn: "venn";
|
|
132
|
+
readonly grid: "grid";
|
|
133
|
+
readonly insertions: "insertions";
|
|
134
|
+
readonly bar: "bar";
|
|
135
|
+
readonly line: "line";
|
|
136
|
+
readonly bubble: "bubble";
|
|
101
137
|
};
|
|
102
138
|
|
|
139
|
+
export declare type YAxisMaxConfig = default_2.infer<typeof yAxisMaxConfigSchema>;
|
|
140
|
+
|
|
141
|
+
declare const yAxisMaxConfigSchema: default_2.ZodObject<{
|
|
142
|
+
linear: default_2.ZodOptional<default_2.ZodUnion<[default_2.ZodLiteral<"maxInData">, default_2.ZodLiteral<"limitTo1">, default_2.ZodNumber]>>;
|
|
143
|
+
logarithmic: default_2.ZodOptional<default_2.ZodUnion<[default_2.ZodLiteral<"maxInData">, default_2.ZodLiteral<"limitTo1">, default_2.ZodNumber]>>;
|
|
144
|
+
}, "strip", default_2.ZodTypeAny, {
|
|
145
|
+
linear?: number | "maxInData" | "limitTo1" | undefined;
|
|
146
|
+
logarithmic?: number | "maxInData" | "limitTo1" | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
linear?: number | "maxInData" | "limitTo1" | undefined;
|
|
149
|
+
logarithmic?: number | "maxInData" | "limitTo1" | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
|
|
103
152
|
export { }
|
|
104
153
|
|
|
105
154
|
|
|
@@ -128,11 +177,7 @@ declare global {
|
|
|
128
177
|
|
|
129
178
|
declare global {
|
|
130
179
|
interface HTMLElementTagNameMap {
|
|
131
|
-
'gs-
|
|
132
|
-
}
|
|
133
|
-
interface HTMLElementEventMap {
|
|
134
|
-
'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
|
|
135
|
-
'gs-date-range-option-changed': DateRangeOptionChangedEvent;
|
|
180
|
+
'gs-mutation-comparison-component': MutationComparisonComponent;
|
|
136
181
|
}
|
|
137
182
|
}
|
|
138
183
|
|
|
@@ -140,7 +185,7 @@ declare global {
|
|
|
140
185
|
declare global {
|
|
141
186
|
namespace JSX {
|
|
142
187
|
interface IntrinsicElements {
|
|
143
|
-
'gs-
|
|
188
|
+
'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
144
189
|
}
|
|
145
190
|
}
|
|
146
191
|
}
|
|
@@ -148,10 +193,7 @@ declare global {
|
|
|
148
193
|
|
|
149
194
|
declare global {
|
|
150
195
|
interface HTMLElementTagNameMap {
|
|
151
|
-
'gs-
|
|
152
|
-
}
|
|
153
|
-
interface HTMLElementEventMap {
|
|
154
|
-
'gs-location-changed': CustomEvent<Record<string, string>>;
|
|
196
|
+
'gs-mutations-component': MutationsComponent;
|
|
155
197
|
}
|
|
156
198
|
}
|
|
157
199
|
|
|
@@ -159,7 +201,7 @@ declare global {
|
|
|
159
201
|
declare global {
|
|
160
202
|
namespace JSX {
|
|
161
203
|
interface IntrinsicElements {
|
|
162
|
-
'gs-
|
|
204
|
+
'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
163
205
|
}
|
|
164
206
|
}
|
|
165
207
|
}
|
|
@@ -167,10 +209,7 @@ declare global {
|
|
|
167
209
|
|
|
168
210
|
declare global {
|
|
169
211
|
interface HTMLElementTagNameMap {
|
|
170
|
-
'gs-
|
|
171
|
-
}
|
|
172
|
-
interface HTMLElementEventMap {
|
|
173
|
-
'gs-text-input-changed': CustomEvent<Record<string, string>>;
|
|
212
|
+
'gs-prevalence-over-time': PrevalenceOverTimeComponent;
|
|
174
213
|
}
|
|
175
214
|
}
|
|
176
215
|
|
|
@@ -178,7 +217,7 @@ declare global {
|
|
|
178
217
|
declare global {
|
|
179
218
|
namespace JSX {
|
|
180
219
|
interface IntrinsicElements {
|
|
181
|
-
'gs-
|
|
220
|
+
'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
182
221
|
}
|
|
183
222
|
}
|
|
184
223
|
}
|
|
@@ -186,10 +225,7 @@ declare global {
|
|
|
186
225
|
|
|
187
226
|
declare global {
|
|
188
227
|
interface HTMLElementTagNameMap {
|
|
189
|
-
'gs-
|
|
190
|
-
}
|
|
191
|
-
interface HTMLElementEventMap {
|
|
192
|
-
'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
|
|
228
|
+
'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
|
|
193
229
|
}
|
|
194
230
|
}
|
|
195
231
|
|
|
@@ -197,7 +233,7 @@ declare global {
|
|
|
197
233
|
declare global {
|
|
198
234
|
namespace JSX {
|
|
199
235
|
interface IntrinsicElements {
|
|
200
|
-
'gs-
|
|
236
|
+
'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
201
237
|
}
|
|
202
238
|
}
|
|
203
239
|
}
|
|
@@ -205,10 +241,7 @@ declare global {
|
|
|
205
241
|
|
|
206
242
|
declare global {
|
|
207
243
|
interface HTMLElementTagNameMap {
|
|
208
|
-
'gs-
|
|
209
|
-
}
|
|
210
|
-
interface HTMLElementEventMap {
|
|
211
|
-
'gs-lineage-filter-changed': CustomEvent<Record<string, string>>;
|
|
244
|
+
'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
|
|
212
245
|
}
|
|
213
246
|
}
|
|
214
247
|
|
|
@@ -216,7 +249,7 @@ declare global {
|
|
|
216
249
|
declare global {
|
|
217
250
|
namespace JSX {
|
|
218
251
|
interface IntrinsicElements {
|
|
219
|
-
'gs-
|
|
252
|
+
'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
220
253
|
}
|
|
221
254
|
}
|
|
222
255
|
}
|
|
@@ -224,7 +257,7 @@ declare global {
|
|
|
224
257
|
|
|
225
258
|
declare global {
|
|
226
259
|
interface HTMLElementTagNameMap {
|
|
227
|
-
'gs-
|
|
260
|
+
'gs-aggregate': AggregateComponent;
|
|
228
261
|
}
|
|
229
262
|
}
|
|
230
263
|
|
|
@@ -232,7 +265,7 @@ declare global {
|
|
|
232
265
|
declare global {
|
|
233
266
|
namespace JSX {
|
|
234
267
|
interface IntrinsicElements {
|
|
235
|
-
'gs-
|
|
268
|
+
'gs-aggregate': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
236
269
|
}
|
|
237
270
|
}
|
|
238
271
|
}
|
|
@@ -240,7 +273,7 @@ declare global {
|
|
|
240
273
|
|
|
241
274
|
declare global {
|
|
242
275
|
interface HTMLElementTagNameMap {
|
|
243
|
-
'gs-mutations-
|
|
276
|
+
'gs-mutations-over-time': MutationsOverTimeComponent;
|
|
244
277
|
}
|
|
245
278
|
}
|
|
246
279
|
|
|
@@ -248,7 +281,7 @@ declare global {
|
|
|
248
281
|
declare global {
|
|
249
282
|
namespace JSX {
|
|
250
283
|
interface IntrinsicElements {
|
|
251
|
-
'gs-mutations-
|
|
284
|
+
'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
252
285
|
}
|
|
253
286
|
}
|
|
254
287
|
}
|
|
@@ -256,7 +289,7 @@ declare global {
|
|
|
256
289
|
|
|
257
290
|
declare global {
|
|
258
291
|
interface HTMLElementTagNameMap {
|
|
259
|
-
'gs-
|
|
292
|
+
'gs-statistics': StatisticsComponent;
|
|
260
293
|
}
|
|
261
294
|
}
|
|
262
295
|
|
|
@@ -264,7 +297,7 @@ declare global {
|
|
|
264
297
|
declare global {
|
|
265
298
|
namespace JSX {
|
|
266
299
|
interface IntrinsicElements {
|
|
267
|
-
'gs-
|
|
300
|
+
'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
268
301
|
}
|
|
269
302
|
}
|
|
270
303
|
}
|
|
@@ -272,7 +305,11 @@ declare global {
|
|
|
272
305
|
|
|
273
306
|
declare global {
|
|
274
307
|
interface HTMLElementTagNameMap {
|
|
275
|
-
'gs-
|
|
308
|
+
'gs-date-range-selector': DateRangeSelectorComponent;
|
|
309
|
+
}
|
|
310
|
+
interface HTMLElementEventMap {
|
|
311
|
+
'gs-date-range-filter-changed': CustomEvent<Record<string, string>>;
|
|
312
|
+
'gs-date-range-option-changed': DateRangeOptionChangedEvent;
|
|
276
313
|
}
|
|
277
314
|
}
|
|
278
315
|
|
|
@@ -280,7 +317,7 @@ declare global {
|
|
|
280
317
|
declare global {
|
|
281
318
|
namespace JSX {
|
|
282
319
|
interface IntrinsicElements {
|
|
283
|
-
'gs-
|
|
320
|
+
'gs-date-range-selector': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
284
321
|
}
|
|
285
322
|
}
|
|
286
323
|
}
|
|
@@ -288,7 +325,10 @@ declare global {
|
|
|
288
325
|
|
|
289
326
|
declare global {
|
|
290
327
|
interface HTMLElementTagNameMap {
|
|
291
|
-
'gs-
|
|
328
|
+
'gs-location-filter': LocationFilterComponent;
|
|
329
|
+
}
|
|
330
|
+
interface HTMLElementEventMap {
|
|
331
|
+
'gs-location-changed': CustomEvent<Record<string, string>>;
|
|
292
332
|
}
|
|
293
333
|
}
|
|
294
334
|
|
|
@@ -296,7 +336,7 @@ declare global {
|
|
|
296
336
|
declare global {
|
|
297
337
|
namespace JSX {
|
|
298
338
|
interface IntrinsicElements {
|
|
299
|
-
'gs-
|
|
339
|
+
'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
300
340
|
}
|
|
301
341
|
}
|
|
302
342
|
}
|
|
@@ -304,7 +344,10 @@ declare global {
|
|
|
304
344
|
|
|
305
345
|
declare global {
|
|
306
346
|
interface HTMLElementTagNameMap {
|
|
307
|
-
'gs-
|
|
347
|
+
'gs-text-input': TextInputComponent;
|
|
348
|
+
}
|
|
349
|
+
interface HTMLElementEventMap {
|
|
350
|
+
'gs-text-input-changed': CustomEvent<Record<string, string>>;
|
|
308
351
|
}
|
|
309
352
|
}
|
|
310
353
|
|
|
@@ -312,7 +355,7 @@ declare global {
|
|
|
312
355
|
declare global {
|
|
313
356
|
namespace JSX {
|
|
314
357
|
interface IntrinsicElements {
|
|
315
|
-
'gs-
|
|
358
|
+
'gs-text-input': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
316
359
|
}
|
|
317
360
|
}
|
|
318
361
|
}
|
|
@@ -320,7 +363,10 @@ declare global {
|
|
|
320
363
|
|
|
321
364
|
declare global {
|
|
322
365
|
interface HTMLElementTagNameMap {
|
|
323
|
-
'gs-
|
|
366
|
+
'gs-mutation-filter': MutationFilterComponent;
|
|
367
|
+
}
|
|
368
|
+
interface HTMLElementEventMap {
|
|
369
|
+
'gs-mutation-filter-changed': CustomEvent<SelectedMutationFilterStrings>;
|
|
324
370
|
}
|
|
325
371
|
}
|
|
326
372
|
|
|
@@ -328,7 +374,7 @@ declare global {
|
|
|
328
374
|
declare global {
|
|
329
375
|
namespace JSX {
|
|
330
376
|
interface IntrinsicElements {
|
|
331
|
-
'gs-
|
|
377
|
+
'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
332
378
|
}
|
|
333
379
|
}
|
|
334
380
|
}
|
|
@@ -336,7 +382,10 @@ declare global {
|
|
|
336
382
|
|
|
337
383
|
declare global {
|
|
338
384
|
interface HTMLElementTagNameMap {
|
|
339
|
-
'gs-
|
|
385
|
+
'gs-lineage-filter': LineageFilterComponent;
|
|
386
|
+
}
|
|
387
|
+
interface HTMLElementEventMap {
|
|
388
|
+
'gs-lineage-filter-changed': CustomEvent<Record<string, string>>;
|
|
340
389
|
}
|
|
341
390
|
}
|
|
342
391
|
|
|
@@ -344,7 +393,7 @@ declare global {
|
|
|
344
393
|
declare global {
|
|
345
394
|
namespace JSX {
|
|
346
395
|
interface IntrinsicElements {
|
|
347
|
-
'gs-
|
|
396
|
+
'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
348
397
|
}
|
|
349
398
|
}
|
|
350
399
|
}
|
package/dist/util.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genspectrum/dashboard-components",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "GenSpectrum web components for building dashboards",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@storybook/preact": "^8.0.9",
|
|
108
108
|
"@storybook/preact-vite": "^8.0.9",
|
|
109
109
|
"@storybook/test": "^8.0.0",
|
|
110
|
-
"@storybook/test-runner": "^0.
|
|
110
|
+
"@storybook/test-runner": "^0.20.1",
|
|
111
111
|
"@storybook/types": "^8.0.9",
|
|
112
112
|
"@storybook/web-components": "^8.0.9",
|
|
113
113
|
"@storybook/web-components-vite": "^8.0.9",
|
|
@@ -5,6 +5,7 @@ import aggregatedData from './__mockData__/aggregated.json';
|
|
|
5
5
|
import { Aggregate, type AggregateProps } from './aggregate';
|
|
6
6
|
import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
|
|
7
7
|
import { LapisUrlContext } from '../LapisUrlContext';
|
|
8
|
+
import { expectInvalidAttributesErrorMessage } from '../shared/stories/expectInvalidAttributesErrorMessage';
|
|
8
9
|
|
|
9
10
|
const meta: Meta<AggregateProps> = {
|
|
10
11
|
title: 'Visualization/Aggregate',
|
|
@@ -94,3 +95,16 @@ export const FailsLoadingData: StoryObj<AggregateProps> = {
|
|
|
94
95
|
});
|
|
95
96
|
},
|
|
96
97
|
};
|
|
98
|
+
|
|
99
|
+
export const WithEmptyFieldString: StoryObj<AggregateProps> = {
|
|
100
|
+
...Default,
|
|
101
|
+
args: {
|
|
102
|
+
...Default.args,
|
|
103
|
+
fields: [''],
|
|
104
|
+
},
|
|
105
|
+
play: async ({ canvasElement, step }) => {
|
|
106
|
+
step('expect error message', async () => {
|
|
107
|
+
await expectInvalidAttributesErrorMessage(canvasElement, 'String must contain at least 1 character(s)');
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type FunctionComponent } from 'preact';
|
|
2
2
|
import { useContext } from 'preact/hooks';
|
|
3
|
+
import z from 'zod';
|
|
3
4
|
|
|
4
5
|
import { AggregateTable } from './aggregate-table';
|
|
5
6
|
import { type AggregateData, queryAggregateData } from '../../query/queryAggregateData';
|
|
6
|
-
import {
|
|
7
|
+
import { lapisFilterSchema, views } from '../../types';
|
|
7
8
|
import { LapisUrlContext } from '../LapisUrlContext';
|
|
8
9
|
import { CsvDownloadButton } from '../components/csv-download-button';
|
|
9
10
|
import { ErrorBoundary } from '../components/error-boundary';
|
|
@@ -15,26 +16,27 @@ import { ResizeContainer } from '../components/resize-container';
|
|
|
15
16
|
import Tabs from '../components/tabs';
|
|
16
17
|
import { useQuery } from '../useQuery';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
19
|
+
const viewSchema = z.literal(views.table);
|
|
20
|
+
export type View = z.infer<typeof viewSchema>;
|
|
21
|
+
|
|
22
|
+
const aggregatePropsSchema = z.object({
|
|
23
|
+
filter: lapisFilterSchema,
|
|
24
|
+
fields: z.array(z.string().min(1)),
|
|
25
|
+
views: z.array(viewSchema),
|
|
26
|
+
initialSortField: z.string(),
|
|
27
|
+
initialSortDirection: z.union([z.literal('ascending'), z.literal('descending')]),
|
|
28
|
+
pageSize: z.union([z.boolean(), z.number()]),
|
|
29
|
+
width: z.string(),
|
|
30
|
+
height: z.string(),
|
|
31
|
+
});
|
|
32
|
+
export type AggregateProps = z.infer<typeof aggregatePropsSchema>;
|
|
31
33
|
|
|
32
34
|
export const Aggregate: FunctionComponent<AggregateProps> = (componentProps) => {
|
|
33
35
|
const { width, height } = componentProps;
|
|
34
36
|
const size = { height, width };
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
|
-
<ErrorBoundary size={size}>
|
|
39
|
+
<ErrorBoundary size={size} schema={aggregatePropsSchema} componentProps={componentProps}>
|
|
38
40
|
<ResizeContainer size={size}>
|
|
39
41
|
<AggregateInner {...componentProps} />
|
|
40
42
|
</ResizeContainer>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Meta, type StoryObj } from '@storybook/preact';
|
|
2
2
|
import { expect, waitFor, within } from '@storybook/test';
|
|
3
|
+
import z from 'zod';
|
|
3
4
|
|
|
4
5
|
import { ErrorBoundary } from './error-boundary';
|
|
5
6
|
import { UserFacingError } from './error-display';
|
|
@@ -21,9 +22,15 @@ const meta: Meta = {
|
|
|
21
22
|
|
|
22
23
|
export default meta;
|
|
23
24
|
|
|
25
|
+
const someSchema = z.object({
|
|
26
|
+
test: z.string().min(1),
|
|
27
|
+
});
|
|
28
|
+
const someValidProps = { test: 'someValue' };
|
|
29
|
+
const someInvalidProps = { test: '' };
|
|
30
|
+
|
|
24
31
|
export const ErrorBoundaryWithoutErrorStory: StoryObj = {
|
|
25
32
|
render: (args) => (
|
|
26
|
-
<ErrorBoundary size={args.size}>
|
|
33
|
+
<ErrorBoundary size={args.size} schema={someSchema} componentProps={someValidProps}>
|
|
27
34
|
<div>Some content</div>
|
|
28
35
|
</ErrorBoundary>
|
|
29
36
|
),
|
|
@@ -36,7 +43,7 @@ export const ErrorBoundaryWithoutErrorStory: StoryObj = {
|
|
|
36
43
|
|
|
37
44
|
export const ErrorBoundaryWithErrorStory: StoryObj = {
|
|
38
45
|
render: (args) => (
|
|
39
|
-
<ErrorBoundary size={args.size}>
|
|
46
|
+
<ErrorBoundary size={args.size} schema={someSchema} componentProps={someValidProps}>
|
|
40
47
|
<ContentThatThrowsError error={() => new Error('Some error')} />
|
|
41
48
|
</ErrorBoundary>
|
|
42
49
|
),
|
|
@@ -48,9 +55,23 @@ export const ErrorBoundaryWithErrorStory: StoryObj = {
|
|
|
48
55
|
},
|
|
49
56
|
};
|
|
50
57
|
|
|
58
|
+
export const ErrorBoundaryWithParsingErrorStory: StoryObj = {
|
|
59
|
+
render: (args) => (
|
|
60
|
+
<ErrorBoundary size={args.size} schema={someSchema} componentProps={someInvalidProps}>
|
|
61
|
+
<ContentThatThrowsError error={() => new Error('Some error')} />
|
|
62
|
+
</ErrorBoundary>
|
|
63
|
+
),
|
|
64
|
+
play: async ({ canvasElement }) => {
|
|
65
|
+
const canvas = within(canvasElement);
|
|
66
|
+
const content = canvas.queryByText('Some content.', { exact: false });
|
|
67
|
+
await waitFor(() => expect(content).not.toBeInTheDocument());
|
|
68
|
+
await waitFor(() => expect(canvas.getByText('Error - Invalid component attributes')).toBeInTheDocument());
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
51
72
|
export const ErrorBoundaryWithUserFacingErrorStory: StoryObj = {
|
|
52
73
|
render: (args) => (
|
|
53
|
-
<ErrorBoundary size={args.size}>
|
|
74
|
+
<ErrorBoundary size={args.size} schema={someSchema} componentProps={someValidProps}>
|
|
54
75
|
<ContentThatThrowsError error={() => new UserFacingError('Error Headline', 'Some error')} />
|
|
55
76
|
</ErrorBoundary>
|
|
56
77
|
),
|
|
@@ -7,9 +7,9 @@ import { ResizeContainer, type Size } from './resize-container';
|
|
|
7
7
|
|
|
8
8
|
type ErrorBoundaryProps<T> = {
|
|
9
9
|
size: Size;
|
|
10
|
+
componentProps: T;
|
|
11
|
+
schema: ZodSchema<T>;
|
|
10
12
|
layout?: ErrorDisplayProps['layout'];
|
|
11
|
-
componentProps?: T;
|
|
12
|
-
schema?: ZodSchema<T>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const ErrorBoundary = <T extends Record<string, unknown>>({
|
|
@@ -41,8 +41,7 @@ export const ErrorBoundary = <T extends Record<string, unknown>>({
|
|
|
41
41
|
return <>{children}</>;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
function useCheckComponentProps<T extends Record<string, unknown>>(schema?: ZodSchema<T>, componentProps?: T) {
|
|
44
|
+
function useCheckComponentProps<T extends Record<string, unknown>>(schema: ZodSchema<T>, componentProps: T) {
|
|
46
45
|
return useMemo(() => {
|
|
47
46
|
if (schema === undefined || componentProps === undefined) {
|
|
48
47
|
return undefined;
|