@cdx-ui/components 0.3.5 → 0.3.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 (416) hide show
  1. package/README.md +1 -1
  2. package/coverage.svg +1 -1
  3. package/docs/components/bar-chart/content.md +703 -0
  4. package/docs/components/content.md +10 -1
  5. package/docs/components/country-flag/content.md +232 -0
  6. package/docs/components/data-grid/content.md +3 -1
  7. package/docs/components/icon/content.md +1 -1
  8. package/docs/components/input/content.md +1 -0
  9. package/docs/components/line-chart/content.md +567 -0
  10. package/docs/components/pie-chart/content.md +493 -0
  11. package/docs/components/progress-bar/content.md +164 -3
  12. package/docs/components/progress-segmented/content.md +1 -1
  13. package/docs/components/select/content.md +1 -0
  14. package/docs/components/stepper/content.md +599 -0
  15. package/docs/components/system-alert/content.md +533 -0
  16. package/docs/foundations/expressions/icons/content.md +2 -1
  17. package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
  18. package/docs/getting-started/developers/content.md +1 -1
  19. package/docs/llms.txt +12 -0
  20. package/docs/patterns/content.md +1 -0
  21. package/docs/patterns/dashboard/content.md +423 -19
  22. package/docs/patterns/insights/content.md +659 -0
  23. package/docs/resources/content.md +1 -0
  24. package/docs/resources/release-notes/0.3.5/content.md +7 -0
  25. package/docs/resources/release-notes/0.3.6/content.md +29 -0
  26. package/docs/resources/release-notes/content.md +2 -0
  27. package/docs/resources/skills/content.md +66 -0
  28. package/lib/commonjs/components/BarChart/geometry.js +1130 -0
  29. package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
  30. package/lib/commonjs/components/BarChart/index.js +935 -0
  31. package/lib/commonjs/components/BarChart/index.js.map +1 -0
  32. package/lib/commonjs/components/BarChart/styles.js +26 -0
  33. package/lib/commonjs/components/BarChart/styles.js.map +1 -0
  34. package/lib/commonjs/components/Button/index.js +2 -2
  35. package/lib/commonjs/components/Button/index.js.map +1 -1
  36. package/lib/commonjs/components/CountryFlag/index.js +56 -0
  37. package/lib/commonjs/components/CountryFlag/index.js.map +1 -0
  38. package/lib/commonjs/components/Input/index.js.map +1 -1
  39. package/lib/commonjs/components/LineChart/geometry.js +698 -0
  40. package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
  41. package/lib/commonjs/components/LineChart/index.js +744 -0
  42. package/lib/commonjs/components/LineChart/index.js.map +1 -0
  43. package/lib/commonjs/components/LineChart/styles.js +25 -0
  44. package/lib/commonjs/components/LineChart/styles.js.map +1 -0
  45. package/lib/commonjs/components/PieChart/geometry.js +216 -0
  46. package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
  47. package/lib/commonjs/components/PieChart/index.js +476 -0
  48. package/lib/commonjs/components/PieChart/index.js.map +1 -0
  49. package/lib/commonjs/components/PieChart/styles.js +88 -0
  50. package/lib/commonjs/components/PieChart/styles.js.map +1 -0
  51. package/lib/commonjs/components/ProgressBar/index.js +44 -12
  52. package/lib/commonjs/components/ProgressBar/index.js.map +1 -1
  53. package/lib/commonjs/components/ProgressBar/styles.js +31 -2
  54. package/lib/commonjs/components/ProgressBar/styles.js.map +1 -1
  55. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
  56. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  57. package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
  58. package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
  59. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
  60. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
  61. package/lib/commonjs/components/Select/index.js.map +1 -1
  62. package/lib/commonjs/components/Stepper/index.js +369 -0
  63. package/lib/commonjs/components/Stepper/index.js.map +1 -0
  64. package/lib/commonjs/components/Stepper/styles.js +211 -0
  65. package/lib/commonjs/components/Stepper/styles.js.map +1 -0
  66. package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
  67. package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
  68. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
  69. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  70. package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
  71. package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
  72. package/lib/commonjs/components/SystemAlert/animation.js +218 -0
  73. package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
  74. package/lib/commonjs/components/SystemAlert/index.js +525 -0
  75. package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
  76. package/lib/commonjs/components/SystemAlert/styles.js +178 -0
  77. package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
  78. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
  79. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  80. package/lib/commonjs/components/Tabs/index.js +4 -0
  81. package/lib/commonjs/components/Tabs/index.js.map +1 -1
  82. package/lib/commonjs/components/Tabs/styles.js +1 -1
  83. package/lib/commonjs/components/Tabs/styles.js.map +1 -1
  84. package/lib/commonjs/components/chart/ChartInspector.js +610 -0
  85. package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
  86. package/lib/commonjs/components/chart/format.js +93 -0
  87. package/lib/commonjs/components/chart/format.js.map +1 -0
  88. package/lib/commonjs/components/chart/hiddenSvgProps.js +23 -0
  89. package/lib/commonjs/components/chart/hiddenSvgProps.js.map +1 -0
  90. package/lib/commonjs/components/chart/index.js +2 -0
  91. package/lib/commonjs/components/chart/index.js.map +1 -0
  92. package/lib/commonjs/components/chart/motion.js +97 -0
  93. package/lib/commonjs/components/chart/motion.js.map +1 -0
  94. package/lib/commonjs/components/chart/palette.js +178 -0
  95. package/lib/commonjs/components/chart/palette.js.map +1 -0
  96. package/lib/commonjs/components/chart/size.js +34 -0
  97. package/lib/commonjs/components/chart/size.js.map +1 -0
  98. package/lib/commonjs/components/chart/ticks.js +59 -0
  99. package/lib/commonjs/components/chart/ticks.js.map +1 -0
  100. package/lib/commonjs/components/chart/types.js +6 -0
  101. package/lib/commonjs/components/chart/types.js.map +1 -0
  102. package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
  103. package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
  104. package/lib/commonjs/components/index.js +72 -0
  105. package/lib/commonjs/components/index.js.map +1 -1
  106. package/lib/commonjs/figma/Accordion.figma.js +2 -2
  107. package/lib/commonjs/figma/Accordion.figma.js.map +1 -1
  108. package/lib/commonjs/figma/Alert.figma.js +7 -7
  109. package/lib/commonjs/figma/Alert.figma.js.map +1 -1
  110. package/lib/commonjs/figma/Badge.Indicator.figma.js +6 -5
  111. package/lib/commonjs/figma/Badge.Indicator.figma.js.map +1 -1
  112. package/lib/commonjs/figma/Badge.figma.js +22 -22
  113. package/lib/commonjs/figma/Badge.figma.js.map +1 -1
  114. package/lib/commonjs/figma/Button.figma.js +5 -2
  115. package/lib/commonjs/figma/Button.figma.js.map +1 -1
  116. package/lib/commonjs/figma/CLAUDE.md +1 -0
  117. package/lib/commonjs/figma/Card.Header.figma.js +8 -4
  118. package/lib/commonjs/figma/Card.Header.figma.js.map +1 -1
  119. package/lib/commonjs/figma/Card.figma.js +2 -1
  120. package/lib/commonjs/figma/Card.figma.js.map +1 -1
  121. package/lib/commonjs/figma/Chip.figma.js +2 -2
  122. package/lib/commonjs/figma/Chip.figma.js.map +1 -1
  123. package/lib/commonjs/figma/CurrencyInput.figma.js +1 -1
  124. package/lib/commonjs/figma/CurrencyInput.figma.js.map +1 -1
  125. package/lib/commonjs/figma/Dialog.figma.js +5 -2
  126. package/lib/commonjs/figma/Dialog.figma.js.map +1 -1
  127. package/lib/commonjs/figma/Divider.figma.js +1 -1
  128. package/lib/commonjs/figma/Divider.figma.js.map +1 -1
  129. package/lib/commonjs/figma/Drawer.figma.js +3 -3
  130. package/lib/commonjs/figma/Drawer.figma.js.map +1 -1
  131. package/lib/commonjs/figma/IconButton.figma.js +10 -4
  132. package/lib/commonjs/figma/IconButton.figma.js.map +1 -1
  133. package/lib/commonjs/figma/Input.figma.js +2 -1
  134. package/lib/commonjs/figma/Input.figma.js.map +1 -1
  135. package/lib/commonjs/figma/Insight.figma.js +3 -3
  136. package/lib/commonjs/figma/Insight.figma.js.map +1 -1
  137. package/lib/commonjs/figma/ProgressBar.figma.js +11 -2
  138. package/lib/commonjs/figma/ProgressBar.figma.js.map +1 -1
  139. package/lib/commonjs/figma/ProgressSegmented.figma.js +9 -1
  140. package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -1
  141. package/lib/commonjs/figma/Select.figma.js +2 -1
  142. package/lib/commonjs/figma/Select.figma.js.map +1 -1
  143. package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
  144. package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
  145. package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
  146. package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
  147. package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
  148. package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
  149. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
  150. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
  151. package/lib/commonjs/figma/SystemAlert.figma.js +47 -0
  152. package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
  153. package/lib/commonjs/styles.css +0 -1
  154. package/lib/module/components/BarChart/geometry.js +1110 -0
  155. package/lib/module/components/BarChart/geometry.js.map +1 -0
  156. package/lib/module/components/BarChart/index.js +929 -0
  157. package/lib/module/components/BarChart/index.js.map +1 -0
  158. package/lib/module/components/BarChart/styles.js +22 -0
  159. package/lib/module/components/BarChart/styles.js.map +1 -0
  160. package/lib/module/components/Button/index.js +2 -2
  161. package/lib/module/components/Button/index.js.map +1 -1
  162. package/lib/module/components/CountryFlag/index.js +52 -0
  163. package/lib/module/components/CountryFlag/index.js.map +1 -0
  164. package/lib/module/components/Input/index.js.map +1 -1
  165. package/lib/module/components/LineChart/geometry.js +685 -0
  166. package/lib/module/components/LineChart/geometry.js.map +1 -0
  167. package/lib/module/components/LineChart/index.js +738 -0
  168. package/lib/module/components/LineChart/index.js.map +1 -0
  169. package/lib/module/components/LineChart/styles.js +21 -0
  170. package/lib/module/components/LineChart/styles.js.map +1 -0
  171. package/lib/module/components/PieChart/geometry.js +209 -0
  172. package/lib/module/components/PieChart/geometry.js.map +1 -0
  173. package/lib/module/components/PieChart/index.js +471 -0
  174. package/lib/module/components/PieChart/index.js.map +1 -0
  175. package/lib/module/components/PieChart/styles.js +84 -0
  176. package/lib/module/components/PieChart/styles.js.map +1 -0
  177. package/lib/module/components/ProgressBar/index.js +47 -15
  178. package/lib/module/components/ProgressBar/index.js.map +1 -1
  179. package/lib/module/components/ProgressBar/styles.js +31 -2
  180. package/lib/module/components/ProgressBar/styles.js.map +1 -1
  181. package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
  182. package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  183. package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
  184. package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
  185. package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
  186. package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
  187. package/lib/module/components/Select/index.js.map +1 -1
  188. package/lib/module/components/Stepper/index.js +360 -0
  189. package/lib/module/components/Stepper/index.js.map +1 -0
  190. package/lib/module/components/Stepper/styles.js +206 -0
  191. package/lib/module/components/Stepper/styles.js.map +1 -0
  192. package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
  193. package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
  194. package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
  195. package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  196. package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
  197. package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
  198. package/lib/module/components/SystemAlert/animation.js +213 -0
  199. package/lib/module/components/SystemAlert/animation.js.map +1 -0
  200. package/lib/module/components/SystemAlert/index.js +515 -0
  201. package/lib/module/components/SystemAlert/index.js.map +1 -0
  202. package/lib/module/components/SystemAlert/styles.js +174 -0
  203. package/lib/module/components/SystemAlert/styles.js.map +1 -0
  204. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
  205. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  206. package/lib/module/components/Tabs/index.js +4 -0
  207. package/lib/module/components/Tabs/index.js.map +1 -1
  208. package/lib/module/components/Tabs/styles.js +1 -1
  209. package/lib/module/components/Tabs/styles.js.map +1 -1
  210. package/lib/module/components/chart/ChartInspector.js +600 -0
  211. package/lib/module/components/chart/ChartInspector.js.map +1 -0
  212. package/lib/module/components/chart/format.js +84 -0
  213. package/lib/module/components/chart/format.js.map +1 -0
  214. package/lib/module/components/chart/hiddenSvgProps.js +20 -0
  215. package/lib/module/components/chart/hiddenSvgProps.js.map +1 -0
  216. package/lib/module/components/chart/index.js +2 -0
  217. package/lib/module/components/chart/index.js.map +1 -0
  218. package/lib/module/components/chart/motion.js +89 -0
  219. package/lib/module/components/chart/motion.js.map +1 -0
  220. package/lib/module/components/chart/palette.js +168 -0
  221. package/lib/module/components/chart/palette.js.map +1 -0
  222. package/lib/module/components/chart/size.js +29 -0
  223. package/lib/module/components/chart/size.js.map +1 -0
  224. package/lib/module/components/chart/ticks.js +55 -0
  225. package/lib/module/components/chart/ticks.js.map +1 -0
  226. package/lib/module/components/chart/types.js +4 -0
  227. package/lib/module/components/chart/types.js.map +1 -0
  228. package/lib/module/components/chart/useChartHostWidth.js +23 -0
  229. package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
  230. package/lib/module/components/index.js +6 -0
  231. package/lib/module/components/index.js.map +1 -1
  232. package/lib/module/figma/Accordion.figma.js +2 -2
  233. package/lib/module/figma/Accordion.figma.js.map +1 -1
  234. package/lib/module/figma/Alert.figma.js +7 -7
  235. package/lib/module/figma/Alert.figma.js.map +1 -1
  236. package/lib/module/figma/Badge.Indicator.figma.js +6 -5
  237. package/lib/module/figma/Badge.Indicator.figma.js.map +1 -1
  238. package/lib/module/figma/Badge.figma.js +22 -22
  239. package/lib/module/figma/Badge.figma.js.map +1 -1
  240. package/lib/module/figma/Button.figma.js +5 -2
  241. package/lib/module/figma/Button.figma.js.map +1 -1
  242. package/lib/module/figma/CLAUDE.md +1 -0
  243. package/lib/module/figma/Card.Header.figma.js +8 -4
  244. package/lib/module/figma/Card.Header.figma.js.map +1 -1
  245. package/lib/module/figma/Card.figma.js +2 -1
  246. package/lib/module/figma/Card.figma.js.map +1 -1
  247. package/lib/module/figma/Chip.figma.js +2 -2
  248. package/lib/module/figma/Chip.figma.js.map +1 -1
  249. package/lib/module/figma/CurrencyInput.figma.js +1 -1
  250. package/lib/module/figma/CurrencyInput.figma.js.map +1 -1
  251. package/lib/module/figma/Dialog.figma.js +5 -2
  252. package/lib/module/figma/Dialog.figma.js.map +1 -1
  253. package/lib/module/figma/Divider.figma.js +1 -1
  254. package/lib/module/figma/Divider.figma.js.map +1 -1
  255. package/lib/module/figma/Drawer.figma.js +3 -3
  256. package/lib/module/figma/Drawer.figma.js.map +1 -1
  257. package/lib/module/figma/IconButton.figma.js +10 -4
  258. package/lib/module/figma/IconButton.figma.js.map +1 -1
  259. package/lib/module/figma/Input.figma.js +2 -1
  260. package/lib/module/figma/Input.figma.js.map +1 -1
  261. package/lib/module/figma/Insight.figma.js +3 -3
  262. package/lib/module/figma/Insight.figma.js.map +1 -1
  263. package/lib/module/figma/ProgressBar.figma.js +12 -2
  264. package/lib/module/figma/ProgressBar.figma.js.map +1 -1
  265. package/lib/module/figma/ProgressSegmented.figma.js +9 -1
  266. package/lib/module/figma/ProgressSegmented.figma.js.map +1 -1
  267. package/lib/module/figma/Select.figma.js +2 -1
  268. package/lib/module/figma/Select.figma.js.map +1 -1
  269. package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
  270. package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
  271. package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
  272. package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
  273. package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
  274. package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
  275. package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
  276. package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
  277. package/lib/module/figma/SystemAlert.figma.js +41 -0
  278. package/lib/module/figma/SystemAlert.figma.js.map +1 -0
  279. package/lib/module/styles.css +0 -1
  280. package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
  281. package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
  282. package/lib/typescript/components/BarChart/index.d.ts +193 -0
  283. package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
  284. package/lib/typescript/components/BarChart/styles.d.ts +32 -0
  285. package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
  286. package/lib/typescript/components/CountryFlag/index.d.ts +35 -0
  287. package/lib/typescript/components/CountryFlag/index.d.ts.map +1 -0
  288. package/lib/typescript/components/Input/index.d.ts +2 -0
  289. package/lib/typescript/components/Input/index.d.ts.map +1 -1
  290. package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
  291. package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
  292. package/lib/typescript/components/LineChart/index.d.ts +105 -0
  293. package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
  294. package/lib/typescript/components/LineChart/styles.d.ts +12 -0
  295. package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
  296. package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
  297. package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
  298. package/lib/typescript/components/PieChart/index.d.ts +147 -0
  299. package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
  300. package/lib/typescript/components/PieChart/styles.d.ts +27 -0
  301. package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
  302. package/lib/typescript/components/ProgressBar/index.d.ts +16 -1
  303. package/lib/typescript/components/ProgressBar/index.d.ts.map +1 -1
  304. package/lib/typescript/components/ProgressBar/styles.d.ts +7 -2
  305. package/lib/typescript/components/ProgressBar/styles.d.ts.map +1 -1
  306. package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
  307. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
  308. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
  309. package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
  310. package/lib/typescript/components/Select/index.d.ts +2 -0
  311. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  312. package/lib/typescript/components/Stepper/index.d.ts +68 -0
  313. package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
  314. package/lib/typescript/components/Stepper/styles.d.ts +46 -0
  315. package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
  316. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
  317. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
  318. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
  319. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
  320. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
  321. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
  322. package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
  323. package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
  324. package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
  325. package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
  326. package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
  327. package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
  328. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
  329. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
  330. package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
  331. package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
  332. package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
  333. package/lib/typescript/components/chart/format.d.ts +16 -0
  334. package/lib/typescript/components/chart/format.d.ts.map +1 -0
  335. package/lib/typescript/components/chart/hiddenSvgProps.d.ts +17 -0
  336. package/lib/typescript/components/chart/hiddenSvgProps.d.ts.map +1 -0
  337. package/lib/typescript/components/chart/index.d.ts +3 -0
  338. package/lib/typescript/components/chart/index.d.ts.map +1 -0
  339. package/lib/typescript/components/chart/motion.d.ts +27 -0
  340. package/lib/typescript/components/chart/motion.d.ts.map +1 -0
  341. package/lib/typescript/components/chart/palette.d.ts +44 -0
  342. package/lib/typescript/components/chart/palette.d.ts.map +1 -0
  343. package/lib/typescript/components/chart/size.d.ts +25 -0
  344. package/lib/typescript/components/chart/size.d.ts.map +1 -0
  345. package/lib/typescript/components/chart/ticks.d.ts +3 -0
  346. package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
  347. package/lib/typescript/components/chart/types.d.ts +163 -0
  348. package/lib/typescript/components/chart/types.d.ts.map +1 -0
  349. package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
  350. package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
  351. package/lib/typescript/components/index.d.ts +6 -0
  352. package/lib/typescript/components/index.d.ts.map +1 -1
  353. package/lib/typescript/figma/Alert.figma.d.ts.map +1 -1
  354. package/lib/typescript/figma/Badge.Indicator.figma.d.ts.map +1 -1
  355. package/lib/typescript/figma/Badge.figma.d.ts.map +1 -1
  356. package/lib/typescript/figma/Button.figma.d.ts.map +1 -1
  357. package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -1
  358. package/lib/typescript/figma/Card.figma.d.ts.map +1 -1
  359. package/lib/typescript/figma/Dialog.figma.d.ts.map +1 -1
  360. package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -1
  361. package/lib/typescript/figma/Input.figma.d.ts.map +1 -1
  362. package/lib/typescript/figma/ProgressBar.figma.d.ts.map +1 -1
  363. package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -1
  364. package/lib/typescript/figma/Select.figma.d.ts.map +1 -1
  365. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
  366. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
  367. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
  368. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
  369. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
  370. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
  371. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
  372. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
  373. package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
  374. package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
  375. package/package.json +5 -5
  376. package/src/components/BarChart/geometry.ts +1469 -0
  377. package/src/components/BarChart/index.tsx +1417 -0
  378. package/src/components/BarChart/styles.ts +31 -0
  379. package/src/components/Button/index.tsx +1 -1
  380. package/src/components/CountryFlag/index.tsx +53 -0
  381. package/src/components/Input/index.tsx +2 -0
  382. package/src/components/LineChart/geometry.ts +957 -0
  383. package/src/components/LineChart/index.tsx +1106 -0
  384. package/src/components/LineChart/styles.ts +26 -0
  385. package/src/components/PieChart/geometry.ts +295 -0
  386. package/src/components/PieChart/index.tsx +715 -0
  387. package/src/components/PieChart/styles.ts +101 -0
  388. package/src/components/ProgressBar/index.tsx +66 -14
  389. package/src/components/ProgressBar/styles.ts +35 -4
  390. package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
  391. package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
  392. package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
  393. package/src/components/Select/index.tsx +2 -0
  394. package/src/components/Stepper/index.tsx +452 -0
  395. package/src/components/Stepper/styles.ts +234 -0
  396. package/src/components/Stepper/useStepperLabelFit.ts +21 -0
  397. package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
  398. package/src/components/Stepper/useStepperRingColors.ts +29 -0
  399. package/src/components/SystemAlert/animation.ts +252 -0
  400. package/src/components/SystemAlert/index.tsx +684 -0
  401. package/src/components/SystemAlert/styles.ts +212 -0
  402. package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
  403. package/src/components/Tabs/index.tsx +4 -0
  404. package/src/components/Tabs/styles.ts +1 -1
  405. package/src/components/chart/ChartInspector.tsx +726 -0
  406. package/src/components/chart/format.ts +95 -0
  407. package/src/components/chart/hiddenSvgProps.ts +15 -0
  408. package/src/components/chart/index.ts +24 -0
  409. package/src/components/chart/motion.ts +98 -0
  410. package/src/components/chart/palette.tsx +247 -0
  411. package/src/components/chart/size.ts +21 -0
  412. package/src/components/chart/ticks.ts +53 -0
  413. package/src/components/chart/types.ts +183 -0
  414. package/src/components/chart/useChartHostWidth.ts +26 -0
  415. package/src/components/index.ts +6 -0
  416. package/src/styles.css +0 -1
@@ -0,0 +1,1130 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OVERLAY_SPACING_RATIO = exports.OVERLAY_PRIMARY_RATIO = exports.OVERLAY_COMPARE_RATIO = exports.MIN_CATEGORY_BAND = exports.DEFAULT_TICK_COUNT = exports.DEFAULT_STACK_GAP = exports.CATEGORY_GAP_RATIO = exports.BAR_GAP_RATIO = void 0;
7
+ exports.barChartGutters = barChartGutters;
8
+ exports.barKeyboardNeighbor = barKeyboardNeighbor;
9
+ exports.barPath = barPath;
10
+ exports.barValueAnchor = barValueAnchor;
11
+ exports.formatBarValue = formatBarValue;
12
+ exports.formatWaterfallBarValue = formatWaterfallBarValue;
13
+ exports.isExpandAxis = isExpandAxis;
14
+ exports.layoutBarChart = layoutBarChart;
15
+ exports.overlayDelta = overlayDelta;
16
+ exports.readBarValue = readBarValue;
17
+ exports.resolveBarChartContentSize = resolveBarChartContentSize;
18
+ exports.resolveBarChartGutters = resolveBarChartGutters;
19
+ exports.resolveBarGroups = resolveBarGroups;
20
+ exports.resolveBarValueScale = resolveBarValueScale;
21
+ exports.resolveCategoryLabelPosition = resolveCategoryLabelPosition;
22
+ exports.stackedTotalAnchors = stackedTotalAnchors;
23
+ exports.waterfallValueAnchor = waterfallValueAnchor;
24
+ var _ticks = require("../chart/ticks");
25
+ /**
26
+ * Where category names sit around the plot. `top` / `bottom` apply to vertical
27
+ * bars; `left` / `right` apply to horizontal bars. Other combinations fall back
28
+ * to `bottom` or `left`. `none` draws no category names.
29
+ */
30
+
31
+ /**
32
+ * How a stack group piles its series. `diverging` stacks positive values up and negative values
33
+ * down from zero. `none` adds every value to one running total. `expand` scales each category to
34
+ * the same length, so segments show their share.
35
+ */
36
+
37
+ /** How the chart draws its series: side by side or stacked, a comparison overlay, or a waterfall. */
38
+
39
+ /** A series resolved for layout. `id` is the public series id. */
40
+
41
+ /** Share of each category slot left empty around the bars. MUI X `categoryGapRatio`. */
42
+ const CATEGORY_GAP_RATIO = exports.CATEGORY_GAP_RATIO = 0.36;
43
+ /** Gap between bars in one category, as a share of one bar's thickness. MUI X `barGapRatio`. */
44
+ const BAR_GAP_RATIO = exports.BAR_GAP_RATIO = 0.5;
45
+ /** Primary bar share of the overlay slot. Comparison series are thinner and peek out. */
46
+ const OVERLAY_PRIMARY_RATIO = exports.OVERLAY_PRIMARY_RATIO = 0.7;
47
+ const OVERLAY_COMPARE_RATIO = exports.OVERLAY_COMPARE_RATIO = 0.16;
48
+ const OVERLAY_SPACING_RATIO = exports.OVERLAY_SPACING_RATIO = 0.08;
49
+ /** Pixel gap between stacked segments. `0` joins them with only the outer cap rounded. */
50
+ const DEFAULT_STACK_GAP = exports.DEFAULT_STACK_GAP = 3;
51
+ const DEFAULT_TICK_COUNT = exports.DEFAULT_TICK_COUNT = 4;
52
+ /** Minimum pixels per category when scrolling. Keeps labels and bars readable. */
53
+ const MIN_CATEGORY_BAND = exports.MIN_CATEGORY_BAND = 48;
54
+ /** `expand` ticks when the value axis sets no `min`, `max`, or `tickNumber`. */
55
+ const EXPAND_TICKS = [0, 25, 50, 75, 100];
56
+ function clamp(value, min, max) {
57
+ return Math.min(max, Math.max(min, value));
58
+ }
59
+ function round2(value) {
60
+ const rounded = Math.round(value * 100) / 100;
61
+ return Object.is(rounded, -0) ? 0 : rounded;
62
+ }
63
+
64
+ /** Reads a finite number from `row[key]`. Anything else is a missing value. */
65
+ function readBarValue(row, key) {
66
+ const raw = row[key];
67
+ if (typeof raw !== 'number' || !Number.isFinite(raw)) {
68
+ return null;
69
+ }
70
+ return raw;
71
+ }
72
+ function readBarFlag(row, key) {
73
+ return key !== undefined && row[key] === true;
74
+ }
75
+ /**
76
+ * One slot per stack group, in first-appearance order. A series without `stack` gets its own
77
+ * slot. The first `stackOffset` set in a group applies to the whole group.
78
+ */
79
+ function resolveBarGroups(series) {
80
+ const groups = [];
81
+ const byStack = new Map();
82
+ series.forEach((item, seriesIndex) => {
83
+ if (item.stack === undefined) {
84
+ groups.push({
85
+ stackId: undefined,
86
+ offset: null,
87
+ members: [{
88
+ item,
89
+ seriesIndex
90
+ }]
91
+ });
92
+ return;
93
+ }
94
+ let group = byStack.get(item.stack);
95
+ if (group === undefined) {
96
+ group = {
97
+ stackId: item.stack,
98
+ offset: null,
99
+ members: []
100
+ };
101
+ byStack.set(item.stack, group);
102
+ groups.push(group);
103
+ }
104
+ group.members.push({
105
+ item,
106
+ seriesIndex
107
+ });
108
+ if (group.offset === null && item.stackOffset !== undefined) {
109
+ group.offset = item.stackOffset;
110
+ }
111
+ });
112
+ return groups.map(group => group.stackId === undefined ? group : {
113
+ ...group,
114
+ offset: group.offset ?? 'diverging'
115
+ });
116
+ }
117
+ function groupDomainValues(dataset, group) {
118
+ if (group.offset === 'expand') {
119
+ return [0, 100];
120
+ }
121
+ const values = [];
122
+ for (const row of dataset) {
123
+ if (group.offset === null) {
124
+ for (const {
125
+ item
126
+ } of group.members) {
127
+ const value = readBarValue(row, item.dataKey);
128
+ if (value !== null) {
129
+ values.push(value);
130
+ }
131
+ }
132
+ continue;
133
+ }
134
+ let positive = 0;
135
+ let negative = 0;
136
+ let running = 0;
137
+ for (const {
138
+ item
139
+ } of group.members) {
140
+ const value = readBarValue(row, item.dataKey);
141
+ if (value === null) {
142
+ continue;
143
+ }
144
+ if (group.offset === 'none') {
145
+ running += value;
146
+ values.push(running);
147
+ } else if (value >= 0) {
148
+ positive += value;
149
+ } else {
150
+ negative += value;
151
+ }
152
+ }
153
+ if (group.offset === 'diverging') {
154
+ values.push(positive, negative);
155
+ }
156
+ }
157
+ return values;
158
+ }
159
+ function collectWaterfallTotals(dataset, dataKey, totalKey) {
160
+ let cursor = 0;
161
+ const totals = [0];
162
+ dataset.forEach((row, index) => {
163
+ const raw = readBarValue(row, dataKey);
164
+ if (readBarFlag(row, totalKey)) {
165
+ if (raw !== null && index === 0) {
166
+ cursor = raw;
167
+ }
168
+ totals.push(cursor);
169
+ return;
170
+ }
171
+ if (raw === null) {
172
+ return;
173
+ }
174
+ cursor += raw;
175
+ totals.push(cursor);
176
+ });
177
+ return totals;
178
+ }
179
+ function stackSegments(row, members, offset) {
180
+ const raw = [];
181
+ let positiveTotal = 0;
182
+ for (const {
183
+ item,
184
+ seriesIndex
185
+ } of members) {
186
+ const value = readBarValue(row, item.dataKey);
187
+ if (value === null) {
188
+ continue;
189
+ }
190
+ if (offset === 'expand' && value <= 0) {
191
+ continue;
192
+ }
193
+ if (value > 0) {
194
+ positiveTotal += value;
195
+ }
196
+ raw.push({
197
+ item,
198
+ seriesIndex,
199
+ value,
200
+ display: value
201
+ });
202
+ }
203
+ if (offset !== 'expand' || positiveTotal <= 0) {
204
+ return raw;
205
+ }
206
+ return raw.map(segment => ({
207
+ ...segment,
208
+ display: segment.value / positiveTotal * 100
209
+ }));
210
+ }
211
+ function computeDomain(values) {
212
+ if (values.length === 0) {
213
+ return {
214
+ min: 0,
215
+ max: 1
216
+ };
217
+ }
218
+ const min = Math.min(0, ...values);
219
+ let max = Math.max(0, ...values);
220
+ if (min === max) {
221
+ max = 1;
222
+ }
223
+ return {
224
+ min,
225
+ max
226
+ };
227
+ }
228
+ function finite(value) {
229
+ return value !== undefined && Number.isFinite(value) ? value : undefined;
230
+ }
231
+
232
+ /**
233
+ * Value-axis domain and ticks. `min` / `max` pin the domain exactly; otherwise it rounds out to
234
+ * readable ticks. On an `expand` axis, `min` / `max` are 0–1 shares.
235
+ */
236
+ function resolveBarValueScale(values, axis, expand) {
237
+ const scale = expand ? 100 : 1;
238
+ const axisMin = finite(axis?.min);
239
+ const axisMax = finite(axis?.max);
240
+ const tickNumber = finite(axis?.tickNumber);
241
+ const raw = expand ? {
242
+ min: 0,
243
+ max: 100
244
+ } : computeDomain(values);
245
+ const lo = axisMin !== undefined ? axisMin * scale : raw.min;
246
+ let hi = axisMax !== undefined ? axisMax * scale : raw.max;
247
+ if (hi <= lo) {
248
+ hi = lo + 1;
249
+ }
250
+ const candidates = expand && axisMin === undefined && axisMax === undefined && tickNumber === undefined ? EXPAND_TICKS : (0, _ticks.niceTicks)(lo, hi, Math.round(tickNumber ?? (expand ? EXPAND_TICKS.length : DEFAULT_TICK_COUNT)));
251
+ const min = axisMin !== undefined ? lo : Math.min(lo, candidates[0] ?? lo);
252
+ const max = axisMax !== undefined ? hi : Math.max(hi, candidates.at(-1) ?? hi);
253
+ const epsilon = (max - min) * 1e-9;
254
+ const ticks = candidates.filter(tick => tick >= min - epsilon && tick <= max + epsilon);
255
+ return {
256
+ min,
257
+ max,
258
+ ticks
259
+ };
260
+ }
261
+
262
+ /** Default tick formatter when the chart passes no `formatTick`. */
263
+ function formatBarValue(value) {
264
+ if (Number.isInteger(value)) {
265
+ return String(value);
266
+ }
267
+ return String(round2(value));
268
+ }
269
+ function categoryLabelPadding(categories, orientation) {
270
+ if (orientation !== 'horizontal') {
271
+ return 40;
272
+ }
273
+ const longest = categories.reduce((max, label) => Math.max(max, label.length), 0);
274
+ return clamp(longest * 8 + 16, 64, 168);
275
+ }
276
+ const CATEGORY_EDGE_GUTTER = 28;
277
+ /** Average `text-xs` glyph width; SVG text cannot be measured before layout. */
278
+ const CATEGORY_LABEL_CHAR_WIDTH = 6.5;
279
+ const VALUE_TICK_LEFT = 40;
280
+ const VALUE_TICK_END = 28;
281
+ const TIGHT_GUTTER = 8;
282
+ const VALUES_END_GUTTER = 72;
283
+ const OVERLAY_VALUES_END_GUTTER = 156;
284
+ /** Room for `$1,234` above the tallest bar (`fontSize` 10 + iOS baseline). */
285
+ const VALUES_TOP_GUTTER = 36;
286
+ const PLOT_END_GUTTER = 20;
287
+ const NEGATIVE_VALUES_GUTTER = 16;
288
+ function resolveCategoryLabelPosition(orientation, position) {
289
+ if (position === 'none') {
290
+ return 'none';
291
+ }
292
+ if (orientation === 'vertical') {
293
+ return position === 'top' ? 'top' : 'bottom';
294
+ }
295
+ return position === 'right' ? 'right' : 'left';
296
+ }
297
+ function resolveBarChartGutters({
298
+ categories,
299
+ hasNegative,
300
+ orientation,
301
+ barLabel,
302
+ categoryLabelPosition,
303
+ showTicks = true,
304
+ overlay = false
305
+ }) {
306
+ const labels = resolveCategoryLabelPosition(orientation, categoryLabelPosition);
307
+ if (orientation === 'vertical') {
308
+ const labelsTop = labels === 'top';
309
+ return {
310
+ paddingLeft: showTicks ? VALUE_TICK_LEFT : TIGHT_GUTTER,
311
+ paddingRight: showTicks ? VALUE_TICK_END : PLOT_END_GUTTER,
312
+ paddingTop: labelsTop ? CATEGORY_EDGE_GUTTER : barLabel ? VALUES_TOP_GUTTER : TIGHT_GUTTER,
313
+ paddingBottom: (labelsTop || labels === 'none' ? TIGHT_GUTTER : CATEGORY_EDGE_GUTTER) + (hasNegative && barLabel ? NEGATIVE_VALUES_GUTTER : 0)
314
+ };
315
+ }
316
+ const labelsRight = labels === 'right';
317
+ const categoryPad = labels === 'none' ? TIGHT_GUTTER : categoryLabelPadding(categories, orientation);
318
+ const valuesEnd = barLabel && overlay ? OVERLAY_VALUES_END_GUTTER : barLabel ? VALUES_END_GUTTER : TIGHT_GUTTER;
319
+ return {
320
+ paddingLeft: labelsRight ? TIGHT_GUTTER : categoryPad,
321
+ paddingRight: labelsRight ? categoryPad : Math.max(valuesEnd, showTicks ? VALUE_TICK_END : 0),
322
+ paddingTop: TIGHT_GUTTER,
323
+ paddingBottom: showTicks ? CATEGORY_EDGE_GUTTER : TIGHT_GUTTER
324
+ };
325
+ }
326
+
327
+ /**
328
+ * Gutters from rows with a string `label` field. `LineChart` lays out with the same gutters.
329
+ */
330
+ function barChartGutters(data, orientation, barLabel, categoryLabelPosition, showTicks = true, overlay = false) {
331
+ return resolveBarChartGutters({
332
+ categories: data.map(row => {
333
+ const label = row.label;
334
+ return typeof label === 'string' ? label : '';
335
+ }),
336
+ hasNegative: data.some(row => Object.values(row).some(value => typeof value === 'number' && value < 0)),
337
+ orientation,
338
+ barLabel,
339
+ categoryLabelPosition,
340
+ showTicks,
341
+ overlay
342
+ });
343
+ }
344
+
345
+ /**
346
+ * Viewport is the visible box (screen or parent). Content grows when there are
347
+ * too many categories to keep a readable band (`scrollable` / `visiblePoints`).
348
+ */
349
+ function resolveBarChartContentSize({
350
+ viewportWidth,
351
+ viewportHeight,
352
+ categoryCount,
353
+ orientation,
354
+ gutters,
355
+ scrollable,
356
+ visiblePoints
357
+ }) {
358
+ if (!scrollable || categoryCount <= 0) {
359
+ return {
360
+ width: viewportWidth,
361
+ height: viewportHeight
362
+ };
363
+ }
364
+ if (orientation === 'vertical') {
365
+ const plotWidth = Math.max(viewportWidth - gutters.paddingLeft - gutters.paddingRight, 0);
366
+ const band = visiblePoints !== undefined && visiblePoints > 0 ? plotWidth / visiblePoints : MIN_CATEGORY_BAND;
367
+ const contentPlot = Math.max(plotWidth, categoryCount * band);
368
+ return {
369
+ width: contentPlot + gutters.paddingLeft + gutters.paddingRight,
370
+ height: viewportHeight
371
+ };
372
+ }
373
+ const plotHeight = Math.max(viewportHeight - gutters.paddingTop - gutters.paddingBottom, 0);
374
+ const band = visiblePoints !== undefined && visiblePoints > 0 ? plotHeight / visiblePoints : MIN_CATEGORY_BAND;
375
+ const contentPlot = Math.max(plotHeight, categoryCount * band);
376
+ return {
377
+ width: viewportWidth,
378
+ height: contentPlot + gutters.paddingTop + gutters.paddingBottom
379
+ };
380
+ }
381
+ function groupedRect({
382
+ index,
383
+ seriesIndex,
384
+ slot,
385
+ item,
386
+ label,
387
+ value,
388
+ orientation,
389
+ band,
390
+ groupOffset,
391
+ thickness,
392
+ gap,
393
+ plotX,
394
+ plotY,
395
+ valueToX,
396
+ valueToY
397
+ }) {
398
+ const zeroY = valueToY(0);
399
+ const zeroX = valueToX(0);
400
+ const base = {
401
+ index,
402
+ seriesId: item.id,
403
+ seriesIndex,
404
+ label,
405
+ seriesLabel: item.label,
406
+ value,
407
+ plotValue: value,
408
+ rounded: true
409
+ };
410
+ if (orientation === 'vertical') {
411
+ const x = plotX + index * band + groupOffset + slot * (thickness + gap);
412
+ const y = value >= 0 ? valueToY(value) : zeroY;
413
+ const barHeight = Math.abs(valueToY(value) - zeroY);
414
+ return {
415
+ ...base,
416
+ x: round2(x),
417
+ y: round2(y),
418
+ width: round2(Math.max(thickness, 0)),
419
+ height: round2(Math.max(barHeight, 0))
420
+ };
421
+ }
422
+ const y = plotY + index * band + groupOffset + slot * (thickness + gap);
423
+ const x = value >= 0 ? zeroX : valueToX(value);
424
+ const barWidth = Math.abs(valueToX(value) - zeroX);
425
+ return {
426
+ ...base,
427
+ x: round2(x),
428
+ y: round2(y),
429
+ width: round2(Math.max(barWidth, 0)),
430
+ height: round2(Math.max(thickness, 0))
431
+ };
432
+ }
433
+ function overlayRect({
434
+ index,
435
+ seriesIndex,
436
+ item,
437
+ label,
438
+ value,
439
+ orientation,
440
+ band,
441
+ groupOffset,
442
+ inner,
443
+ plotX,
444
+ plotY,
445
+ valueToX,
446
+ valueToY
447
+ }) {
448
+ const isPrimary = seriesIndex === 0;
449
+ const primaryThickness = inner * OVERLAY_PRIMARY_RATIO;
450
+ const thickness = isPrimary ? primaryThickness : inner * OVERLAY_COMPARE_RATIO;
451
+ const slot = plotX + index * band + groupOffset;
452
+ const slotY = plotY + index * band + groupOffset;
453
+ const offset = isPrimary ? 0 : primaryThickness + inner * OVERLAY_SPACING_RATIO;
454
+ const zeroY = valueToY(0);
455
+ const zeroX = valueToX(0);
456
+ const base = {
457
+ index,
458
+ seriesId: item.id,
459
+ seriesIndex,
460
+ label,
461
+ seriesLabel: item.label,
462
+ value,
463
+ plotValue: value,
464
+ rounded: true
465
+ };
466
+ if (orientation === 'vertical') {
467
+ const x = slot + offset;
468
+ const y = value >= 0 ? valueToY(value) : zeroY;
469
+ const barHeight = Math.abs(valueToY(value) - zeroY);
470
+ return {
471
+ ...base,
472
+ x: round2(x),
473
+ y: round2(y),
474
+ width: round2(Math.max(thickness, 0)),
475
+ height: round2(Math.max(barHeight, 0))
476
+ };
477
+ }
478
+ const y = slotY + offset;
479
+ const x = value >= 0 ? zeroX : valueToX(value);
480
+ const barWidth = Math.abs(valueToX(value) - zeroX);
481
+ return {
482
+ ...base,
483
+ x: round2(x),
484
+ y: round2(y),
485
+ width: round2(Math.max(barWidth, 0)),
486
+ height: round2(Math.max(thickness, 0))
487
+ };
488
+ }
489
+ function layoutStackedRow({
490
+ row,
491
+ label,
492
+ index,
493
+ group,
494
+ orientation,
495
+ band,
496
+ groupOffset,
497
+ thickness,
498
+ plotX,
499
+ plotY,
500
+ valueToX,
501
+ valueToY,
502
+ bars,
503
+ stackGap
504
+ }) {
505
+ const offset = group.offset ?? 'diverging';
506
+ const shared = offset === 'none';
507
+ const segments = stackSegments(row, group.members, offset);
508
+ const lastPositiveId = shared ? segments.at(-1)?.item.id : [...segments].reverse().find(segment => segment.display >= 0)?.item.id;
509
+ const lastNegativeId = shared ? segments.at(-1)?.item.id : [...segments].reverse().find(segment => segment.display < 0)?.item.id;
510
+ const separated = stackGap > 0;
511
+ let positiveCursor = 0;
512
+ let negativeCursor = 0;
513
+ let positiveCount = 0;
514
+ let negativeCount = 0;
515
+ segments.forEach(segment => {
516
+ const positive = segment.display >= 0;
517
+ const countBefore = shared ? positiveCount + negativeCount : positive ? positiveCount : negativeCount;
518
+ const gap = countBefore > 0 ? stackGap : 0;
519
+ if (positive) {
520
+ positiveCount += 1;
521
+ } else {
522
+ negativeCount += 1;
523
+ }
524
+ const rounded = separated || positive && segment.item.id === lastPositiveId || !positive && segment.item.id === lastNegativeId;
525
+ const from = shared || positive ? positiveCursor : negativeCursor;
526
+ const to = from + segment.display;
527
+ if (shared) {
528
+ positiveCursor = to;
529
+ negativeCursor = to;
530
+ } else if (positive) {
531
+ positiveCursor = to;
532
+ } else {
533
+ negativeCursor = to;
534
+ }
535
+ const base = {
536
+ index,
537
+ seriesId: segment.item.id,
538
+ seriesIndex: segment.seriesIndex,
539
+ label,
540
+ seriesLabel: segment.item.label,
541
+ value: segment.value,
542
+ plotValue: segment.display,
543
+ rounded,
544
+ roundAll: separated && countBefore > 0,
545
+ stackId: group.stackId,
546
+ ...(offset === 'expand' ? {
547
+ expand: true
548
+ } : {})
549
+ };
550
+ if (orientation === 'vertical') {
551
+ const top = valueToY(Math.max(from, to));
552
+ const bottom = valueToY(Math.min(from, to));
553
+ bars.push({
554
+ ...base,
555
+ x: round2(plotX + index * band + groupOffset),
556
+ y: round2(positive ? top : top + gap),
557
+ width: round2(Math.max(thickness, 0)),
558
+ height: round2(Math.max(bottom - top - gap, 0))
559
+ });
560
+ return;
561
+ }
562
+ const left = valueToX(Math.min(from, to));
563
+ const right = valueToX(Math.max(from, to));
564
+ bars.push({
565
+ ...base,
566
+ x: round2(positive ? left + gap : left),
567
+ y: round2(plotY + index * band + groupOffset),
568
+ width: round2(Math.max(right - left - gap, 0)),
569
+ height: round2(Math.max(thickness, 0))
570
+ });
571
+ });
572
+ }
573
+ function waterfallRole(isTotal, delta) {
574
+ if (isTotal) {
575
+ return 'total';
576
+ }
577
+ return delta >= 0 ? 'increase' : 'decrease';
578
+ }
579
+ function layoutWaterfallBar({
580
+ item,
581
+ label,
582
+ index,
583
+ orientation,
584
+ band,
585
+ groupOffset,
586
+ thickness,
587
+ plotX,
588
+ plotY,
589
+ from,
590
+ to,
591
+ delta,
592
+ role,
593
+ valueToX,
594
+ valueToY
595
+ }) {
596
+ const low = Math.min(from, to);
597
+ const high = Math.max(from, to);
598
+ const base = {
599
+ index,
600
+ seriesId: item.id,
601
+ seriesIndex: index,
602
+ label,
603
+ seriesLabel: item.label,
604
+ value: role === 'total' ? to : delta,
605
+ plotValue: to - from,
606
+ rounded: true,
607
+ // Totals sit on the axis, so only the free end is rounded.
608
+ roundAll: role !== 'total',
609
+ waterfallRole: role
610
+ };
611
+ if (orientation === 'vertical') {
612
+ const top = valueToY(high);
613
+ const bottom = valueToY(low);
614
+ return {
615
+ ...base,
616
+ x: round2(plotX + index * band + groupOffset),
617
+ y: round2(top),
618
+ width: round2(Math.max(thickness, 0)),
619
+ height: round2(Math.max(bottom - top, 0))
620
+ };
621
+ }
622
+ const left = valueToX(low);
623
+ const right = valueToX(high);
624
+ return {
625
+ ...base,
626
+ x: round2(left),
627
+ y: round2(plotY + index * band + groupOffset),
628
+ width: round2(Math.max(right - left, 0)),
629
+ height: round2(Math.max(thickness, 0))
630
+ };
631
+ }
632
+ function waterfallConnector(fromBar, toBar, value, orientation, valueToX, valueToY) {
633
+ if (orientation === 'vertical') {
634
+ const y = round2(valueToY(value));
635
+ return {
636
+ x1: round2(fromBar.x + fromBar.width),
637
+ y1: y,
638
+ x2: round2(toBar.x),
639
+ y2: y
640
+ };
641
+ }
642
+ const x = round2(valueToX(value));
643
+ return {
644
+ x1: x,
645
+ y1: round2(fromBar.y + fromBar.height),
646
+ x2: x,
647
+ y2: round2(toBar.y)
648
+ };
649
+ }
650
+ function barPath(bar, orientation, radius) {
651
+ 'worklet';
652
+
653
+ const {
654
+ x,
655
+ y,
656
+ width,
657
+ height
658
+ } = bar;
659
+ if (width <= 0 || height <= 0) {
660
+ return '';
661
+ }
662
+ if (!bar.rounded) {
663
+ return `M ${String(x)} ${String(y)} L ${String(x + width)} ${String(y)} L ${String(x + width)} ${String(y + height)} L ${String(x)} ${String(y + height)} Z`;
664
+ }
665
+ if (bar.roundAll) {
666
+ const r = Math.min(radius, width / 2, height / 2);
667
+ const x2 = x + width;
668
+ const y2 = y + height;
669
+ return `M ${String(x + r)} ${String(y)} L ${String(x2 - r)} ${String(y)} Q ${String(x2)} ${String(y)} ${String(x2)} ${String(y + r)} L ${String(x2)} ${String(y2 - r)} Q ${String(x2)} ${String(y2)} ${String(x2 - r)} ${String(y2)} L ${String(x + r)} ${String(y2)} Q ${String(x)} ${String(y2)} ${String(x)} ${String(y2 - r)} L ${String(x)} ${String(y + r)} Q ${String(x)} ${String(y)} ${String(x + r)} ${String(y)} Z`;
670
+ }
671
+ const r = orientation === 'vertical' ? Math.min(radius, width / 2, height) : Math.min(radius, height / 2, width);
672
+ const x2 = x + width;
673
+ const y2 = y + height;
674
+ const capPositive = bar.value >= 0;
675
+ if (orientation === 'vertical') {
676
+ if (capPositive) {
677
+ return `M ${String(x)} ${String(y2)} L ${String(x)} ${String(y + r)} Q ${String(x)} ${String(y)} ${String(x + r)} ${String(y)} L ${String(x2 - r)} ${String(y)} Q ${String(x2)} ${String(y)} ${String(x2)} ${String(y + r)} L ${String(x2)} ${String(y2)} Z`;
678
+ }
679
+ return `M ${String(x)} ${String(y)} L ${String(x2)} ${String(y)} L ${String(x2)} ${String(y2 - r)} Q ${String(x2)} ${String(y2)} ${String(x2 - r)} ${String(y2)} L ${String(x + r)} ${String(y2)} Q ${String(x)} ${String(y2)} ${String(x)} ${String(y2 - r)} Z`;
680
+ }
681
+ if (capPositive) {
682
+ return `M ${String(x)} ${String(y)} L ${String(x2 - r)} ${String(y)} Q ${String(x2)} ${String(y)} ${String(x2)} ${String(y + r)} L ${String(x2)} ${String(y2 - r)} Q ${String(x2)} ${String(y2)} ${String(x2 - r)} ${String(y2)} L ${String(x)} ${String(y2)} Z`;
683
+ }
684
+ return `M ${String(x2)} ${String(y)} L ${String(x2)} ${String(y2)} L ${String(x + r)} ${String(y2)} Q ${String(x)} ${String(y2)} ${String(x)} ${String(y2 - r)} L ${String(x)} ${String(y + r)} Q ${String(x)} ${String(y)} ${String(x + r)} ${String(y)} Z`;
685
+ }
686
+ const EMPTY_LAYOUT = {
687
+ bars: [],
688
+ categoryLabels: [],
689
+ valueTicks: [],
690
+ gridLines: [],
691
+ referenceLines: [],
692
+ connectors: [],
693
+ baseline: 0,
694
+ plot: {
695
+ x: 0,
696
+ y: 0,
697
+ width: 0,
698
+ height: 0
699
+ }
700
+ };
701
+
702
+ /** True when every stack group uses `expand`, so the value axis is a 0–1 share axis. */
703
+ function isExpandAxis(kind, groups) {
704
+ return kind === 'bars' && groups.length > 0 && groups.every(group => group.offset === 'expand');
705
+ }
706
+ function layoutBarChart({
707
+ dataset,
708
+ categories,
709
+ series,
710
+ kind = 'bars',
711
+ waterfallTotalKey,
712
+ width,
713
+ height,
714
+ orientation,
715
+ barLabel,
716
+ categoryLabelPosition,
717
+ showTicks = true,
718
+ referenceLines = [],
719
+ valueAxis,
720
+ formatTick = formatBarValue,
721
+ stackGap = DEFAULT_STACK_GAP,
722
+ categoryGapRatio = CATEGORY_GAP_RATIO,
723
+ barGapRatio = BAR_GAP_RATIO,
724
+ showCategoryLabel
725
+ }) {
726
+ if (width <= 0 || height <= 0 || dataset.length === 0 || series.length === 0) {
727
+ return EMPTY_LAYOUT;
728
+ }
729
+ const categoryOf = index => categories?.[index] ?? String(index);
730
+ const resolvedCategories = dataset.map((_, index) => categoryOf(index));
731
+ const overlay = kind === 'overlay';
732
+ const waterfall = kind === 'waterfall';
733
+ const groups = resolveBarGroups(series);
734
+ const expand = isExpandAxis(kind, groups);
735
+ const labels = resolveCategoryLabelPosition(orientation, categoryLabelPosition);
736
+ const {
737
+ paddingLeft,
738
+ paddingRight,
739
+ paddingTop,
740
+ paddingBottom
741
+ } = resolveBarChartGutters({
742
+ categories: resolvedCategories,
743
+ hasNegative: dataset.some(row => series.some(item => (readBarValue(row, item.dataKey) ?? 0) < 0)),
744
+ orientation,
745
+ barLabel,
746
+ categoryLabelPosition: labels,
747
+ showTicks,
748
+ overlay
749
+ });
750
+ const plot = {
751
+ x: paddingLeft,
752
+ y: paddingTop,
753
+ width: Math.max(width - paddingLeft - paddingRight, 0),
754
+ height: Math.max(height - paddingTop - paddingBottom, 0)
755
+ };
756
+ const waterfallSeries = series.at(0);
757
+ const dataValues = waterfall ? collectWaterfallTotals(dataset, waterfallSeries?.dataKey ?? '', waterfallTotalKey) : overlay ? groupDomainValues(dataset, {
758
+ stackId: undefined,
759
+ offset: null,
760
+ members: series.map((item, seriesIndex) => ({
761
+ item,
762
+ seriesIndex
763
+ }))
764
+ }) : groups.flatMap(group => groupDomainValues(dataset, group));
765
+ const values = [...dataValues, ...referenceLines.flatMap(line => Number.isFinite(line.value) ? [line.value] : [])];
766
+ const scale = resolveBarValueScale(values, valueAxis, expand);
767
+ const domainMin = scale.min;
768
+ const domainMax = scale.max;
769
+ const span = domainMax - domainMin || 1;
770
+ const categoryCount = dataset.length;
771
+ const slotCount = overlay || waterfall ? 1 : groups.length;
772
+ const band = orientation === 'vertical' ? plot.width / categoryCount : plot.height / categoryCount;
773
+ const gapShare = clamp(Number.isFinite(categoryGapRatio) ? categoryGapRatio : CATEGORY_GAP_RATIO, 0, 0.95);
774
+ const inner = band * (1 - gapShare);
775
+ const barGap = Math.max(Number.isFinite(barGapRatio) ? barGapRatio : BAR_GAP_RATIO, 0);
776
+ const gapSlots = Math.max(slotCount - 1, 0);
777
+ const thickness = inner / (slotCount + gapSlots * barGap);
778
+ const gap = gapSlots > 0 ? thickness * barGap : 0;
779
+ const groupOffset = (band - inner) / 2;
780
+ const toPlot = value => (clamp(value, domainMin, domainMax) - domainMin) / span;
781
+ const valueToY = value => plot.y + plot.height * (1 - toPlot(value));
782
+ const valueToX = value => plot.x + plot.width * toPlot(value);
783
+ const bars = [];
784
+ const categoryLabels = [];
785
+ const connectors = [];
786
+ let waterfallCursor = 0;
787
+ let waterfallPrev = null;
788
+ dataset.forEach((row, index) => {
789
+ const label = categoryOf(index);
790
+ const shownLabel = showCategoryLabel === undefined || showCategoryLabel(index) ? label : '';
791
+ // With `none`, category names still reach the tooltip and screen readers through the bars.
792
+ if (labels !== 'none' && orientation === 'vertical') {
793
+ const center = plot.x + index * band + band / 2;
794
+ const halfWidth = shownLabel.length * CATEGORY_LABEL_CHAR_WIDTH / 2;
795
+ const anchor = center - halfWidth < plot.x ? {
796
+ x: plot.x,
797
+ textAnchor: 'start'
798
+ } : center + halfWidth > plot.x + plot.width ? {
799
+ x: plot.x + plot.width,
800
+ textAnchor: 'end'
801
+ } : {
802
+ x: center,
803
+ textAnchor: 'middle'
804
+ };
805
+ categoryLabels.push({
806
+ label: shownLabel,
807
+ x: round2(anchor.x),
808
+ y: round2(labels === 'top' ? paddingTop / 2 : height - 8),
809
+ textAnchor: anchor.textAnchor
810
+ });
811
+ } else if (labels !== 'none') {
812
+ categoryLabels.push({
813
+ label: shownLabel,
814
+ x: round2(labels === 'right' ? plot.x + plot.width + 8 : plot.x - 8),
815
+ y: round2(plot.y + index * band + band / 2),
816
+ textAnchor: labels === 'right' ? 'start' : 'end'
817
+ });
818
+ }
819
+ if (waterfall) {
820
+ if (waterfallSeries === undefined) {
821
+ return;
822
+ }
823
+ const isTotal = readBarFlag(row, waterfallTotalKey);
824
+ const raw = readBarValue(row, waterfallSeries.dataKey);
825
+ if (!isTotal && raw === null) {
826
+ return;
827
+ }
828
+ const from = isTotal ? 0 : waterfallCursor;
829
+ if (isTotal) {
830
+ if (raw !== null && index === 0) {
831
+ waterfallCursor = raw;
832
+ }
833
+ } else if (raw !== null) {
834
+ waterfallCursor += raw;
835
+ }
836
+ const to = waterfallCursor;
837
+ const delta = isTotal ? to : raw ?? 0;
838
+ const bar = layoutWaterfallBar({
839
+ item: waterfallSeries,
840
+ label,
841
+ index,
842
+ orientation,
843
+ band,
844
+ groupOffset,
845
+ thickness,
846
+ plotX: plot.x,
847
+ plotY: plot.y,
848
+ from,
849
+ to,
850
+ delta,
851
+ role: waterfallRole(isTotal, delta),
852
+ valueToX,
853
+ valueToY
854
+ });
855
+ if (waterfallPrev !== null) {
856
+ connectors.push(waterfallConnector(waterfallPrev.bar, bar, waterfallPrev.total, orientation, valueToX, valueToY));
857
+ }
858
+ bars.push(bar);
859
+ waterfallPrev = {
860
+ bar,
861
+ total: to
862
+ };
863
+ return;
864
+ }
865
+ if (overlay) {
866
+ series.forEach((item, seriesIndex) => {
867
+ const value = readBarValue(row, item.dataKey);
868
+ if (value === null) {
869
+ return;
870
+ }
871
+ bars.push(overlayRect({
872
+ index,
873
+ seriesIndex,
874
+ item,
875
+ label,
876
+ value,
877
+ orientation,
878
+ band,
879
+ groupOffset,
880
+ inner,
881
+ plotX: plot.x,
882
+ plotY: plot.y,
883
+ valueToX,
884
+ valueToY
885
+ }));
886
+ });
887
+ return;
888
+ }
889
+ groups.forEach((group, slot) => {
890
+ const slotOffset = groupOffset + slot * (thickness + gap);
891
+ if (group.stackId !== undefined) {
892
+ layoutStackedRow({
893
+ row,
894
+ label,
895
+ index,
896
+ group,
897
+ orientation,
898
+ band,
899
+ groupOffset: slotOffset,
900
+ thickness,
901
+ plotX: plot.x,
902
+ plotY: plot.y,
903
+ valueToX,
904
+ valueToY,
905
+ bars,
906
+ stackGap: Math.max(stackGap, 0)
907
+ });
908
+ return;
909
+ }
910
+ const member = group.members.at(0);
911
+ if (member === undefined) {
912
+ return;
913
+ }
914
+ const value = readBarValue(row, member.item.dataKey);
915
+ if (value === null) {
916
+ return;
917
+ }
918
+ bars.push(groupedRect({
919
+ index,
920
+ seriesIndex: member.seriesIndex,
921
+ slot,
922
+ item: member.item,
923
+ label,
924
+ value,
925
+ orientation,
926
+ band,
927
+ groupOffset,
928
+ thickness,
929
+ gap,
930
+ plotX: plot.x,
931
+ plotY: plot.y,
932
+ valueToX,
933
+ valueToY
934
+ }));
935
+ });
936
+ });
937
+ const tickText = value => formatTick(expand ? value / 100 : value);
938
+ const valueTicks = scale.ticks.map(value => {
939
+ if (orientation === 'vertical') {
940
+ return {
941
+ value,
942
+ x: round2(plot.x - 8),
943
+ y: round2(valueToY(value)),
944
+ text: tickText(value)
945
+ };
946
+ }
947
+ return {
948
+ value,
949
+ x: round2(valueToX(value)),
950
+ y: round2(height - 8),
951
+ text: tickText(value)
952
+ };
953
+ });
954
+ const gridLines = scale.ticks.map(value => {
955
+ if (orientation === 'vertical') {
956
+ const y = round2(valueToY(value));
957
+ return {
958
+ x1: round2(plot.x),
959
+ y1: y,
960
+ x2: round2(plot.x + plot.width),
961
+ y2: y
962
+ };
963
+ }
964
+ const x = round2(valueToX(value));
965
+ return {
966
+ x1: x,
967
+ y1: round2(plot.y),
968
+ x2: x,
969
+ y2: round2(plot.y + plot.height)
970
+ };
971
+ });
972
+ const zero = clamp(0, domainMin, domainMax);
973
+ const baseline = round2(orientation === 'vertical' ? valueToY(zero) : valueToX(zero));
974
+ const laidReferenceLines = referenceLines.flatMap(line => {
975
+ if (!Number.isFinite(line.value) || line.value < domainMin || line.value > domainMax) {
976
+ return [];
977
+ }
978
+ if (orientation === 'vertical') {
979
+ const y = round2(valueToY(line.value));
980
+ return [{
981
+ x1: round2(plot.x),
982
+ y1: y,
983
+ x2: round2(plot.x + plot.width),
984
+ y2: y,
985
+ label: line.label
986
+ }];
987
+ }
988
+ const x = round2(valueToX(line.value));
989
+ return [{
990
+ x1: x,
991
+ y1: round2(plot.y),
992
+ x2: x,
993
+ y2: round2(plot.y + plot.height),
994
+ label: line.label
995
+ }];
996
+ });
997
+ return {
998
+ bars,
999
+ categoryLabels,
1000
+ valueTicks,
1001
+ gridLines,
1002
+ referenceLines: laidReferenceLines,
1003
+ connectors,
1004
+ baseline,
1005
+ plot
1006
+ };
1007
+ }
1008
+ function overlayDelta(bars, index) {
1009
+ const group = bars.filter(bar => bar.index === index);
1010
+ const primary = group.find(bar => bar.seriesIndex === 0);
1011
+ const comparison = group.find(bar => bar.seriesIndex === 1);
1012
+ if (primary === undefined || comparison === undefined) {
1013
+ return null;
1014
+ }
1015
+ return round2(primary.value - comparison.value);
1016
+ }
1017
+
1018
+ /** Waterfall steps read as signed changes; totals read as the running total. */
1019
+ function formatWaterfallBarValue(bar, formatValue) {
1020
+ if (bar.waterfallRole === 'increase') {
1021
+ return `+${formatValue(bar.value)}`;
1022
+ }
1023
+ if (bar.waterfallRole === 'decrease') {
1024
+ return `-${formatValue(Math.abs(bar.value))}`;
1025
+ }
1026
+ return formatValue(bar.value);
1027
+ }
1028
+ function waterfallValueAnchor(bar, orientation) {
1029
+ if (orientation === 'vertical') {
1030
+ return {
1031
+ x: round2(bar.x + bar.width / 2),
1032
+ y: round2(bar.y - 4),
1033
+ textAnchor: 'middle'
1034
+ };
1035
+ }
1036
+ return {
1037
+ x: round2(bar.x + bar.width + 4),
1038
+ y: round2(bar.y + bar.height / 2),
1039
+ textAnchor: 'start'
1040
+ };
1041
+ }
1042
+ function barValueAnchor(bar, orientation) {
1043
+ if (orientation === 'vertical') {
1044
+ return {
1045
+ x: round2(bar.x + bar.width / 2),
1046
+ y: round2(bar.plotValue >= 0 ? Math.max(bar.y - 12, 12) : bar.y + bar.height + 12),
1047
+ textAnchor: 'middle'
1048
+ };
1049
+ }
1050
+ return {
1051
+ x: round2(bar.plotValue >= 0 ? bar.x + bar.width + 4 : bar.x - 4),
1052
+ y: round2(bar.y + bar.height / 2),
1053
+ textAnchor: bar.plotValue >= 0 ? 'start' : 'end'
1054
+ };
1055
+ }
1056
+ /** One total label per stack in each category. */
1057
+ function stackedTotalAnchors(bars, orientation) {
1058
+ const byStack = new Map();
1059
+ bars.forEach(bar => {
1060
+ if (bar.stackId === undefined) {
1061
+ return;
1062
+ }
1063
+ const key = `${String(bar.index)}:${bar.stackId}`;
1064
+ const group = byStack.get(key) ?? [];
1065
+ group.push(bar);
1066
+ byStack.set(key, group);
1067
+ });
1068
+ return [...byStack.entries()].flatMap(([key, group]) => {
1069
+ const outer = group.filter(bar => bar.plotValue >= 0).at(-1) ?? group.at(-1);
1070
+ if (outer === undefined) {
1071
+ return [];
1072
+ }
1073
+ const total = group.reduce((sum, bar) => sum + bar.plotValue, 0);
1074
+ const anchor = barValueAnchor({
1075
+ ...outer,
1076
+ plotValue: total,
1077
+ value: total
1078
+ }, orientation);
1079
+ return [{
1080
+ key,
1081
+ index: outer.index,
1082
+ ...anchor,
1083
+ total,
1084
+ expand: outer.expand === true,
1085
+ seriesId: outer.seriesId
1086
+ }];
1087
+ });
1088
+ }
1089
+
1090
+ /**
1091
+ * Next bar for keyboard movement. Along the category axis keeps the same series; along the
1092
+ * value axis steps series inside the category. Home / End jump the category axis.
1093
+ */
1094
+ function barKeyboardNeighbor(bars, from, key, orientation) {
1095
+ const current = bars[from];
1096
+ if (current === undefined) {
1097
+ return null;
1098
+ }
1099
+ const categories = [...new Set(bars.map(bar => bar.index))];
1100
+ const categoryPos = categories.indexOf(current.index);
1101
+ const seriesInCategory = bars.map((bar, index) => ({
1102
+ bar,
1103
+ index
1104
+ })).filter(item => item.bar.index === current.index);
1105
+ const seriesPos = seriesInCategory.findIndex(item => item.index === from);
1106
+ const alongCategory = key === 'Tab' ? 1 : key === 'Shift+Tab' ? -1 : orientation === 'vertical' ? key === 'ArrowRight' || key === 'End' ? 1 : key === 'ArrowLeft' || key === 'Home' ? -1 : 0 : key === 'ArrowDown' || key === 'End' ? 1 : key === 'ArrowUp' || key === 'Home' ? -1 : 0;
1107
+ const alongSeries = orientation === 'vertical' ? key === 'ArrowDown' ? 1 : key === 'ArrowUp' ? -1 : 0 : key === 'ArrowRight' ? 1 : key === 'ArrowLeft' ? -1 : 0;
1108
+ if (key === 'Home' || key === 'End') {
1109
+ const nextCategory = alongCategory > 0 ? categories.at(-1) : categories[0];
1110
+ if (nextCategory === undefined) {
1111
+ return from;
1112
+ }
1113
+ const match = bars.findIndex(bar => bar.index === nextCategory && bar.seriesIndex === current.seriesIndex);
1114
+ return match >= 0 ? match : bars.findIndex(bar => bar.index === nextCategory);
1115
+ }
1116
+ if (alongCategory !== 0) {
1117
+ const nextCategory = categories[categoryPos + alongCategory];
1118
+ if (nextCategory === undefined) {
1119
+ return from;
1120
+ }
1121
+ const match = bars.findIndex(bar => bar.index === nextCategory && bar.seriesIndex === current.seriesIndex);
1122
+ return match >= 0 ? match : bars.findIndex(bar => bar.index === nextCategory);
1123
+ }
1124
+ if (alongSeries !== 0) {
1125
+ const next = seriesInCategory[seriesPos + alongSeries];
1126
+ return next === undefined ? from : next.index;
1127
+ }
1128
+ return null;
1129
+ }
1130
+ //# sourceMappingURL=geometry.js.map