@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,142 +1,142 @@
1
1
  <script module lang="ts">
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import Matrix from './Matrix.svelte';
4
- import { backgroundColor } from '../../../tokens';
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Matrix from './Matrix.svelte';
4
+ import { backgroundColor } from '../../../tokens';
5
5
 
6
- const { Story } = defineMeta({
7
- component: Matrix,
8
- title: 'Design System/Graphs/Matrix',
9
- tags: ['autodocs']
10
- });
6
+ const { Story } = defineMeta({
7
+ component: Matrix,
8
+ title: 'Design System/Graphs/Matrix',
9
+ tags: ['autodocs'],
10
+ });
11
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
- ];
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
24
 
25
- const rowLabels = ['TNTC', 'Not TNTC'];
26
- const colLabels = ['TNTC', 'Not TNTC'];
25
+ const rowLabels = ['TNTC', 'Not TNTC'];
26
+ const colLabels = ['TNTC', 'Not TNTC'];
27
27
 
28
- function handleCellClick(cell: any) {
29
- console.log('Cell clicked:', cell);
30
- }
28
+ function handleCellClick(cell: any) {
29
+ console.log('Cell clicked:', cell);
30
+ }
31
31
 
32
- function handleCellHover(cell: any) {
33
- console.log('Cell hover:', cell);
34
- }
32
+ function handleCellHover(cell: any) {
33
+ console.log('Cell hover:', cell);
34
+ }
35
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
- ];
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
54
 
55
- const multiclassLabels = ['Class A', 'Class B', 'Class C'];
55
+ const multiclassLabels = ['Class A', 'Class B', 'Class C'];
56
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
- ];
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
68
  </script>
69
69
 
70
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>
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
82
  </Story>
83
83
 
84
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>
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
95
  </Story>
96
96
 
97
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>
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
108
  </Story>
109
109
 
110
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>
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
124
  </Story>
125
125
 
126
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>
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
142
  </Story>
@@ -1,149 +1,149 @@
1
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'>;
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
23
  </script>
24
24
 
25
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
- }
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
81
  </script>
82
82
 
83
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}
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
149
  </div>