@reshape-biotech/design-system 1.2.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +5 -1
  2. package/dist/app.css +97 -97
  3. package/dist/components/activity/Activity.stories.svelte +104 -104
  4. package/dist/components/activity/Activity.svelte +112 -112
  5. package/dist/components/avatar/Avatar.stories.svelte +23 -23
  6. package/dist/components/avatar/Avatar.svelte +54 -54
  7. package/dist/components/banner/Banner.stories.svelte +105 -105
  8. package/dist/components/banner/Banner.svelte +42 -42
  9. package/dist/components/button/Button.stories.svelte +61 -61
  10. package/dist/components/button/Button.svelte +95 -95
  11. package/dist/components/card/Card.stories.svelte +112 -112
  12. package/dist/components/card/Card.svelte +18 -18
  13. package/dist/components/checkbox/Checkbox.stories.svelte +8 -8
  14. package/dist/components/checkbox/Checkbox.svelte +17 -17
  15. package/dist/components/collapsible/Collapsible.stories.svelte +26 -26
  16. package/dist/components/collapsible/components/collapsible-content.svelte +20 -20
  17. package/dist/components/collapsible/components/collapsible-trigger.svelte +12 -12
  18. package/dist/components/collapsible/index.d.ts +1 -1
  19. package/dist/components/combobox/Combobox.stories.svelte +412 -412
  20. package/dist/components/combobox/components/combobox-add.svelte +8 -8
  21. package/dist/components/combobox/components/combobox-content.svelte +39 -39
  22. package/dist/components/combobox/components/combobox-indicator.svelte +1 -1
  23. package/dist/components/combobox/index.d.ts +1 -1
  24. package/dist/components/datepicker/DatePicker.stories.svelte +196 -196
  25. package/dist/components/datepicker/DatePicker.svelte +173 -173
  26. package/dist/components/divider/Divider.stories.svelte +7 -7
  27. package/dist/components/divider/Divider.svelte +9 -9
  28. package/dist/components/drawer/Drawer.stories.svelte +51 -51
  29. package/dist/components/drawer/Drawer.svelte +33 -33
  30. package/dist/components/drawer/DrawerLabel.svelte +10 -10
  31. package/dist/components/dropdown/Dropdown.stories.svelte +210 -210
  32. package/dist/components/dropdown/Dropdown.svelte +57 -57
  33. package/dist/components/dropdown/components/DropdownContent.svelte +16 -16
  34. package/dist/components/dropdown/components/DropdownMenu.svelte +10 -10
  35. package/dist/components/dropdown/components/DropdownTrigger.svelte +37 -37
  36. package/dist/components/dropdown/components/OutlinedButton.svelte +9 -9
  37. package/dist/components/empty-content/EmptyContent.stories.svelte +38 -38
  38. package/dist/components/empty-content/EmptyContent.svelte +12 -12
  39. package/dist/components/graphs/bar-chart/BarChart.stories.svelte +91 -91
  40. package/dist/components/graphs/bar-chart/BarChart.svelte +147 -147
  41. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +57 -57
  42. package/dist/components/graphs/bar-chart/StackedBarChart.svelte +198 -199
  43. package/dist/components/graphs/chart/Chart.stories.svelte +96 -96
  44. package/dist/components/graphs/chart/Chart.svelte +207 -207
  45. package/dist/components/graphs/line/LineChart.stories.svelte +138 -138
  46. package/dist/components/graphs/line/LineChart.svelte +140 -142
  47. package/dist/components/graphs/matrix/Matrix.stories.svelte +117 -117
  48. package/dist/components/graphs/matrix/Matrix.svelte +141 -141
  49. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +168 -168
  50. package/dist/components/graphs/multiline/MultiLineChart.svelte +236 -236
  51. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +84 -84
  52. package/dist/components/graphs/scatterplot/Scatterplot.svelte +302 -302
  53. package/dist/components/graphs/utils/duration.d.ts +1 -0
  54. package/dist/components/graphs/utils/duration.js +33 -0
  55. package/dist/components/graphs/utils/tooltipFormatter.js +1 -1
  56. package/dist/components/icon-button/IconButton.stories.svelte +64 -64
  57. package/dist/components/icon-button/IconButton.svelte +88 -88
  58. package/dist/components/icons/AnalysisIcon.stories.svelte +18 -18
  59. package/dist/components/icons/AnalysisIcon.svelte +96 -96
  60. package/dist/components/icons/Icon.stories.svelte +111 -111
  61. package/dist/components/icons/Icon.svelte +17 -17
  62. package/dist/components/icons/PrincipalIcon.svelte +59 -59
  63. package/dist/components/icons/custom/Halo.svelte +31 -31
  64. package/dist/components/icons/custom/Well.svelte +27 -27
  65. package/dist/components/icons/index.js +1 -1
  66. package/dist/components/image/Image.svelte +42 -42
  67. package/dist/components/input/Input.stories.svelte +55 -55
  68. package/dist/components/input/Input.svelte +121 -121
  69. package/dist/components/label/Label.stories.svelte +18 -18
  70. package/dist/components/label/Label.svelte +11 -11
  71. package/dist/components/list/List.stories.svelte +84 -84
  72. package/dist/components/list/List.svelte +20 -20
  73. package/dist/components/logo/Logo.stories.svelte +15 -15
  74. package/dist/components/logo/Logo.svelte +30 -30
  75. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +102 -102
  76. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +557 -557
  77. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +11 -11
  78. package/dist/components/markdown/Markdown.stories.svelte +10 -10
  79. package/dist/components/markdown/Markdown.svelte +6 -6
  80. package/dist/components/modal/Modal.stories.svelte +29 -29
  81. package/dist/components/modal/Modal.svelte +71 -71
  82. package/dist/components/multi-cfu-counter/MultiCFUCounter.stories.svelte +201 -201
  83. package/dist/components/multi-cfu-counter/MultiCFUCounter.svelte +606 -606
  84. package/dist/components/multi-cfu-counter/test/MultiCFUCounterTestWrapper.svelte +17 -17
  85. package/dist/components/notification-popup/NotificationPopup.stories.svelte +18 -18
  86. package/dist/components/notification-popup/NotificationPopup.svelte +26 -26
  87. package/dist/components/notifications/Notifications.stories.svelte +101 -101
  88. package/dist/components/notifications/Notifications.svelte +9 -9
  89. package/dist/components/pill/Pill.stories.svelte +8 -8
  90. package/dist/components/pill/Pill.svelte +27 -27
  91. package/dist/components/progress-circle/ProgressCircle.stories.svelte +8 -8
  92. package/dist/components/progress-circle/ProgressCircle.svelte +54 -54
  93. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +18 -18
  94. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +14 -14
  95. package/dist/components/segmented-control-buttons/ControlButton.svelte +36 -36
  96. package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +35 -35
  97. package/dist/components/segmented-control-buttons/SegmentedControlButtons.svelte +13 -13
  98. package/dist/components/select/Select.stories.svelte +200 -94
  99. package/dist/components/select/Select.stories.svelte.d.ts +1 -1
  100. package/dist/components/select/components/Group.svelte +24 -0
  101. package/dist/components/select/components/MultiSelectTrigger.svelte +66 -0
  102. package/dist/components/select/components/SelectContent.svelte +33 -0
  103. package/dist/components/select/components/SelectGroupHeading.svelte +19 -0
  104. package/dist/components/select/components/SelectItem.svelte +39 -0
  105. package/dist/components/select/components/SelectTrigger.svelte +48 -0
  106. package/dist/components/select/index.d.ts +10 -7
  107. package/dist/components/select/index.js +12 -1
  108. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +102 -87
  109. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +1 -1
  110. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +53 -53
  111. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +1 -1
  112. package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +1 -1
  113. package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +32 -32
  114. package/dist/components/skeleton-loader/SkeletonLoader.svelte +10 -10
  115. package/dist/components/skeleton-loader/StatcardSkeleton.svelte +9 -9
  116. package/dist/components/skeleton-loader/components/Skeleton.svelte +7 -7
  117. package/dist/components/skeleton-loader/components/SkeletonImage.svelte +12 -12
  118. package/dist/components/slider/Slider.stories.svelte +23 -23
  119. package/dist/components/slider/Slider.svelte +107 -107
  120. package/dist/components/spinner/Spinner.stories.svelte +8 -8
  121. package/dist/components/spinner/Spinner.svelte +18 -18
  122. package/dist/components/stat-card/StatCard.stories.svelte +26 -26
  123. package/dist/components/stat-card/StatCard.svelte +128 -128
  124. package/dist/components/status-badge/StatusBadge.stories.svelte +365 -365
  125. package/dist/components/status-badge/StatusBadge.svelte +54 -54
  126. package/dist/components/stepper/Stepper.stories.svelte +219 -219
  127. package/dist/components/stepper/components/stepper-root.svelte +12 -12
  128. package/dist/components/stepper/components/stepper-step.svelte +83 -83
  129. package/dist/components/table/Table.stories.svelte +87 -87
  130. package/dist/components/table/Table.svelte +32 -32
  131. package/dist/components/table/components/TBody.svelte +7 -7
  132. package/dist/components/table/components/THead.svelte +7 -7
  133. package/dist/components/table/components/Td.svelte +8 -8
  134. package/dist/components/table/components/Th.svelte +8 -8
  135. package/dist/components/table/components/Tr.svelte +11 -11
  136. package/dist/components/tabs/Tabs.stories.svelte +20 -20
  137. package/dist/components/tabs/Tabs.svelte +8 -8
  138. package/dist/components/tabs/components/Content.svelte +8 -8
  139. package/dist/components/tabs/components/Tab.svelte +14 -14
  140. package/dist/components/tabs/components/Tabs.svelte +7 -7
  141. package/dist/components/tag/Tag.stories.svelte +57 -57
  142. package/dist/components/tag/Tag.svelte +95 -95
  143. package/dist/components/textarea/Textarea.stories.svelte +70 -70
  144. package/dist/components/textarea/Textarea.svelte +76 -76
  145. package/dist/components/toast/Toast.stories.svelte +204 -204
  146. package/dist/components/toast/Toast.svelte +53 -53
  147. package/dist/components/toggle/Toggle.stories.svelte +9 -9
  148. package/dist/components/toggle/Toggle.svelte +53 -53
  149. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +152 -152
  150. package/dist/components/toggle-icon-button/ToggleIconButton.svelte +99 -99
  151. package/dist/components/tooltip/Tooltip.stories.svelte +85 -111
  152. package/dist/components/tooltip/Tooltip.svelte +57 -46
  153. package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
  154. package/dist/components/tooltip/TooltipTest.svelte +31 -0
  155. package/dist/components/tooltip/TooltipTest.svelte.d.ts +11 -0
  156. package/dist/fonts/index.js +1 -1
  157. package/dist/index.d.ts +0 -1
  158. package/dist/index.js +0 -1
  159. package/dist/notifications.d.ts +1 -4
  160. package/dist/notifications.js +1 -1
  161. package/dist/tailwind-safelist.js +406 -406
  162. package/dist/tailwind.preset.js +10 -10
  163. package/dist/tokens/colors.js +18 -18
  164. package/dist/tokens/typography.js +6 -6
  165. package/dist/tokens.js +19 -19
  166. package/dist/types/fonts.d.ts +2 -2
  167. package/package.json +199 -204
  168. package/dist/components/select/Select.svelte +0 -139
  169. package/dist/components/select/Select.svelte.d.ts +0 -60
  170. package/dist/components/select-new/Select.stories.svelte +0 -219
  171. package/dist/components/select-new/Select.stories.svelte.d.ts +0 -19
  172. package/dist/components/select-new/components/Group.svelte +0 -24
  173. package/dist/components/select-new/components/MultiSelectTrigger.svelte +0 -66
  174. package/dist/components/select-new/components/SelectContent.svelte +0 -33
  175. package/dist/components/select-new/components/SelectGroupHeading.svelte +0 -19
  176. package/dist/components/select-new/components/SelectItem.svelte +0 -39
  177. package/dist/components/select-new/components/SelectTrigger.svelte +0 -48
  178. package/dist/components/select-new/index.d.ts +0 -10
  179. package/dist/components/select-new/index.js +0 -12
  180. /package/dist/components/{select-new → select}/components/Group.svelte.d.ts +0 -0
  181. /package/dist/components/{select-new → select}/components/MultiSelectTrigger.svelte.d.ts +0 -0
  182. /package/dist/components/{select-new → select}/components/SelectContent.svelte.d.ts +0 -0
  183. /package/dist/components/{select-new → select}/components/SelectGroupHeading.svelte.d.ts +0 -0
  184. /package/dist/components/{select-new → select}/components/SelectItem.svelte.d.ts +0 -0
  185. /package/dist/components/{select-new → select}/components/SelectTrigger.svelte.d.ts +0 -0
  186. /package/dist/components/{select-new → select}/types.d.ts +0 -0
  187. /package/dist/components/{select-new → select}/types.js +0 -0
@@ -1,203 +1,202 @@
1
1
  <script lang="ts">
2
- import { textColor, borderColor, backgroundColor, chartColor, boxShadow } from '../../../tokens';
3
- import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
4
- import type { EChartsOption, BarSeriesOption } from 'echarts';
5
- import type { CallbackDataParams } from 'echarts/types/dist/shared';
6
- import { Duration } from 'luxon';
7
-
8
- type StackedSeriesItem = {
9
- name: string;
10
- data: (number | null)[];
11
- };
12
-
13
- interface StackedBarChartProps extends GenericChartProps {
14
- xAxisCategories: (string | number)[];
15
- series: StackedSeriesItem[];
16
- colors?: Record<string, string>; // Optional: Color mapping per series name
17
- rotateXAxisLabels?: boolean;
18
- grid?: EChartsOption['grid'];
19
- captureInterval?: number;
20
- }
21
-
22
- let {
23
- xAxisCategories,
24
- series,
25
- colors,
26
- rotateXAxisLabels = false,
27
- captureInterval,
28
- ...props
29
- }: StackedBarChartProps = $props();
30
-
31
- const defaultColors: Record<string, string> = {
32
- accent: chartColor['accent'],
33
- blue: chartColor['blue'],
34
- orange: chartColor['orange'],
35
- plum: chartColor['plum'],
36
- sky: chartColor['sky'],
37
- pear: chartColor['pear'],
38
- pink: chartColor['pink'],
39
- lilac: chartColor['lilac'],
40
- lime: chartColor['lime']
41
- };
42
- const defaultColorRotationArray = $derived(Object.values(defaultColors));
43
-
44
- const xAxisData = $derived(xAxisCategories);
45
-
46
- const captureIntervals = captureInterval
47
- ? Array(xAxisCategories.length)
48
- .fill(null)
49
- .map((_, timeIndex) => {
50
- const seconds = timeIndex * captureInterval;
51
- const duration = Duration.fromObject({ seconds }).shiftTo('days', 'hours', 'minutes');
52
- return duration.days >= 1 ? duration.toFormat('dd:hh:mm') : duration.toFormat('hh:mm');
53
- })
54
- : undefined;
55
-
56
- const createBarDataItem = (value: number | null, color: string) => ({
57
- value,
58
- itemStyle: {
59
- color,
60
- borderRadius: 2,
61
- borderWidth: 0.5,
62
- borderColor: borderColor['white']
63
- },
64
- emphasis: {
65
- disabled: true
66
- }
67
- });
68
-
69
- const chartSeries: BarSeriesOption[] = $derived.by(() => {
70
- return series.map((seriesItem, index): BarSeriesOption => {
71
- let seriesColor: string;
72
- // Use provided color for the series name if available, otherwise rotate through defaults
73
- if (colors && colors[seriesItem.name]) {
74
- seriesColor = colors[seriesItem.name];
75
- } else {
76
- seriesColor = defaultColorRotationArray[index % defaultColorRotationArray.length];
77
- }
78
- return {
79
- name: seriesItem.name,
80
- type: 'bar',
81
- stack: 'total',
82
- emphasis: { focus: 'none', disabled: true },
83
- data: seriesItem.data.map((val) => createBarDataItem(val, seriesColor))
84
- };
85
- });
86
- });
87
-
88
- const formatTooltip = (params: CallbackDataParams | CallbackDataParams[]): string => {
89
- if (typeof params !== 'object' || params === null) {
90
- return '';
91
- }
92
-
93
- // ECharts passes an array for axis trigger, single object for item
94
- const paramArray = Array.isArray(params) ? params : [params];
95
- if (paramArray.length === 0) return '';
96
-
97
- const firstParam = paramArray[0];
98
- const categoryName = firstParam.name;
99
-
100
- let tooltipContent = `<div class="font-medium mb-1 text-primary">${categoryName}</div>`;
101
-
102
- // Sort tooltip items by value descending for readability
103
- paramArray.sort((a, b) => (b.value as number) - (a.value as number));
104
-
105
- paramArray.forEach((p) => {
106
- if (p.value == null) return;
107
-
108
- const seriesName = p.seriesName ?? '';
109
- const value = p.value;
110
- let color = p.color as string | undefined;
111
-
112
- // Attempt to find the originally assigned color for consistency
113
- if (!color) {
114
- if (colors && colors[seriesName]) {
115
- color = colors[seriesName];
116
- } else {
117
- // Fallback: find index in original series data to get default color
118
- const seriesIndex = series.findIndex((s) => s.name === seriesName);
119
- if (seriesIndex !== -1) {
120
- color = defaultColorRotationArray[seriesIndex % defaultColorRotationArray.length];
121
- } else {
122
- color = textColor['icon-blue']; // Use a default color as final fallback
123
- }
124
- }
125
- }
126
-
127
- const marker = `<span class="size-2 rounded-sm" style="background-color:${color}"></span>`;
128
- tooltipContent += `<div class="flex items-center justify-between gap-4"><span class="flex items-center gap-2">${marker}${seriesName}</span><span class="text-primary">${value}</span></div>`;
129
- });
130
-
131
- return tooltipContent;
132
- };
133
-
134
- const options: EChartsOption = $derived.by(() => {
135
- return {
136
- tooltip: {
137
- trigger: 'axis', // Trigger per category for stacked charts
138
- axisPointer: {
139
- type: 'shadow',
140
- shadowStyle: {
141
- color: backgroundColor['neutral']
142
- }
143
- },
144
- extraCssText: `box-shadow: ${boxShadow.menu}`,
145
- borderWidth: 0,
146
- borderRadius: 6,
147
- formatter: formatTooltip
148
- },
149
- grid: {
150
- containLabel: true,
151
- left: 0,
152
- right: 16,
153
- bottom: 16,
154
- top: 16
155
- },
156
- xAxis: {
157
- type: 'category',
158
- data: captureIntervals || xAxisData,
159
- axisTick: {
160
- show: false,
161
- alignWithLabel: true
162
- },
163
- axisLabel: {
164
- fontSize: 11,
165
- color: textColor['secondary'],
166
- show: true,
167
- ...(rotateXAxisLabels
168
- ? { rotate: 90, overflow: 'break', width: 60, padding: [0, 40, 0, 0] }
169
- : { rotate: 0, overflow: 'truncate', ellipsis: '...', width: 80 })
170
- },
171
- axisLine: {
172
- lineStyle: {
173
- color: borderColor['axis']
174
- }
175
- }
176
- },
177
- yAxis: {
178
- type: 'value',
179
- axisLabel: {
180
- fontSize: 11,
181
- color: textColor['secondary']
182
- },
183
- axisLine: {
184
- show: false
185
- },
186
- splitLine: {
187
- lineStyle: {
188
- color: borderColor['input'],
189
- type: 'dashed'
190
- }
191
- }
192
- },
193
- textStyle: {
194
- color: textColor['secondary'],
195
- fontFamily: 'af Another Sans'
196
- },
197
- series: chartSeries,
198
- color: defaultColorRotationArray
199
- };
200
- });
2
+ import { textColor, borderColor, backgroundColor, chartColor, boxShadow } from '../../../tokens';
3
+ import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
4
+ import type { EChartsOption, BarSeriesOption } from 'echarts';
5
+ import type { CallbackDataParams } from 'echarts/types/dist/shared';
6
+ import { formattedDurationCompact } from '../utils/duration';
7
+
8
+ type StackedSeriesItem = {
9
+ name: string;
10
+ data: (number | null)[];
11
+ };
12
+
13
+ interface StackedBarChartProps extends GenericChartProps {
14
+ xAxisCategories: (string | number)[];
15
+ series: StackedSeriesItem[];
16
+ colors?: Record<string, string>; // Optional: Color mapping per series name
17
+ rotateXAxisLabels?: boolean;
18
+ grid?: EChartsOption['grid'];
19
+ captureInterval?: number;
20
+ }
21
+
22
+ let {
23
+ xAxisCategories,
24
+ series,
25
+ colors,
26
+ rotateXAxisLabels = false,
27
+ captureInterval,
28
+ ...props
29
+ }: StackedBarChartProps = $props();
30
+
31
+ const defaultColors: Record<string, string> = {
32
+ accent: chartColor['accent'],
33
+ blue: chartColor['blue'],
34
+ orange: chartColor['orange'],
35
+ plum: chartColor['plum'],
36
+ sky: chartColor['sky'],
37
+ pear: chartColor['pear'],
38
+ pink: chartColor['pink'],
39
+ lilac: chartColor['lilac'],
40
+ lime: chartColor['lime'],
41
+ };
42
+ const defaultColorRotationArray = $derived(Object.values(defaultColors));
43
+
44
+ const xAxisData = $derived(xAxisCategories);
45
+
46
+ const captureIntervals = captureInterval
47
+ ? Array(xAxisCategories.length)
48
+ .fill(null)
49
+ .map((_, timeIndex) => {
50
+ const seconds = timeIndex * captureInterval;
51
+ return formattedDurationCompact(seconds);
52
+ })
53
+ : undefined;
54
+
55
+ const createBarDataItem = (value: number | null, color: string) => ({
56
+ value,
57
+ itemStyle: {
58
+ color,
59
+ borderRadius: 2,
60
+ borderWidth: 0.5,
61
+ borderColor: borderColor['white'],
62
+ },
63
+ emphasis: {
64
+ disabled: true,
65
+ },
66
+ });
67
+
68
+ const chartSeries: BarSeriesOption[] = $derived.by(() => {
69
+ return series.map((seriesItem, index): BarSeriesOption => {
70
+ let seriesColor: string;
71
+ // Use provided color for the series name if available, otherwise rotate through defaults
72
+ if (colors && colors[seriesItem.name]) {
73
+ seriesColor = colors[seriesItem.name];
74
+ } else {
75
+ seriesColor = defaultColorRotationArray[index % defaultColorRotationArray.length];
76
+ }
77
+ return {
78
+ name: seriesItem.name,
79
+ type: 'bar',
80
+ stack: 'total',
81
+ emphasis: { focus: 'none', disabled: true },
82
+ data: seriesItem.data.map((val) => createBarDataItem(val, seriesColor)),
83
+ };
84
+ });
85
+ });
86
+
87
+ const formatTooltip = (params: CallbackDataParams | CallbackDataParams[]): string => {
88
+ if (typeof params !== 'object' || params === null) {
89
+ return '';
90
+ }
91
+
92
+ // ECharts passes an array for axis trigger, single object for item
93
+ const paramArray = Array.isArray(params) ? params : [params];
94
+ if (paramArray.length === 0) return '';
95
+
96
+ const firstParam = paramArray[0];
97
+ const categoryName = firstParam.name;
98
+
99
+ let tooltipContent = `<div class="font-medium mb-1 text-primary">${categoryName}</div>`;
100
+
101
+ // Sort tooltip items by value descending for readability
102
+ paramArray.sort((a, b) => (b.value as number) - (a.value as number));
103
+
104
+ paramArray.forEach((p) => {
105
+ if (p.value == null) return;
106
+
107
+ const seriesName = p.seriesName ?? '';
108
+ const value = p.value;
109
+ let color = p.color as string | undefined;
110
+
111
+ // Attempt to find the originally assigned color for consistency
112
+ if (!color) {
113
+ if (colors && colors[seriesName]) {
114
+ color = colors[seriesName];
115
+ } else {
116
+ // Fallback: find index in original series data to get default color
117
+ const seriesIndex = series.findIndex((s) => s.name === seriesName);
118
+ if (seriesIndex !== -1) {
119
+ color = defaultColorRotationArray[seriesIndex % defaultColorRotationArray.length];
120
+ } else {
121
+ color = textColor['icon-blue']; // Use a default color as final fallback
122
+ }
123
+ }
124
+ }
125
+
126
+ const marker = `<span class="size-2 rounded-sm" style="background-color:${color}"></span>`;
127
+ tooltipContent += `<div class="flex items-center justify-between gap-4"><span class="flex items-center gap-2">${marker}${seriesName}</span><span class="text-primary">${value}</span></div>`;
128
+ });
129
+
130
+ return tooltipContent;
131
+ };
132
+
133
+ const options: EChartsOption = $derived.by(() => {
134
+ return {
135
+ tooltip: {
136
+ trigger: 'axis', // Trigger per category for stacked charts
137
+ axisPointer: {
138
+ type: 'shadow',
139
+ shadowStyle: {
140
+ color: backgroundColor['neutral'],
141
+ },
142
+ },
143
+ extraCssText: `box-shadow: ${boxShadow.menu}`,
144
+ borderWidth: 0,
145
+ borderRadius: 6,
146
+ formatter: formatTooltip,
147
+ },
148
+ grid: {
149
+ containLabel: true,
150
+ left: 0,
151
+ right: 16,
152
+ bottom: 16,
153
+ top: 16,
154
+ },
155
+ xAxis: {
156
+ type: 'category',
157
+ data: captureIntervals || xAxisData,
158
+ axisTick: {
159
+ show: false,
160
+ alignWithLabel: true,
161
+ },
162
+ axisLabel: {
163
+ fontSize: 11,
164
+ color: textColor['secondary'],
165
+ show: true,
166
+ ...(rotateXAxisLabels
167
+ ? { rotate: 90, overflow: 'break', width: 60, padding: [0, 40, 0, 0] }
168
+ : { rotate: 0, overflow: 'truncate', ellipsis: '...', width: 80 }),
169
+ },
170
+ axisLine: {
171
+ lineStyle: {
172
+ color: borderColor['axis'],
173
+ },
174
+ },
175
+ },
176
+ yAxis: {
177
+ type: 'value',
178
+ axisLabel: {
179
+ fontSize: 11,
180
+ color: textColor['secondary'],
181
+ },
182
+ axisLine: {
183
+ show: false,
184
+ },
185
+ splitLine: {
186
+ lineStyle: {
187
+ color: borderColor['input'],
188
+ type: 'dashed',
189
+ },
190
+ },
191
+ },
192
+ textStyle: {
193
+ color: textColor['secondary'],
194
+ fontFamily: 'af Another Sans',
195
+ },
196
+ series: chartSeries,
197
+ color: defaultColorRotationArray,
198
+ };
199
+ });
201
200
  </script>
202
201
 
203
202
  <Chart {options} {...props} />
@@ -1,51 +1,51 @@
1
1
  <script lang="ts" context="module">
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Chart from './Chart.svelte';
4
- import { colors } from '../../../tokens';
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Chart from './Chart.svelte';
4
+ import { colors } from '../../../tokens';
5
5
 
6
- const { Story } = defineMeta({
7
- component: Chart,
8
- title: 'Design System/Graphs/Chart',
9
- tags: ['autodocs']
10
- });
6
+ const { Story } = defineMeta({
7
+ component: Chart,
8
+ title: 'Design System/Graphs/Chart',
9
+ tags: ['autodocs'],
10
+ });
11
11
  </script>
12
12
 
13
13
  <script lang="ts">
14
- const baseOptions = {
15
- xAxis: { type: 'value' as const },
16
- yAxis: { type: 'value' as const },
17
- series: [
18
- {
19
- type: 'scatter' as const,
20
- data: [
21
- [10, 8.04],
22
- [8.07, 6.95],
23
- [13.0, 7.58]
24
- ]
25
- }
26
- ]
27
- };
14
+ const baseOptions = {
15
+ xAxis: { type: 'value' as const },
16
+ yAxis: { type: 'value' as const },
17
+ series: [
18
+ {
19
+ type: 'scatter' as const,
20
+ data: [
21
+ [10, 8.04],
22
+ [8.07, 6.95],
23
+ [13.0, 7.58],
24
+ ],
25
+ },
26
+ ],
27
+ };
28
28
 
29
- const defaultProps = {
30
- xAxisName: 'Day',
31
- yAxisName: 'Value',
32
- height: '400px'
33
- };
29
+ const defaultProps = {
30
+ xAxisName: 'Day',
31
+ yAxisName: 'Value',
32
+ height: '400px',
33
+ };
34
34
 
35
- const lineOptions = {
36
- xAxis: { type: 'category' as const, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
37
- yAxis: { type: 'value' as const },
38
- series: [
39
- {
40
- type: 'line' as const,
41
- data: [150, 230, 224, 218, 135]
42
- }
43
- ]
44
- };
35
+ const lineOptions = {
36
+ xAxis: { type: 'category' as const, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
37
+ yAxis: { type: 'value' as const },
38
+ series: [
39
+ {
40
+ type: 'line' as const,
41
+ data: [150, 230, 224, 218, 135],
42
+ },
43
+ ],
44
+ };
45
45
 
46
- function handleClick(params: any) {
47
- console.log('Clicked:', params);
48
- }
46
+ function handleClick(params: any) {
47
+ console.log('Clicked:', params);
48
+ }
49
49
  </script>
50
50
 
51
51
  <!-- Basic Usage -->
@@ -56,13 +56,13 @@
56
56
 
57
57
  <!-- With Events -->
58
58
  <Story
59
- name="With Click Events"
60
- args={{
61
- options: baseOptions,
62
- ...defaultProps,
63
- onitemclick: handleClick,
64
- onmouseover: (params) => console.log('Hover:', params)
65
- }}
59
+ name="With Click Events"
60
+ args={{
61
+ options: baseOptions,
62
+ ...defaultProps,
63
+ onitemclick: handleClick,
64
+ onmouseover: (params) => console.log('Hover:', params),
65
+ }}
66
66
  />
67
67
 
68
68
  <!-- Different Chart Types -->
@@ -70,64 +70,64 @@
70
70
 
71
71
  <!-- Theme Example -->
72
72
  <Story name="Dark Theme" asChild>
73
- <div style="background: #333; padding: 20px;">
74
- <Chart
75
- {...defaultProps}
76
- options={{
77
- ...baseOptions,
78
- backgroundColor: '#333',
79
- textStyle: { color: '#fff' }
80
- }}
81
- theme={{
82
- textStyle: { color: '#fff' },
83
- color: [colors.blue[5].default]
84
- }}
85
- />
86
- </div>
73
+ <div style="background: #333; padding: 20px;">
74
+ <Chart
75
+ {...defaultProps}
76
+ options={{
77
+ ...baseOptions,
78
+ backgroundColor: '#333',
79
+ textStyle: { color: '#fff' },
80
+ }}
81
+ theme={{
82
+ textStyle: { color: '#fff' },
83
+ color: [colors.blue[5].default],
84
+ }}
85
+ />
86
+ </div>
87
87
  </Story>
88
88
 
89
89
  <!-- Responsive Example -->
90
90
  <Story name="Responsive" asChild>
91
- <div
92
- style="resize: both; overflow: auto; min-width: 300px; min-height: 200px; border: 1px solid #ccc;"
93
- >
94
- <Chart options={baseOptions} autoResize={true} xAxisName="Day" yAxisName="Value" />
95
- </div>
91
+ <div
92
+ style="resize: both; overflow: auto; min-width: 300px; min-height: 200px; border: 1px solid #ccc;"
93
+ >
94
+ <Chart options={baseOptions} autoResize={true} xAxisName="Day" yAxisName="Value" />
95
+ </div>
96
96
  </Story>
97
97
 
98
98
  <!-- Multiple Series -->
99
99
  <Story name="Multiple Series" asChild>
100
- <Chart
101
- options={{
102
- ...baseOptions,
103
- series: [
104
- {
105
- type: 'scatter' as const,
106
- data: [
107
- [10, 8.04],
108
- [8.07, 6.95],
109
- [13.0, 7.58]
110
- ],
111
- name: 'Series 1'
112
- },
113
- {
114
- type: 'scatter' as const,
115
- data: [
116
- [9, 7.5],
117
- [7.5, 6.3],
118
- [12.5, 7.0]
119
- ],
120
- name: 'Series 2'
121
- }
122
- ],
123
- legend: { data: ['Series 1', 'Series 2'] }
124
- }}
125
- {...defaultProps}
126
- />
100
+ <Chart
101
+ options={{
102
+ ...baseOptions,
103
+ series: [
104
+ {
105
+ type: 'scatter' as const,
106
+ data: [
107
+ [10, 8.04],
108
+ [8.07, 6.95],
109
+ [13.0, 7.58],
110
+ ],
111
+ name: 'Series 1',
112
+ },
113
+ {
114
+ type: 'scatter' as const,
115
+ data: [
116
+ [9, 7.5],
117
+ [7.5, 6.3],
118
+ [12.5, 7.0],
119
+ ],
120
+ name: 'Series 2',
121
+ },
122
+ ],
123
+ legend: { data: ['Series 1', 'Series 2'] },
124
+ }}
125
+ {...defaultProps}
126
+ />
127
127
  </Story>
128
128
 
129
129
  <Story name="With Current Location" asChild>
130
- <div style="height: 300px; width: 500px;">
131
- <Chart options={baseOptions} {...defaultProps} timeIndex={2} />
132
- </div>
130
+ <div style="height: 300px; width: 500px;">
131
+ <Chart options={baseOptions} {...defaultProps} timeIndex={2} />
132
+ </div>
133
133
  </Story>