@cdx-ui/components 0.3.5 → 0.3.6

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 (278) 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 +9 -1
  5. package/docs/components/line-chart/content.md +567 -0
  6. package/docs/components/pie-chart/content.md +493 -0
  7. package/docs/components/progress-segmented/content.md +1 -1
  8. package/docs/components/stepper/content.md +599 -0
  9. package/docs/components/system-alert/content.md +533 -0
  10. package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
  11. package/docs/llms.txt +9 -0
  12. package/docs/patterns/content.md +1 -0
  13. package/docs/patterns/dashboard/content.md +423 -19
  14. package/docs/patterns/insights/content.md +590 -0
  15. package/docs/resources/release-notes/0.3.5/content.md +7 -0
  16. package/docs/resources/release-notes/content.md +1 -0
  17. package/lib/commonjs/components/BarChart/geometry.js +1130 -0
  18. package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
  19. package/lib/commonjs/components/BarChart/index.js +942 -0
  20. package/lib/commonjs/components/BarChart/index.js.map +1 -0
  21. package/lib/commonjs/components/BarChart/styles.js +26 -0
  22. package/lib/commonjs/components/BarChart/styles.js.map +1 -0
  23. package/lib/commonjs/components/Button/index.js +2 -2
  24. package/lib/commonjs/components/Button/index.js.map +1 -1
  25. package/lib/commonjs/components/LineChart/geometry.js +698 -0
  26. package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
  27. package/lib/commonjs/components/LineChart/index.js +747 -0
  28. package/lib/commonjs/components/LineChart/index.js.map +1 -0
  29. package/lib/commonjs/components/LineChart/styles.js +25 -0
  30. package/lib/commonjs/components/LineChart/styles.js.map +1 -0
  31. package/lib/commonjs/components/PieChart/geometry.js +216 -0
  32. package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
  33. package/lib/commonjs/components/PieChart/index.js +476 -0
  34. package/lib/commonjs/components/PieChart/index.js.map +1 -0
  35. package/lib/commonjs/components/PieChart/styles.js +88 -0
  36. package/lib/commonjs/components/PieChart/styles.js.map +1 -0
  37. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
  38. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  39. package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
  40. package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
  41. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
  42. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
  43. package/lib/commonjs/components/Stepper/index.js +369 -0
  44. package/lib/commonjs/components/Stepper/index.js.map +1 -0
  45. package/lib/commonjs/components/Stepper/styles.js +211 -0
  46. package/lib/commonjs/components/Stepper/styles.js.map +1 -0
  47. package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
  48. package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
  49. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
  50. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  51. package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
  52. package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
  53. package/lib/commonjs/components/SystemAlert/animation.js +218 -0
  54. package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
  55. package/lib/commonjs/components/SystemAlert/index.js +525 -0
  56. package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
  57. package/lib/commonjs/components/SystemAlert/styles.js +178 -0
  58. package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
  59. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
  60. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  61. package/lib/commonjs/components/Tabs/index.js +4 -0
  62. package/lib/commonjs/components/Tabs/index.js.map +1 -1
  63. package/lib/commonjs/components/Tabs/styles.js +1 -1
  64. package/lib/commonjs/components/Tabs/styles.js.map +1 -1
  65. package/lib/commonjs/components/chart/ChartInspector.js +610 -0
  66. package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
  67. package/lib/commonjs/components/chart/format.js +93 -0
  68. package/lib/commonjs/components/chart/format.js.map +1 -0
  69. package/lib/commonjs/components/chart/index.js +2 -0
  70. package/lib/commonjs/components/chart/index.js.map +1 -0
  71. package/lib/commonjs/components/chart/motion.js +97 -0
  72. package/lib/commonjs/components/chart/motion.js.map +1 -0
  73. package/lib/commonjs/components/chart/palette.js +178 -0
  74. package/lib/commonjs/components/chart/palette.js.map +1 -0
  75. package/lib/commonjs/components/chart/size.js +34 -0
  76. package/lib/commonjs/components/chart/size.js.map +1 -0
  77. package/lib/commonjs/components/chart/ticks.js +59 -0
  78. package/lib/commonjs/components/chart/ticks.js.map +1 -0
  79. package/lib/commonjs/components/chart/types.js +6 -0
  80. package/lib/commonjs/components/chart/types.js.map +1 -0
  81. package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
  82. package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
  83. package/lib/commonjs/components/index.js +60 -0
  84. package/lib/commonjs/components/index.js.map +1 -1
  85. package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
  86. package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
  87. package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
  88. package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
  89. package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
  90. package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
  91. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
  92. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
  93. package/lib/commonjs/figma/SystemAlert.figma.js +48 -0
  94. package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
  95. package/lib/module/components/BarChart/geometry.js +1110 -0
  96. package/lib/module/components/BarChart/geometry.js.map +1 -0
  97. package/lib/module/components/BarChart/index.js +936 -0
  98. package/lib/module/components/BarChart/index.js.map +1 -0
  99. package/lib/module/components/BarChart/styles.js +22 -0
  100. package/lib/module/components/BarChart/styles.js.map +1 -0
  101. package/lib/module/components/Button/index.js +2 -2
  102. package/lib/module/components/Button/index.js.map +1 -1
  103. package/lib/module/components/LineChart/geometry.js +685 -0
  104. package/lib/module/components/LineChart/geometry.js.map +1 -0
  105. package/lib/module/components/LineChart/index.js +741 -0
  106. package/lib/module/components/LineChart/index.js.map +1 -0
  107. package/lib/module/components/LineChart/styles.js +21 -0
  108. package/lib/module/components/LineChart/styles.js.map +1 -0
  109. package/lib/module/components/PieChart/geometry.js +209 -0
  110. package/lib/module/components/PieChart/geometry.js.map +1 -0
  111. package/lib/module/components/PieChart/index.js +471 -0
  112. package/lib/module/components/PieChart/index.js.map +1 -0
  113. package/lib/module/components/PieChart/styles.js +84 -0
  114. package/lib/module/components/PieChart/styles.js.map +1 -0
  115. package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
  116. package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  117. package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
  118. package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
  119. package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
  120. package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
  121. package/lib/module/components/Stepper/index.js +360 -0
  122. package/lib/module/components/Stepper/index.js.map +1 -0
  123. package/lib/module/components/Stepper/styles.js +206 -0
  124. package/lib/module/components/Stepper/styles.js.map +1 -0
  125. package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
  126. package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
  127. package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
  128. package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  129. package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
  130. package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
  131. package/lib/module/components/SystemAlert/animation.js +213 -0
  132. package/lib/module/components/SystemAlert/animation.js.map +1 -0
  133. package/lib/module/components/SystemAlert/index.js +515 -0
  134. package/lib/module/components/SystemAlert/index.js.map +1 -0
  135. package/lib/module/components/SystemAlert/styles.js +174 -0
  136. package/lib/module/components/SystemAlert/styles.js.map +1 -0
  137. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
  138. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  139. package/lib/module/components/Tabs/index.js +4 -0
  140. package/lib/module/components/Tabs/index.js.map +1 -1
  141. package/lib/module/components/Tabs/styles.js +1 -1
  142. package/lib/module/components/Tabs/styles.js.map +1 -1
  143. package/lib/module/components/chart/ChartInspector.js +600 -0
  144. package/lib/module/components/chart/ChartInspector.js.map +1 -0
  145. package/lib/module/components/chart/format.js +84 -0
  146. package/lib/module/components/chart/format.js.map +1 -0
  147. package/lib/module/components/chart/index.js +2 -0
  148. package/lib/module/components/chart/index.js.map +1 -0
  149. package/lib/module/components/chart/motion.js +89 -0
  150. package/lib/module/components/chart/motion.js.map +1 -0
  151. package/lib/module/components/chart/palette.js +168 -0
  152. package/lib/module/components/chart/palette.js.map +1 -0
  153. package/lib/module/components/chart/size.js +29 -0
  154. package/lib/module/components/chart/size.js.map +1 -0
  155. package/lib/module/components/chart/ticks.js +55 -0
  156. package/lib/module/components/chart/ticks.js.map +1 -0
  157. package/lib/module/components/chart/types.js +4 -0
  158. package/lib/module/components/chart/types.js.map +1 -0
  159. package/lib/module/components/chart/useChartHostWidth.js +23 -0
  160. package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
  161. package/lib/module/components/index.js +5 -0
  162. package/lib/module/components/index.js.map +1 -1
  163. package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
  164. package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
  165. package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
  166. package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
  167. package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
  168. package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
  169. package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
  170. package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
  171. package/lib/module/figma/SystemAlert.figma.js +42 -0
  172. package/lib/module/figma/SystemAlert.figma.js.map +1 -0
  173. package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
  174. package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
  175. package/lib/typescript/components/BarChart/index.d.ts +193 -0
  176. package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
  177. package/lib/typescript/components/BarChart/styles.d.ts +32 -0
  178. package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
  179. package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
  180. package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
  181. package/lib/typescript/components/LineChart/index.d.ts +105 -0
  182. package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
  183. package/lib/typescript/components/LineChart/styles.d.ts +12 -0
  184. package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
  185. package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
  186. package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
  187. package/lib/typescript/components/PieChart/index.d.ts +147 -0
  188. package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
  189. package/lib/typescript/components/PieChart/styles.d.ts +27 -0
  190. package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
  191. package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
  192. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
  193. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
  194. package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
  195. package/lib/typescript/components/Stepper/index.d.ts +68 -0
  196. package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
  197. package/lib/typescript/components/Stepper/styles.d.ts +46 -0
  198. package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
  199. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
  200. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
  201. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
  202. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
  203. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
  204. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
  205. package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
  206. package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
  207. package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
  208. package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
  209. package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
  210. package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
  211. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
  212. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
  213. package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
  214. package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
  215. package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
  216. package/lib/typescript/components/chart/format.d.ts +16 -0
  217. package/lib/typescript/components/chart/format.d.ts.map +1 -0
  218. package/lib/typescript/components/chart/index.d.ts +3 -0
  219. package/lib/typescript/components/chart/index.d.ts.map +1 -0
  220. package/lib/typescript/components/chart/motion.d.ts +27 -0
  221. package/lib/typescript/components/chart/motion.d.ts.map +1 -0
  222. package/lib/typescript/components/chart/palette.d.ts +44 -0
  223. package/lib/typescript/components/chart/palette.d.ts.map +1 -0
  224. package/lib/typescript/components/chart/size.d.ts +25 -0
  225. package/lib/typescript/components/chart/size.d.ts.map +1 -0
  226. package/lib/typescript/components/chart/ticks.d.ts +3 -0
  227. package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
  228. package/lib/typescript/components/chart/types.d.ts +163 -0
  229. package/lib/typescript/components/chart/types.d.ts.map +1 -0
  230. package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
  231. package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
  232. package/lib/typescript/components/index.d.ts +5 -0
  233. package/lib/typescript/components/index.d.ts.map +1 -1
  234. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
  235. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
  236. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
  237. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
  238. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
  239. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
  240. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
  241. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
  242. package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
  243. package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
  244. package/package.json +5 -5
  245. package/src/components/BarChart/geometry.ts +1469 -0
  246. package/src/components/BarChart/index.tsx +1424 -0
  247. package/src/components/BarChart/styles.ts +31 -0
  248. package/src/components/Button/index.tsx +1 -1
  249. package/src/components/LineChart/geometry.ts +957 -0
  250. package/src/components/LineChart/index.tsx +1109 -0
  251. package/src/components/LineChart/styles.ts +26 -0
  252. package/src/components/PieChart/geometry.ts +295 -0
  253. package/src/components/PieChart/index.tsx +715 -0
  254. package/src/components/PieChart/styles.ts +101 -0
  255. package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
  256. package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
  257. package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
  258. package/src/components/Stepper/index.tsx +452 -0
  259. package/src/components/Stepper/styles.ts +234 -0
  260. package/src/components/Stepper/useStepperLabelFit.ts +21 -0
  261. package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
  262. package/src/components/Stepper/useStepperRingColors.ts +29 -0
  263. package/src/components/SystemAlert/animation.ts +252 -0
  264. package/src/components/SystemAlert/index.tsx +684 -0
  265. package/src/components/SystemAlert/styles.ts +212 -0
  266. package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
  267. package/src/components/Tabs/index.tsx +4 -0
  268. package/src/components/Tabs/styles.ts +1 -1
  269. package/src/components/chart/ChartInspector.tsx +726 -0
  270. package/src/components/chart/format.ts +95 -0
  271. package/src/components/chart/index.ts +24 -0
  272. package/src/components/chart/motion.ts +98 -0
  273. package/src/components/chart/palette.tsx +247 -0
  274. package/src/components/chart/size.ts +21 -0
  275. package/src/components/chart/ticks.ts +53 -0
  276. package/src/components/chart/types.ts +183 -0
  277. package/src/components/chart/useChartHostWidth.ts +26 -0
  278. package/src/components/index.ts +5 -0
@@ -0,0 +1,942 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BarChart = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeSvg = require("react-native-svg");
11
+ var _primitives = require("@cdx-ui/primitives");
12
+ var _utils = require("@cdx-ui/utils");
13
+ var _ChartInspector = require("../chart/ChartInspector");
14
+ var _format = require("../chart/format");
15
+ var _useChartHostWidth = require("../chart/useChartHostWidth");
16
+ var _motion = require("../chart/motion");
17
+ var _palette = require("../chart/palette");
18
+ var _geometry = require("./geometry");
19
+ var _styles = require("./styles");
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
22
+ /* SVG `x`/`y` are paint coordinates. RN View `x`/`y` layout props are deprecated and share the name. */
23
+ /* eslint-disable @typescript-eslint/no-deprecated */
24
+
25
+ const INACTIVE_OPACITY = 0.4;
26
+ const DASH = '6 4';
27
+ const SVG_OVERFLOW_VISIBLE = {
28
+ overflow: 'visible'
29
+ };
30
+ const LABEL_FADE_DURATION = 220;
31
+ const AnimatedPath = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Path);
32
+
33
+ /** Keys of `TRow` whose value is a boolean. */
34
+
35
+ /** Running-total series. Each row is a change, except rows flagged as totals. */
36
+
37
+ /** Draws this series as a thinner comparison bar beside another series' bar. */
38
+
39
+ function resolveBarPlan(series) {
40
+ const toGeometry = item => ({
41
+ id: item.id,
42
+ dataKey: item.dataKey,
43
+ label: item.label ?? '',
44
+ stack: item.stack,
45
+ stackOffset: item.stackOffset
46
+ });
47
+ const waterfall = series.find(item => item.waterfall !== undefined);
48
+ if (waterfall !== undefined) {
49
+ return {
50
+ kind: 'waterfall',
51
+ series: [waterfall],
52
+ geometry: [toGeometry(waterfall)],
53
+ totalKey: waterfall.waterfall?.totalKey
54
+ };
55
+ }
56
+ for (const comparison of series) {
57
+ const primary = comparison.overlay === undefined ? undefined : series.find(item => item.id === comparison.overlay?.seriesId && item !== comparison);
58
+ if (primary !== undefined) {
59
+ const pair = [primary, comparison];
60
+ return {
61
+ kind: 'overlay',
62
+ series: pair,
63
+ geometry: pair.map(item => ({
64
+ ...toGeometry(item),
65
+ stack: undefined
66
+ })),
67
+ totalKey: undefined
68
+ };
69
+ }
70
+ }
71
+ return {
72
+ kind: 'bars',
73
+ series,
74
+ geometry: series.map(toGeometry),
75
+ totalKey: undefined
76
+ };
77
+ }
78
+ function sameItem(a, b) {
79
+ return a?.seriesId === b.seriesId && a.dataIndex === b.dataIndex;
80
+ }
81
+ function barSelection(bar) {
82
+ return {
83
+ seriesId: bar.seriesId,
84
+ dataIndex: bar.index
85
+ };
86
+ }
87
+ function barAccessibilityName(label, seriesLabel, formatted, change = null) {
88
+ const base = seriesLabel.length > 0 ? `${label}, ${seriesLabel}, ${formatted}` : `${label}, ${formatted}`;
89
+ return change === null ? base : `${base}, ${change}`;
90
+ }
91
+ function BarChartInner({
92
+ dataset,
93
+ series: seriesProp,
94
+ xAxis,
95
+ yAxis,
96
+ size = 'lg',
97
+ width: widthProp,
98
+ height: heightProp,
99
+ layout: orientation = 'vertical',
100
+ hideLegend = false,
101
+ grid,
102
+ palette: paletteProp = 'auto',
103
+ barLabel = false,
104
+ borderRadius = _styles.BAR_RADIUS,
105
+ stackGap = _geometry.DEFAULT_STACK_GAP,
106
+ categoryGapRatio = _geometry.CATEGORY_GAP_RATIO,
107
+ barGapRatio = _geometry.BAR_GAP_RATIO,
108
+ referenceLines,
109
+ emphasizedIndex,
110
+ scrollable = true,
111
+ visiblePoints,
112
+ selectedItem,
113
+ defaultSelectedItem,
114
+ onSelectedItemChange,
115
+ tooltip: tooltipProp,
116
+ locale,
117
+ localeText: localeTextProp,
118
+ animation,
119
+ accessibilityLabel,
120
+ className,
121
+ style,
122
+ onLayout,
123
+ ...props
124
+ }, ref) {
125
+ const animated = (0, _motion.useChartMotionEnabled)(animation);
126
+ const simpleColor = (0, _palette.useChartSimpleColor)();
127
+ const gradientId = (0, _palette.useChartGradientId)('bar-fill');
128
+ const chrome = (0, _palette.useChartChrome)();
129
+ const palette = (0, _palette.useChartPalette)();
130
+ const paints = (0, _palette.useChartColorPaints)();
131
+ const localeText = (0, _react.useMemo)(() => (0, _format.resolveChartLocaleText)(localeTextProp), [localeTextProp]);
132
+ const plan = (0, _react.useMemo)(() => resolveBarPlan(seriesProp), [seriesProp]);
133
+ const {
134
+ kind,
135
+ geometry
136
+ } = plan;
137
+ const overlay = kind === 'overlay';
138
+ const waterfall = kind === 'waterfall';
139
+ const expandAxis = (0, _react.useMemo)(() => (0, _geometry.isExpandAxis)(kind, (0, _geometry.resolveBarGroups)(geometry)), [kind, geometry]);
140
+ const categoryAxis = (orientation === 'vertical' ? xAxis : yAxis)?.[0];
141
+ const valueAxis = (orientation === 'vertical' ? yAxis : xAxis)?.[0];
142
+ const categoryKey = categoryAxis?.dataKey;
143
+ const categoryLabelPosition = categoryAxis?.position;
144
+ const showTicks = valueAxis?.position !== 'none';
145
+ const showGrid = grid === undefined ? true : (orientation === 'vertical' ? grid.horizontal : grid.vertical) === true;
146
+ const tickLabelInterval = categoryAxis?.tickLabelInterval;
147
+ const categories = (0, _react.useMemo)(() => dataset.map((row, index) => {
148
+ if (categoryKey === undefined) {
149
+ return String(index);
150
+ }
151
+ const raw = row[categoryKey];
152
+ return raw === null || raw === undefined ? '' : String(raw);
153
+ }), [dataset, categoryKey]);
154
+ const hasNegative = (0, _react.useMemo)(() => dataset.some(row => geometry.some(item => ((0, _geometry.readBarValue)(row, item.dataKey) ?? 0) < 0)), [dataset, geometry]);
155
+ const sourceById = (0, _react.useMemo)(() => new Map(plan.series.map(item => [item.id, item])), [plan.series]);
156
+ const valueAxisMin = valueAxis?.min;
157
+ const valueAxisMax = valueAxis?.max;
158
+ const valueAxisTicks = valueAxis?.tickNumber;
159
+ const valueAxisFormatter = valueAxis?.valueFormatter;
160
+ const valueAxisConfig = (0, _react.useMemo)(() => ({
161
+ min: valueAxisMin,
162
+ max: valueAxisMax,
163
+ tickNumber: valueAxisTicks
164
+ }), [valueAxisMin, valueAxisMax, valueAxisTicks]);
165
+ const percentFormatter = (0, _react.useMemo)(() => value => value === null ? '' : (0, _format.formatChartPercent)(value, locale), [locale]);
166
+ const formatTick = (0, _react.useMemo)(() => {
167
+ const formatter = valueAxisFormatter ?? (expandAxis ? percentFormatter : (0, _format.defaultChartValueFormatter)(locale));
168
+ return value => formatter(value, {
169
+ location: 'tick'
170
+ });
171
+ }, [valueAxisFormatter, expandAxis, percentFormatter, locale]);
172
+ const formatBar = (bar, location) => {
173
+ const source = sourceById.get(bar.seriesId);
174
+ const context = {
175
+ location,
176
+ seriesId: bar.seriesId,
177
+ dataIndex: bar.index
178
+ };
179
+ if (bar.expand === true && source?.valueFormatter === undefined) {
180
+ return (valueAxisFormatter ?? percentFormatter)(bar.plotValue / 100, context);
181
+ }
182
+ const formatter = (0, _format.resolveValueFormatter)(source, valueAxis, locale);
183
+ const format = value => formatter(value, context);
184
+ return bar.waterfallRole === undefined ? format(bar.value) : (0, _geometry.formatWaterfallBarValue)(bar, format);
185
+ };
186
+ const seriesLabelOf = bar => {
187
+ if (bar.waterfallRole === 'increase') {
188
+ return localeText.waterfallIncrease;
189
+ }
190
+ if (bar.waterfallRole === 'decrease') {
191
+ return localeText.waterfallDecrease;
192
+ }
193
+ return bar.seriesLabel;
194
+ };
195
+ const box = (0, _styles.resolveBarChartBox)(size, widthProp, heightProp);
196
+ const [hostWidth, handleHostLayout] = (0, _useChartHostWidth.useChartHostWidth)(onLayout);
197
+ const viewportWidth = hostWidth > 0 ? Math.min(hostWidth, box.width) : box.width;
198
+ const viewportHeight = box.height;
199
+ const gutters = (0, _react.useMemo)(() => (0, _geometry.resolveBarChartGutters)({
200
+ categories,
201
+ hasNegative,
202
+ orientation,
203
+ barLabel,
204
+ categoryLabelPosition,
205
+ showTicks,
206
+ overlay
207
+ }), [categories, hasNegative, orientation, barLabel, categoryLabelPosition, showTicks, overlay]);
208
+ const content = (0, _react.useMemo)(() => (0, _geometry.resolveBarChartContentSize)({
209
+ viewportWidth,
210
+ viewportHeight,
211
+ categoryCount: dataset.length,
212
+ orientation,
213
+ gutters,
214
+ scrollable,
215
+ visiblePoints
216
+ }), [viewportWidth, viewportHeight, dataset.length, orientation, gutters, scrollable, visiblePoints]);
217
+ const showCategoryLabel = (0, _react.useMemo)(() => {
218
+ if (typeof tickLabelInterval !== 'function') {
219
+ return undefined;
220
+ }
221
+ return index => {
222
+ const row = dataset.at(index);
223
+ const value = row === undefined || categoryKey === undefined ? index : row[categoryKey];
224
+ return tickLabelInterval(value, index);
225
+ };
226
+ }, [tickLabelInterval, dataset, categoryKey]);
227
+ const layout = (0, _react.useMemo)(() => (0, _geometry.layoutBarChart)({
228
+ dataset,
229
+ categories,
230
+ series: geometry,
231
+ kind,
232
+ waterfallTotalKey: plan.totalKey,
233
+ width: content.width,
234
+ height: content.height,
235
+ orientation,
236
+ barLabel,
237
+ categoryLabelPosition,
238
+ showTicks,
239
+ referenceLines,
240
+ valueAxis: valueAxisConfig,
241
+ formatTick,
242
+ stackGap,
243
+ categoryGapRatio,
244
+ barGapRatio,
245
+ showCategoryLabel
246
+ }), [dataset, categories, geometry, kind, plan.totalKey, content.width, content.height, orientation, barLabel, categoryLabelPosition, showTicks, referenceLines, valueAxisConfig, formatTick, stackGap, categoryGapRatio, barGapRatio, showCategoryLabel]);
247
+ const overflowsX = content.width > viewportWidth + 0.5;
248
+ const overflowsY = content.height > viewportHeight + 0.5;
249
+ const fills = waterfall ? dataset.map((_, index) => palette[index % palette.length] ?? simpleColor) : plan.series.map((item, seriesIndex) => {
250
+ const custom = (0, _palette.resolveChartColor)(item.color, paints);
251
+ if (custom !== undefined) {
252
+ return custom;
253
+ }
254
+ if (overlay) {
255
+ return seriesIndex === 0 ? simpleColor : chrome.grid;
256
+ }
257
+ return paints[(0, _palette.chartSeriesColor)(seriesIndex, plan.series.length, paletteProp, 'bar')];
258
+ });
259
+ const summaryCategories = dataset.map((row, dataIndex) => ({
260
+ label: categories[dataIndex] ?? '',
261
+ values: plan.series.flatMap(item => {
262
+ const value = (0, _geometry.readBarValue)(row, item.dataKey);
263
+ if (value === null) {
264
+ return [];
265
+ }
266
+ // An expand axis formats 0–1 shares; the summary reads raw values.
267
+ const formatter = (0, _format.resolveValueFormatter)(item, expandAxis ? null : valueAxis, locale);
268
+ return [{
269
+ label: item.label ?? '',
270
+ formattedValue: formatter(value, {
271
+ location: 'a11y',
272
+ seriesId: item.id,
273
+ dataIndex
274
+ })
275
+ }];
276
+ })
277
+ }));
278
+ const summary = accessibilityLabel ?? localeText.barChartSummary(summaryCategories);
279
+ const trigger = tooltipProp?.trigger ?? 'axis';
280
+ const tooltip = trigger !== 'none';
281
+ const interactive = onSelectedItemChange !== undefined || selectedItem !== undefined || defaultSelectedItem !== undefined;
282
+ const [selectedState, setSelectedItem] = (0, _utils.useControllableState)({
283
+ prop: selectedItem,
284
+ defaultProp: defaultSelectedItem ?? null,
285
+ onChange: onSelectedItemChange
286
+ });
287
+ const selected = selectedState ?? null;
288
+ const visibleBars = layout.bars.filter(bar => bar.stackId !== undefined ? bar.width > 0 && bar.height > 0 : orientation === 'vertical' ? bar.width > 0 : bar.height > 0);
289
+ const inspectable = (interactive || tooltip) && visibleBars.length > 0;
290
+ const [activeIndex, setActiveIndex] = (0, _react.useState)(null);
291
+ const [dismissed, setDismissed] = (0, _react.useState)(false);
292
+ const [scrubbing, setScrubbing] = (0, _react.useState)(false);
293
+ const scrollOffset = (0, _react.useRef)({
294
+ x: 0,
295
+ y: 0
296
+ });
297
+ const selectedIndex = selected ? visibleBars.findIndex(bar => sameItem(selected, barSelection(bar))) : -1;
298
+ const activeBar = activeIndex === null ? undefined : visibleBars.at(activeIndex);
299
+ const highlightBar = activeBar ? barSelection(activeBar) : selectedIndex >= 0 && selected !== null ? selected : null;
300
+ const tooltipIndex = tooltip && !dismissed && activeIndex !== null ? activeIndex : null;
301
+ const activate = index => {
302
+ setDismissed(false);
303
+ setActiveIndex(prev => prev === index ? prev : index);
304
+ };
305
+ const deactivate = index => {
306
+ setActiveIndex(prev => prev === index ? null : prev);
307
+ };
308
+ const showLegend = !waterfall && plan.series.length > 0 && !hideLegend;
309
+ const plot = /*#__PURE__*/(0, _jsxRuntime.jsx)(BarPlot, {
310
+ layout: layout,
311
+ orientation: orientation,
312
+ overlay: overlay,
313
+ waterfall: waterfall,
314
+ showGrid: showGrid,
315
+ barLabel: barLabel,
316
+ formatBar: formatBar,
317
+ formatStackTotal: anchor => {
318
+ const context = {
319
+ location: 'label',
320
+ dataIndex: anchor.index
321
+ };
322
+ if (anchor.expand) {
323
+ return (valueAxisFormatter ?? percentFormatter)(anchor.total / 100, context);
324
+ }
325
+ return (0, _format.resolveValueFormatter)(sourceById.get(anchor.seriesId), valueAxis, locale)(anchor.total, context);
326
+ },
327
+ fills: fills,
328
+ gradientId: gradientId,
329
+ chrome: chrome,
330
+ accent: simpleColor,
331
+ borderRadius: Math.max(borderRadius, 0),
332
+ animated: animated,
333
+ highlightBar: highlightBar,
334
+ emphasizedIndex: emphasizedIndex
335
+ });
336
+ const vertical = orientation === 'vertical';
337
+ const targets = inspectable ? barInspectorTargets({
338
+ bars: visibleBars,
339
+ layout,
340
+ orientation,
341
+ overlay,
342
+ waterfall,
343
+ trigger,
344
+ offsetX: vertical ? layout.plot.x : 0,
345
+ fills,
346
+ fallbackFill: chrome.grid,
347
+ formatBar,
348
+ seriesLabelOf,
349
+ localeText,
350
+ selectedIndex: selectedIndex >= 0 ? selectedIndex : null
351
+ }) : [];
352
+ const tip = tooltipIndex === null ? undefined : targets.at(tooltipIndex);
353
+ const dismissOnScroll = event => {
354
+ scrollOffset.current = event.nativeEvent.contentOffset;
355
+ if (tooltipIndex !== null) {
356
+ setDismissed(true);
357
+ }
358
+ };
359
+ const inspector = inspectable ? /*#__PURE__*/(0, _jsxRuntime.jsx)(BarInspector, {
360
+ bars: visibleBars,
361
+ targets: targets,
362
+ orientation: orientation,
363
+ summary: summary,
364
+ selectable: interactive,
365
+ activeIndex: activeIndex,
366
+ selectedIndex: selectedIndex >= 0 ? selectedIndex : null,
367
+ holdToScrub: overflowsX || overflowsY,
368
+ onScrubLockChange: setScrubbing,
369
+ onActivate: activate,
370
+ onDeactivate: deactivate,
371
+ onDismiss: () => {
372
+ setDismissed(true);
373
+ },
374
+ onSelectIndex: index => {
375
+ const bar = visibleBars.at(index);
376
+ if (bar) {
377
+ setDismissed(false);
378
+ const next = barSelection(bar);
379
+ setSelectedItem(sameItem(selected, next) ? null : next);
380
+ }
381
+ }
382
+ }) : null;
383
+ const tooltipLayer = tip !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartInspector.ChartTooltipLayer, {
384
+ content: tip.tooltip,
385
+ noValueText: localeText.noValue,
386
+ slot: "bar-chart",
387
+ anchorX: vertical ? layout.plot.x + tip.anchorX - scrollOffset.current.x : tip.anchorX,
388
+ anchorY: vertical ? tip.anchorY : tip.anchorY - scrollOffset.current.y,
389
+ anchorRadius: tip.anchorRadius,
390
+ width: viewportWidth,
391
+ height: viewportHeight
392
+ }) : null;
393
+ const ticks = showTicks ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
394
+ children: layout.valueTicks.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
395
+ x: tick.x,
396
+ y: tick.y,
397
+ fill: chrome.label,
398
+ fontFamily: chrome.fontFamily,
399
+ fontSize: chrome.labelSize,
400
+ textAnchor: orientation === 'vertical' ? 'end' : 'middle',
401
+ alignmentBaseline: "middle",
402
+ children: tick.text
403
+ }, `tick-${String(tick.value)}`))
404
+ }) : null;
405
+ const chart = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
406
+ style: {
407
+ width: '100%',
408
+ maxWidth: viewportWidth,
409
+ height: viewportHeight
410
+ },
411
+ ...(0, _primitives.dataAttributes)({
412
+ slot: 'bar-chart-plot'
413
+ }),
414
+ children: [orientation === 'vertical' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
415
+ className: "w-full flex-row",
416
+ style: {
417
+ height: viewportHeight
418
+ },
419
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
420
+ width: layout.plot.x,
421
+ height: viewportHeight,
422
+ viewBox: `0 0 ${String(layout.plot.x)} ${String(content.height)}`,
423
+ accessible: false,
424
+ accessibilityElementsHidden: true,
425
+ importantForAccessibility: "no-hide-descendants",
426
+ children: ticks
427
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
428
+ horizontal: true,
429
+ nestedScrollEnabled: true,
430
+ scrollEnabled: overflowsX && !scrubbing,
431
+ showsHorizontalScrollIndicator: overflowsX,
432
+ scrollEventThrottle: 16,
433
+ onScroll: dismissOnScroll,
434
+ className: "flex-1",
435
+ style: {
436
+ height: viewportHeight
437
+ },
438
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
439
+ style: {
440
+ width: content.width - layout.plot.x,
441
+ height: viewportHeight
442
+ },
443
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
444
+ width: content.width - layout.plot.x,
445
+ height: viewportHeight,
446
+ viewBox: `0 0 ${String(content.width - layout.plot.x)} ${String(content.height)}`,
447
+ style: SVG_OVERFLOW_VISIBLE,
448
+ pointerEvents: "none",
449
+ accessible: false,
450
+ accessibilityElementsHidden: true,
451
+ importantForAccessibility: "no-hide-descendants",
452
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
453
+ transform: `translate(${String(-layout.plot.x)}, 0)`,
454
+ children: plot
455
+ })
456
+ }), inspector]
457
+ })
458
+ })]
459
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
460
+ style: {
461
+ width: viewportWidth,
462
+ height: viewportHeight
463
+ },
464
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
465
+ nestedScrollEnabled: true,
466
+ scrollEnabled: overflowsY && !scrubbing,
467
+ showsVerticalScrollIndicator: overflowsY,
468
+ scrollEventThrottle: 16,
469
+ onScroll: dismissOnScroll,
470
+ style: {
471
+ height: viewportHeight - gutters.paddingBottom
472
+ },
473
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
474
+ style: {
475
+ width: viewportWidth,
476
+ height: content.height - gutters.paddingBottom
477
+ },
478
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
479
+ width: viewportWidth,
480
+ height: content.height - gutters.paddingBottom,
481
+ viewBox: `0 0 ${String(content.width)} ${String(content.height - gutters.paddingBottom)}`,
482
+ pointerEvents: "none",
483
+ accessible: false,
484
+ accessibilityElementsHidden: true,
485
+ importantForAccessibility: "no-hide-descendants",
486
+ children: plot
487
+ }), inspector]
488
+ })
489
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
490
+ width: viewportWidth,
491
+ height: gutters.paddingBottom,
492
+ viewBox: `0 0 ${String(content.width)} ${String(gutters.paddingBottom)}`,
493
+ accessible: false,
494
+ accessibilityElementsHidden: true,
495
+ importantForAccessibility: "no-hide-descendants",
496
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
497
+ transform: `translate(0, ${String(-(content.height - gutters.paddingBottom))})`,
498
+ children: ticks
499
+ })
500
+ })]
501
+ }), tooltipLayer]
502
+ });
503
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
504
+ ref: ref,
505
+ className: (0, _utils.cn)((0, _styles.barChartRootVariants)(), className),
506
+ style: style,
507
+ accessible: !inspectable && !showLegend,
508
+ accessibilityRole: !inspectable && !showLegend ? 'image' : undefined,
509
+ accessibilityLabel: !inspectable && !showLegend ? summary : undefined,
510
+ ...props,
511
+ onLayout: handleHostLayout,
512
+ ...(0, _primitives.mergeDataAttributes)(props, (0, _primitives.dataAttributes)({
513
+ slot: 'bar-chart'
514
+ })),
515
+ children: [chart, showLegend ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
516
+ className: (0, _styles.barChartLegendVariants)(),
517
+ ...(0, _primitives.dataAttributes)({
518
+ slot: 'bar-chart-legend'
519
+ }),
520
+ children: plan.series.map((item, seriesIndex) => {
521
+ const isSelected = highlightBar?.seriesId === item.id;
522
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
523
+ className: (0, _styles.barChartLegendItemVariants)(),
524
+ ...(0, _primitives.dataAttributes)({
525
+ slot: 'bar-chart-legend-item'
526
+ }),
527
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
528
+ className: "h-2 w-3 rounded-sm",
529
+ style: {
530
+ backgroundColor: fills[seriesIndex]
531
+ }
532
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
533
+ className: (0, _styles.barChartLegendLabelVariants)({
534
+ selected: isSelected
535
+ }),
536
+ children: item.label !== undefined && item.label.length > 0 ? item.label : localeText.defaultSeriesLabel
537
+ })]
538
+ }, item.id);
539
+ })
540
+ }) : null]
541
+ });
542
+ }
543
+
544
+ /**
545
+ * Category bars from `dataset` rows. MUI X Charts–shaped: `series[].dataKey`, axis arrays,
546
+ * `layout`, `stack` groups, and `selectedItem`.
547
+ */
548
+ const BarChart = exports.BarChart = /*#__PURE__*/(0, _react.forwardRef)(BarChartInner);
549
+ BarChart.displayName = 'BarChart';
550
+ function BarPlot({
551
+ layout,
552
+ orientation,
553
+ overlay,
554
+ waterfall,
555
+ showGrid,
556
+ barLabel,
557
+ formatBar,
558
+ formatStackTotal,
559
+ fills,
560
+ gradientId,
561
+ chrome,
562
+ accent,
563
+ borderRadius,
564
+ animated,
565
+ highlightBar,
566
+ emphasizedIndex
567
+ }) {
568
+ const labeledBars = layout.bars.filter(bar => {
569
+ if (bar.stackId !== undefined) {
570
+ return false;
571
+ }
572
+ if (emphasizedIndex !== undefined && bar.index !== emphasizedIndex) {
573
+ return false;
574
+ }
575
+ return !overlay || bar.seriesIndex === 0;
576
+ });
577
+ const stackLabels = (0, _geometry.stackedTotalAnchors)(layout.bars, orientation).filter(anchor => emphasizedIndex === undefined || anchor.index === emphasizedIndex);
578
+ const paintedBars = overlay ? [...layout.bars].sort((a, b) => b.seriesIndex - a.seriesIndex) : layout.bars;
579
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
580
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_palette.ChartLinearFills, {
581
+ idPrefix: gradientId,
582
+ colors: fills,
583
+ x2: orientation === 'vertical' ? '0%' : '100%',
584
+ y2: orientation === 'vertical' ? '100%' : '0%'
585
+ }), showGrid ? layout.gridLines.map(line => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
586
+ x1: line.x1,
587
+ y1: line.y1,
588
+ x2: line.x2,
589
+ y2: line.y2,
590
+ stroke: chrome.grid,
591
+ strokeWidth: 1
592
+ }, `grid-${String(line.x1)}-${String(line.y1)}`)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
593
+ x1: orientation === 'vertical' ? layout.plot.x : layout.baseline,
594
+ y1: orientation === 'vertical' ? layout.baseline : layout.plot.y,
595
+ x2: orientation === 'vertical' ? layout.plot.x + layout.plot.width : layout.baseline,
596
+ y2: orientation === 'vertical' ? layout.baseline : layout.plot.y + layout.plot.height,
597
+ stroke: chrome.grid,
598
+ strokeWidth: 1
599
+ }), layout.referenceLines.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
600
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
601
+ x1: line.x1,
602
+ y1: line.y1,
603
+ x2: line.x2,
604
+ y2: line.y2,
605
+ stroke: accent,
606
+ strokeWidth: 1,
607
+ strokeDasharray: DASH
608
+ }), line.label !== undefined && line.label.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
609
+ x: line.x1 + 4,
610
+ y: orientation === 'vertical' ? line.y1 - 4 : line.y1 + 12,
611
+ fill: accent,
612
+ fontFamily: chrome.fontFamily,
613
+ fontSize: chrome.captionSize,
614
+ textAnchor: "start",
615
+ children: line.label
616
+ }) : null]
617
+ }, `ref-${String(line.x1)}-${String(line.y1)}-${String(index)}`)), layout.connectors.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
618
+ x1: line.x1,
619
+ y1: line.y1,
620
+ x2: line.x2,
621
+ y2: line.y2,
622
+ stroke: chrome.grid,
623
+ strokeWidth: 1,
624
+ strokeDasharray: DASH
625
+ }, `wf-${String(line.x1)}-${String(line.y1)}-${String(index)}`)), paintedBars.map(bar => {
626
+ if (bar.width <= 0 || bar.height <= 0) {
627
+ return null;
628
+ }
629
+ const dimmed = highlightBar !== null && (bar.stackId !== undefined ? !sameItem(highlightBar, barSelection(bar)) : highlightBar.dataIndex !== bar.index);
630
+ const muted = emphasizedIndex !== undefined && bar.index !== emphasizedIndex;
631
+ const comparison = overlay && bar.seriesIndex > 0;
632
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedBar, {
633
+ bar: bar,
634
+ orientation: orientation,
635
+ baseline: layout.baseline,
636
+ animated: animated,
637
+ fill: muted || waterfall && dimmed ? chrome.grid : comparison || waterfall ? fills[bar.seriesIndex] ?? chrome.grid : (0, _palette.chartFillUrl)(gradientId, bar.seriesIndex),
638
+ opacity: waterfall ? 1 : dimmed ? INACTIVE_OPACITY : 1,
639
+ radius: borderRadius
640
+ }, `${String(bar.index)}-${bar.seriesId}`);
641
+ }), layout.categoryLabels.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
642
+ x: item.x,
643
+ y: item.y,
644
+ fill: chrome.label,
645
+ fontFamily: chrome.fontFamily,
646
+ fontSize: chrome.labelSize,
647
+ textAnchor: item.textAnchor,
648
+ alignmentBaseline: "middle",
649
+ children: item.label
650
+ }, `cat-${String(index)}-${item.label}`)), barLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ValueLabels, {
651
+ animated: animated,
652
+ motionKey: `${orientation}-${overlay ? '1' : '0'}-${layout.bars.map(bar => [bar.x, bar.y, bar.width, bar.height].join(',')).join(';')}`,
653
+ children: labelOpacity => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
654
+ children: [stackLabels.map(label => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
655
+ x: label.x,
656
+ y: label.y,
657
+ fill: chrome.label,
658
+ fillOpacity: labelOpacity,
659
+ fontFamily: chrome.fontFamily,
660
+ fontSize: chrome.captionSize,
661
+ textAnchor: label.textAnchor,
662
+ alignmentBaseline: "middle",
663
+ children: formatStackTotal(label)
664
+ }, `stack-val-${label.key}`)), labeledBars.map(bar => {
665
+ const anchor = waterfall ? (0, _geometry.waterfallValueAnchor)(bar, orientation) : (0, _geometry.barValueAnchor)(bar, orientation);
666
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
667
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
668
+ x: anchor.x,
669
+ y: anchor.y,
670
+ fill: chrome.label,
671
+ fillOpacity: labelOpacity,
672
+ fontFamily: chrome.fontFamily,
673
+ fontSize: chrome.captionSize,
674
+ textAnchor: anchor.textAnchor,
675
+ alignmentBaseline: "middle",
676
+ children: formatBar(bar, 'label')
677
+ })
678
+ }, `val-${String(bar.index)}-${bar.seriesId}`);
679
+ })]
680
+ })
681
+ }) : null]
682
+ });
683
+ }
684
+ function barTooltipContent(group, bar, trigger, fills, fallbackFill, formatBar, seriesLabelOf) {
685
+ const shown = trigger === 'axis' ? group : [bar];
686
+ return {
687
+ title: bar.label,
688
+ items: shown.map(item => ({
689
+ seriesId: item.seriesId,
690
+ label: seriesLabelOf(item),
691
+ color: fills[item.seriesIndex] ?? fallbackFill,
692
+ formattedValue: formatBar(item, 'tooltip')
693
+ }))
694
+ };
695
+ }
696
+
697
+ /**
698
+ * One hit target per drawn bar. Grouped bars get the full value-axis span of their slot so short
699
+ * bars stay easy to hover. Stacked segments keep their own rect, expanded to a 44px minimum
700
+ * (WCAG 2.5.8 / HIG) so a 9px-tall bar is still a usable touch target.
701
+ */
702
+ /** Targets in scroll-content coordinates, shifted left by `offsetX`. */
703
+ function barInspectorTargets({
704
+ bars,
705
+ layout,
706
+ orientation,
707
+ overlay,
708
+ waterfall,
709
+ trigger,
710
+ offsetX,
711
+ fills,
712
+ fallbackFill,
713
+ formatBar,
714
+ seriesLabelOf,
715
+ localeText,
716
+ selectedIndex
717
+ }) {
718
+ const {
719
+ plot
720
+ } = layout;
721
+ const vertical = orientation === 'vertical';
722
+ const groups = new Map();
723
+ bars.forEach(bar => {
724
+ const group = groups.get(bar.index);
725
+ if (group === undefined) {
726
+ groups.set(bar.index, [bar]);
727
+ } else {
728
+ group.push(bar);
729
+ }
730
+ });
731
+ const outlines = new Map([...groups].map(([categoryIndex, group]) => {
732
+ const start = Math.min(...group.map(item => vertical ? item.x : item.y));
733
+ const end = Math.max(...group.map(item => vertical ? item.x + item.width : item.y + item.height));
734
+ const outline = vertical ? {
735
+ left: start - offsetX - 4,
736
+ top: plot.y,
737
+ width: end - start + 8,
738
+ height: plot.height
739
+ } : {
740
+ left: plot.x - offsetX,
741
+ top: start - 4,
742
+ width: plot.width,
743
+ height: end - start + 8
744
+ };
745
+ return [categoryIndex, outline];
746
+ }));
747
+ const trendText = bar => {
748
+ if (!overlay || bar.seriesIndex !== 0) {
749
+ return null;
750
+ }
751
+ const group = groups.get(bar.index) ?? [];
752
+ const delta = (0, _geometry.overlayDelta)(group, bar.index);
753
+ if (delta === null) {
754
+ return null;
755
+ }
756
+ const comparison = group.find(item => item.seriesIndex === 1);
757
+ return localeText.trend({
758
+ direction: delta > 0 ? 'up' : delta < 0 ? 'down' : 'none',
759
+ formattedDelta: formatBar({
760
+ ...bar,
761
+ value: Math.abs(delta)
762
+ }, 'a11y'),
763
+ comparisonLabel: comparison?.seriesLabel ?? ''
764
+ });
765
+ };
766
+ return bars.map((bar, index) => {
767
+ const x = bar.x - offsetX;
768
+ const raw = bar.stackId !== undefined || waterfall || !vertical ? {
769
+ left: x,
770
+ top: bar.y,
771
+ width: bar.width,
772
+ height: bar.height
773
+ } : {
774
+ left: x,
775
+ top: plot.y,
776
+ width: bar.width,
777
+ height: plot.height
778
+ };
779
+ const box = (0, _ChartInspector.expandHitBox)(raw.left, raw.top, raw.width, raw.height);
780
+ const group = groups.get(bar.index) ?? [bar];
781
+ const outline = outlines.get(bar.index);
782
+ return {
783
+ key: `hit-${String(bar.index)}-${bar.seriesId}`,
784
+ ...box,
785
+ outline,
786
+ anchorX: vertical ? x + bar.width / 2 : x + bar.width,
787
+ anchorY: bar.y,
788
+ anchorRadius: vertical ? bar.width / 2 : 0,
789
+ tooltip: barTooltipContent(group, bar, trigger === 'item' ? 'item' : 'axis', fills, fallbackFill, formatBar, seriesLabelOf),
790
+ accessibilityLabel: barAccessibilityName(bar.label, seriesLabelOf(bar), formatBar(bar, 'a11y'), trendText(bar)),
791
+ selected: selectedIndex === index
792
+ };
793
+ });
794
+ }
795
+ function BarInspector({
796
+ bars,
797
+ targets,
798
+ orientation,
799
+ summary,
800
+ selectable,
801
+ activeIndex,
802
+ selectedIndex,
803
+ onActivate,
804
+ onDeactivate,
805
+ onDismiss,
806
+ onSelectIndex,
807
+ holdToScrub,
808
+ onScrubLockChange
809
+ }) {
810
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartInspector.ChartInspector, {
811
+ targets: targets,
812
+ summary: summary,
813
+ selectable: selectable,
814
+ activeIndex: activeIndex,
815
+ selectedIndex: selectedIndex,
816
+ slot: "bar-chart",
817
+ holdToScrub: holdToScrub,
818
+ onScrubLockChange: onScrubLockChange,
819
+ hitTest: (x, y) => {
820
+ let best = null;
821
+ let bestDist = Number.POSITIVE_INFINITY;
822
+ targets.forEach((target, index) => {
823
+ if (x < target.left || x > target.left + target.width || y < target.top || y > target.top + target.height) {
824
+ return;
825
+ }
826
+ const dist = Math.hypot(x - (target.left + target.width / 2), y - (target.top + target.height / 2));
827
+ if (dist < bestDist) {
828
+ bestDist = dist;
829
+ best = index;
830
+ }
831
+ });
832
+ return best;
833
+ },
834
+ onActivate: onActivate,
835
+ onDeactivate: onDeactivate,
836
+ onDismiss: onDismiss,
837
+ onSelectIndex: onSelectIndex,
838
+ neighborIndex: (index, key) => (0, _geometry.barKeyboardNeighbor)(bars, index, key, orientation)
839
+ });
840
+ }
841
+ function collapsedBar(bar, orientation, baseline) {
842
+ if (orientation === 'vertical') {
843
+ const onBaseline = Math.abs((bar.plotValue >= 0 ? bar.y + bar.height : bar.y) - baseline) < 1;
844
+ return onBaseline ? [bar.x, baseline, bar.width, 0] : [bar.x, bar.y + bar.height, bar.width, 0];
845
+ }
846
+ const onBaseline = Math.abs((bar.plotValue >= 0 ? bar.x : bar.x + bar.width) - baseline) < 1;
847
+ return onBaseline ? [baseline, bar.y, 0, bar.height] : [bar.x, bar.y, 0, bar.height];
848
+ }
849
+ function AnimatedBar({
850
+ bar,
851
+ orientation,
852
+ baseline,
853
+ animated,
854
+ fill,
855
+ opacity,
856
+ radius
857
+ }) {
858
+ const {
859
+ rounded,
860
+ roundAll,
861
+ value
862
+ } = bar;
863
+ const morph = (0, _motion.useChartMorph)([bar.x, bar.y, bar.width, bar.height], collapsedBar(bar, orientation, baseline), animated);
864
+ const {
865
+ from,
866
+ to,
867
+ progress
868
+ } = morph;
869
+ const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
870
+ const [x = 0, y = 0, width = 0, height = 0] = (0, _motion.lerpVector)(from.get(), to.get(), progress.get());
871
+ return {
872
+ d: (0, _geometry.barPath)({
873
+ x,
874
+ y,
875
+ width,
876
+ height,
877
+ rounded,
878
+ roundAll,
879
+ value
880
+ }, orientation, radius)
881
+ };
882
+ }, [from, to, progress, rounded, roundAll, value, orientation, radius]);
883
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedPath, {
884
+ animatedProps: animatedProps,
885
+ fill: fill,
886
+ opacity: opacity
887
+ });
888
+ }
889
+ function ValueLabels({
890
+ animated,
891
+ motionKey,
892
+ children
893
+ }) {
894
+ const [shownKey, setShownKey] = (0, _react.useState)(animated ? null : motionKey);
895
+ (0, _react.useEffect)(() => {
896
+ if (!animated) {
897
+ setShownKey(motionKey);
898
+ return;
899
+ }
900
+ const id = setTimeout(() => setShownKey(motionKey), _motion.CHART_MOTION_DURATION);
901
+ return () => {
902
+ clearTimeout(id);
903
+ };
904
+ }, [animated, motionKey]);
905
+ if (!animated) {
906
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
907
+ children: children(1)
908
+ });
909
+ }
910
+ if (shownKey !== motionKey) {
911
+ return null;
912
+ }
913
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(FadeInLabels, {
914
+ children: children
915
+ }, motionKey);
916
+ }
917
+
918
+ /** Group opacity on native SVG flashes a full-opacity frame; fade each text's fill instead. */
919
+ function FadeInLabels({
920
+ children
921
+ }) {
922
+ const [opacity, setOpacity] = (0, _react.useState)(0);
923
+ (0, _react.useEffect)(() => {
924
+ let frame = 0;
925
+ const started = Date.now();
926
+ const tick = () => {
927
+ const t = Math.min(1, (Date.now() - started) / LABEL_FADE_DURATION);
928
+ setOpacity(1 - (1 - t) ** 3);
929
+ if (t < 1) {
930
+ frame = requestAnimationFrame(tick);
931
+ }
932
+ };
933
+ frame = requestAnimationFrame(tick);
934
+ return () => {
935
+ cancelAnimationFrame(frame);
936
+ };
937
+ }, []);
938
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
939
+ children: children(opacity)
940
+ });
941
+ }
942
+ //# sourceMappingURL=index.js.map