@reshape-biotech/design-system 0.0.52 → 1.1.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 (184) hide show
  1. package/dist/components/activity/Activity.stories.svelte +21 -8
  2. package/dist/components/activity/Activity.svelte +49 -9
  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/button/Button.stories.svelte +54 -21
  9. package/dist/components/button/Button.svelte +58 -11
  10. package/dist/components/button/Button.svelte.d.ts +4 -3
  11. package/dist/components/card/Card.stories.svelte +130 -0
  12. package/dist/components/card/Card.stories.svelte.d.ts +19 -0
  13. package/dist/components/card/Card.svelte +25 -0
  14. package/dist/components/card/Card.svelte.d.ts +10 -0
  15. package/dist/components/card/index.d.ts +1 -0
  16. package/dist/components/card/index.js +1 -0
  17. package/dist/components/checkbox/Checkbox.stories.svelte +22 -0
  18. package/dist/components/checkbox/Checkbox.stories.svelte.d.ts +19 -0
  19. package/dist/components/checkbox/Checkbox.svelte +24 -0
  20. package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
  21. package/dist/components/checkbox/index.d.ts +1 -0
  22. package/dist/components/checkbox/index.js +1 -0
  23. package/dist/components/collapsible/Collapsible.stories.svelte +5 -4
  24. package/dist/components/collapsible/components/collapsible-trigger.svelte +1 -1
  25. package/dist/components/combobox/Combobox.stories.svelte +7 -5
  26. package/dist/components/combobox/components/combobox-add.svelte +2 -1
  27. package/dist/components/combobox/components/combobox-content.svelte +4 -0
  28. package/dist/components/combobox/types.d.ts +2 -0
  29. package/dist/components/datepicker/DatePicker.stories.svelte +8 -14
  30. package/dist/components/divider/Divider.stories.svelte +1 -3
  31. package/dist/components/divider/Divider.svelte +8 -2
  32. package/dist/components/divider/Divider.svelte.d.ts +2 -0
  33. package/dist/components/drawer/Drawer.stories.svelte +3 -3
  34. package/dist/components/dropdown/Dropdown.stories.svelte +8 -8
  35. package/dist/components/empty-content/EmptyContent.stories.svelte +2 -2
  36. package/dist/components/graphs/bar-chart/BarChart.stories.svelte +81 -0
  37. package/dist/components/graphs/bar-chart/BarChart.stories.svelte.d.ts +19 -0
  38. package/dist/components/graphs/bar-chart/BarChart.svelte +136 -0
  39. package/dist/components/graphs/bar-chart/BarChart.svelte.d.ts +15 -0
  40. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +42 -0
  41. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte.d.ts +19 -0
  42. package/dist/components/graphs/bar-chart/StackedBarChart.svelte +177 -0
  43. package/dist/components/graphs/bar-chart/StackedBarChart.svelte.d.ts +16 -0
  44. package/dist/components/graphs/chart/Chart.stories.svelte +31 -23
  45. package/dist/components/graphs/chart/Chart.svelte +104 -32
  46. package/dist/components/graphs/chart/Chart.svelte.d.ts +15 -5
  47. package/dist/components/graphs/index.d.ts +3 -0
  48. package/dist/components/graphs/index.js +3 -0
  49. package/dist/components/graphs/line/LineChart.stories.svelte +107 -15
  50. package/dist/components/graphs/line/LineChart.svelte +90 -51
  51. package/dist/components/graphs/line/LineChart.svelte.d.ts +6 -13
  52. package/dist/components/graphs/matrix/Matrix.stories.svelte +156 -0
  53. package/dist/components/graphs/matrix/Matrix.stories.svelte.d.ts +19 -0
  54. package/dist/components/graphs/matrix/Matrix.svelte +149 -0
  55. package/dist/components/graphs/matrix/Matrix.svelte.d.ts +24 -0
  56. package/dist/components/graphs/matrix/index.d.ts +3 -0
  57. package/dist/components/graphs/matrix/index.js +3 -0
  58. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +130 -18
  59. package/dist/components/graphs/multiline/MultiLineChart.svelte +187 -50
  60. package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +9 -12
  61. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +68 -41
  62. package/dist/components/graphs/scatterplot/Scatterplot.svelte +312 -45
  63. package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +23 -13
  64. package/dist/components/graphs/utils/tooltipFormatter.d.ts +10 -0
  65. package/dist/components/graphs/utils/tooltipFormatter.js +52 -0
  66. package/dist/components/icon-button/IconButton.stories.svelte +6 -6
  67. package/dist/components/icon-button/IconButton.svelte +50 -9
  68. package/dist/components/icon-button/IconButton.svelte.d.ts +3 -5
  69. package/dist/components/icons/AnalysisIcon.stories.svelte +15 -21
  70. package/dist/components/icons/AnalysisIcon.svelte +53 -43
  71. package/dist/components/icons/Icon.stories.svelte +4 -4
  72. package/dist/components/icons/Icon.svelte +1 -1
  73. package/dist/components/icons/PrincipalIcon.svelte +96 -0
  74. package/dist/components/icons/PrincipalIcon.svelte.d.ts +10 -0
  75. package/dist/components/icons/custom/Halo.svelte +14 -8
  76. package/dist/components/icons/custom/Halo.svelte.d.ts +7 -25
  77. package/dist/components/icons/custom/Well.svelte +14 -6
  78. package/dist/components/icons/custom/Well.svelte.d.ts +7 -25
  79. package/dist/components/icons/index.d.ts +3 -2
  80. package/dist/components/icons/index.js +26 -0
  81. package/dist/components/input/Input.stories.svelte +16 -22
  82. package/dist/components/input/Input.svelte +140 -134
  83. package/dist/components/input/Input.svelte.d.ts +12 -13
  84. package/dist/components/label/Label.stories.svelte +28 -0
  85. package/dist/components/label/Label.stories.svelte.d.ts +19 -0
  86. package/dist/components/label/Label.svelte +17 -0
  87. package/dist/components/label/Label.svelte.d.ts +9 -0
  88. package/dist/components/list/List.stories.svelte +3 -3
  89. package/dist/components/logo/Logo.stories.svelte +1 -1
  90. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +125 -0
  91. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte.d.ts +3 -0
  92. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +577 -0
  93. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte.d.ts +16 -0
  94. package/dist/components/manual-cfu-counter/index.d.ts +1 -0
  95. package/dist/components/manual-cfu-counter/index.js +1 -0
  96. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +22 -0
  97. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte.d.ts +19 -0
  98. package/dist/components/markdown/Markdown.stories.svelte +1 -1
  99. package/dist/components/markdown/Markdown.svelte +1 -1
  100. package/dist/components/modal/Modal.stories.svelte +2 -2
  101. package/dist/components/modal/Modal.svelte +27 -22
  102. package/dist/components/modal/Modal.svelte.d.ts +4 -1
  103. package/dist/components/notification-popup/NotificationPopup.stories.svelte +1 -1
  104. package/dist/components/pill/Pill.stories.svelte +13 -0
  105. package/dist/components/pill/Pill.stories.svelte.d.ts +19 -0
  106. package/dist/components/progress-circle/ProgressCircle.stories.svelte +15 -0
  107. package/dist/components/progress-circle/ProgressCircle.stories.svelte.d.ts +19 -0
  108. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +28 -0
  109. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte.d.ts +19 -0
  110. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +22 -0
  111. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte.d.ts +8 -0
  112. package/dist/components/required-status-indicator/index.d.ts +1 -0
  113. package/dist/components/required-status-indicator/index.js +1 -0
  114. package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +3 -3
  115. package/dist/components/select/Select.stories.svelte +12 -12
  116. package/dist/components/select/Select.svelte +0 -2
  117. package/dist/components/select-new/Select.stories.svelte +219 -0
  118. package/dist/components/select-new/Select.stories.svelte.d.ts +19 -0
  119. package/dist/components/select-new/components/Group.svelte +23 -0
  120. package/dist/components/select-new/components/Group.svelte.d.ts +10 -0
  121. package/dist/components/select-new/components/MultiSelectTrigger.svelte +66 -0
  122. package/dist/components/select-new/components/MultiSelectTrigger.svelte.d.ts +17 -0
  123. package/dist/components/select-new/components/SelectContent.svelte +33 -0
  124. package/dist/components/select-new/components/SelectContent.svelte.d.ts +10 -0
  125. package/dist/components/select-new/components/SelectGroupHeading.svelte +19 -0
  126. package/dist/components/select-new/components/SelectGroupHeading.svelte.d.ts +9 -0
  127. package/dist/components/select-new/components/SelectItem.svelte +41 -0
  128. package/dist/components/select-new/components/SelectItem.svelte.d.ts +9 -0
  129. package/dist/components/select-new/components/SelectTrigger.svelte +48 -0
  130. package/dist/components/select-new/components/SelectTrigger.svelte.d.ts +12 -0
  131. package/dist/components/select-new/index.d.ts +10 -0
  132. package/dist/components/select-new/index.js +12 -0
  133. package/dist/components/select-new/types.d.ts +25 -0
  134. package/dist/components/select-new/types.js +1 -0
  135. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +92 -0
  136. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +3 -0
  137. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +65 -0
  138. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +3 -0
  139. package/dist/components/sjsf-wrappers/index.d.ts +2 -0
  140. package/dist/components/sjsf-wrappers/index.js +2 -0
  141. package/dist/components/sjsf-wrappers/sjsfCustomTheme.d.ts +2 -0
  142. package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +8 -0
  143. package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +4 -4
  144. package/dist/components/slider/Slider.stories.svelte +4 -4
  145. package/dist/components/spinner/Spinner.stories.svelte +13 -0
  146. package/dist/components/spinner/Spinner.stories.svelte.d.ts +19 -0
  147. package/dist/components/stat-card/StatCard.stories.svelte +27 -19
  148. package/dist/components/stat-card/StatCard.svelte +100 -6
  149. package/dist/components/stat-card/StatCard.svelte.d.ts +3 -0
  150. package/dist/components/status-badge/StatusBadge.stories.svelte +6 -6
  151. package/dist/components/status-badge/StatusBadge.svelte +5 -3
  152. package/dist/components/table/Table.stories.svelte +1 -1
  153. package/dist/components/table/components/Td.svelte +3 -2
  154. package/dist/components/table/components/Td.svelte.d.ts +1 -0
  155. package/dist/components/table/components/Tr.svelte +3 -2
  156. package/dist/components/table/components/Tr.svelte.d.ts +1 -0
  157. package/dist/components/tabs/Tabs.stories.svelte +1 -1
  158. package/dist/components/tag/Tag.stories.svelte +38 -7
  159. package/dist/components/tag/Tag.svelte +34 -21
  160. package/dist/components/tag/Tag.svelte.d.ts +1 -1
  161. package/dist/components/textarea/Textarea.stories.svelte +97 -0
  162. package/dist/components/textarea/Textarea.stories.svelte.d.ts +19 -0
  163. package/dist/components/textarea/Textarea.svelte +94 -0
  164. package/dist/components/textarea/Textarea.svelte.d.ts +17 -0
  165. package/dist/components/textarea/index.d.ts +1 -0
  166. package/dist/components/textarea/index.js +1 -0
  167. package/dist/components/toggle/Toggle.stories.svelte +1 -1
  168. package/dist/components/toggle/Toggle.svelte +3 -2
  169. package/dist/components/toggle/Toggle.svelte.d.ts +1 -0
  170. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +173 -0
  171. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte.d.ts +19 -0
  172. package/dist/components/toggle-icon-button/ToggleIconButton.svelte +117 -0
  173. package/dist/components/toggle-icon-button/ToggleIconButton.svelte.d.ts +15 -0
  174. package/dist/components/toggle-icon-button/index.d.ts +3 -0
  175. package/dist/components/toggle-icon-button/index.js +3 -0
  176. package/dist/components/tooltip/Tooltip.stories.svelte +6 -6
  177. package/dist/components/tooltip/Tooltip.svelte +1 -1
  178. package/dist/index.d.ts +7 -0
  179. package/dist/index.js +7 -0
  180. package/dist/tailwind-safelist.js +2 -0
  181. package/dist/tailwind.preset.d.ts +2 -0
  182. package/dist/tokens.d.ts +4 -0
  183. package/dist/tokens.js +3 -1
  184. package/package.json +1 -2
@@ -0,0 +1,156 @@
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="Loading" asChild>
85
+ <div class="h-[500px] w-full">
86
+ <Matrix
87
+ data={confusionMatrix}
88
+ {rowLabels}
89
+ {colLabels}
90
+ loading={true}
91
+ invertYAxis={true}
92
+ xAxisName="Model count"
93
+ yAxisName="Manual count"
94
+ />
95
+ </div>
96
+ </Story>
97
+
98
+ <Story name="Multiple Classes" asChild>
99
+ <div class="h-[500px] w-full">
100
+ <Matrix
101
+ data={multiclassMatrix}
102
+ rowLabels={multiclassLabels}
103
+ colLabels={multiclassLabels}
104
+ invertYAxis={true}
105
+ xAxisName="Model count"
106
+ yAxisName="Manual count"
107
+ />
108
+ </div>
109
+ </Story>
110
+
111
+ <Story name="Non-Inverted Axis" asChild>
112
+ <div class="h-[500px] w-full">
113
+ <Matrix
114
+ data={confusionMatrix}
115
+ {rowLabels}
116
+ {colLabels}
117
+ invertYAxis={false}
118
+ xAxisName="Model count"
119
+ yAxisName="Manual count"
120
+ />
121
+ </div>
122
+ </Story>
123
+
124
+ <Story name="Custom Colors" asChild>
125
+ <div class="h-[500px] w-full">
126
+ <Matrix
127
+ data={customColorMatrix}
128
+ {rowLabels}
129
+ {colLabels}
130
+ invertYAxis={true}
131
+ xAxisName="Model count"
132
+ yAxisName="Manual count"
133
+ />
134
+ <div class="mt-4 text-center text-sm">
135
+ <p>Using custom colors directly in the cell objects</p>
136
+ </div>
137
+ </div>
138
+ </Story>
139
+
140
+ <Story name="Semantic Colors" asChild>
141
+ <div class="h-[500px] w-full">
142
+ <Matrix
143
+ data={confusionMatrix}
144
+ {rowLabels}
145
+ {colLabels}
146
+ invertYAxis={true}
147
+ xAxisName="Model count"
148
+ yAxisName="Manual count"
149
+ />
150
+ <div class="mt-4 text-center text-sm">
151
+ <p>Using semantic colors from tokens:</p>
152
+ <p>Diagonal cells: backgroundColor.success</p>
153
+ <p>Off-diagonal cells: backgroundColor.neutral</p>
154
+ </div>
155
+ </div>
156
+ </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,5 +1,7 @@
1
1
  <script module lang="ts">
2
2
  import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ // Import the specific type to resolve mismatch
4
+ import type { ECElementEvent } from 'echarts';
3
5
 
4
6
  import MultiLineChart from './MultiLineChart.svelte';
5
7
 
@@ -8,9 +10,11 @@
8
10
  title: 'Design System/Graphs/MultiLineChart',
9
11
  tags: ['autodocs']
10
12
  });
13
+ </script>
11
14
 
12
- const xAxis = '€€€';
13
- const yAxis = '$$$';
15
+ <script lang="ts">
16
+ const xAxisName = 'Time';
17
+ const yAxisName = 'Value';
14
18
 
15
19
  const smooth = (data: number[]) =>
16
20
  data.map((_, i, arr) => {
@@ -21,39 +25,50 @@
21
25
  return subset.reduce((sum, v) => sum + v, 0) / subset.length;
22
26
  });
23
27
 
28
+ // Define static data arrays
29
+ const rawDataGroup1 = [
30
+ 10, 12, 15, 13, 16, 18, 20, 22, 25, 23, 26, 28, 30, 32, 35, 33, 36, 38, 40, 42, 45, 43, 46, 48,
31
+ 50
32
+ ]; // length 25
33
+ const rawDataGroup2 = [
34
+ 5, 7, 9, 8, 10, 12, 14, 13, 15, 17, 19, 18, 20, 22, 24, 23, 25, 27, 29, 28
35
+ ]; // length 20
36
+ const rawDataGroup3 = [
37
+ 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66,
38
+ 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88
39
+ ]; // length 35
40
+
24
41
  const data = [
25
42
  {
26
43
  key: 'Group 1',
27
- series: smooth(Array.from({ length: 25 }, () => Math.random() * 80))
44
+ series: smooth(rawDataGroup1)
28
45
  },
29
46
  {
30
47
  key: 'Group 2',
31
- series: smooth(Array.from({ length: 20 }, () => Math.random() * 60))
48
+ series: smooth(rawDataGroup2)
32
49
  },
33
50
  {
34
51
  key: 'Group 3',
35
- series: smooth(Array.from({ length: 35 }, () => Math.random() * 100))
52
+ series: smooth(rawDataGroup3)
36
53
  }
37
54
  ];
38
55
 
39
- function handleItemClick(params: echarts.ECElementEvent) {
40
- console.log(params);
41
- }
56
+ // Use the imported ECElementEvent type
57
+ function handleItemClick(params: ECElementEvent) {}
42
58
 
43
- function handleMouseOver(params: echarts.ECElementEvent) {
59
+ // Use the imported ECElementEvent type
60
+ function handleMouseOver(params: ECElementEvent) {
44
61
  console.log(params);
45
62
  }
46
63
 
47
- function handleMouseOut() {
48
- console.log('mouse out');
49
- }
64
+ function handleMouseOut() {}
50
65
  </script>
51
66
 
52
- <Story name="Base">
67
+ <Story name="Base" asChild>
53
68
  <div class="h-[400px] w-full">
54
69
  <MultiLineChart
55
- {xAxis}
56
- {yAxis}
70
+ {xAxisName}
71
+ {yAxisName}
57
72
  {data}
58
73
  onitemclick={handleItemClick}
59
74
  onmouseover={handleMouseOver}
@@ -62,11 +77,11 @@
62
77
  </div>
63
78
  </Story>
64
79
 
65
- <Story name="Loading">
80
+ <Story name="Loading" asChild>
66
81
  <div class="h-[400px] w-full">
67
82
  <MultiLineChart
68
- {xAxis}
69
- {yAxis}
83
+ {xAxisName}
84
+ {yAxisName}
70
85
  {data}
71
86
  loading
72
87
  onitemclick={handleItemClick}
@@ -75,3 +90,100 @@
75
90
  />
76
91
  </div>
77
92
  </Story>
93
+
94
+ <Story name="With Area Gradient" asChild>
95
+ <div class="h-[400px] w-full">
96
+ <MultiLineChart
97
+ {xAxisName}
98
+ {yAxisName}
99
+ {data}
100
+ withArea
101
+ onitemclick={handleItemClick}
102
+ onmouseover={handleMouseOver}
103
+ onmouseout={handleMouseOut}
104
+ />
105
+ </div>
106
+ </Story>
107
+
108
+ <Story name="Custom Colors" asChild>
109
+ <div class="h-[400px] w-full">
110
+ <MultiLineChart
111
+ {xAxisName}
112
+ {yAxisName}
113
+ {data}
114
+ colors={{
115
+ 'Group 1': '#ff6b6b', // Custom Red
116
+ 'Group 2': '#48dbfb' // Custom Cyan
117
+ }}
118
+ onitemclick={handleItemClick}
119
+ onmouseover={handleMouseOver}
120
+ onmouseout={handleMouseOut}
121
+ />
122
+ </div>
123
+ </Story>
124
+
125
+ <Story name="Custom Colors with Area" asChild>
126
+ <div class="h-[400px] w-full">
127
+ <MultiLineChart
128
+ {xAxisName}
129
+ {yAxisName}
130
+ {data}
131
+ colors={{
132
+ 'Group 1': '#feca57', // Custom Yellow
133
+ 'Group 3': '#1dd1a1' // Custom Teal
134
+ }}
135
+ withArea
136
+ onitemclick={handleItemClick}
137
+ onmouseover={handleMouseOver}
138
+ onmouseout={handleMouseOut}
139
+ />
140
+ </div>
141
+ </Story>
142
+
143
+ <Story name="Without Focus Emphasis" asChild>
144
+ <div class="h-[400px] w-full">
145
+ <MultiLineChart
146
+ {xAxisName}
147
+ {yAxisName}
148
+ {data}
149
+ withFocus={false}
150
+ onitemclick={handleItemClick}
151
+ onmouseover={handleMouseOver}
152
+ onmouseout={handleMouseOut}
153
+ />
154
+ </div>
155
+ </Story>
156
+
157
+ <Story name="With Y-Axis Unit" asChild>
158
+ <div class="h-[400px] w-full">
159
+ <MultiLineChart
160
+ {xAxisName}
161
+ {yAxisName}
162
+ {data}
163
+ yAxisUnit="kg"
164
+ onitemclick={handleItemClick}
165
+ onmouseover={handleMouseOver}
166
+ onmouseout={handleMouseOut}
167
+ />
168
+ </div>
169
+ </Story>
170
+
171
+ <Story name="Focus Target" asChild>
172
+ <div class="h-[400px] w-full">
173
+ <MultiLineChart
174
+ {xAxisName}
175
+ {yAxisName}
176
+ {data}
177
+ focusTargetKey="Group 2"
178
+ onitemclick={handleItemClick}
179
+ onmouseover={handleMouseOver}
180
+ onmouseout={handleMouseOut}
181
+ />
182
+ </div>
183
+ </Story>
184
+
185
+ <Story name="With Current Location" asChild>
186
+ <div class="h-[400px] w-full">
187
+ <MultiLineChart {xAxisName} {yAxisName} {data} timeIndex={15} withFocus />
188
+ </div>
189
+ </Story>