@reshape-biotech/design-system 0.0.54 → 1.1.2

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 (181) hide show
  1. package/dist/components/activity/Activity.stories.svelte +21 -8
  2. package/dist/components/activity/Activity.svelte +44 -6
  3. package/dist/components/activity/Activity.svelte.d.ts +1 -1
  4. package/dist/components/avatar/Avatar.stories.svelte +7 -17
  5. package/dist/components/avatar/Avatar.svelte +2 -2
  6. package/dist/components/avatar/Avatar.svelte.d.ts +2 -2
  7. package/dist/components/banner/Banner.stories.svelte +5 -5
  8. package/dist/components/banner/Banner.svelte +1 -1
  9. package/dist/components/button/Button.stories.svelte +54 -21
  10. package/dist/components/button/Button.svelte +58 -11
  11. package/dist/components/button/Button.svelte.d.ts +4 -3
  12. package/dist/components/card/Card.stories.svelte +130 -0
  13. package/dist/components/card/Card.stories.svelte.d.ts +19 -0
  14. package/dist/components/card/Card.svelte +25 -0
  15. package/dist/components/card/Card.svelte.d.ts +10 -0
  16. package/dist/components/card/index.d.ts +1 -0
  17. package/dist/components/card/index.js +1 -0
  18. package/dist/components/checkbox/Checkbox.stories.svelte +7 -15
  19. package/dist/components/checkbox/Checkbox.svelte +7 -7
  20. package/dist/components/checkbox/Checkbox.svelte.d.ts +3 -5
  21. package/dist/components/collapsible/Collapsible.stories.svelte +5 -4
  22. package/dist/components/combobox/Combobox.stories.svelte +7 -5
  23. package/dist/components/datepicker/DatePicker.stories.svelte +13 -18
  24. package/dist/components/datepicker/DatePicker.svelte +1 -0
  25. package/dist/components/divider/Divider.stories.svelte +1 -3
  26. package/dist/components/divider/Divider.svelte +8 -2
  27. package/dist/components/divider/Divider.svelte.d.ts +2 -0
  28. package/dist/components/drawer/Drawer.stories.svelte +3 -3
  29. package/dist/components/dropdown/Dropdown.stories.svelte +8 -8
  30. package/dist/components/empty-content/EmptyContent.stories.svelte +2 -2
  31. package/dist/components/graphs/bar-chart/BarChart.stories.svelte +81 -0
  32. package/dist/components/graphs/bar-chart/BarChart.stories.svelte.d.ts +19 -0
  33. package/dist/components/graphs/bar-chart/BarChart.svelte +136 -0
  34. package/dist/components/graphs/bar-chart/BarChart.svelte.d.ts +15 -0
  35. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +42 -0
  36. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte.d.ts +19 -0
  37. package/dist/components/graphs/bar-chart/StackedBarChart.svelte +177 -0
  38. package/dist/components/graphs/bar-chart/StackedBarChart.svelte.d.ts +16 -0
  39. package/dist/components/graphs/chart/Chart.stories.svelte +30 -25
  40. package/dist/components/graphs/chart/Chart.svelte +104 -32
  41. package/dist/components/graphs/chart/Chart.svelte.d.ts +15 -5
  42. package/dist/components/graphs/index.d.ts +3 -0
  43. package/dist/components/graphs/index.js +3 -0
  44. package/dist/components/graphs/line/LineChart.stories.svelte +97 -17
  45. package/dist/components/graphs/line/LineChart.svelte +90 -51
  46. package/dist/components/graphs/line/LineChart.svelte.d.ts +6 -13
  47. package/dist/components/graphs/matrix/Matrix.stories.svelte +142 -0
  48. package/dist/components/graphs/matrix/Matrix.stories.svelte.d.ts +19 -0
  49. package/dist/components/graphs/matrix/Matrix.svelte +149 -0
  50. package/dist/components/graphs/matrix/Matrix.svelte.d.ts +24 -0
  51. package/dist/components/graphs/matrix/index.d.ts +3 -0
  52. package/dist/components/graphs/matrix/index.js +3 -0
  53. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +115 -28
  54. package/dist/components/graphs/multiline/MultiLineChart.svelte +187 -50
  55. package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +9 -12
  56. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +68 -41
  57. package/dist/components/graphs/scatterplot/Scatterplot.svelte +312 -45
  58. package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +23 -13
  59. package/dist/components/graphs/utils/tooltipFormatter.d.ts +10 -0
  60. package/dist/components/graphs/utils/tooltipFormatter.js +52 -0
  61. package/dist/components/icon-button/IconButton.stories.svelte +6 -6
  62. package/dist/components/icon-button/IconButton.svelte +50 -9
  63. package/dist/components/icon-button/IconButton.svelte.d.ts +3 -5
  64. package/dist/components/icons/AnalysisIcon.stories.svelte +15 -21
  65. package/dist/components/icons/AnalysisIcon.svelte +63 -44
  66. package/dist/components/icons/AnalysisIcon.svelte.d.ts +1 -0
  67. package/dist/components/icons/Icon.stories.svelte +4 -4
  68. package/dist/components/icons/Icon.svelte +1 -1
  69. package/dist/components/icons/PrincipalIcon.svelte +96 -0
  70. package/dist/components/icons/PrincipalIcon.svelte.d.ts +10 -0
  71. package/dist/components/icons/custom/Halo.svelte +14 -8
  72. package/dist/components/icons/custom/Halo.svelte.d.ts +7 -25
  73. package/dist/components/icons/custom/Well.svelte +14 -6
  74. package/dist/components/icons/custom/Well.svelte.d.ts +7 -25
  75. package/dist/components/icons/index.d.ts +3 -2
  76. package/dist/components/icons/index.js +34 -0
  77. package/dist/components/input/Input.stories.svelte +16 -22
  78. package/dist/components/input/Input.svelte +140 -134
  79. package/dist/components/input/Input.svelte.d.ts +12 -13
  80. package/dist/components/label/Label.stories.svelte +28 -0
  81. package/dist/components/label/Label.stories.svelte.d.ts +19 -0
  82. package/dist/components/label/Label.svelte +17 -0
  83. package/dist/components/label/Label.svelte.d.ts +9 -0
  84. package/dist/components/list/List.stories.svelte +3 -3
  85. package/dist/components/logo/Logo.stories.svelte +1 -1
  86. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +125 -0
  87. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte.d.ts +3 -0
  88. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +577 -0
  89. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte.d.ts +16 -0
  90. package/dist/components/manual-cfu-counter/index.d.ts +1 -0
  91. package/dist/components/manual-cfu-counter/index.js +1 -0
  92. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +22 -0
  93. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte.d.ts +19 -0
  94. package/dist/components/markdown/Markdown.stories.svelte +1 -1
  95. package/dist/components/markdown/Markdown.svelte +1 -1
  96. package/dist/components/modal/Modal.stories.svelte +2 -2
  97. package/dist/components/modal/Modal.svelte +27 -22
  98. package/dist/components/modal/Modal.svelte.d.ts +4 -1
  99. package/dist/components/notification-popup/NotificationPopup.stories.svelte +1 -1
  100. package/dist/components/pill/Pill.stories.svelte +13 -0
  101. package/dist/components/pill/Pill.stories.svelte.d.ts +19 -0
  102. package/dist/components/progress-circle/ProgressCircle.stories.svelte +15 -0
  103. package/dist/components/progress-circle/ProgressCircle.stories.svelte.d.ts +19 -0
  104. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +28 -0
  105. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte.d.ts +19 -0
  106. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +22 -0
  107. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte.d.ts +8 -0
  108. package/dist/components/required-status-indicator/index.d.ts +1 -0
  109. package/dist/components/required-status-indicator/index.js +1 -0
  110. package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +3 -3
  111. package/dist/components/select/Select.stories.svelte +12 -12
  112. package/dist/components/select/Select.svelte +0 -2
  113. package/dist/components/select-new/Select.stories.svelte +219 -0
  114. package/dist/components/select-new/Select.stories.svelte.d.ts +19 -0
  115. package/dist/components/select-new/components/Group.svelte +24 -0
  116. package/dist/components/select-new/components/Group.svelte.d.ts +11 -0
  117. package/dist/components/select-new/components/MultiSelectTrigger.svelte +66 -0
  118. package/dist/components/select-new/components/MultiSelectTrigger.svelte.d.ts +17 -0
  119. package/dist/components/select-new/components/SelectContent.svelte +33 -0
  120. package/dist/components/select-new/components/SelectContent.svelte.d.ts +10 -0
  121. package/dist/components/select-new/components/SelectGroupHeading.svelte +19 -0
  122. package/dist/components/select-new/components/SelectGroupHeading.svelte.d.ts +9 -0
  123. package/dist/components/select-new/components/SelectItem.svelte +41 -0
  124. package/dist/components/select-new/components/SelectItem.svelte.d.ts +9 -0
  125. package/dist/components/select-new/components/SelectTrigger.svelte +48 -0
  126. package/dist/components/select-new/components/SelectTrigger.svelte.d.ts +12 -0
  127. package/dist/components/select-new/index.d.ts +10 -0
  128. package/dist/components/select-new/index.js +12 -0
  129. package/dist/components/select-new/types.d.ts +25 -0
  130. package/dist/components/select-new/types.js +1 -0
  131. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +92 -0
  132. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +3 -0
  133. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +65 -0
  134. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +3 -0
  135. package/dist/components/sjsf-wrappers/index.d.ts +2 -0
  136. package/dist/components/sjsf-wrappers/index.js +2 -0
  137. package/dist/components/sjsf-wrappers/sjsfCustomTheme.d.ts +2 -0
  138. package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +8 -0
  139. package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +4 -4
  140. package/dist/components/slider/Slider.stories.svelte +4 -4
  141. package/dist/components/spinner/Spinner.stories.svelte +13 -0
  142. package/dist/components/spinner/Spinner.stories.svelte.d.ts +19 -0
  143. package/dist/components/stat-card/StatCard.stories.svelte +27 -19
  144. package/dist/components/stat-card/StatCard.svelte +100 -6
  145. package/dist/components/stat-card/StatCard.svelte.d.ts +3 -0
  146. package/dist/components/status-badge/StatusBadge.stories.svelte +6 -6
  147. package/dist/components/status-badge/StatusBadge.svelte +5 -3
  148. package/dist/components/stepper/Stepper.stories.svelte +243 -0
  149. package/dist/components/stepper/Stepper.stories.svelte.d.ts +19 -0
  150. package/dist/components/stepper/components/stepper-root.svelte +20 -0
  151. package/dist/components/stepper/components/stepper-root.svelte.d.ts +9 -0
  152. package/dist/components/stepper/components/stepper-step.svelte +100 -0
  153. package/dist/components/stepper/components/stepper-step.svelte.d.ts +11 -0
  154. package/dist/components/stepper/index.d.ts +15 -0
  155. package/dist/components/stepper/index.js +2 -0
  156. package/dist/components/table/Table.stories.svelte +1 -1
  157. package/dist/components/table/components/Td.svelte +3 -2
  158. package/dist/components/table/components/Td.svelte.d.ts +1 -0
  159. package/dist/components/table/components/Tr.svelte +3 -2
  160. package/dist/components/table/components/Tr.svelte.d.ts +1 -0
  161. package/dist/components/tabs/Tabs.stories.svelte +1 -1
  162. package/dist/components/tag/Tag.stories.svelte +9 -9
  163. package/dist/components/tag/Tag.svelte +0 -18
  164. package/dist/components/textarea/Textarea.stories.svelte +97 -0
  165. package/dist/components/textarea/Textarea.stories.svelte.d.ts +19 -0
  166. package/dist/components/textarea/Textarea.svelte +94 -0
  167. package/dist/components/textarea/Textarea.svelte.d.ts +17 -0
  168. package/dist/components/textarea/index.d.ts +1 -0
  169. package/dist/components/textarea/index.js +1 -0
  170. package/dist/components/toggle/Toggle.stories.svelte +1 -1
  171. package/dist/components/toggle/Toggle.svelte +3 -2
  172. package/dist/components/toggle/Toggle.svelte.d.ts +1 -0
  173. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +6 -6
  174. package/dist/components/tooltip/Tooltip.stories.svelte +6 -6
  175. package/dist/components/tooltip/Tooltip.svelte +1 -1
  176. package/dist/index.d.ts +7 -0
  177. package/dist/index.js +7 -0
  178. package/dist/tailwind.preset.d.ts +5 -0
  179. package/dist/tokens.d.ts +10 -0
  180. package/dist/tokens.js +6 -4
  181. package/package.json +1 -2
@@ -0,0 +1,142 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Matrix from './Matrix.svelte';
4
+ import { backgroundColor } from '../../../tokens';
5
+
6
+ const { Story } = defineMeta({
7
+ component: Matrix,
8
+ title: 'Design System/Graphs/Matrix',
9
+ tags: ['autodocs']
10
+ });
11
+
12
+ // Create sample data for a confusion matrix
13
+ // Format: [row][col] where row = manual label, col = model prediction
14
+ const confusionMatrix = [
15
+ [
16
+ { value: 2, row: 1, col: 0, backgroundColor: backgroundColor.danger }, // Top-left (Not TNTC/TNTC)
17
+ { value: 123, row: 1, col: 1, backgroundColor: backgroundColor.success } // Top-right (Not TNTC/Not TNTC)
18
+ ],
19
+ [
20
+ { value: 27, row: 0, col: 1, backgroundColor: backgroundColor.success }, // Bottom-right (TNTC/Not TNTC)
21
+ { value: 8, row: 0, col: 0, backgroundColor: backgroundColor.danger } // Bottom-left (TNTC/TNTC)
22
+ ]
23
+ ];
24
+
25
+ const rowLabels = ['TNTC', 'Not TNTC'];
26
+ const colLabels = ['TNTC', 'Not TNTC'];
27
+
28
+ function handleCellClick(cell: any) {
29
+ console.log('Cell clicked:', cell);
30
+ }
31
+
32
+ function handleCellHover(cell: any) {
33
+ console.log('Cell hover:', cell);
34
+ }
35
+
36
+ // Sample data with more categories
37
+ const multiclassMatrix = [
38
+ [
39
+ { value: 45, row: 0, col: 0, backgroundColor: backgroundColor.success },
40
+ { value: 12, row: 0, col: 1, backgroundColor: backgroundColor.neutral },
41
+ { value: 3, row: 0, col: 2, backgroundColor: backgroundColor.neutral }
42
+ ],
43
+ [
44
+ { value: 8, row: 1, col: 0, backgroundColor: backgroundColor.neutral },
45
+ { value: 78, row: 1, col: 1, backgroundColor: backgroundColor.success },
46
+ { value: 5, row: 1, col: 2, backgroundColor: backgroundColor.neutral }
47
+ ],
48
+ [
49
+ { value: 2, row: 2, col: 0, backgroundColor: backgroundColor.neutral },
50
+ { value: 6, row: 2, col: 1, backgroundColor: backgroundColor.neutral },
51
+ { value: 52, row: 2, col: 2, backgroundColor: backgroundColor.success }
52
+ ]
53
+ ];
54
+
55
+ const multiclassLabels = ['Class A', 'Class B', 'Class C'];
56
+
57
+ // Custom colored matrix
58
+ const customColorMatrix = [
59
+ [
60
+ { value: 8, row: 0, col: 0, backgroundColor: 'rgba(200, 250, 205, 0.8)' }, // Custom green
61
+ { value: 27, row: 0, col: 1, backgroundColor: 'rgba(255, 235, 235, 0.8)' } // Custom red tint
62
+ ],
63
+ [
64
+ { value: 2, row: 1, col: 0, backgroundColor: 'rgba(255, 235, 235, 0.8)' },
65
+ { value: 123, row: 1, col: 1, backgroundColor: 'rgba(200, 250, 205, 0.8)' }
66
+ ]
67
+ ];
68
+ </script>
69
+
70
+ <Story name="TNTC Confusion Matrix" asChild>
71
+ <div class="h-[500px] w-full">
72
+ <Matrix
73
+ data={confusionMatrix}
74
+ {rowLabels}
75
+ {colLabels}
76
+ xAxisName="Model count"
77
+ yAxisName="Manual count"
78
+ onCellClick={handleCellClick}
79
+ onCellHover={handleCellHover}
80
+ />
81
+ </div>
82
+ </Story>
83
+
84
+ <Story name="Multiple Classes" asChild>
85
+ <div class="h-[500px] w-full">
86
+ <Matrix
87
+ data={multiclassMatrix}
88
+ rowLabels={multiclassLabels}
89
+ colLabels={multiclassLabels}
90
+ invertYAxis={true}
91
+ xAxisName="Model count"
92
+ yAxisName="Manual count"
93
+ />
94
+ </div>
95
+ </Story>
96
+
97
+ <Story name="Non-Inverted Axis" asChild>
98
+ <div class="h-[500px] w-full">
99
+ <Matrix
100
+ data={confusionMatrix}
101
+ {rowLabels}
102
+ {colLabels}
103
+ invertYAxis={false}
104
+ xAxisName="Model count"
105
+ yAxisName="Manual count"
106
+ />
107
+ </div>
108
+ </Story>
109
+
110
+ <Story name="Custom Colors" asChild>
111
+ <div class="h-[500px] w-full">
112
+ <Matrix
113
+ data={customColorMatrix}
114
+ {rowLabels}
115
+ {colLabels}
116
+ invertYAxis={true}
117
+ xAxisName="Model count"
118
+ yAxisName="Manual count"
119
+ />
120
+ <div class="mt-4 text-center text-sm">
121
+ <p>Using custom colors directly in the cell objects</p>
122
+ </div>
123
+ </div>
124
+ </Story>
125
+
126
+ <Story name="Semantic Colors" asChild>
127
+ <div class="h-[500px] w-full">
128
+ <Matrix
129
+ data={confusionMatrix}
130
+ {rowLabels}
131
+ {colLabels}
132
+ invertYAxis={true}
133
+ xAxisName="Model count"
134
+ yAxisName="Manual count"
135
+ />
136
+ <div class="mt-4 text-center text-sm">
137
+ <p>Using semantic colors from tokens:</p>
138
+ <p>Diagonal cells: backgroundColor.success</p>
139
+ <p>Off-diagonal cells: backgroundColor.neutral</p>
140
+ </div>
141
+ </div>
142
+ </Story>
@@ -0,0 +1,19 @@
1
+ import Matrix from './Matrix.svelte';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const Matrix: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, string>;
18
+ type Matrix = InstanceType<typeof Matrix>;
19
+ export default Matrix;
@@ -0,0 +1,149 @@
1
+ <script lang="ts" module>
2
+ export interface Cell {
3
+ value: number;
4
+ row: number;
5
+ col: number;
6
+ highlighted?: boolean;
7
+ backgroundColor?: string;
8
+ hideAxisNames?: boolean;
9
+ }
10
+
11
+ export type MatrixChartProps = {
12
+ /**
13
+ * Matrix data as a 2D array (cells[row][col])
14
+ */
15
+ data: Cell[][];
16
+ rowLabels: string[];
17
+ colLabels: string[];
18
+ onCellClick?: (cell: Cell) => void;
19
+ onCellHover?: (cell: Cell) => void;
20
+ invertYAxis?: boolean;
21
+ hideAxisNames?: boolean;
22
+ } & Omit<GenericChartProps, 'timeIndex'>;
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import { backgroundColor } from '../../../tokens';
27
+ import type { GenericChartProps } from '../chart/Chart.svelte';
28
+
29
+ const {
30
+ data,
31
+ rowLabels,
32
+ colLabels,
33
+ xAxisName,
34
+ yAxisName,
35
+ width = '100%',
36
+ height = '100%',
37
+ onCellClick,
38
+ onCellHover,
39
+ loading = false,
40
+ invertYAxis = false,
41
+ hideAxisNames = false
42
+ }: MatrixChartProps = $props();
43
+
44
+ let container: HTMLElement | undefined = $state();
45
+
46
+ function getCellWithColor(cell: Cell): Cell {
47
+ let defaultBackgroundColor: string;
48
+
49
+ if (data.length === 2 && data[0].length === 2) {
50
+ const isDiagonal = cell.row === cell.col;
51
+ defaultBackgroundColor = isDiagonal ? backgroundColor.success : backgroundColor.neutral;
52
+ } else {
53
+ defaultBackgroundColor = backgroundColor.neutral;
54
+ }
55
+
56
+ return {
57
+ ...cell,
58
+ backgroundColor: cell.backgroundColor || defaultBackgroundColor
59
+ };
60
+ }
61
+
62
+ let displayData = $derived(
63
+ invertYAxis
64
+ ? [...data].reverse().map((row) => row.map((cell) => getCellWithColor(cell)))
65
+ : data.map((row) => row.map((cell) => getCellWithColor(cell)))
66
+ );
67
+
68
+ let displayRowLabels = $derived(invertYAxis ? [...rowLabels].reverse() : rowLabels);
69
+
70
+ function handleCellClick(cell: Cell) {
71
+ if (onCellClick) {
72
+ onCellClick(cell);
73
+ }
74
+ }
75
+
76
+ function handleCellHover(cell: Cell) {
77
+ if (onCellHover) {
78
+ onCellHover(cell);
79
+ }
80
+ }
81
+ </script>
82
+
83
+ <div class="flex h-full w-full flex-col" style="width: {width}; height: {height};">
84
+ {#if xAxisName && !hideAxisNames}
85
+ <!-- 80px is the width of the yAxisName, 72px is the width of the yAxisName, 72px is the yLabels -->
86
+ <div class="flex w-[calc(100%-72px-72px)] items-center self-end text-center">
87
+ <div class="mb-2 inline-block w-full border-b pb-3 text-sm font-normal text-secondary">
88
+ {xAxisName}
89
+ </div>
90
+ </div>
91
+ {/if}
92
+
93
+ <div class="flex h-full flex-1 flex-row overflow-hidden">
94
+ {#if yAxisName && !hideAxisNames}
95
+ <!-- 26px is the height of the xAxisName -->
96
+ <div class="mr-2 flex h-[calc(100%-26px)] w-12 items-center self-end border-r">
97
+ <div class="-rotate-90 transform whitespace-nowrap text-sm font-normal text-secondary">
98
+ {yAxisName}
99
+ </div>
100
+ </div>
101
+ {/if}
102
+
103
+ <div bind:this={container} class="relative flex flex-1 flex-col">
104
+ <div class="ml-20 flex h-6">
105
+ {#each colLabels as label}
106
+ <div class="flex-1 pr-1 text-center text-sm text-secondary">
107
+ {label}
108
+ </div>
109
+ {/each}
110
+ </div>
111
+
112
+ <div class="flex flex-1">
113
+ <div class="flex w-20 flex-col">
114
+ {#each displayRowLabels as label}
115
+ <div class="flex flex-1 items-center justify-end pr-2 text-sm text-secondary">
116
+ {label}
117
+ </div>
118
+ {/each}
119
+ </div>
120
+ <div
121
+ class="grid flex-1"
122
+ style="grid-template-columns: repeat({colLabels.length}, 1fr); grid-template-rows: repeat({rowLabels.length}, 1fr);"
123
+ >
124
+ {#each displayData as row}
125
+ {#each row as cell}
126
+ <button
127
+ class="flex items-center justify-center border border-white"
128
+ style="background-color: {cell.backgroundColor};"
129
+ onclick={() => handleCellClick(cell)}
130
+ onmouseover={() => handleCellHover(cell)}
131
+ onfocus={() => handleCellHover(cell)}
132
+ data-row={cell.row}
133
+ data-col={cell.col}
134
+ >
135
+ <span class="text-base font-bold text-primary">{cell.value}</span>
136
+ </button>
137
+ {/each}
138
+ {/each}
139
+ </div>
140
+ </div>
141
+ </div>
142
+ </div>
143
+
144
+ {#if loading}
145
+ <div class="absolute inset-0 flex items-center justify-center bg-white bg-opacity-70">
146
+ <div class="text-lg">Loading...</div>
147
+ </div>
148
+ {/if}
149
+ </div>
@@ -0,0 +1,24 @@
1
+ export interface Cell {
2
+ value: number;
3
+ row: number;
4
+ col: number;
5
+ highlighted?: boolean;
6
+ backgroundColor?: string;
7
+ hideAxisNames?: boolean;
8
+ }
9
+ export type MatrixChartProps = {
10
+ /**
11
+ * Matrix data as a 2D array (cells[row][col])
12
+ */
13
+ data: Cell[][];
14
+ rowLabels: string[];
15
+ colLabels: string[];
16
+ onCellClick?: (cell: Cell) => void;
17
+ onCellHover?: (cell: Cell) => void;
18
+ invertYAxis?: boolean;
19
+ hideAxisNames?: boolean;
20
+ } & Omit<GenericChartProps, 'timeIndex'>;
21
+ import type { GenericChartProps } from '../chart/Chart.svelte';
22
+ declare const Matrix: import("svelte").Component<MatrixChartProps, {}, "">;
23
+ type Matrix = ReturnType<typeof Matrix>;
24
+ export default Matrix;
@@ -0,0 +1,3 @@
1
+ import Matrix from './Matrix.svelte';
2
+ export { Matrix };
3
+ export default Matrix;
@@ -0,0 +1,3 @@
1
+ import Matrix from './Matrix.svelte';
2
+ export { Matrix };
3
+ export default Matrix;
@@ -1,6 +1,6 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from '@storybook/addon-svelte-csf';
3
-
3
+ import type { ECElementEvent } from 'echarts';
4
4
  import MultiLineChart from './MultiLineChart.svelte';
5
5
 
6
6
  const { Story } = defineMeta({
@@ -8,53 +8,106 @@
8
8
  title: 'Design System/Graphs/MultiLineChart',
9
9
  tags: ['autodocs']
10
10
  });
11
+ </script>
11
12
 
12
- const xAxis = '€€€';
13
- const yAxis = '$$$';
13
+ <script lang="ts">
14
+ const xAxisName = 'Time';
15
+ const yAxisName = 'Value';
14
16
 
15
- const smooth = (data: number[]) =>
16
- data.map((_, i, arr) => {
17
- const windowSize = 2;
18
- const start = Math.max(i - windowSize, 0);
19
- const end = Math.min(i + windowSize, arr.length - 1);
20
- const subset = arr.slice(start, end + 1);
21
- return subset.reduce((sum, v) => sum + v, 0) / subset.length;
22
- });
17
+ const staticSmoothedData1 = [
18
+ 12.333333333333334, 13.5, 14.8, 15.6, 17.4, 19.8, 22.2, 23.6, 25.2, 26.8, 29, 31.6, 33.8, 34.8,
19
+ 36.4, 37.6, 40.2, 42.4, 44.4, 45.6, 46.4, 46.75, 48.25, 49, 49.333333333333336
20
+ ];
21
+ const staticSmoothedData2 = [
22
+ 7, 8, 8.8, 10.2, 11.8, 13.2, 14.8, 16.2, 17.6, 18.4, 19.2, 20.6, 22.4, 23.6, 24.8, 25.8, 27,
23
+ 27.75, 28.5, 28.5
24
+ ];
25
+ const staticSmoothedData3 = [
26
+ 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68,
27
+ 70, 72, 74, 76, 78, 80, 82, 84, 86, 87, 88
28
+ ];
23
29
 
24
30
  const data = [
25
31
  {
26
32
  key: 'Group 1',
27
- series: smooth(Array.from({ length: 25 }, () => Math.random() * 80))
33
+ series: staticSmoothedData1
28
34
  },
29
35
  {
30
36
  key: 'Group 2',
31
- series: smooth(Array.from({ length: 20 }, () => Math.random() * 60))
37
+ series: staticSmoothedData2
32
38
  },
33
39
  {
34
40
  key: 'Group 3',
35
- series: smooth(Array.from({ length: 35 }, () => Math.random() * 100))
41
+ series: staticSmoothedData3
36
42
  }
37
43
  ];
38
44
 
39
- function handleItemClick(params: echarts.ECElementEvent) {
40
- console.log(params);
41
- }
45
+ // Use the imported ECElementEvent type
46
+ function handleItemClick(params: ECElementEvent) {}
42
47
 
43
- function handleMouseOver(params: echarts.ECElementEvent) {
48
+ // Use the imported ECElementEvent type
49
+ function handleMouseOver(params: ECElementEvent) {
44
50
  console.log(params);
45
51
  }
46
52
 
47
- function handleMouseOut() {
48
- console.log('mouse out');
49
- }
53
+ function handleMouseOut() {}
50
54
  </script>
51
55
 
52
- <Story name="Base">
56
+ <Story name="Base" asChild>
57
+ <div class="h-[400px] w-full">
58
+ <MultiLineChart
59
+ {xAxisName}
60
+ {yAxisName}
61
+ {data}
62
+ onitemclick={handleItemClick}
63
+ onmouseover={handleMouseOver}
64
+ onmouseout={handleMouseOut}
65
+ />
66
+ </div>
67
+ </Story>
68
+
69
+ <Story name="With Area Gradient" asChild>
70
+ <div class="h-[400px] w-full">
71
+ <MultiLineChart
72
+ {xAxisName}
73
+ {yAxisName}
74
+ {data}
75
+ withArea
76
+ onitemclick={handleItemClick}
77
+ onmouseover={handleMouseOver}
78
+ onmouseout={handleMouseOut}
79
+ />
80
+ </div>
81
+ </Story>
82
+
83
+ <Story name="Custom Colors" asChild>
84
+ <div class="h-[400px] w-full">
85
+ <MultiLineChart
86
+ {xAxisName}
87
+ {yAxisName}
88
+ {data}
89
+ colors={{
90
+ 'Group 1': '#ff6b6b', // Custom Red
91
+ 'Group 2': '#48dbfb' // Custom Cyan
92
+ }}
93
+ onitemclick={handleItemClick}
94
+ onmouseover={handleMouseOver}
95
+ onmouseout={handleMouseOut}
96
+ />
97
+ </div>
98
+ </Story>
99
+
100
+ <Story name="Custom Colors with Area" asChild>
53
101
  <div class="h-[400px] w-full">
54
102
  <MultiLineChart
55
- {xAxis}
56
- {yAxis}
103
+ {xAxisName}
104
+ {yAxisName}
57
105
  {data}
106
+ colors={{
107
+ 'Group 1': '#feca57', // Custom Yellow
108
+ 'Group 3': '#1dd1a1' // Custom Teal
109
+ }}
110
+ withArea
58
111
  onitemclick={handleItemClick}
59
112
  onmouseover={handleMouseOver}
60
113
  onmouseout={handleMouseOut}
@@ -62,16 +115,50 @@
62
115
  </div>
63
116
  </Story>
64
117
 
65
- <Story name="Loading">
118
+ <Story name="Without Focus Emphasis" asChild>
66
119
  <div class="h-[400px] w-full">
67
120
  <MultiLineChart
68
- {xAxis}
69
- {yAxis}
121
+ {xAxisName}
122
+ {yAxisName}
70
123
  {data}
71
- loading
124
+ withFocus={false}
72
125
  onitemclick={handleItemClick}
73
126
  onmouseover={handleMouseOver}
74
127
  onmouseout={handleMouseOut}
75
128
  />
76
129
  </div>
77
130
  </Story>
131
+
132
+ <Story name="With Y-Axis Unit" asChild>
133
+ <div class="h-[400px] w-full">
134
+ <MultiLineChart
135
+ {xAxisName}
136
+ {yAxisName}
137
+ {data}
138
+ yAxisUnit="kg"
139
+ onitemclick={handleItemClick}
140
+ onmouseover={handleMouseOver}
141
+ onmouseout={handleMouseOut}
142
+ />
143
+ </div>
144
+ </Story>
145
+
146
+ <Story name="Focus Target" asChild>
147
+ <div class="h-[400px] w-full">
148
+ <MultiLineChart
149
+ {xAxisName}
150
+ {yAxisName}
151
+ {data}
152
+ focusTargetKey="Group 2"
153
+ onitemclick={handleItemClick}
154
+ onmouseover={handleMouseOver}
155
+ onmouseout={handleMouseOut}
156
+ />
157
+ </div>
158
+ </Story>
159
+
160
+ <Story name="With Current Location" asChild>
161
+ <div class="h-[400px] w-full">
162
+ <MultiLineChart {xAxisName} {yAxisName} {data} timeIndex={15} withFocus />
163
+ </div>
164
+ </Story>