@reshape-biotech/design-system 1.2.5 → 1.2.7

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 (175) hide show
  1. package/README.md +3 -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/combobox/Combobox.stories.svelte +412 -412
  19. package/dist/components/combobox/components/combobox-add.svelte +8 -8
  20. package/dist/components/combobox/components/combobox-content.svelte +39 -39
  21. package/dist/components/combobox/components/combobox-indicator.svelte +1 -1
  22. package/dist/components/datepicker/DatePicker.stories.svelte +196 -196
  23. package/dist/components/datepicker/DatePicker.svelte +173 -173
  24. package/dist/components/divider/Divider.stories.svelte +7 -7
  25. package/dist/components/divider/Divider.svelte +9 -9
  26. package/dist/components/drawer/Drawer.stories.svelte +51 -51
  27. package/dist/components/drawer/Drawer.svelte +33 -33
  28. package/dist/components/drawer/DrawerLabel.svelte +10 -10
  29. package/dist/components/dropdown/Dropdown.stories.svelte +210 -210
  30. package/dist/components/dropdown/Dropdown.svelte +57 -57
  31. package/dist/components/dropdown/components/DropdownContent.svelte +16 -16
  32. package/dist/components/dropdown/components/DropdownMenu.svelte +10 -10
  33. package/dist/components/dropdown/components/DropdownTrigger.svelte +37 -37
  34. package/dist/components/dropdown/components/OutlinedButton.svelte +9 -9
  35. package/dist/components/empty-content/EmptyContent.stories.svelte +38 -38
  36. package/dist/components/empty-content/EmptyContent.svelte +12 -12
  37. package/dist/components/graphs/bar-chart/BarChart.stories.svelte +91 -91
  38. package/dist/components/graphs/bar-chart/BarChart.svelte +147 -147
  39. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +57 -57
  40. package/dist/components/graphs/bar-chart/StackedBarChart.svelte +198 -199
  41. package/dist/components/graphs/chart/Chart.stories.svelte +96 -96
  42. package/dist/components/graphs/chart/Chart.svelte +207 -207
  43. package/dist/components/graphs/line/LineChart.stories.svelte +138 -138
  44. package/dist/components/graphs/line/LineChart.svelte +140 -142
  45. package/dist/components/graphs/matrix/Matrix.stories.svelte +117 -117
  46. package/dist/components/graphs/matrix/Matrix.svelte +141 -141
  47. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +168 -168
  48. package/dist/components/graphs/multiline/MultiLineChart.svelte +236 -236
  49. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +84 -84
  50. package/dist/components/graphs/scatterplot/Scatterplot.svelte +302 -302
  51. package/dist/components/graphs/utils/duration.d.ts +1 -0
  52. package/dist/components/graphs/utils/duration.js +33 -0
  53. package/dist/components/graphs/utils/tooltipFormatter.js +1 -1
  54. package/dist/components/icon-button/IconButton.stories.svelte +64 -64
  55. package/dist/components/icon-button/IconButton.svelte +88 -88
  56. package/dist/components/icons/AnalysisIcon.stories.svelte +18 -18
  57. package/dist/components/icons/AnalysisIcon.svelte +96 -96
  58. package/dist/components/icons/Icon.stories.svelte +111 -111
  59. package/dist/components/icons/Icon.svelte +17 -17
  60. package/dist/components/icons/PrincipalIcon.svelte +59 -59
  61. package/dist/components/icons/custom/Halo.svelte +31 -31
  62. package/dist/components/icons/custom/Well.svelte +27 -27
  63. package/dist/components/icons/index.d.ts +3 -2
  64. package/dist/components/icons/index.js +3 -1
  65. package/dist/components/image/Image.svelte +42 -42
  66. package/dist/components/input/Input.stories.svelte +55 -55
  67. package/dist/components/input/Input.svelte +121 -121
  68. package/dist/components/label/Label.stories.svelte +18 -18
  69. package/dist/components/label/Label.svelte +11 -11
  70. package/dist/components/list/List.stories.svelte +84 -84
  71. package/dist/components/list/List.svelte +20 -20
  72. package/dist/components/logo/Logo.stories.svelte +15 -15
  73. package/dist/components/logo/Logo.svelte +30 -30
  74. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +102 -102
  75. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +557 -565
  76. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +11 -11
  77. package/dist/components/markdown/Markdown.stories.svelte +10 -10
  78. package/dist/components/markdown/Markdown.svelte +6 -6
  79. package/dist/components/modal/Modal.stories.svelte +29 -29
  80. package/dist/components/modal/Modal.svelte +71 -71
  81. package/dist/components/multi-cfu-counter/MultiCFUCounter.stories.svelte +215 -0
  82. package/dist/components/multi-cfu-counter/MultiCFUCounter.stories.svelte.d.ts +3 -0
  83. package/dist/components/multi-cfu-counter/MultiCFUCounter.svelte +662 -0
  84. package/dist/components/multi-cfu-counter/MultiCFUCounter.svelte.d.ts +32 -0
  85. package/dist/components/multi-cfu-counter/index.d.ts +1 -0
  86. package/dist/components/multi-cfu-counter/index.js +1 -0
  87. package/dist/components/multi-cfu-counter/test/MultiCFUCounterTestWrapper.svelte +28 -0
  88. package/dist/components/multi-cfu-counter/test/MultiCFUCounterTestWrapper.svelte.d.ts +20 -0
  89. package/dist/components/notification-popup/NotificationPopup.stories.svelte +18 -18
  90. package/dist/components/notification-popup/NotificationPopup.svelte +26 -26
  91. package/dist/components/notifications/Notifications.stories.svelte +101 -101
  92. package/dist/components/notifications/Notifications.svelte +9 -9
  93. package/dist/components/pill/Pill.stories.svelte +8 -8
  94. package/dist/components/pill/Pill.svelte +27 -27
  95. package/dist/components/progress-circle/ProgressCircle.stories.svelte +8 -8
  96. package/dist/components/progress-circle/ProgressCircle.svelte +54 -54
  97. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +18 -18
  98. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +14 -14
  99. package/dist/components/segmented-control-buttons/ControlButton.svelte +36 -36
  100. package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +35 -35
  101. package/dist/components/segmented-control-buttons/SegmentedControlButtons.svelte +13 -13
  102. package/dist/components/select/Select.stories.svelte +77 -77
  103. package/dist/components/select/Select.svelte +114 -114
  104. package/dist/components/select-new/Select.stories.svelte +188 -188
  105. package/dist/components/select-new/components/Group.svelte +17 -17
  106. package/dist/components/select-new/components/MultiSelectTrigger.svelte +57 -57
  107. package/dist/components/select-new/components/SelectContent.svelte +22 -22
  108. package/dist/components/select-new/components/SelectGroupHeading.svelte +10 -10
  109. package/dist/components/select-new/components/SelectItem.svelte +25 -25
  110. package/dist/components/select-new/components/SelectTrigger.svelte +38 -38
  111. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +76 -76
  112. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +1 -1
  113. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +53 -53
  114. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +1 -1
  115. package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +1 -1
  116. package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +32 -32
  117. package/dist/components/skeleton-loader/SkeletonLoader.svelte +10 -10
  118. package/dist/components/skeleton-loader/StatcardSkeleton.svelte +9 -9
  119. package/dist/components/skeleton-loader/components/Skeleton.svelte +7 -7
  120. package/dist/components/skeleton-loader/components/SkeletonImage.svelte +12 -12
  121. package/dist/components/slider/Slider.stories.svelte +23 -23
  122. package/dist/components/slider/Slider.svelte +107 -107
  123. package/dist/components/spinner/Spinner.stories.svelte +8 -8
  124. package/dist/components/spinner/Spinner.svelte +18 -18
  125. package/dist/components/stat-card/StatCard.stories.svelte +26 -26
  126. package/dist/components/stat-card/StatCard.svelte +128 -128
  127. package/dist/components/status-badge/StatusBadge.stories.svelte +365 -365
  128. package/dist/components/status-badge/StatusBadge.svelte +54 -54
  129. package/dist/components/stepper/Stepper.stories.svelte +219 -219
  130. package/dist/components/stepper/components/stepper-root.svelte +12 -12
  131. package/dist/components/stepper/components/stepper-step.svelte +83 -83
  132. package/dist/components/table/Table.stories.svelte +87 -87
  133. package/dist/components/table/Table.svelte +32 -32
  134. package/dist/components/table/components/TBody.svelte +7 -7
  135. package/dist/components/table/components/THead.svelte +7 -7
  136. package/dist/components/table/components/Td.svelte +8 -8
  137. package/dist/components/table/components/Th.svelte +8 -8
  138. package/dist/components/table/components/Tr.svelte +11 -11
  139. package/dist/components/tabs/Tabs.stories.svelte +20 -20
  140. package/dist/components/tabs/Tabs.svelte +8 -8
  141. package/dist/components/tabs/components/Content.svelte +8 -8
  142. package/dist/components/tabs/components/Tab.svelte +14 -14
  143. package/dist/components/tabs/components/Tabs.svelte +7 -7
  144. package/dist/components/tag/Tag.stories.svelte +57 -57
  145. package/dist/components/tag/Tag.svelte +95 -95
  146. package/dist/components/textarea/Textarea.stories.svelte +70 -70
  147. package/dist/components/textarea/Textarea.svelte +76 -76
  148. package/dist/components/toast/Toast.stories.svelte +204 -204
  149. package/dist/components/toast/Toast.svelte +53 -53
  150. package/dist/components/toggle/Toggle.stories.svelte +9 -9
  151. package/dist/components/toggle/Toggle.svelte +53 -53
  152. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +152 -152
  153. package/dist/components/toggle-icon-button/ToggleIconButton.svelte +99 -99
  154. package/dist/components/tooltip/Tooltip.stories.svelte +105 -105
  155. package/dist/components/tooltip/Tooltip.svelte +26 -26
  156. package/dist/fonts/index.js +1 -1
  157. package/dist/index.d.ts +4 -1
  158. package/dist/index.js +5 -1
  159. package/dist/notifications.d.ts +1 -4
  160. package/dist/notifications.js +1 -1
  161. package/dist/styles.d.ts +1 -0
  162. package/dist/styles.js +4 -0
  163. package/dist/tailwind-safelist.js +406 -398
  164. package/dist/tailwind.preset.d.ts +4 -0
  165. package/dist/tailwind.preset.js +10 -10
  166. package/dist/tokens/colors.d.ts +246 -0
  167. package/dist/tokens/colors.js +139 -0
  168. package/dist/tokens/index.d.ts +3 -0
  169. package/dist/tokens/index.js +5 -0
  170. package/dist/tokens/typography.d.ts +48 -0
  171. package/dist/tokens/typography.js +48 -0
  172. package/dist/tokens.d.ts +16 -252
  173. package/dist/tokens.js +33 -164
  174. package/dist/types/fonts.d.ts +2 -2
  175. package/package.json +398 -78
@@ -1,119 +1,119 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import { textColor } from '../../../tokens';
4
- import BarChart from './BarChart.svelte';
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import { textColor } from '../../../tokens';
4
+ import BarChart from './BarChart.svelte';
5
5
 
6
- const { Story } = defineMeta({
7
- title: 'Design System/Graphs/BarChart',
8
- component: BarChart,
9
- tags: ['autodocs'],
10
- argTypes: {
11
- // Define argTypes for props if needed, e.g., for controls
12
- }
13
- });
6
+ const { Story } = defineMeta({
7
+ title: 'Design System/Graphs/BarChart',
8
+ component: BarChart,
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ // Define argTypes for props if needed, e.g., for controls
12
+ },
13
+ });
14
14
 
15
- const simpleData = [
16
- { category: 'A', value: 10 },
17
- { category: 'B', value: 20 },
18
- { category: 'C', value: 15 },
19
- { category: 'D', value: 25 },
20
- { category: 'E', value: 30 }
21
- ];
15
+ const simpleData = [
16
+ { category: 'A', value: 10 },
17
+ { category: 'B', value: 20 },
18
+ { category: 'C', value: 15 },
19
+ { category: 'D', value: 25 },
20
+ { category: 'E', value: 30 },
21
+ ];
22
22
 
23
- const longerLabelsData = [
24
- { longCategoryName: 'Very Long Label One', value: 45 },
25
- { longCategoryName: 'Another Quite Long Label', value: 35 },
26
- { longCategoryName: 'Short', value: 55 },
27
- { longCategoryName: 'Label Four Is Also Lengthy', value: 25 },
28
- { longCategoryName: 'Fifth Label Is Here', value: 65 }
29
- ];
23
+ const longerLabelsData = [
24
+ { longCategoryName: 'Very Long Label One', value: 45 },
25
+ { longCategoryName: 'Another Quite Long Label', value: 35 },
26
+ { longCategoryName: 'Short', value: 55 },
27
+ { longCategoryName: 'Label Four Is Also Lengthy', value: 25 },
28
+ { longCategoryName: 'Fifth Label Is Here', value: 65 },
29
+ ];
30
30
 
31
- const customColorData = [
32
- { category: 'Apple', value: 50 },
33
- { category: 'Banana', value: 70 },
34
- { category: 'Cherry', value: 60 },
35
- { category: 'Date', value: 40 }
36
- ];
31
+ const customColorData = [
32
+ { category: 'Apple', value: 50 },
33
+ { category: 'Banana', value: 70 },
34
+ { category: 'Cherry', value: 60 },
35
+ { category: 'Date', value: 40 },
36
+ ];
37
37
 
38
- const customColors = {
39
- Apple: '#ff6b6b', // Red
40
- Banana: '#feca57', // Yellow
41
- Cherry: '#ff9ff3', // Pink
42
- Date: '#a4b0be' // Grey
43
- };
38
+ const customColors = {
39
+ Apple: '#ff6b6b', // Red
40
+ Banana: '#feca57', // Yellow
41
+ Cherry: '#ff9ff3', // Pink
42
+ Date: '#a4b0be', // Grey
43
+ };
44
44
  </script>
45
45
 
46
46
  <Story
47
- name="Base"
48
- args={{ data: simpleData, xAxisName: 'category', yAxisName: 'Count', height: '400px' }}
47
+ name="Base"
48
+ args={{ data: simpleData, xAxisName: 'category', yAxisName: 'Count', height: '400px' }}
49
49
  />
50
50
 
51
51
  <Story
52
- name="Custom Y-Axis Name"
53
- args={{ data: simpleData, xAxisName: 'category', yAxisName: 'Units Sold', height: '400px' }}
52
+ name="Custom Y-Axis Name"
53
+ args={{ data: simpleData, xAxisName: 'category', yAxisName: 'Units Sold', height: '400px' }}
54
54
  />
55
55
 
56
56
  <Story
57
- name="With Custom Colors"
58
- args={{
59
- data: customColorData,
60
- xAxisName: 'category',
61
- yAxisName: 'Fruit Amount',
62
- colors: customColors,
63
- height: '400px'
64
- }}
57
+ name="With Custom Colors"
58
+ args={{
59
+ data: customColorData,
60
+ xAxisName: 'category',
61
+ yAxisName: 'Fruit Amount',
62
+ colors: customColors,
63
+ height: '400px',
64
+ }}
65
65
  />
66
66
 
67
67
  <Story
68
- name="With Rotated Labels"
69
- args={{
70
- data: longerLabelsData,
71
- xAxisName: 'longCategoryName',
72
- yAxisName: 'Measurement',
73
- rotateXAxisLabels: true,
74
- height: '400px'
75
- }}
68
+ name="With Rotated Labels"
69
+ args={{
70
+ data: longerLabelsData,
71
+ xAxisName: 'longCategoryName',
72
+ yAxisName: 'Measurement',
73
+ rotateXAxisLabels: true,
74
+ height: '400px',
75
+ }}
76
76
  />
77
77
 
78
78
  <Story
79
- name="Empty Data"
80
- args={{ data: [], xAxisName: 'category', yAxisName: 'Value', height: '400px' }}
79
+ name="Empty Data"
80
+ args={{ data: [], xAxisName: 'category', yAxisName: 'Value', height: '400px' }}
81
81
  />
82
82
 
83
83
  <Story
84
- name="With Capture Interval"
85
- args={{
86
- data: [
87
- { category: '0', value: 10 },
88
- { category: '1', value: 20 },
89
- { category: '2', value: 15 },
90
- { category: '3', value: 25 },
91
- { category: '4', value: 30 },
92
- { category: '5', value: 18 },
93
- { category: '6', value: 22 }
94
- ],
95
- xAxisName: 'category',
96
- yAxisName: 'Value',
97
- height: '400px',
98
- captureInterval: 3600
99
- }}
84
+ name="With Capture Interval"
85
+ args={{
86
+ data: [
87
+ { category: '0', value: 10 },
88
+ { category: '1', value: 20 },
89
+ { category: '2', value: 15 },
90
+ { category: '3', value: 25 },
91
+ { category: '4', value: 30 },
92
+ { category: '5', value: 18 },
93
+ { category: '6', value: 22 },
94
+ ],
95
+ xAxisName: 'category',
96
+ yAxisName: 'Value',
97
+ height: '400px',
98
+ captureInterval: 3600,
99
+ }}
100
100
  />
101
101
 
102
102
  <Story
103
- name="With Capture Interval - Short Duration"
104
- args={{
105
- data: [
106
- { category: '0', value: 10 },
107
- { category: '1', value: 20 },
108
- { category: '2', value: 15 },
109
- { category: '3', value: 25 },
110
- { category: '4', value: 30 },
111
- { category: '5', value: 18 },
112
- { category: '6', value: 22 }
113
- ],
114
- xAxisName: 'category',
115
- yAxisName: 'Value',
116
- height: '400px',
117
- captureInterval: 600
118
- }}
103
+ name="With Capture Interval - Short Duration"
104
+ args={{
105
+ data: [
106
+ { category: '0', value: 10 },
107
+ { category: '1', value: 20 },
108
+ { category: '2', value: 15 },
109
+ { category: '3', value: 25 },
110
+ { category: '4', value: 30 },
111
+ { category: '5', value: 18 },
112
+ { category: '6', value: 22 },
113
+ ],
114
+ xAxisName: 'category',
115
+ yAxisName: 'Value',
116
+ height: '400px',
117
+ captureInterval: 600,
118
+ }}
119
119
  />
@@ -1,162 +1,162 @@
1
1
  <script lang="ts">
2
- import { textColor, borderColor, backgroundColor, boxShadow, chartColor } from '../../../tokens';
3
- import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
4
- import type { EChartsOption, BarSeriesOption } from 'echarts';
5
- import { createTooltipFormatter } from '../utils/tooltipFormatter';
6
- import { Duration } from 'luxon';
2
+ import { textColor, borderColor, backgroundColor, boxShadow, chartColor } from '../../../tokens';
3
+ import Chart, { type GenericChartProps } from '../chart/Chart.svelte';
4
+ import type { EChartsOption, BarSeriesOption } from 'echarts';
5
+ import { createTooltipFormatter } from '../utils/tooltipFormatter';
6
+ import { Duration } from 'luxon';
7
+ import { formattedDurationCompact } from '../utils/duration';
7
8
 
8
- type DataItem = {
9
- value: number;
10
- [key: string]: string | number; // Allows other properties, like the one used for xAxisName
11
- };
9
+ type DataItem = {
10
+ value: number;
11
+ [key: string]: string | number; // Allows other properties, like the one used for xAxisName
12
+ };
12
13
 
13
- interface BarChartProps extends Omit<GenericChartProps, 'timeIndex'> {
14
- data: DataItem[];
15
- colors?: Record<string, string>; // Optional: Color mapping per x-axis category
16
- rotateXAxisLabels?: boolean;
17
- grid?: EChartsOption['grid'];
18
- captureInterval?: number;
19
- }
14
+ interface BarChartProps extends Omit<GenericChartProps, 'timeIndex'> {
15
+ data: DataItem[];
16
+ colors?: Record<string, string>; // Optional: Color mapping per x-axis category
17
+ rotateXAxisLabels?: boolean;
18
+ grid?: EChartsOption['grid'];
19
+ captureInterval?: number;
20
+ }
20
21
 
21
- let {
22
- data,
23
- colors,
24
- rotateXAxisLabels = false,
25
- xAxisName,
26
- yAxisName,
27
- captureInterval,
28
- ...props
29
- }: BarChartProps = $props();
22
+ let {
23
+ data,
24
+ colors,
25
+ rotateXAxisLabels = false,
26
+ xAxisName,
27
+ yAxisName,
28
+ captureInterval,
29
+ ...props
30
+ }: BarChartProps = $props();
30
31
 
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));
32
+ const defaultColors: Record<string, string> = {
33
+ accent: chartColor['accent'],
34
+ blue: chartColor['blue'],
35
+ orange: chartColor['orange'],
36
+ plum: chartColor['plum'],
37
+ sky: chartColor['sky'],
38
+ pear: chartColor['pear'],
39
+ pink: chartColor['pink'],
40
+ lilac: chartColor['lilac'],
41
+ lime: chartColor['lime'],
42
+ };
43
+ const defaultColorRotationArray = $derived(Object.values(defaultColors));
43
44
 
44
- const xAxisData = $derived(data.map((item) => item[xAxisName]));
45
+ const xAxisData = $derived(data.map((item) => item[xAxisName]));
45
46
 
46
- const captureIntervals = captureInterval
47
- ? Array(data.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;
47
+ const captureIntervals = captureInterval
48
+ ? Array(data.length)
49
+ .fill(null)
50
+ .map((_, timeIndex) => {
51
+ const seconds = timeIndex * captureInterval;
52
+ return formattedDurationCompact(seconds);
53
+ })
54
+ : undefined;
55
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
- });
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
68
 
69
- const chartSeries: BarSeriesOption[] = $derived.by(() => {
70
- const seriesData = data.map((item) => item.value);
71
- const seriesColors = data.map(
72
- (item, index) =>
73
- colors?.[item[xAxisName] as string] ??
74
- defaultColorRotationArray[index % defaultColorRotationArray.length]
75
- );
69
+ const chartSeries: BarSeriesOption[] = $derived.by(() => {
70
+ const seriesData = data.map((item) => item.value);
71
+ const seriesColors = data.map(
72
+ (item, index) =>
73
+ colors?.[item[xAxisName] as string] ??
74
+ defaultColorRotationArray[index % defaultColorRotationArray.length]
75
+ );
76
76
 
77
- const singleSeries: BarSeriesOption[] = [
78
- {
79
- name: yAxisName,
80
- type: 'bar',
81
- data: seriesData.map((value, index) => createBarDataItem(value, seriesColors[index])),
82
- emphasis: { disabled: true }
83
- }
84
- ];
85
- return singleSeries;
86
- });
77
+ const singleSeries: BarSeriesOption[] = [
78
+ {
79
+ name: yAxisName,
80
+ type: 'bar',
81
+ data: seriesData.map((value, index) => createBarDataItem(value, seriesColors[index])),
82
+ emphasis: { disabled: true },
83
+ },
84
+ ];
85
+ return singleSeries;
86
+ });
87
87
 
88
- const formatTooltip = createTooltipFormatter({
89
- yAxisName: yAxisName,
90
- yAxisUnit: props.yAxisUnit
91
- });
88
+ const formatTooltip = createTooltipFormatter({
89
+ yAxisName: yAxisName,
90
+ yAxisUnit: props.yAxisUnit,
91
+ });
92
92
 
93
- const options: EChartsOption = $derived.by(() => {
94
- return {
95
- tooltip: {
96
- trigger: 'axis',
97
- axisPointer: {
98
- type: 'shadow',
99
- shadowStyle: {
100
- color: backgroundColor['neutral']
101
- }
102
- },
103
- borderWidth: 0,
104
- borderRadius: 6,
105
- extraCssText: `box-shadow: ${boxShadow.menu}`,
106
- formatter: formatTooltip
107
- },
108
- grid: {
109
- containLabel: true,
110
- left: 0,
111
- right: 16,
112
- bottom: 16,
113
- top: 16
114
- },
115
- xAxis: {
116
- type: 'category',
117
- data: captureIntervals || xAxisData,
118
- axisTick: {
119
- show: false,
120
- alignWithLabel: true
121
- },
122
- axisLabel: {
123
- fontSize: 11,
124
- color: textColor['secondary'],
125
- show: true,
126
- ...(rotateXAxisLabels
127
- ? { rotate: 90, overflow: 'break', width: 60, padding: [0, 40, 0, 0] }
128
- : { rotate: 0, overflow: 'truncate', ellipsis: '...', width: 80 })
129
- },
130
- axisLine: {
131
- lineStyle: {
132
- color: borderColor['axis']
133
- }
134
- }
135
- },
136
- yAxis: {
137
- type: 'value',
138
- axisLabel: {
139
- fontSize: 11,
140
- color: textColor['secondary']
141
- },
142
- axisLine: {
143
- show: false
144
- },
145
- splitLine: {
146
- lineStyle: {
147
- color: borderColor['input'],
148
- type: 'dashed'
149
- }
150
- }
151
- },
152
- textStyle: {
153
- color: textColor['secondary'],
154
- fontFamily: 'af Another Sans'
155
- },
156
- series: chartSeries,
157
- color: defaultColorRotationArray
158
- };
159
- });
93
+ const options: EChartsOption = $derived.by(() => {
94
+ return {
95
+ tooltip: {
96
+ trigger: 'axis',
97
+ axisPointer: {
98
+ type: 'shadow',
99
+ shadowStyle: {
100
+ color: backgroundColor['neutral'],
101
+ },
102
+ },
103
+ borderWidth: 0,
104
+ borderRadius: 6,
105
+ extraCssText: `box-shadow: ${boxShadow.menu}`,
106
+ formatter: formatTooltip,
107
+ },
108
+ grid: {
109
+ containLabel: true,
110
+ left: 0,
111
+ right: 16,
112
+ bottom: 16,
113
+ top: 16,
114
+ },
115
+ xAxis: {
116
+ type: 'category',
117
+ data: captureIntervals || xAxisData,
118
+ axisTick: {
119
+ show: false,
120
+ alignWithLabel: true,
121
+ },
122
+ axisLabel: {
123
+ fontSize: 11,
124
+ color: textColor['secondary'],
125
+ show: true,
126
+ ...(rotateXAxisLabels
127
+ ? { rotate: 90, overflow: 'break', width: 60, padding: [0, 40, 0, 0] }
128
+ : { rotate: 0, overflow: 'truncate', ellipsis: '...', width: 80 }),
129
+ },
130
+ axisLine: {
131
+ lineStyle: {
132
+ color: borderColor['axis'],
133
+ },
134
+ },
135
+ },
136
+ yAxis: {
137
+ type: 'value',
138
+ axisLabel: {
139
+ fontSize: 11,
140
+ color: textColor['secondary'],
141
+ },
142
+ axisLine: {
143
+ show: false,
144
+ },
145
+ splitLine: {
146
+ lineStyle: {
147
+ color: borderColor['input'],
148
+ type: 'dashed',
149
+ },
150
+ },
151
+ },
152
+ textStyle: {
153
+ color: textColor['secondary'],
154
+ fontFamily: 'af Another Sans',
155
+ },
156
+ series: chartSeries,
157
+ color: defaultColorRotationArray,
158
+ };
159
+ });
160
160
  </script>
161
161
 
162
162
  <Chart {options} {...props} {xAxisName} {yAxisName} />
@@ -1,74 +1,74 @@
1
1
  <script lang="ts" context="module">
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import { textColor } from '../../../tokens';
4
- import StackedBarChart from './StackedBarChart.svelte';
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import { textColor } from '../../../tokens';
4
+ import StackedBarChart from './StackedBarChart.svelte';
5
5
 
6
- const { Story } = defineMeta({
7
- title: 'Design System/Graphs/StackedBarChart',
8
- component: StackedBarChart,
9
- tags: ['autodocs']
10
- });
6
+ const { Story } = defineMeta({
7
+ title: 'Design System/Graphs/StackedBarChart',
8
+ component: StackedBarChart,
9
+ tags: ['autodocs'],
10
+ });
11
11
 
12
- const stackedChartProps = {
13
- xAxisCategories: ['ID 1', 'ID 2', 'ID 3', 'ID 4'],
14
- series: [
15
- { name: 'Halo', data: [100, 132, 101, 134] },
16
- { name: 'Spot', data: [220, 182, 191, 234] },
17
- { name: 'Microbial', data: [150, 232, 201, 154] }
18
- ]
19
- };
12
+ const stackedChartProps = {
13
+ xAxisCategories: ['ID 1', 'ID 2', 'ID 3', 'ID 4'],
14
+ series: [
15
+ { name: 'Halo', data: [100, 132, 101, 134] },
16
+ { name: 'Spot', data: [220, 182, 191, 234] },
17
+ { name: 'Microbial', data: [150, 232, 201, 154] },
18
+ ],
19
+ };
20
20
 
21
- const seriesColors = {
22
- Halo: textColor['icon-warning'],
23
- Spot: textColor['icon-tertiary'],
24
- Microbial: textColor['icon-lime']
25
- };
21
+ const seriesColors = {
22
+ Halo: textColor['icon-warning'],
23
+ Spot: textColor['icon-tertiary'],
24
+ Microbial: textColor['icon-lime'],
25
+ };
26
26
  </script>
27
27
 
28
28
  <Story
29
- name="Default Colors"
30
- args={{ ...stackedChartProps, height: '400px', xAxisName: 'ID', yAxisName: 'Count' }}
29
+ name="Default Colors"
30
+ args={{ ...stackedChartProps, height: '400px', xAxisName: 'ID', yAxisName: 'Count' }}
31
31
  />
32
32
 
33
33
  <Story
34
- name="Custom Colors"
35
- args={{
36
- ...stackedChartProps,
37
- height: '400px',
38
- colors: seriesColors,
39
- xAxisName: 'ID',
40
- yAxisName: 'Count'
41
- }}
34
+ name="Custom Colors"
35
+ args={{
36
+ ...stackedChartProps,
37
+ height: '400px',
38
+ colors: seriesColors,
39
+ xAxisName: 'ID',
40
+ yAxisName: 'Count',
41
+ }}
42
42
  />
43
43
 
44
44
  <Story
45
- name="With Capture Interval"
46
- args={{
47
- xAxisCategories: ['0', '1', '2', '3', '4', '5', '6'],
48
- series: [
49
- { name: 'Halo', data: [120, 132, 101, 134, 90, 230, 210] },
50
- { name: 'Spot', data: [220, 182, 191, 234, 290, 330, 310] },
51
- { name: 'Microbial', data: [150, 232, 201, 154, 190, 330, 410] }
52
- ],
53
- height: '400px',
54
- xAxisName: 'Time',
55
- yAxisName: 'Count',
56
- captureInterval: 3600
57
- }}
45
+ name="With Capture Interval"
46
+ args={{
47
+ xAxisCategories: ['0', '1', '2', '3', '4', '5', '6'],
48
+ series: [
49
+ { name: 'Halo', data: [120, 132, 101, 134, 90, 230, 210] },
50
+ { name: 'Spot', data: [220, 182, 191, 234, 290, 330, 310] },
51
+ { name: 'Microbial', data: [150, 232, 201, 154, 190, 330, 410] },
52
+ ],
53
+ height: '400px',
54
+ xAxisName: 'Time',
55
+ yAxisName: 'Count',
56
+ captureInterval: 3600,
57
+ }}
58
58
  />
59
59
 
60
60
  <Story
61
- name="With Capture Interval - Short Duration"
62
- args={{
63
- xAxisCategories: ['0', '1', '2', '3', '4', '5', '6'],
64
- series: [
65
- { name: 'Halo', data: [120, 132, 101, 134, 90, 230, 210] },
66
- { name: 'Spot', data: [220, 182, 191, 234, 290, 330, 310] },
67
- { name: 'Microbial', data: [150, 232, 201, 154, 190, 330, 410] }
68
- ],
69
- height: '400px',
70
- xAxisName: 'Time',
71
- yAxisName: 'Count',
72
- captureInterval: 600
73
- }}
61
+ name="With Capture Interval - Short Duration"
62
+ args={{
63
+ xAxisCategories: ['0', '1', '2', '3', '4', '5', '6'],
64
+ series: [
65
+ { name: 'Halo', data: [120, 132, 101, 134, 90, 230, 210] },
66
+ { name: 'Spot', data: [220, 182, 191, 234, 290, 330, 310] },
67
+ { name: 'Microbial', data: [150, 232, 201, 154, 190, 330, 410] },
68
+ ],
69
+ height: '400px',
70
+ xAxisName: 'Time',
71
+ yAxisName: 'Count',
72
+ captureInterval: 600,
73
+ }}
74
74
  />