@plenustech/design-system 0.2.2 → 0.2.3

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 (373) hide show
  1. package/dist/components/actions/ButtonTile/ButtonTile.cjs +2 -0
  2. package/dist/components/actions/ButtonTile/ButtonTile.cjs.map +1 -0
  3. package/dist/components/actions/ButtonTile/ButtonTile.js +23 -0
  4. package/dist/components/actions/ButtonTile/ButtonTile.js.map +1 -0
  5. package/dist/components/actions/ButtonTile/ButtonTile.module.css.cjs +2 -0
  6. package/dist/components/actions/ButtonTile/ButtonTile.module.css.cjs.map +1 -0
  7. package/dist/components/actions/ButtonTile/ButtonTile.module.css.js +16 -0
  8. package/dist/components/actions/ButtonTile/ButtonTile.module.css.js.map +1 -0
  9. package/dist/components/actions/Toolbar/Toolbar.cjs +2 -0
  10. package/dist/components/actions/Toolbar/Toolbar.cjs.map +1 -0
  11. package/dist/components/actions/Toolbar/Toolbar.js +118 -0
  12. package/dist/components/actions/Toolbar/Toolbar.js.map +1 -0
  13. package/dist/components/actions/Toolbar/Toolbar.module.css.cjs +2 -0
  14. package/dist/components/actions/Toolbar/Toolbar.module.css.cjs.map +1 -0
  15. package/dist/components/actions/Toolbar/Toolbar.module.css.js +20 -0
  16. package/dist/components/actions/Toolbar/Toolbar.module.css.js.map +1 -0
  17. package/dist/components/charts/ChartArea/ChartArea.cjs +1 -1
  18. package/dist/components/charts/ChartArea/ChartArea.cjs.map +1 -1
  19. package/dist/components/charts/ChartArea/ChartArea.js +196 -148
  20. package/dist/components/charts/ChartArea/ChartArea.js.map +1 -1
  21. package/dist/components/charts/ChartArea/ChartArea.module.css.cjs +1 -1
  22. package/dist/components/charts/ChartArea/ChartArea.module.css.js +12 -10
  23. package/dist/components/charts/ChartArea/ChartArea.module.css.js.map +1 -1
  24. package/dist/components/charts/ChartBar/ChartBar.cjs +1 -1
  25. package/dist/components/charts/ChartBar/ChartBar.cjs.map +1 -1
  26. package/dist/components/charts/ChartBar/ChartBar.js +168 -145
  27. package/dist/components/charts/ChartBar/ChartBar.js.map +1 -1
  28. package/dist/components/charts/ChartBar/ChartBar.module.css.cjs +1 -1
  29. package/dist/components/charts/ChartBar/ChartBar.module.css.js +12 -10
  30. package/dist/components/charts/ChartBar/ChartBar.module.css.js.map +1 -1
  31. package/dist/components/charts/ChartCombo/ChartCombo.cjs +1 -1
  32. package/dist/components/charts/ChartCombo/ChartCombo.cjs.map +1 -1
  33. package/dist/components/charts/ChartCombo/ChartCombo.js +179 -154
  34. package/dist/components/charts/ChartCombo/ChartCombo.js.map +1 -1
  35. package/dist/components/charts/ChartCombo/ChartCombo.module.css.cjs +1 -1
  36. package/dist/components/charts/ChartCombo/ChartCombo.module.css.js +16 -14
  37. package/dist/components/charts/ChartCombo/ChartCombo.module.css.js.map +1 -1
  38. package/dist/components/charts/ChartDonut/ChartDonut.cjs +1 -1
  39. package/dist/components/charts/ChartDonut/ChartDonut.cjs.map +1 -1
  40. package/dist/components/charts/ChartDonut/ChartDonut.js +72 -61
  41. package/dist/components/charts/ChartDonut/ChartDonut.js.map +1 -1
  42. package/dist/components/charts/ChartLine/ChartLine.cjs +1 -1
  43. package/dist/components/charts/ChartLine/ChartLine.cjs.map +1 -1
  44. package/dist/components/charts/ChartLine/ChartLine.js +196 -143
  45. package/dist/components/charts/ChartLine/ChartLine.js.map +1 -1
  46. package/dist/components/charts/ChartLine/ChartLine.module.css.cjs +1 -1
  47. package/dist/components/charts/ChartLine/ChartLine.module.css.js +16 -14
  48. package/dist/components/charts/ChartLine/ChartLine.module.css.js.map +1 -1
  49. package/dist/components/charts/ChartPie/ChartPie.cjs +1 -1
  50. package/dist/components/charts/ChartPie/ChartPie.cjs.map +1 -1
  51. package/dist/components/charts/ChartPie/ChartPie.js +71 -60
  52. package/dist/components/charts/ChartPie/ChartPie.js.map +1 -1
  53. package/dist/components/charts/ChartRadial/ChartRadial.cjs +1 -1
  54. package/dist/components/charts/ChartRadial/ChartRadial.cjs.map +1 -1
  55. package/dist/components/charts/ChartRadial/ChartRadial.js +101 -84
  56. package/dist/components/charts/ChartRadial/ChartRadial.js.map +1 -1
  57. package/dist/components/charts/ChartSankey/ChartSankey.cjs +1 -1
  58. package/dist/components/charts/ChartSankey/ChartSankey.cjs.map +1 -1
  59. package/dist/components/charts/ChartSankey/ChartSankey.js +148 -125
  60. package/dist/components/charts/ChartSankey/ChartSankey.js.map +1 -1
  61. package/dist/components/charts/ChartScatter/ChartScatter.cjs +1 -1
  62. package/dist/components/charts/ChartScatter/ChartScatter.cjs.map +1 -1
  63. package/dist/components/charts/ChartScatter/ChartScatter.js +138 -106
  64. package/dist/components/charts/ChartScatter/ChartScatter.js.map +1 -1
  65. package/dist/components/charts/ChartScatter/ChartScatter.module.css.cjs +1 -1
  66. package/dist/components/charts/ChartScatter/ChartScatter.module.css.js +3 -3
  67. package/dist/components/charts/ChartSunburst/ChartSunburst.cjs +1 -1
  68. package/dist/components/charts/ChartSunburst/ChartSunburst.cjs.map +1 -1
  69. package/dist/components/charts/ChartSunburst/ChartSunburst.js +115 -100
  70. package/dist/components/charts/ChartSunburst/ChartSunburst.js.map +1 -1
  71. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +1 -1
  72. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -1
  73. package/dist/components/charts/ChartTooltip/ChartTooltip.js +1 -1
  74. package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -1
  75. package/dist/components/charts/ChartTreemap/ChartTreemap.cjs +1 -1
  76. package/dist/components/charts/ChartTreemap/ChartTreemap.cjs.map +1 -1
  77. package/dist/components/charts/ChartTreemap/ChartTreemap.js +100 -89
  78. package/dist/components/charts/ChartTreemap/ChartTreemap.js.map +1 -1
  79. package/dist/components/charts/ChartWaterfall/ChartWaterfall.cjs +1 -1
  80. package/dist/components/charts/ChartWaterfall/ChartWaterfall.cjs.map +1 -1
  81. package/dist/components/charts/ChartWaterfall/ChartWaterfall.js +125 -105
  82. package/dist/components/charts/ChartWaterfall/ChartWaterfall.js.map +1 -1
  83. package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.cjs +1 -1
  84. package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.js +8 -6
  85. package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.js.map +1 -1
  86. package/dist/components/charts/core/CartesianFrame.cjs +1 -1
  87. package/dist/components/charts/core/CartesianFrame.cjs.map +1 -1
  88. package/dist/components/charts/core/CartesianFrame.js +61 -96
  89. package/dist/components/charts/core/CartesianFrame.js.map +1 -1
  90. package/dist/components/charts/core/Chart.module.css.cjs +1 -1
  91. package/dist/components/charts/core/Chart.module.css.js +52 -54
  92. package/dist/components/charts/core/Chart.module.css.js.map +1 -1
  93. package/dist/components/charts/core/ChartFrame.cjs +1 -1
  94. package/dist/components/charts/core/ChartFrame.cjs.map +1 -1
  95. package/dist/components/charts/core/ChartFrame.js +53 -47
  96. package/dist/components/charts/core/ChartFrame.js.map +1 -1
  97. package/dist/components/charts/core/PointBands.cjs +2 -0
  98. package/dist/components/charts/core/PointBands.cjs.map +1 -0
  99. package/dist/components/charts/core/PointBands.js +41 -0
  100. package/dist/components/charts/core/PointBands.js.map +1 -0
  101. package/dist/components/charts/core/cartesianLayout.cjs +1 -1
  102. package/dist/components/charts/core/cartesianLayout.cjs.map +1 -1
  103. package/dist/components/charts/core/cartesianLayout.js +49 -41
  104. package/dist/components/charts/core/cartesianLayout.js.map +1 -1
  105. package/dist/components/charts/core/hoverPath.cjs +2 -0
  106. package/dist/components/charts/core/hoverPath.cjs.map +1 -0
  107. package/dist/components/charts/core/hoverPath.js +7 -0
  108. package/dist/components/charts/core/hoverPath.js.map +1 -0
  109. package/dist/components/charts/core/pointLabels.cjs +2 -0
  110. package/dist/components/charts/core/pointLabels.cjs.map +1 -0
  111. package/dist/components/charts/core/pointLabels.js +12 -0
  112. package/dist/components/charts/core/pointLabels.js.map +1 -0
  113. package/dist/components/charts/core/tooltips.cjs +2 -0
  114. package/dist/components/charts/core/tooltips.cjs.map +1 -0
  115. package/dist/components/charts/core/tooltips.js +48 -0
  116. package/dist/components/charts/core/tooltips.js.map +1 -0
  117. package/dist/components/charts/core/useCartesianLayout.cjs +2 -0
  118. package/dist/components/charts/core/useCartesianLayout.cjs.map +1 -0
  119. package/dist/components/charts/core/useCartesianLayout.js +38 -0
  120. package/dist/components/charts/core/useCartesianLayout.js.map +1 -0
  121. package/dist/components/charts/core/useSeriesToggle.cjs +1 -1
  122. package/dist/components/charts/core/useSeriesToggle.cjs.map +1 -1
  123. package/dist/components/charts/core/useSeriesToggle.js +19 -12
  124. package/dist/components/charts/core/useSeriesToggle.js.map +1 -1
  125. package/dist/components/data-display/Accordion/Accordion.cjs +1 -1
  126. package/dist/components/data-display/Accordion/Accordion.cjs.map +1 -1
  127. package/dist/components/data-display/Accordion/Accordion.js +56 -46
  128. package/dist/components/data-display/Accordion/Accordion.js.map +1 -1
  129. package/dist/components/data-display/Accordion/Accordion.module.css.cjs +1 -1
  130. package/dist/components/data-display/Accordion/Accordion.module.css.js +16 -16
  131. package/dist/components/data-display/SortableList/SortableList.cjs +2 -0
  132. package/dist/components/data-display/SortableList/SortableList.cjs.map +1 -0
  133. package/dist/components/data-display/SortableList/SortableList.js +168 -0
  134. package/dist/components/data-display/SortableList/SortableList.js.map +1 -0
  135. package/dist/components/data-display/SortableList/SortableList.module.css.cjs +2 -0
  136. package/dist/components/data-display/SortableList/SortableList.module.css.cjs.map +1 -0
  137. package/dist/components/data-display/SortableList/SortableList.module.css.js +34 -0
  138. package/dist/components/data-display/SortableList/SortableList.module.css.js.map +1 -0
  139. package/dist/components/data-display/Table/Table.cjs +1 -1
  140. package/dist/components/data-display/Table/Table.cjs.map +1 -1
  141. package/dist/components/data-display/Table/Table.js +86 -85
  142. package/dist/components/data-display/Table/Table.js.map +1 -1
  143. package/dist/components/data-display/Table/Table.module.css.cjs +1 -1
  144. package/dist/components/data-display/Table/Table.module.css.js +50 -51
  145. package/dist/components/data-display/Table/Table.module.css.js.map +1 -1
  146. package/dist/components/data-display/Tag/Tag.cjs +2 -0
  147. package/dist/components/data-display/Tag/Tag.cjs.map +1 -0
  148. package/dist/components/data-display/Tag/Tag.js +50 -0
  149. package/dist/components/data-display/Tag/Tag.js.map +1 -0
  150. package/dist/components/data-display/Tag/Tag.module.css.cjs +2 -0
  151. package/dist/components/data-display/Tag/Tag.module.css.cjs.map +1 -0
  152. package/dist/components/data-display/Tag/Tag.module.css.js +22 -0
  153. package/dist/components/data-display/Tag/Tag.module.css.js.map +1 -0
  154. package/dist/components/data-display/Timeline/Timeline.cjs +2 -0
  155. package/dist/components/data-display/Timeline/Timeline.cjs.map +1 -0
  156. package/dist/components/data-display/Timeline/Timeline.js +31 -0
  157. package/dist/components/data-display/Timeline/Timeline.js.map +1 -0
  158. package/dist/components/data-display/Timeline/Timeline.module.css.cjs +2 -0
  159. package/dist/components/data-display/Timeline/Timeline.module.css.cjs.map +1 -0
  160. package/dist/components/data-display/Timeline/Timeline.module.css.js +30 -0
  161. package/dist/components/data-display/Timeline/Timeline.module.css.js.map +1 -0
  162. package/dist/components/feedback/Skeleton/Skeleton.cjs +2 -0
  163. package/dist/components/feedback/Skeleton/Skeleton.cjs.map +1 -0
  164. package/dist/components/feedback/Skeleton/Skeleton.js +17 -0
  165. package/dist/components/feedback/Skeleton/Skeleton.js.map +1 -0
  166. package/dist/components/feedback/Skeleton/Skeleton.module.css.cjs +2 -0
  167. package/dist/components/feedback/Skeleton/Skeleton.module.css.cjs.map +1 -0
  168. package/dist/components/feedback/Skeleton/Skeleton.module.css.js +15 -0
  169. package/dist/components/feedback/Skeleton/Skeleton.module.css.js.map +1 -0
  170. package/dist/components/feedback/Toast/Toast.module.css.cjs +2 -0
  171. package/dist/components/feedback/Toast/Toast.module.css.cjs.map +1 -0
  172. package/dist/components/feedback/Toast/Toast.module.css.js +31 -0
  173. package/dist/components/feedback/Toast/Toast.module.css.js.map +1 -0
  174. package/dist/components/feedback/Toast/ToastRegion.cjs +2 -0
  175. package/dist/components/feedback/Toast/ToastRegion.cjs.map +1 -0
  176. package/dist/components/feedback/Toast/ToastRegion.js +62 -0
  177. package/dist/components/feedback/Toast/ToastRegion.js.map +1 -0
  178. package/dist/components/feedback/Toast/toastStore.cjs +2 -0
  179. package/dist/components/feedback/Toast/toastStore.cjs.map +1 -0
  180. package/dist/components/feedback/Toast/toastStore.js +33 -0
  181. package/dist/components/feedback/Toast/toastStore.js.map +1 -0
  182. package/dist/components/forms/Checkbox/Checkbox.cjs +1 -1
  183. package/dist/components/forms/Checkbox/Checkbox.cjs.map +1 -1
  184. package/dist/components/forms/Checkbox/Checkbox.js +43 -31
  185. package/dist/components/forms/Checkbox/Checkbox.js.map +1 -1
  186. package/dist/components/forms/Checkbox/Checkbox.module.css.cjs +1 -1
  187. package/dist/components/forms/Checkbox/Checkbox.module.css.js +1 -1
  188. package/dist/components/forms/CheckboxGroup/CheckboxGroup.cjs +2 -0
  189. package/dist/components/forms/CheckboxGroup/CheckboxGroup.cjs.map +1 -0
  190. package/dist/components/forms/CheckboxGroup/CheckboxGroup.js +54 -0
  191. package/dist/components/forms/CheckboxGroup/CheckboxGroup.js.map +1 -0
  192. package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.cjs +2 -0
  193. package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.cjs.map +1 -0
  194. package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.js +22 -0
  195. package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.js.map +1 -0
  196. package/dist/components/forms/ColorPicker/ColorPicker.cjs +2 -0
  197. package/dist/components/forms/ColorPicker/ColorPicker.cjs.map +1 -0
  198. package/dist/components/forms/ColorPicker/ColorPicker.js +57 -0
  199. package/dist/components/forms/ColorPicker/ColorPicker.js.map +1 -0
  200. package/dist/components/forms/ColorPicker/ColorPicker.module.css.cjs +2 -0
  201. package/dist/components/forms/ColorPicker/ColorPicker.module.css.cjs.map +1 -0
  202. package/dist/components/forms/ColorPicker/ColorPicker.module.css.js +22 -0
  203. package/dist/components/forms/ColorPicker/ColorPicker.module.css.js.map +1 -0
  204. package/dist/components/forms/ComboBox/ComboBox.module.css.cjs +1 -1
  205. package/dist/components/forms/ComboBox/ComboBox.module.css.js +20 -20
  206. package/dist/components/forms/Field/Field.cjs +1 -1
  207. package/dist/components/forms/Field/Field.cjs.map +1 -1
  208. package/dist/components/forms/Field/Field.js +21 -20
  209. package/dist/components/forms/Field/Field.js.map +1 -1
  210. package/dist/components/forms/Field/Field.module.css.cjs +1 -1
  211. package/dist/components/forms/Field/Field.module.css.js +18 -12
  212. package/dist/components/forms/Field/Field.module.css.js.map +1 -1
  213. package/dist/components/forms/FileUpload/FileUpload.cjs +2 -0
  214. package/dist/components/forms/FileUpload/FileUpload.cjs.map +1 -0
  215. package/dist/components/forms/FileUpload/FileUpload.js +142 -0
  216. package/dist/components/forms/FileUpload/FileUpload.js.map +1 -0
  217. package/dist/components/forms/FileUpload/FileUpload.module.css.cjs +2 -0
  218. package/dist/components/forms/FileUpload/FileUpload.module.css.cjs.map +1 -0
  219. package/dist/components/forms/FileUpload/FileUpload.module.css.js +46 -0
  220. package/dist/components/forms/FileUpload/FileUpload.module.css.js.map +1 -0
  221. package/dist/components/forms/InputPassword/InputPassword.module.css.cjs +1 -1
  222. package/dist/components/forms/InputPassword/InputPassword.module.css.js +12 -12
  223. package/dist/components/forms/InputText/InputText.cjs +1 -1
  224. package/dist/components/forms/InputText/InputText.cjs.map +1 -1
  225. package/dist/components/forms/InputText/InputText.js +55 -47
  226. package/dist/components/forms/InputText/InputText.js.map +1 -1
  227. package/dist/components/forms/InputText/InputText.module.css.cjs +1 -1
  228. package/dist/components/forms/InputText/InputText.module.css.js +10 -10
  229. package/dist/components/forms/RadioGroup/RadioGroup.module.css.cjs +1 -1
  230. package/dist/components/forms/RadioGroup/RadioGroup.module.css.js +4 -4
  231. package/dist/components/forms/SegmentedControl/SegmentedControl.cjs +2 -0
  232. package/dist/components/forms/SegmentedControl/SegmentedControl.cjs.map +1 -0
  233. package/dist/components/forms/SegmentedControl/SegmentedControl.js +52 -0
  234. package/dist/components/forms/SegmentedControl/SegmentedControl.js.map +1 -0
  235. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs +2 -0
  236. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs.map +1 -0
  237. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.js +22 -0
  238. package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.js.map +1 -0
  239. package/dist/components/forms/Select/Select.module.css.cjs +1 -1
  240. package/dist/components/forms/Select/Select.module.css.js +13 -13
  241. package/dist/components/forms/Switch/Switch.module.css.cjs +1 -1
  242. package/dist/components/forms/Switch/Switch.module.css.js +2 -2
  243. package/dist/components/icons/icons.cjs +1 -1
  244. package/dist/components/icons/icons.cjs.map +1 -1
  245. package/dist/components/icons/icons.js +198 -40
  246. package/dist/components/icons/icons.js.map +1 -1
  247. package/dist/components/navigation/SkipLink/SkipLink.cjs +2 -0
  248. package/dist/components/navigation/SkipLink/SkipLink.cjs.map +1 -0
  249. package/dist/components/navigation/SkipLink/SkipLink.js +9 -0
  250. package/dist/components/navigation/SkipLink/SkipLink.js.map +1 -0
  251. package/dist/components/navigation/SkipLink/SkipLink.module.css.cjs +2 -0
  252. package/dist/components/navigation/SkipLink/SkipLink.module.css.cjs.map +1 -0
  253. package/dist/components/navigation/SkipLink/SkipLink.module.css.js +8 -0
  254. package/dist/components/navigation/SkipLink/SkipLink.module.css.js.map +1 -0
  255. package/dist/components/navigation/Steps/Steps.cjs +2 -0
  256. package/dist/components/navigation/Steps/Steps.cjs.map +1 -0
  257. package/dist/components/navigation/Steps/Steps.js +30 -0
  258. package/dist/components/navigation/Steps/Steps.js.map +1 -0
  259. package/dist/components/navigation/Steps/Steps.module.css.cjs +2 -0
  260. package/dist/components/navigation/Steps/Steps.module.css.cjs.map +1 -0
  261. package/dist/components/navigation/Steps/Steps.module.css.js +26 -0
  262. package/dist/components/navigation/Steps/Steps.module.css.js.map +1 -0
  263. package/dist/components/navigation/Tabs/Tabs.cjs +1 -1
  264. package/dist/components/navigation/Tabs/Tabs.cjs.map +1 -1
  265. package/dist/components/navigation/Tabs/Tabs.js +88 -79
  266. package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
  267. package/dist/components/navigation/Tabs/Tabs.module.css.cjs +1 -1
  268. package/dist/components/navigation/Tabs/Tabs.module.css.js +18 -14
  269. package/dist/components/navigation/Tabs/Tabs.module.css.js.map +1 -1
  270. package/dist/components/overlays/Dialog/Dialog.cjs +1 -1
  271. package/dist/components/overlays/Dialog/Dialog.cjs.map +1 -1
  272. package/dist/components/overlays/Dialog/Dialog.js +11 -58
  273. package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
  274. package/dist/components/overlays/Dialog/DialogFrame.cjs +2 -0
  275. package/dist/components/overlays/Dialog/DialogFrame.cjs.map +1 -0
  276. package/dist/components/overlays/Dialog/DialogFrame.js +65 -0
  277. package/dist/components/overlays/Dialog/DialogFrame.js.map +1 -0
  278. package/dist/components/overlays/Drawer/Drawer.cjs +2 -0
  279. package/dist/components/overlays/Drawer/Drawer.cjs.map +1 -0
  280. package/dist/components/overlays/Drawer/Drawer.js +17 -0
  281. package/dist/components/overlays/Drawer/Drawer.js.map +1 -0
  282. package/dist/components/overlays/Drawer/Drawer.module.css.cjs +2 -0
  283. package/dist/components/overlays/Drawer/Drawer.module.css.cjs.map +1 -0
  284. package/dist/components/overlays/Drawer/Drawer.module.css.js +23 -0
  285. package/dist/components/overlays/Drawer/Drawer.module.css.js.map +1 -0
  286. package/dist/components/overlays/Menu/Menu.cjs +1 -1
  287. package/dist/components/overlays/Menu/Menu.cjs.map +1 -1
  288. package/dist/components/overlays/Menu/Menu.js +105 -86
  289. package/dist/components/overlays/Menu/Menu.js.map +1 -1
  290. package/dist/components/overlays/Menu/Menu.module.css.cjs +1 -1
  291. package/dist/components/overlays/Menu/Menu.module.css.js +24 -6
  292. package/dist/components/overlays/Menu/Menu.module.css.js.map +1 -1
  293. package/dist/design-system.css +1 -1
  294. package/dist/index.cjs +1 -1
  295. package/dist/index.js +184 -122
  296. package/dist/index.js.map +1 -1
  297. package/dist/types/components/actions/ButtonTile/ButtonTile.d.ts +14 -0
  298. package/dist/types/components/actions/ButtonTile/index.d.ts +2 -0
  299. package/dist/types/components/actions/Toolbar/Toolbar.d.ts +27 -0
  300. package/dist/types/components/actions/Toolbar/index.d.ts +2 -0
  301. package/dist/types/components/charts/ChartArea/ChartArea.d.ts +15 -4
  302. package/dist/types/components/charts/ChartBar/ChartBar.d.ts +11 -4
  303. package/dist/types/components/charts/ChartCombo/ChartCombo.d.ts +16 -4
  304. package/dist/types/components/charts/ChartDonut/ChartDonut.d.ts +5 -1
  305. package/dist/types/components/charts/ChartLine/ChartLine.d.ts +15 -4
  306. package/dist/types/components/charts/ChartPie/ChartPie.d.ts +5 -1
  307. package/dist/types/components/charts/ChartRadial/ChartRadial.d.ts +5 -1
  308. package/dist/types/components/charts/ChartSankey/ChartSankey.d.ts +5 -1
  309. package/dist/types/components/charts/ChartScatter/ChartScatter.d.ts +7 -1
  310. package/dist/types/components/charts/ChartSunburst/ChartSunburst.d.ts +11 -2
  311. package/dist/types/components/charts/ChartTooltip/ChartTooltip.d.ts +2 -0
  312. package/dist/types/components/charts/ChartTreemap/ChartTreemap.d.ts +11 -2
  313. package/dist/types/components/charts/ChartWaterfall/ChartWaterfall.d.ts +8 -3
  314. package/dist/types/components/charts/core/CartesianFrame.d.ts +6 -1
  315. package/dist/types/components/charts/core/ChartFrame.d.ts +7 -1
  316. package/dist/types/components/charts/core/PointBands.d.ts +22 -0
  317. package/dist/types/components/charts/core/cartesianLayout.d.ts +10 -4
  318. package/dist/types/components/charts/core/hoverPath.d.ts +10 -0
  319. package/dist/types/components/charts/core/index.d.ts +13 -3
  320. package/dist/types/components/charts/core/pointLabels.d.ts +13 -0
  321. package/dist/types/components/charts/core/tooltips.d.ts +49 -0
  322. package/dist/types/components/charts/core/useCartesianLayout.d.ts +20 -0
  323. package/dist/types/components/charts/core/useSeriesToggle.d.ts +15 -1
  324. package/dist/types/components/data-display/Accordion/Accordion.d.ts +6 -1
  325. package/dist/types/components/data-display/Accordion/index.d.ts +1 -1
  326. package/dist/types/components/data-display/SortableList/SortableList.d.ts +22 -0
  327. package/dist/types/components/data-display/SortableList/index.d.ts +2 -0
  328. package/dist/types/components/data-display/Tag/Tag.d.ts +13 -0
  329. package/dist/types/components/data-display/Tag/index.d.ts +2 -0
  330. package/dist/types/components/data-display/Timeline/Timeline.d.ts +15 -0
  331. package/dist/types/components/data-display/Timeline/index.d.ts +2 -0
  332. package/dist/types/components/feedback/Skeleton/Skeleton.d.ts +13 -0
  333. package/dist/types/components/feedback/Skeleton/index.d.ts +2 -0
  334. package/dist/types/components/feedback/Toast/ToastRegion.d.ts +2 -0
  335. package/dist/types/components/feedback/Toast/index.d.ts +3 -0
  336. package/dist/types/components/feedback/Toast/toastStore.d.ts +24 -0
  337. package/dist/types/components/forms/CheckboxGroup/CheckboxGroup.d.ts +28 -0
  338. package/dist/types/components/forms/CheckboxGroup/index.d.ts +2 -0
  339. package/dist/types/components/forms/ColorPicker/ColorPicker.d.ts +26 -0
  340. package/dist/types/components/forms/ColorPicker/index.d.ts +2 -0
  341. package/dist/types/components/forms/Field/Field.d.ts +6 -2
  342. package/dist/types/components/forms/Field/index.d.ts +1 -1
  343. package/dist/types/components/forms/FileUpload/FileUpload.d.ts +37 -0
  344. package/dist/types/components/forms/FileUpload/index.d.ts +2 -0
  345. package/dist/types/components/forms/InputText/InputText.d.ts +4 -2
  346. package/dist/types/components/forms/SegmentedControl/SegmentedControl.d.ts +23 -0
  347. package/dist/types/components/forms/SegmentedControl/index.d.ts +2 -0
  348. package/dist/types/components/icons/icons.d.ts +29 -0
  349. package/dist/types/components/icons/index.d.ts +1 -1
  350. package/dist/types/components/navigation/SkipLink/SkipLink.d.ts +7 -0
  351. package/dist/types/components/navigation/SkipLink/index.d.ts +2 -0
  352. package/dist/types/components/navigation/Steps/Steps.d.ts +16 -0
  353. package/dist/types/components/navigation/Steps/index.d.ts +2 -0
  354. package/dist/types/components/navigation/Tabs/Tabs.d.ts +5 -1
  355. package/dist/types/components/overlays/Dialog/Dialog.d.ts +2 -2
  356. package/dist/types/components/overlays/Dialog/DialogFrame.d.ts +7 -0
  357. package/dist/types/components/overlays/Drawer/Drawer.d.ts +9 -0
  358. package/dist/types/components/overlays/Drawer/index.d.ts +2 -0
  359. package/dist/types/components/overlays/Menu/Menu.d.ts +16 -2
  360. package/dist/types/components/overlays/Menu/index.d.ts +1 -1
  361. package/dist/types/index.d.ts +35 -7
  362. package/dist/types/utils/formatters/formatarNumero.d.ts +6 -1
  363. package/dist/types/utils/formatters/formatarTamanhoDeArquivo.d.ts +7 -0
  364. package/dist/types/utils/formatters/index.d.ts +3 -1
  365. package/dist/utils/formatters/formatarNumero.cjs +1 -1
  366. package/dist/utils/formatters/formatarNumero.cjs.map +1 -1
  367. package/dist/utils/formatters/formatarNumero.js +42 -17
  368. package/dist/utils/formatters/formatarNumero.js.map +1 -1
  369. package/dist/utils/formatters/formatarTamanhoDeArquivo.cjs +2 -0
  370. package/dist/utils/formatters/formatarTamanhoDeArquivo.cjs.map +1 -0
  371. package/dist/utils/formatters/formatarTamanhoDeArquivo.js +17 -0
  372. package/dist/utils/formatters/formatarTamanhoDeArquivo.js.map +1 -0
  373. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ChartTooltip.js","sources":["../../../../src/components/charts/ChartTooltip/ChartTooltip.tsx"],"sourcesContent":["import {\n Fragment,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type PointerEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { formatarNumero, formatarPercentual } from '../../../utils/formatters';\nimport styles from './ChartTooltip.module.css';\n\nexport interface ChartTooltipRow {\n color?: string;\n /** Realca a linha, como a serie sob o ponteiro entre as demais. */\n emphasis?: boolean;\n label: string;\n values: readonly number[];\n}\n\n/** Como a linha de total resume uma coluna. A soma raramente serve a todas. */\nexport type ChartTooltipTotal = 'sum' | 'average' | 'none' | ((values: readonly number[]) => number);\n\nexport interface ChartTooltipColumn {\n format?: (value: number) => string;\n total?: ChartTooltipTotal;\n}\n\nexport interface ChartTooltipComputed {\n /** Coluna que serve de base. A ultima por padrao, que e a de valor. */\n column?: number;\n /** Valor da linha, a partir do valor dela e do total da coluna base. */\n compute?: (value: number, total: number) => number;\n format?: (value: number) => string;\n}\n\nexport interface ChartTooltipProps {\n children: ReactNode;\n columns?: readonly ChartTooltipColumn[];\n /** Coluna ao fim. Percentual sobre a base por padrao; `none` a dispensa. */\n computed?: ChartTooltipComputed | 'none';\n rows: readonly ChartTooltipRow[];\n showTotal?: boolean;\n subtitle?: string;\n title?: string;\n totalLabel?: string;\n}\n\ninterface Ponto {\n x: number;\n y: number;\n}\n\n/** Distancia entre o ponteiro e o balao, para o cursor nao cobrir o texto. */\nconst AFASTAMENTO = 16;\n\n/** Folga minima ate a borda da janela. */\nconst MARGEM = 8;\n\nfunction somar(valores: readonly number[]) {\n return valores.reduce((total, valor) => total + valor, 0);\n}\n\nfunction totalizar(operador: ChartTooltipTotal, valores: readonly number[]) {\n if (typeof operador === 'function') {\n return operador(valores);\n }\n\n if (operador === 'average') {\n return valores.length === 0 ? 0 : somar(valores) / valores.length;\n }\n\n return somar(valores);\n}\n\n/**\n * Canto do balao a partir do ponteiro. Ele abre para baixo e para a direita\n * enquanto couber, e vira para o lado oposto ao encostar na borda.\n */\nfunction encaixar({ x, y }: Ponto, largura: number, altura: number): Ponto {\n const cabeADireita = x + AFASTAMENTO + largura <= window.innerWidth - MARGEM;\n const cabeAbaixo = y + AFASTAMENTO + altura <= window.innerHeight - MARGEM;\n\n return {\n x: cabeADireita ? x + AFASTAMENTO : Math.max(x - AFASTAMENTO - largura, MARGEM),\n y: cabeAbaixo ? y + AFASTAMENTO : Math.max(y - AFASTAMENTO - altura, MARGEM),\n };\n}\n\n/**\n * Leitura das medidas sob o ponteiro, em portal sobre a pagina. Ele acompanha o\n * cursor enquanto este percorre a area e sai a qualquer outra interacao.\n *\n * Nao conhece grafico algum: recebe linhas e colunas, e quem as monta e quem o\n * usa. E decorativo para leitor de tela: o desenho e `role=\"img\"`, apresentado\n * como imagem unica, e a leitura medida a medida cabe a visao em tabela.\n */\nexport function ChartTooltip({\n children,\n columns,\n computed,\n rows,\n showTotal = false,\n subtitle,\n title,\n totalLabel = 'Total',\n}: ChartTooltipProps) {\n const [ponteiro, setPonteiro] = useState<Ponto | null>(null);\n const visivel = ponteiro !== null && rows.length > 0;\n\n // Sai por qualquer motivo que nao seja o ponteiro andando pela area: rolagem,\n // tecla ou a janela mudando de tamanho deixam o balao preso a um lugar que o\n // desenho ja nao ocupa.\n useEffect(() => {\n if (!visivel) {\n return;\n }\n\n const esconder = () => setPonteiro(null);\n\n window.addEventListener('scroll', esconder, true);\n window.addEventListener('resize', esconder);\n window.addEventListener('keydown', esconder);\n\n return () => {\n window.removeEventListener('scroll', esconder, true);\n window.removeEventListener('resize', esconder);\n window.removeEventListener('keydown', esconder);\n };\n }, [visivel]);\n\n const acompanhar = (evento: PointerEvent<HTMLDivElement>) =>\n setPonteiro({ x: evento.clientX, y: evento.clientY });\n\n return (\n <div\n className={styles.area}\n onPointerLeave={() => setPonteiro(null)}\n onPointerMove={acompanhar}\n >\n {children}\n\n {visivel &&\n createPortal(\n <Balao\n columns={columns}\n computed={computed}\n ponteiro={ponteiro}\n rows={rows}\n showTotal={showTotal}\n subtitle={subtitle}\n title={title}\n totalLabel={totalLabel}\n />,\n document.body,\n )}\n </div>\n );\n}\n\ntype BalaoProps = Omit<ChartTooltipProps, 'children'> & { ponteiro: Ponto };\n\nfunction Balao({\n columns,\n computed,\n ponteiro,\n rows,\n showTotal,\n subtitle,\n title,\n totalLabel,\n}: BalaoProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [medida, setMedida] = useState({ altura: 0, largura: 0 });\n\n // A medida entra antes da pintura, entao o balao ja nasce no lugar certo.\n useLayoutEffect(() => {\n const no = ref.current;\n\n if (!no) {\n return;\n }\n\n const { height, width } = no.getBoundingClientRect();\n\n if (height !== medida.altura || width !== medida.largura) {\n setMedida({ altura: height, largura: width });\n }\n });\n\n const quantidadeDeColunas = rows.reduce((maior, linha) => Math.max(maior, linha.values.length), 0);\n const colunas: readonly ChartTooltipColumn[] =\n columns ?? Array.from({ length: quantidadeDeColunas }, () => ({}));\n\n // Sem coluna de onde derivar, nao ha o que calcular: linhas so com rotulo\n // renderizariam um percentual tirado do nada.\n const calculada = computed === 'none' || colunas.length === 0 ? undefined : computed ?? {};\n const colunaBase = calculada?.column ?? colunas.length - 1;\n const baseDoTotal = somar(rows.map((linha) => linha.values[colunaBase] ?? 0));\n const calcular = calculada?.compute ?? ((valor: number, total: number) => (total === 0 ? 0 : valor / total));\n const formatarCalculada = calculada?.format ?? ((valor: number) => formatarPercentual(valor, { casasDecimais: 2 }));\n\n const { x, y } = encaixar(ponteiro, medida.largura, medida.altura);\n const celulas = `1fr ${'auto '.repeat(colunas.length + (calculada ? 1 : 0))}`.trim();\n\n return (\n <div aria-hidden=\"true\" className={styles.tooltip} ref={ref} style={{ left: x, top: y }}>\n {title !== undefined && <p className={styles.title}>{title}</p>}\n {subtitle !== undefined && <p className={styles.subtitle}>{subtitle}</p>}\n\n <div className={styles.grid} style={{ gridTemplateColumns: celulas }}>\n {rows.map((linha, indiceDaLinha) => (\n <Fragment key={indiceDaLinha}>\n <span className={`${styles.label} ${linha.emphasis ? styles.emphasis : ''}`}>\n {linha.color !== undefined && (\n <span className={styles.swatch} style={{ background: linha.color }} />\n )}\n {linha.label}\n </span>\n\n {colunas.map((coluna, indice) => (\n <span className={`${styles.value} ${linha.emphasis ? styles.emphasis : ''}`} key={indice}>\n {(coluna.format ?? formatarNumero)(linha.values[indice] ?? 0)}\n </span>\n ))}\n\n {calculada && (\n <span className={`${styles.computed} ${linha.emphasis ? styles.emphasis : ''}`}>\n {formatarCalculada(calcular(linha.values[colunaBase] ?? 0, baseDoTotal))}\n </span>\n )}\n </Fragment>\n ))}\n\n {showTotal && (\n <>\n <span className={styles.rule} />\n <span className={`${styles.label} ${styles.totalLabel}`}>{totalLabel}</span>\n\n {colunas.map((coluna, indice) => (\n <span className={`${styles.value} ${styles.totalValue}`} key={indice}>\n {coluna.total === 'none'\n ? ''\n : (coluna.format ?? formatarNumero)(\n totalizar(coluna.total ?? 'sum', rows.map((linha) => linha.values[indice] ?? 0)),\n )}\n </span>\n ))}\n\n {calculada && (\n <span className={`${styles.computed} ${styles.totalValue}`}>\n {formatarCalculada(calcular(baseDoTotal, baseDoTotal))}\n </span>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"names":["AFASTAMENTO","MARGEM","somar","valores","total","valor","totalizar","operador","encaixar","x","y","largura","altura","cabeADireita","cabeAbaixo","ChartTooltip","children","columns","computed","rows","showTotal","subtitle","title","totalLabel","ponteiro","setPonteiro","useState","visivel","useEffect","esconder","acompanhar","evento","jsxs","styles","createPortal","jsx","Balao","ref","useRef","medida","setMedida","useLayoutEffect","no","height","width","quantidadeDeColunas","maior","linha","colunas","calculada","colunaBase","baseDoTotal","calcular","formatarCalculada","formatarPercentual","celulas","indiceDaLinha","Fragment","coluna","indice","formatarNumero"],"mappings":";;;;;AAuDA,MAAMA,IAAc,IAGdC,IAAS;AAEf,SAASC,EAAMC,GAA4B;AACzC,SAAOA,EAAQ,OAAO,CAACC,GAAOC,MAAUD,IAAQC,GAAO,CAAC;AAC1D;AAEA,SAASC,EAAUC,GAA6BJ,GAA4B;AAC1E,SAAI,OAAOI,KAAa,aACfA,EAASJ,CAAO,IAGrBI,MAAa,YACRJ,EAAQ,WAAW,IAAI,IAAID,EAAMC,CAAO,IAAIA,EAAQ,SAGtDD,EAAMC,CAAO;AACtB;AAMA,SAASK,EAAS,EAAE,GAAAC,GAAG,GAAAC,EAAA,GAAYC,GAAiBC,GAAuB;AACzE,QAA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E,GAAgBb,EAAM,OAAOY,CAAM,KAAK,CAAC,EAAA,GADoBA,CAElF,CACD;AAAA,QAEAV,uBACE,QAAA,EAAK,WAAW,GAAGhB,EAAO,QAAQ,IAAIc,EAAM,WAAWd,EAAO,WAAW,EAAE,IACzE,UAAAoB,EAAkBD,EAASL,EAAM,OAAOG,CAAU,KAAK,GAAGC,CAAW,CAAC,EAAA,CACzE;AAAA,MAAA,EAAA,GAjBWK,CAmBf,CACD;AAAA,MAEApC,KACC,gBAAAY,EAAAyB,GAAA,EACE,UAAA;AAAA,QAAA,gBAAAtB,EAAC,QAAA,EAAK,WAAWF,EAAO,KAAA,CAAM;AAAA,QAC9B,gBAAAE,EAAC,QAAA,EAAK,WAAW,GAAGF,EAAO,KAAK,IAAIA,EAAO,UAAU,IAAK,UAAAV,EAAA,CAAW;AAAA,QAEpEyB,EAAQ,IAAI,CAACU,GAAQC,MACpB,gBAAAxB,EAAC,QAAA,EAAK,WAAW,GAAGF,EAAO,KAAK,IAAIA,EAAO,UAAU,IAClD,UAAAyB,EAAO,UAAU,SACd,MACCA,EAAO,UAAUE;AAAA,UAChBtD,EAAUoD,EAAO,SAAS,OAAOvC,EAAK,IAAI,CAAC4B,MAAUA,EAAM,OAAOY,CAAM,KAAK,CAAC,CAAC;AAAA,QAAA,EACjF,GALwDA,CAM9D,CACD;AAAA,QAEAV,KACC,gBAAAd,EAAC,QAAA,EAAK,WAAW,GAAGF,EAAO,QAAQ,IAAIA,EAAO,UAAU,IACrD,UAAAoB,EAAkBD,EAASD,GAAaA,CAAW,CAAC,EAAA,CACvD;AAAA,MAAA,EAAA,CAEJ;AAAA,IAAA,EAAA,CAEJ;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"ChartTooltip.js","sources":["../../../../src/components/charts/ChartTooltip/ChartTooltip.tsx"],"sourcesContent":["import {\n Fragment,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type PointerEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { formatarNumero, formatarPercentual } from '../../../utils/formatters';\nimport styles from './ChartTooltip.module.css';\n\nexport interface ChartTooltipRow {\n color?: string;\n /** Realca a linha, como a serie sob o ponteiro entre as demais. */\n emphasis?: boolean;\n /** Formato dos valores desta linha, quando difere do da coluna, como a serie do eixo da direita. */\n format?: (value: number) => string;\n label: string;\n values: readonly number[];\n}\n\n/** Como a linha de total resume uma coluna. A soma raramente serve a todas. */\nexport type ChartTooltipTotal = 'sum' | 'average' | 'none' | ((values: readonly number[]) => number);\n\nexport interface ChartTooltipColumn {\n format?: (value: number) => string;\n total?: ChartTooltipTotal;\n}\n\nexport interface ChartTooltipComputed {\n /** Coluna que serve de base. A ultima por padrao, que e a de valor. */\n column?: number;\n /** Valor da linha, a partir do valor dela e do total da coluna base. */\n compute?: (value: number, total: number) => number;\n format?: (value: number) => string;\n}\n\nexport interface ChartTooltipProps {\n children: ReactNode;\n columns?: readonly ChartTooltipColumn[];\n /** Coluna ao fim. Percentual sobre a base por padrao; `none` a dispensa. */\n computed?: ChartTooltipComputed | 'none';\n rows: readonly ChartTooltipRow[];\n showTotal?: boolean;\n subtitle?: string;\n title?: string;\n totalLabel?: string;\n}\n\ninterface Ponto {\n x: number;\n y: number;\n}\n\n/** Distancia entre o ponteiro e o balao, para o cursor nao cobrir o texto. */\nconst AFASTAMENTO = 16;\n\n/** Folga minima ate a borda da janela. */\nconst MARGEM = 8;\n\nfunction somar(valores: readonly number[]) {\n return valores.reduce((total, valor) => total + valor, 0);\n}\n\nfunction totalizar(operador: ChartTooltipTotal, valores: readonly number[]) {\n if (typeof operador === 'function') {\n return operador(valores);\n }\n\n if (operador === 'average') {\n return valores.length === 0 ? 0 : somar(valores) / valores.length;\n }\n\n return somar(valores);\n}\n\n/**\n * Canto do balao a partir do ponteiro. Ele abre para baixo e para a direita\n * enquanto couber, e vira para o lado oposto ao encostar na borda.\n */\nfunction encaixar({ x, y }: Ponto, largura: number, altura: number): Ponto {\n const cabeADireita = x + AFASTAMENTO + largura <= window.innerWidth - MARGEM;\n const cabeAbaixo = y + AFASTAMENTO + altura <= window.innerHeight - MARGEM;\n\n return {\n x: cabeADireita ? x + AFASTAMENTO : Math.max(x - AFASTAMENTO - largura, MARGEM),\n y: cabeAbaixo ? y + AFASTAMENTO : Math.max(y - AFASTAMENTO - altura, MARGEM),\n };\n}\n\n/**\n * Leitura das medidas sob o ponteiro, em portal sobre a pagina. Ele acompanha o\n * cursor enquanto este percorre a area e sai a qualquer outra interacao.\n *\n * Nao conhece grafico algum: recebe linhas e colunas, e quem as monta e quem o\n * usa. E decorativo para leitor de tela: o desenho e `role=\"img\"`, apresentado\n * como imagem unica, e a leitura medida a medida cabe a visao em tabela.\n */\nexport function ChartTooltip({\n children,\n columns,\n computed,\n rows,\n showTotal = false,\n subtitle,\n title,\n totalLabel = 'Total',\n}: ChartTooltipProps) {\n const [ponteiro, setPonteiro] = useState<Ponto | null>(null);\n const visivel = ponteiro !== null && rows.length > 0;\n\n // Sai por qualquer motivo que nao seja o ponteiro andando pela area: rolagem,\n // tecla ou a janela mudando de tamanho deixam o balao preso a um lugar que o\n // desenho ja nao ocupa.\n useEffect(() => {\n if (!visivel) {\n return;\n }\n\n const esconder = () => setPonteiro(null);\n\n window.addEventListener('scroll', esconder, true);\n window.addEventListener('resize', esconder);\n window.addEventListener('keydown', esconder);\n\n return () => {\n window.removeEventListener('scroll', esconder, true);\n window.removeEventListener('resize', esconder);\n window.removeEventListener('keydown', esconder);\n };\n }, [visivel]);\n\n const acompanhar = (evento: PointerEvent<HTMLDivElement>) =>\n setPonteiro({ x: evento.clientX, y: evento.clientY });\n\n return (\n <div\n className={styles.area}\n onPointerLeave={() => setPonteiro(null)}\n onPointerMove={acompanhar}\n >\n {children}\n\n {visivel &&\n createPortal(\n <Balao\n columns={columns}\n computed={computed}\n ponteiro={ponteiro}\n rows={rows}\n showTotal={showTotal}\n subtitle={subtitle}\n title={title}\n totalLabel={totalLabel}\n />,\n document.body,\n )}\n </div>\n );\n}\n\ntype BalaoProps = Omit<ChartTooltipProps, 'children'> & { ponteiro: Ponto };\n\nfunction Balao({\n columns,\n computed,\n ponteiro,\n rows,\n showTotal,\n subtitle,\n title,\n totalLabel,\n}: BalaoProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [medida, setMedida] = useState({ altura: 0, largura: 0 });\n\n // A medida entra antes da pintura, entao o balao ja nasce no lugar certo.\n useLayoutEffect(() => {\n const no = ref.current;\n\n if (!no) {\n return;\n }\n\n const { height, width } = no.getBoundingClientRect();\n\n if (height !== medida.altura || width !== medida.largura) {\n setMedida({ altura: height, largura: width });\n }\n });\n\n const quantidadeDeColunas = rows.reduce((maior, linha) => Math.max(maior, linha.values.length), 0);\n const colunas: readonly ChartTooltipColumn[] =\n columns ?? Array.from({ length: quantidadeDeColunas }, () => ({}));\n\n // Sem coluna de onde derivar, nao ha o que calcular: linhas so com rotulo\n // renderizariam um percentual tirado do nada.\n const calculada = computed === 'none' || colunas.length === 0 ? undefined : computed ?? {};\n const colunaBase = calculada?.column ?? colunas.length - 1;\n const baseDoTotal = somar(rows.map((linha) => linha.values[colunaBase] ?? 0));\n const calcular = calculada?.compute ?? ((valor: number, total: number) => (total === 0 ? 0 : valor / total));\n const formatarCalculada = calculada?.format ?? ((valor: number) => formatarPercentual(valor, { casasDecimais: 2 }));\n\n const { x, y } = encaixar(ponteiro, medida.largura, medida.altura);\n const celulas = `1fr ${'auto '.repeat(colunas.length + (calculada ? 1 : 0))}`.trim();\n\n return (\n <div aria-hidden=\"true\" className={styles.tooltip} ref={ref} style={{ left: x, top: y }}>\n {title !== undefined && <p className={styles.title}>{title}</p>}\n {subtitle !== undefined && <p className={styles.subtitle}>{subtitle}</p>}\n\n <div className={styles.grid} style={{ gridTemplateColumns: celulas }}>\n {rows.map((linha, indiceDaLinha) => (\n <Fragment key={indiceDaLinha}>\n <span className={`${styles.label} ${linha.emphasis ? styles.emphasis : ''}`}>\n {linha.color !== undefined && (\n <span className={styles.swatch} style={{ background: linha.color }} />\n )}\n {linha.label}\n </span>\n\n {colunas.map((coluna, indice) => (\n <span className={`${styles.value} ${linha.emphasis ? styles.emphasis : ''}`} key={indice}>\n {(linha.format ?? coluna.format ?? formatarNumero)(linha.values[indice] ?? 0)}\n </span>\n ))}\n\n {calculada && (\n <span className={`${styles.computed} ${linha.emphasis ? styles.emphasis : ''}`}>\n {formatarCalculada(calcular(linha.values[colunaBase] ?? 0, baseDoTotal))}\n </span>\n )}\n </Fragment>\n ))}\n\n {showTotal && (\n <>\n <span className={styles.rule} />\n <span className={`${styles.label} ${styles.totalLabel}`}>{totalLabel}</span>\n\n {colunas.map((coluna, indice) => (\n <span className={`${styles.value} ${styles.totalValue}`} key={indice}>\n {coluna.total === 'none'\n ? ''\n : (coluna.format ?? formatarNumero)(\n totalizar(coluna.total ?? 'sum', rows.map((linha) => linha.values[indice] ?? 0)),\n )}\n </span>\n ))}\n\n {calculada && (\n <span className={`${styles.computed} ${styles.totalValue}`}>\n {formatarCalculada(calcular(baseDoTotal, baseDoTotal))}\n </span>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"names":["AFASTAMENTO","MARGEM","somar","valores","total","valor","totalizar","operador","encaixar","x","y","largura","altura","cabeADireita","cabeAbaixo","ChartTooltip","children","columns","computed","rows","showTotal","subtitle","title","totalLabel","ponteiro","setPonteiro","useState","visivel","useEffect","esconder","acompanhar","evento","jsxs","styles","createPortal","jsx","Balao","ref","useRef","medida","setMedida","useLayoutEffect","no","height","width","quantidadeDeColunas","maior","linha","colunas","calculada","colunaBase","baseDoTotal","calcular","formatarCalculada","formatarPercentual","celulas","indiceDaLinha","Fragment","coluna","indice","formatarNumero"],"mappings":";;;;;AAyDA,MAAMA,IAAc,IAGdC,IAAS;AAEf,SAASC,EAAMC,GAA4B;AACzC,SAAOA,EAAQ,OAAO,CAACC,GAAOC,MAAUD,IAAQC,GAAO,CAAC;AAC1D;AAEA,SAASC,EAAUC,GAA6BJ,GAA4B;AAC1E,SAAI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J;AAAA,IAAA,EAAA,CAEJ;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),E=require("react"),S=require("d3-hierarchy"),m=require("./ChartTreemap.module.css.cjs"),W=require("../core/useChartMetrics.cjs"),z=require("../core/useSeriesToggle.cjs"),c=require("../palette/seriesColor.cjs"),G=require("../core/ChartFrame.cjs"),s=require("../core/spacing.cjs"),V=require("../../../utils/formatters/formatarNumero.cjs"),v=require("../core/measureText.cjs"),k=require("../core/cartesianLayout.cjs");function F(u){return Number.isFinite(u.value)?Math.max(u.value??0,0):0}function J({accent:u,defaultHiddenGroups:H,emptyMessage:y="Sem dados no período",formatValue:b=V.formatarNumero,gap:C=5,height:N=280,hiddenGroups:O,intentLabels:g,legend:A="bottom",legendAlign:L,nodes:i,onHiddenGroupsChange:q,showDataLabels:R=!0,title:j}){const{font:l,height:M,ref:B,width:d}=W.useChartMetrics(),{fillHeight:f,value:T}=k.chartHeight(N,M),{isHidden:h,toggle:D}=z.useSeriesToggle({defaultHiddenSeries:H,hiddenSeries:O,onHiddenSeriesChange:q}),_=E.useMemo(()=>c.resolveSeriesColors(i,{accent:u}),[u,i]),I=E.useMemo(()=>!((S.hierarchy({children:i,label:""}).sum(F).value??0)>0),[i]),$=E.useMemo(()=>{const e=i.filter(t=>!h(t.label));if(d===0||T===0||e.length===0)return[];const r=S.hierarchy({children:e,label:""}).sum(F).sort((t,n)=>(n.value??0)-(t.value??0));return S.treemap().size([d,T]).paddingInner(C).round(!0)(r).leaves()},[T,C,h,i,d]);function K(e){var t;const r=e.data;if(r.color)return r.color;if(r.intent)return c.INTENT_TOKENS[r.intent];const a=(t=e.ancestors().find(n=>n.depth===1))==null?void 0:t.data;return _[i.findIndex(n=>n.label===(a==null?void 0:a.label))]??c.INTENT_TOKENS.neutral}const w=g?Object.entries(g).map(([e,r])=>({color:c.INTENT_TOKENS[e],label:r})):i.map((e,r)=>({color:_[r],hidden:h(e.label),label:e.label}));return o.jsx(G.ChartFrame,{containerRef:B,empty:i.length===0||I,emptyMessage:y,fillHeight:f,height:T,legend:w,legendAlign:L,legendPosition:A,onToggleSeries:g?void 0:D,title:j,width:d,children:$.map(e=>{const r=e.x1-e.x0,a=e.y1-e.y0,t=r-s.CHART_LABEL_OFFSET*2,n=R&&t>0&&a>=l.lineHeight+s.CHART_LABEL_OFFSET,P=n&&a>=l.lineHeight*2+s.CHART_LABEL_OFFSET,p=`${e.data.label}: ${b(e.value??0)}`,x=K(e);return o.jsxs("g",{className:m.default.cell,children:[o.jsx("rect",{"aria-label":p,className:m.default.tile,fill:x,height:a,width:r,x:e.x0,y:e.y0,children:o.jsx("title",{children:p})}),n&&o.jsx("text",{className:m.default.label,fill:c.textColorOn(x),x:e.x0+s.CHART_LABEL_OFFSET,y:e.y0+s.CHART_LABEL_OFFSET+l.lineHeight*.6,children:v.truncateToWidth(e.data.label,l,t)}),P&&o.jsx("text",{className:m.default.value,fill:c.textColorOn(x),x:e.x0+s.CHART_LABEL_OFFSET,y:e.y0+s.CHART_LABEL_OFFSET+l.lineHeight*1.6,children:v.truncateToWidth(b(e.value??0),l,t)})]},`${e.data.label}-${e.x0}-${e.y0}`)})})}exports.ChartTreemap=J;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),g=require("react"),F=require("d3-hierarchy"),x=require("./ChartTreemap.module.css.cjs"),X=require("../core/useChartMetrics.cjs"),Y=require("../core/useSeriesToggle.cjs"),o=require("../palette/seriesColor.cjs"),Z=require("../core/ChartFrame.cjs"),s=require("../core/spacing.cjs"),ee=require("../../../utils/formatters/formatarNumero.cjs"),H=require("../core/measureText.cjs"),te=require("../core/tooltips.cjs"),N=require("../core/hoverPath.cjs"),re=require("../core/cartesianLayout.cjs");function M(u){return Number.isFinite(u.value)?Math.max(u.value??0,0):0}function ie({accent:u,defaultHiddenGroups:R,emptyMessage:j="Sem dados no período",formatTooltipValue:B,formatValue:E=ee.formatarNumero,gap:v=5,height:f=280,hiddenGroups:D,intentLabels:p,legend:I="bottom",legendAlign:P,nodes:i,onHiddenGroupsChange:$,onHoverNode:d,showDataLabels:K=!0,showTooltip:_=!0,title:W}){const{font:c,height:w,ref:z,width:m}=X.useChartMetrics(),{fillHeight:G,value:T}=re.chartHeight(f,w),{isHidden:S,toggle:k}=Y.useSeriesToggle({defaultHiddenSeries:R,hiddenSeries:D,onHiddenSeriesChange:$}),y=g.useMemo(()=>o.resolveSeriesColors(i,{accent:u}),[u,i]),J=g.useMemo(()=>!((F.hierarchy({children:i,label:""}).sum(M).value??0)>0),[i]),O=g.useMemo(()=>{const e=i.filter(r=>!S(r.label));if(m===0||T===0||e.length===0)return[];const t=F.hierarchy({children:e,label:""}).sum(M).sort((r,a)=>(a.value??0)-(r.value??0));return F.treemap().size([m,T]).paddingInner(v).round(!0)(t).leaves()},[T,v,S,i,m]),[b,Q]=g.useState(null),h=b&&O.includes(b)?b:null;function L(e){Q(e),d==null||d(e&&N.hoverPath(e))}function q(e){var r;const t=e.data;if(t.color)return t.color;if(t.intent)return o.INTENT_TOKENS[t.intent];const n=(r=e.ancestors().find(a=>a.depth===1))==null?void 0:r.data;return y[i.findIndex(a=>a.label===(n==null?void 0:n.label))]??o.INTENT_TOKENS.neutral}const U=p?Object.entries(p).map(([e,t])=>({color:o.INTENT_TOKENS[e],label:t})):i.map((e,t)=>({color:y[t],hidden:S(e.label),label:e.label}));return l.jsx(Z.ChartFrame,{containerRef:z,empty:i.length===0||J,emptyMessage:j,fillHeight:G,height:T,legend:U,legendAlign:P,legendPosition:I,onToggleSeries:p?void 0:k,title:W,tooltip:_?te.pathTooltip({color:h?q(h):void 0,format:B??E,path:h&&N.hoverPath(h)}):void 0,width:m,children:O.map(e=>{const t=e.x1-e.x0,n=e.y1-e.y0,r=t-s.CHART_LABEL_OFFSET*2,a=K&&r>0&&n>=c.lineHeight+s.CHART_LABEL_OFFSET,V=a&&n>=c.lineHeight*2+s.CHART_LABEL_OFFSET,A=`${e.data.label}: ${E(e.value??0)}`,C=q(e);return l.jsxs("g",{className:x.default.cell,children:[l.jsx("rect",{"aria-label":A,className:x.default.tile,fill:C,height:n,width:t,onMouseEnter:()=>L(e),onMouseLeave:()=>L(null),x:e.x0,y:e.y0,children:!_&&!d&&l.jsx("title",{children:A})}),a&&l.jsx("text",{className:x.default.label,fill:o.textColorOn(C),x:e.x0+s.CHART_LABEL_OFFSET,y:e.y0+s.CHART_LABEL_OFFSET+c.lineHeight*.6,children:H.truncateToWidth(e.data.label,c,r)}),V&&l.jsx("text",{className:x.default.value,fill:o.textColorOn(C),x:e.x0+s.CHART_LABEL_OFFSET,y:e.y0+s.CHART_LABEL_OFFSET+c.lineHeight*1.6,children:H.truncateToWidth(E(e.value??0),c,r)})]},`${e.data.label}-${e.x0}-${e.y0}`)})})}exports.ChartTreemap=ie;
2
2
  //# sourceMappingURL=ChartTreemap.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartTreemap.cjs","sources":["../../../../src/components/charts/ChartTreemap/ChartTreemap.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { hierarchy, treemap } from 'd3-hierarchy';\nimport {\n CHART_LABEL_OFFSET,\n ChartFrame,\n chartHeight,\n truncateToWidth,\n useChartMetrics,\n useSeriesToggle,\n type ChartHeight,\n type ChartLegendAlign,\n type ChartLegendPosition,\n} from '../core';\nimport {\n INTENT_TOKENS,\n resolveSeriesColors,\n textColorOn,\n type SeriesAppearance,\n type SeriesIntent,\n} from '../palette';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartTreemap.module.css';\n\nexport interface ChartTreemapNode extends SeriesAppearance {\n children?: readonly ChartTreemapNode[];\n label: string;\n value?: number;\n}\n\nexport interface ChartTreemapProps {\n accent?: string;\n defaultHiddenGroups?: readonly string[];\n emptyMessage?: string;\n formatValue?: (value: number) => string;\n /** Folga entre dois retangulos vizinhos. */\n gap?: number;\n height?: ChartHeight;\n hiddenGroups?: readonly string[];\n /**\n * Nome de cada intencao na legenda. Informado, a legenda deixa de listar os\n * grupos e passa a nomear as cores: e o caso do mapa colorido por status,\n * onde o que a legenda explica e o significado da cor, nao a categoria.\n */\n intentLabels?: Partial<Record<SeriesIntent, string>>;\n legend?: ChartLegendPosition;\n legendAlign?: ChartLegendAlign;\n nodes: readonly ChartTreemapNode[];\n onHiddenGroupsChange?: (hidden: readonly string[]) => void;\n showDataLabels?: boolean;\n title: string;\n}\n\n\n/** Area que o no ocupa. Invalido ou negativo nao ocupa nada. */\nfunction ocupacao(no: ChartTreemapNode) {\n return Number.isFinite(no.value) ? Math.max(no.value ?? 0, 0) : 0;\n}\n\nexport function ChartTreemap({\n accent,\n defaultHiddenGroups,\n emptyMessage = 'Sem dados no período',\n formatValue = formatarNumero,\n gap = 5,\n height = 280,\n hiddenGroups,\n intentLabels,\n legend = 'bottom',\n legendAlign,\n nodes,\n onHiddenGroupsChange,\n showDataLabels = true,\n title,\n}: ChartTreemapProps) {\n const { font, height: alturaMedida, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { isHidden, toggle } = useSeriesToggle({\n defaultHiddenSeries: defaultHiddenGroups,\n hiddenSeries: hiddenGroups,\n onHiddenSeriesChange: onHiddenGroupsChange,\n });\n\n // A cor sai da lista inteira, e nao das visiveis: desligar um grupo nao pode\n // repintar os demais.\n const coresDeGrupo = useMemo(() => resolveSeriesColors(nodes, { accent }), [accent, nodes]);\n\n // Sem valor positivo nao ha area a repartir: anuncia vazio. Desligar todos os grupos, nao: a legenda e a volta.\n const semValor = useMemo(\n () => !((hierarchy<ChartTreemapNode>({ children: nodes, label: '' }).sum(ocupacao).value ?? 0) > 0),\n [nodes],\n );\n\n const retangulos = useMemo(() => {\n const visiveis = nodes.filter((grupo) => !isHidden(grupo.label));\n\n if (width === 0 || alturaDoDesenho === 0 || visiveis.length === 0) {\n return [];\n }\n\n const arvore = hierarchy<ChartTreemapNode>({ children: visiveis, label: '' })\n .sum(ocupacao)\n .sort((a, b) => (b.value ?? 0) - (a.value ?? 0));\n\n const posicionar = treemap<ChartTreemapNode>()\n .size([width, alturaDoDesenho])\n .paddingInner(gap)\n .round(true);\n\n return posicionar(arvore).leaves();\n }, [alturaDoDesenho, gap, isHidden, nodes, width]);\n\n /** A folha herda a cor do grupo, e a intencao propria vence a herdada. */\n function corDa(folha: (typeof retangulos)[number]) {\n const proprio = folha.data;\n\n if (proprio.color) {\n return proprio.color;\n }\n\n if (proprio.intent) {\n return INTENT_TOKENS[proprio.intent];\n }\n\n const grupo = folha.ancestors().find((ancestral) => ancestral.depth === 1)?.data;\n\n return coresDeGrupo[nodes.findIndex((no) => no.label === grupo?.label)] ?? INTENT_TOKENS.neutral;\n }\n\n const entradasDaLegenda = intentLabels\n ? (Object.entries(intentLabels) as [SeriesIntent, string][]).map(([intencao, rotulo]) => ({\n color: INTENT_TOKENS[intencao],\n label: rotulo,\n }))\n : nodes.map((grupo, indice) => ({\n color: coresDeGrupo[indice],\n hidden: isHidden(grupo.label),\n label: grupo.label,\n }));\n\n return (\n <ChartFrame\n containerRef={ref}\n empty={nodes.length === 0 || semValor}\n emptyMessage={emptyMessage}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legend={entradasDaLegenda}\n legendAlign={legendAlign}\n legendPosition={legend}\n onToggleSeries={intentLabels ? undefined : toggle}\n title={title}\n width={width}\n >\n {retangulos.map((folha) => {\n const largura = folha.x1 - folha.x0;\n const altura = folha.y1 - folha.y0;\n const disponivel = largura - CHART_LABEL_OFFSET * 2;\n const cabeORotulo = showDataLabels && disponivel > 0 && altura >= font.lineHeight + CHART_LABEL_OFFSET;\n const cabeOValor = cabeORotulo && altura >= font.lineHeight * 2 + CHART_LABEL_OFFSET;\n const descricao = `${folha.data.label}: ${formatValue(folha.value ?? 0)}`;\n const cor = corDa(folha);\n\n return (\n <g className={styles.cell} key={`${folha.data.label}-${folha.x0}-${folha.y0}`}>\n <rect\n aria-label={descricao}\n className={styles.tile}\n fill={cor}\n height={altura}\n width={largura}\n x={folha.x0}\n y={folha.y0}\n >\n <title>{descricao}</title>\n </rect>\n\n {cabeORotulo && (\n <text\n className={styles.label}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 0.6}\n >\n {truncateToWidth(folha.data.label, font, disponivel)}\n </text>\n )}\n\n {cabeOValor && (\n <text\n className={styles.value}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 1.6}\n >\n {truncateToWidth(formatValue(folha.value ?? 0), font, disponivel)}\n </text>\n )}\n </g>\n );\n })}\n </ChartFrame>\n );\n}\n"],"names":["ocupacao","no","ChartTreemap","accent","defaultHiddenGroups","emptyMessage","formatValue","formatarNumero","gap","height","hiddenGroups","intentLabels","legend","legendAlign","nodes","onHiddenGroupsChange","showDataLabels","title","font","alturaMedida","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","isHidden","toggle","useSeriesToggle","coresDeGrupo","useMemo","resolveSeriesColors","semValor","hierarchy","retangulos","visiveis","grupo","arvore","a","b","treemap","corDa","folha","proprio","INTENT_TOKENS","_a","ancestral","entradasDaLegenda","intencao","rotulo","indice","jsx","ChartFrame","largura","altura","disponivel","CHART_LABEL_OFFSET","cabeORotulo","cabeOValor","descricao","cor","jsxs","styles","textColorOn","truncateToWidth"],"mappings":"ohBAsDA,SAASA,EAASC,EAAsB,CACtC,OAAO,OAAO,SAASA,EAAG,KAAK,EAAI,KAAK,IAAIA,EAAG,OAAS,EAAG,CAAC,EAAI,CAClE,CAEO,SAASC,EAAa,CAC3B,OAAAC,EACA,oBAAAC,EACA,aAAAC,EAAe,uBACf,YAAAC,EAAcC,EAAAA,eACd,IAAAC,EAAM,EACN,OAAAC,EAAS,IACT,aAAAC,EACA,aAAAC,EACA,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A,CAAE,UAAWC,EAAAA,QAAO,KACnB,SAAA,CAAAX,EAAAA,IAAC,OAAA,CACC,aAAYQ,EACZ,UAAWG,EAAAA,QAAO,KAClB,KAAMF,EACN,OAAQN,EACR,MAAOD,EACP,EAAGX,EAAM,GACT,EAAGA,EAAM,GAET,SAAAS,EAAAA,IAAC,SAAO,SAAAQ,CAAA,CAAU,CAAA,CAAA,EAGnBF,GACCN,EAAAA,IAAC,OAAA,CACC,UAAWW,EAAAA,QAAO,MAClB,KAAMC,EAAAA,YAAYH,CAAG,EACrB,EAAGlB,EAAM,GAAKc,EAAAA,mBACd,EAAGd,EAAM,GAAKc,EAAAA,mBAAqBtC,EAAK,WAAa,GAEpD,SAAA8C,EAAAA,gBAAgBtB,EAAM,KAAK,MAAOxB,EAAMqC,CAAU,CAAA,CAAA,EAItDG,GACCP,EAAAA,IAAC,OAAA,CACC,UAAWW,EAAAA,QAAO,MAClB,KAAMC,EAAAA,YAAYH,CAAG,EACrB,EAAGlB,EAAM,GAAKc,EAAAA,mBACd,EAAGd,EAAM,GAAKc,EAAAA,mBAAqBtC,EAAK,WAAa,IAEpD,2BAAgBZ,EAAYoC,EAAM,OAAS,CAAC,EAAGxB,EAAMqC,CAAU,CAAA,CAAA,CAClE,CAAA,EAhC4B,GAAGb,EAAM,KAAK,KAAK,IAAIA,EAAM,EAAE,IAAIA,EAAM,EAAE,EAkC3E,CAEJ,CAAC,CAAA,CAAA,CAGP"}
1
+ {"version":3,"file":"ChartTreemap.cjs","sources":["../../../../src/components/charts/ChartTreemap/ChartTreemap.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { hierarchy, treemap } from 'd3-hierarchy';\nimport {\n CHART_LABEL_OFFSET,\n ChartFrame,\n chartHeight,\n hoverPath,\n pathTooltip,\n truncateToWidth,\n useChartMetrics,\n useSeriesToggle,\n type ChartHeight,\n type ChartHoveredNode,\n type ChartLegendAlign,\n type ChartLegendPosition,\n} from '../core';\nimport {\n INTENT_TOKENS,\n resolveSeriesColors,\n textColorOn,\n type SeriesAppearance,\n type SeriesIntent,\n} from '../palette';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartTreemap.module.css';\n\nexport interface ChartTreemapNode extends SeriesAppearance {\n children?: readonly ChartTreemapNode[];\n label: string;\n value?: number;\n}\n\nexport interface ChartTreemapProps {\n accent?: string;\n defaultHiddenGroups?: readonly string[];\n emptyMessage?: string;\n /** Formato dos valores no balao. Sem ele, vale o `formatValue`: o eixo pode sair compacto e o balao, exato. */\n formatTooltipValue?: (value: number) => string;\n formatValue?: (value: number) => string;\n /** Folga entre dois retangulos vizinhos. */\n gap?: number;\n height?: ChartHeight;\n hiddenGroups?: readonly string[];\n /**\n * Nome de cada intencao na legenda. Informado, a legenda deixa de listar os\n * grupos e passa a nomear as cores: e o caso do mapa colorido por status,\n * onde o que a legenda explica e o significado da cor, nao a categoria.\n */\n intentLabels?: Partial<Record<SeriesIntent, string>>;\n legend?: ChartLegendPosition;\n legendAlign?: ChartLegendAlign;\n nodes: readonly ChartTreemapNode[];\n onHiddenGroupsChange?: (hidden: readonly string[]) => void;\n /** Caminho ate o no sob o ponteiro, do grupo ao no, cada nivel com o valor somado, ou `null` ao sair. */\n onHoverNode?: (path: readonly ChartHoveredNode[] | null) => void;\n showDataLabels?: boolean;\n /**\n * Balao com o caminho ate o no sob o ponteiro. Desligue para montar o proprio `ChartTooltip`\n * pela costura; sem balao nem costura, o no volta a ter o `<title>`.\n */\n showTooltip?: boolean;\n title: string;\n}\n\n\n/** Area que o no ocupa. Invalido ou negativo nao ocupa nada. */\nfunction ocupacao(no: ChartTreemapNode) {\n return Number.isFinite(no.value) ? Math.max(no.value ?? 0, 0) : 0;\n}\n\nexport function ChartTreemap({\n accent,\n defaultHiddenGroups,\n emptyMessage = 'Sem dados no período',\n formatTooltipValue,\n formatValue = formatarNumero,\n gap = 5,\n height = 280,\n hiddenGroups,\n intentLabels,\n legend = 'bottom',\n legendAlign,\n nodes,\n onHiddenGroupsChange,\n onHoverNode,\n showDataLabels = true,\n showTooltip = true,\n title,\n}: ChartTreemapProps) {\n const { font, height: alturaMedida, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { isHidden, toggle } = useSeriesToggle({\n defaultHiddenSeries: defaultHiddenGroups,\n hiddenSeries: hiddenGroups,\n onHiddenSeriesChange: onHiddenGroupsChange,\n });\n\n // A cor sai da lista inteira, e nao das visiveis: desligar um grupo nao pode\n // repintar os demais.\n const coresDeGrupo = useMemo(() => resolveSeriesColors(nodes, { accent }), [accent, nodes]);\n\n // Sem valor positivo nao ha area a repartir: anuncia vazio. Desligar todos os grupos, nao: a legenda e a volta.\n const semValor = useMemo(\n () => !((hierarchy<ChartTreemapNode>({ children: nodes, label: '' }).sum(ocupacao).value ?? 0) > 0),\n [nodes],\n );\n\n const retangulos = useMemo(() => {\n const visiveis = nodes.filter((grupo) => !isHidden(grupo.label));\n\n if (width === 0 || alturaDoDesenho === 0 || visiveis.length === 0) {\n return [];\n }\n\n const arvore = hierarchy<ChartTreemapNode>({ children: visiveis, label: '' })\n .sum(ocupacao)\n .sort((a, b) => (b.value ?? 0) - (a.value ?? 0));\n\n const posicionar = treemap<ChartTreemapNode>()\n .size([width, alturaDoDesenho])\n .paddingInner(gap)\n .round(true);\n\n return posicionar(arvore).leaves();\n }, [alturaDoDesenho, gap, isHidden, nodes, width]);\n\n const [emFoco, setEmFoco] = useState<(typeof retangulos)[number] | null>(null);\n // A folha guardada deixa de existir quando o mapa e remontado; sem conferir, o balao falaria de um no que saiu.\n const foco = emFoco && retangulos.includes(emFoco) ? emFoco : null;\n\n function focar(folha: (typeof retangulos)[number] | null) {\n setEmFoco(folha);\n onHoverNode?.(folha && hoverPath(folha));\n }\n\n /** A folha herda a cor do grupo, e a intencao propria vence a herdada. */\n function corDa(folha: (typeof retangulos)[number]) {\n const proprio = folha.data;\n\n if (proprio.color) {\n return proprio.color;\n }\n\n if (proprio.intent) {\n return INTENT_TOKENS[proprio.intent];\n }\n\n const grupo = folha.ancestors().find((ancestral) => ancestral.depth === 1)?.data;\n\n return coresDeGrupo[nodes.findIndex((no) => no.label === grupo?.label)] ?? INTENT_TOKENS.neutral;\n }\n\n const entradasDaLegenda = intentLabels\n ? (Object.entries(intentLabels) as [SeriesIntent, string][]).map(([intencao, rotulo]) => ({\n color: INTENT_TOKENS[intencao],\n label: rotulo,\n }))\n : nodes.map((grupo, indice) => ({\n color: coresDeGrupo[indice],\n hidden: isHidden(grupo.label),\n label: grupo.label,\n }));\n\n return (\n <ChartFrame\n containerRef={ref}\n empty={nodes.length === 0 || semValor}\n emptyMessage={emptyMessage}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legend={entradasDaLegenda}\n legendAlign={legendAlign}\n legendPosition={legend}\n onToggleSeries={intentLabels ? undefined : toggle}\n title={title}\n tooltip={\n showTooltip\n ? pathTooltip({ color: foco ? corDa(foco) : undefined, format: formatTooltipValue ?? formatValue, path: foco && hoverPath(foco) })\n : undefined\n }\n width={width}\n >\n {retangulos.map((folha) => {\n const largura = folha.x1 - folha.x0;\n const altura = folha.y1 - folha.y0;\n const disponivel = largura - CHART_LABEL_OFFSET * 2;\n const cabeORotulo = showDataLabels && disponivel > 0 && altura >= font.lineHeight + CHART_LABEL_OFFSET;\n const cabeOValor = cabeORotulo && altura >= font.lineHeight * 2 + CHART_LABEL_OFFSET;\n const descricao = `${folha.data.label}: ${formatValue(folha.value ?? 0)}`;\n const cor = corDa(folha);\n\n return (\n <g className={styles.cell} key={`${folha.data.label}-${folha.x0}-${folha.y0}`}>\n <rect\n aria-label={descricao}\n className={styles.tile}\n fill={cor}\n height={altura}\n width={largura}\n onMouseEnter={() => focar(folha)}\n onMouseLeave={() => focar(null)}\n x={folha.x0}\n y={folha.y0}\n >\n {!showTooltip && !onHoverNode && <title>{descricao}</title>}\n </rect>\n\n {cabeORotulo && (\n <text\n className={styles.label}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 0.6}\n >\n {truncateToWidth(folha.data.label, font, disponivel)}\n </text>\n )}\n\n {cabeOValor && (\n <text\n className={styles.value}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 1.6}\n >\n {truncateToWidth(formatValue(folha.value ?? 0), font, disponivel)}\n </text>\n )}\n </g>\n );\n })}\n </ChartFrame>\n );\n}\n"],"names":["ocupacao","no","ChartTreemap","accent","defaultHiddenGroups","emptyMessage","formatTooltipValue","formatValue","formatarNumero","gap","height","hiddenGroups","intentLabels","legend","legendAlign","nodes","onHiddenGroupsChange","onHoverNode","showDataLabels","showTooltip","title","font","alturaMedida","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","isHidden","toggle","useSeriesToggle","coresDeGrupo","useMemo","resolveSeriesColors","semValor","hierarchy","retangulos","visiveis","grupo","arvore","a","b","treemap","emFoco","setEmFoco","useState","foco","focar","folha","hoverPath","corDa","proprio","INTENT_TOKENS","_a","ancestral","entradasDaLegenda","intencao","rotulo","indice","jsx","ChartFrame","pathTooltip","largura","altura","disponivel","CHART_LABEL_OFFSET","cabeORotulo","cabeOValor","descricao","cor","jsxs","styles","textColorOn","truncateToWidth"],"mappings":"4lBAkEA,SAASA,EAASC,EAAsB,CACtC,OAAO,OAAO,SAASA,EAAG,KAAK,EAAI,KAAK,IAAIA,EAAG,OAAS,EAAG,CAAC,EAAI,CAClE,CAEO,SAASC,GAAa,CAC3B,OAAAC,EACA,oBAAAC,EACA,aAAAC,EAAe,uBACf,mBAAAC,EACA,YAAAC,EAAcC,GAAAA,eACd,IAAAC,EAAM,EACN,OAAAC,EAAS,IACT,aAAAC,EACA,aAAAC,EACA,OAAAC,EAAS,SACT,YAAAC,EACA,MAAAC,EACA,qBAAAC,EACA,YAAAC,EACA,eAAAC,EAAiB,GACjB,YAAAC,EAAc,GACd,MAAA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AAE,EAoC3E,CAEJ,CAAC,CAAA,CAAA,CAGP"}
@@ -1,114 +1,125 @@
1
- import { jsx as c, jsxs as V } from "react/jsx-runtime";
2
- import { useMemo as b } from "react";
3
- import { hierarchy as N, treemap as W } from "d3-hierarchy";
4
- import u from "./ChartTreemap.module.css.js";
5
- import { useChartMetrics as k } from "../core/useChartMetrics.js";
6
- import { useSeriesToggle as q } from "../core/useSeriesToggle.js";
7
- import { resolveSeriesColors as J, INTENT_TOKENS as x, textColorOn as S } from "../palette/seriesColor.js";
8
- import { ChartFrame as Q } from "../core/ChartFrame.js";
9
- import { CHART_LABEL_OFFSET as n } from "../core/spacing.js";
10
- import { formatarNumero as U } from "../../../utils/formatters/formatarNumero.js";
11
- import { truncateToWidth as T } from "../core/measureText.js";
12
- import { chartHeight as X } from "../core/cartesianLayout.js";
13
- function C(s) {
14
- return Number.isFinite(s.value) ? Math.max(s.value ?? 0, 0) : 0;
1
+ import { jsx as s, jsxs as Y } from "react/jsx-runtime";
2
+ import { useMemo as y, useState as Z } from "react";
3
+ import { hierarchy as H, treemap as ee } from "d3-hierarchy";
4
+ import g from "./ChartTreemap.module.css.js";
5
+ import { useChartMetrics as te } from "../core/useChartMetrics.js";
6
+ import { useSeriesToggle as re } from "../core/useSeriesToggle.js";
7
+ import { resolveSeriesColors as ie, INTENT_TOKENS as S, textColorOn as $ } from "../palette/seriesColor.js";
8
+ import { ChartFrame as oe } from "../core/ChartFrame.js";
9
+ import { CHART_LABEL_OFFSET as l } from "../core/spacing.js";
10
+ import { formatarNumero as ne } from "../../../utils/formatters/formatarNumero.js";
11
+ import { truncateToWidth as N } from "../core/measureText.js";
12
+ import { pathTooltip as le } from "../core/tooltips.js";
13
+ import { hoverPath as j } from "../core/hoverPath.js";
14
+ import { chartHeight as ae } from "../core/cartesianLayout.js";
15
+ function I(c) {
16
+ return Number.isFinite(c.value) ? Math.max(c.value ?? 0, 0) : 0;
15
17
  }
16
- function me({
17
- accent: s,
18
- defaultHiddenGroups: O,
19
- emptyMessage: D = "Sem dados no período",
20
- formatValue: v = U,
21
- gap: y = 5,
22
- height: $ = 280,
23
- hiddenGroups: E,
24
- intentLabels: p,
25
- legend: F = "bottom",
26
- legendAlign: M,
18
+ function Te({
19
+ accent: c,
20
+ defaultHiddenGroups: R,
21
+ emptyMessage: _ = "Sem dados no período",
22
+ formatTooltipValue: A,
23
+ formatValue: h = ne,
24
+ gap: T = 5,
25
+ height: L = 280,
26
+ hiddenGroups: P,
27
+ intentLabels: b,
28
+ legend: w = "bottom",
29
+ legendAlign: z,
27
30
  nodes: i,
28
- onHiddenGroupsChange: j,
29
- showDataLabels: I = !0,
30
- title: R
31
+ onHiddenGroupsChange: B,
32
+ onHoverNode: m,
33
+ showDataLabels: G = !0,
34
+ showTooltip: C = !0,
35
+ title: K
31
36
  }) {
32
- const { font: a, height: _, ref: w, width: m } = k(), { fillHeight: A, value: d } = X($, _), { isHidden: g, toggle: z } = q({
33
- defaultHiddenSeries: O,
34
- hiddenSeries: E,
35
- onHiddenSeriesChange: j
36
- }), f = b(() => J(i, { accent: s }), [s, i]), B = b(
37
- () => !((N({ children: i, label: "" }).sum(C).value ?? 0) > 0),
37
+ const { font: a, height: W, ref: k, width: u } = te(), { fillHeight: q, value: d } = ae(L, W), { isHidden: x, toggle: J } = re({
38
+ defaultHiddenSeries: R,
39
+ hiddenSeries: P,
40
+ onHiddenSeriesChange: B
41
+ }), E = y(() => ie(i, { accent: c }), [c, i]), Q = y(
42
+ () => !((H({ children: i, label: "" }).sum(I).value ?? 0) > 0),
38
43
  [i]
39
- ), G = b(() => {
40
- const e = i.filter((t) => !g(t.label));
41
- if (m === 0 || d === 0 || e.length === 0)
44
+ ), F = y(() => {
45
+ const e = i.filter((r) => !x(r.label));
46
+ if (u === 0 || d === 0 || e.length === 0)
42
47
  return [];
43
- const r = N({ children: e, label: "" }).sum(C).sort((t, l) => (l.value ?? 0) - (t.value ?? 0));
44
- return W().size([m, d]).paddingInner(y).round(!0)(r).leaves();
45
- }, [d, y, g, i, m]);
46
- function K(e) {
47
- var t;
48
- const r = e.data;
49
- if (r.color)
50
- return r.color;
51
- if (r.intent)
52
- return x[r.intent];
53
- const o = (t = e.ancestors().find((l) => l.depth === 1)) == null ? void 0 : t.data;
54
- return f[i.findIndex((l) => l.label === (o == null ? void 0 : o.label))] ?? x.neutral;
48
+ const t = H({ children: e, label: "" }).sum(I).sort((r, n) => (n.value ?? 0) - (r.value ?? 0));
49
+ return ee().size([u, d]).paddingInner(T).round(!0)(t).leaves();
50
+ }, [d, T, x, i, u]), [v, U] = Z(null), p = v && F.includes(v) ? v : null;
51
+ function M(e) {
52
+ U(e), m == null || m(e && j(e));
55
53
  }
56
- const L = p ? Object.entries(p).map(([e, r]) => ({
57
- color: x[e],
58
- label: r
59
- })) : i.map((e, r) => ({
60
- color: f[r],
61
- hidden: g(e.label),
54
+ function O(e) {
55
+ var r;
56
+ const t = e.data;
57
+ if (t.color)
58
+ return t.color;
59
+ if (t.intent)
60
+ return S[t.intent];
61
+ const o = (r = e.ancestors().find((n) => n.depth === 1)) == null ? void 0 : r.data;
62
+ return E[i.findIndex((n) => n.label === (o == null ? void 0 : o.label))] ?? S.neutral;
63
+ }
64
+ const V = b ? Object.entries(b).map(([e, t]) => ({
65
+ color: S[e],
66
+ label: t
67
+ })) : i.map((e, t) => ({
68
+ color: E[t],
69
+ hidden: x(e.label),
62
70
  label: e.label
63
71
  }));
64
- return /* @__PURE__ */ c(
65
- Q,
72
+ return /* @__PURE__ */ s(
73
+ oe,
66
74
  {
67
- containerRef: w,
68
- empty: i.length === 0 || B,
69
- emptyMessage: D,
70
- fillHeight: A,
75
+ containerRef: k,
76
+ empty: i.length === 0 || Q,
77
+ emptyMessage: _,
78
+ fillHeight: q,
71
79
  height: d,
72
- legend: L,
73
- legendAlign: M,
74
- legendPosition: F,
75
- onToggleSeries: p ? void 0 : z,
76
- title: R,
77
- width: m,
78
- children: G.map((e) => {
79
- const r = e.x1 - e.x0, o = e.y1 - e.y0, t = r - n * 2, l = I && t > 0 && o >= a.lineHeight + n, P = l && o >= a.lineHeight * 2 + n, H = `${e.data.label}: ${v(e.value ?? 0)}`, h = K(e);
80
- return /* @__PURE__ */ V("g", { className: u.cell, children: [
81
- /* @__PURE__ */ c(
80
+ legend: V,
81
+ legendAlign: z,
82
+ legendPosition: w,
83
+ onToggleSeries: b ? void 0 : J,
84
+ title: K,
85
+ tooltip: C ? le({ color: p ? O(p) : void 0, format: A ?? h, path: p && j(p) }) : void 0,
86
+ width: u,
87
+ children: F.map((e) => {
88
+ const t = e.x1 - e.x0, o = e.y1 - e.y0, r = t - l * 2, n = G && r > 0 && o >= a.lineHeight + l, X = n && o >= a.lineHeight * 2 + l, D = `${e.data.label}: ${h(e.value ?? 0)}`, f = O(e);
89
+ return /* @__PURE__ */ Y("g", { className: g.cell, children: [
90
+ /* @__PURE__ */ s(
82
91
  "rect",
83
92
  {
84
- "aria-label": H,
85
- className: u.tile,
86
- fill: h,
93
+ "aria-label": D,
94
+ className: g.tile,
95
+ fill: f,
87
96
  height: o,
88
- width: r,
97
+ width: t,
98
+ onMouseEnter: () => M(e),
99
+ onMouseLeave: () => M(null),
89
100
  x: e.x0,
90
101
  y: e.y0,
91
- children: /* @__PURE__ */ c("title", { children: H })
102
+ children: !C && !m && /* @__PURE__ */ s("title", { children: D })
92
103
  }
93
104
  ),
94
- l && /* @__PURE__ */ c(
105
+ n && /* @__PURE__ */ s(
95
106
  "text",
96
107
  {
97
- className: u.label,
98
- fill: S(h),
99
- x: e.x0 + n,
100
- y: e.y0 + n + a.lineHeight * 0.6,
101
- children: T(e.data.label, a, t)
108
+ className: g.label,
109
+ fill: $(f),
110
+ x: e.x0 + l,
111
+ y: e.y0 + l + a.lineHeight * 0.6,
112
+ children: N(e.data.label, a, r)
102
113
  }
103
114
  ),
104
- P && /* @__PURE__ */ c(
115
+ X && /* @__PURE__ */ s(
105
116
  "text",
106
117
  {
107
- className: u.value,
108
- fill: S(h),
109
- x: e.x0 + n,
110
- y: e.y0 + n + a.lineHeight * 1.6,
111
- children: T(v(e.value ?? 0), a, t)
118
+ className: g.value,
119
+ fill: $(f),
120
+ x: e.x0 + l,
121
+ y: e.y0 + l + a.lineHeight * 1.6,
122
+ children: N(h(e.value ?? 0), a, r)
112
123
  }
113
124
  )
114
125
  ] }, `${e.data.label}-${e.x0}-${e.y0}`);
@@ -117,6 +128,6 @@ function me({
117
128
  );
118
129
  }
119
130
  export {
120
- me as ChartTreemap
131
+ Te as ChartTreemap
121
132
  };
122
133
  //# sourceMappingURL=ChartTreemap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartTreemap.js","sources":["../../../../src/components/charts/ChartTreemap/ChartTreemap.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { hierarchy, treemap } from 'd3-hierarchy';\nimport {\n CHART_LABEL_OFFSET,\n ChartFrame,\n chartHeight,\n truncateToWidth,\n useChartMetrics,\n useSeriesToggle,\n type ChartHeight,\n type ChartLegendAlign,\n type ChartLegendPosition,\n} from '../core';\nimport {\n INTENT_TOKENS,\n resolveSeriesColors,\n textColorOn,\n type SeriesAppearance,\n type SeriesIntent,\n} from '../palette';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartTreemap.module.css';\n\nexport interface ChartTreemapNode extends SeriesAppearance {\n children?: readonly ChartTreemapNode[];\n label: string;\n value?: number;\n}\n\nexport interface ChartTreemapProps {\n accent?: string;\n defaultHiddenGroups?: readonly string[];\n emptyMessage?: string;\n formatValue?: (value: number) => string;\n /** Folga entre dois retangulos vizinhos. */\n gap?: number;\n height?: ChartHeight;\n hiddenGroups?: readonly string[];\n /**\n * Nome de cada intencao na legenda. Informado, a legenda deixa de listar os\n * grupos e passa a nomear as cores: e o caso do mapa colorido por status,\n * onde o que a legenda explica e o significado da cor, nao a categoria.\n */\n intentLabels?: Partial<Record<SeriesIntent, string>>;\n legend?: ChartLegendPosition;\n legendAlign?: ChartLegendAlign;\n nodes: readonly ChartTreemapNode[];\n onHiddenGroupsChange?: (hidden: readonly string[]) => void;\n showDataLabels?: boolean;\n title: string;\n}\n\n\n/** Area que o no ocupa. Invalido ou negativo nao ocupa nada. */\nfunction ocupacao(no: ChartTreemapNode) {\n return Number.isFinite(no.value) ? Math.max(no.value ?? 0, 0) : 0;\n}\n\nexport function ChartTreemap({\n accent,\n defaultHiddenGroups,\n emptyMessage = 'Sem dados no período',\n formatValue = formatarNumero,\n gap = 5,\n height = 280,\n hiddenGroups,\n intentLabels,\n legend = 'bottom',\n legendAlign,\n nodes,\n onHiddenGroupsChange,\n showDataLabels = true,\n title,\n}: ChartTreemapProps) {\n const { font, height: alturaMedida, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { isHidden, toggle } = useSeriesToggle({\n defaultHiddenSeries: defaultHiddenGroups,\n hiddenSeries: hiddenGroups,\n onHiddenSeriesChange: onHiddenGroupsChange,\n });\n\n // A cor sai da lista inteira, e nao das visiveis: desligar um grupo nao pode\n // repintar os demais.\n const coresDeGrupo = useMemo(() => resolveSeriesColors(nodes, { accent }), [accent, nodes]);\n\n // Sem valor positivo nao ha area a repartir: anuncia vazio. Desligar todos os grupos, nao: a legenda e a volta.\n const semValor = useMemo(\n () => !((hierarchy<ChartTreemapNode>({ children: nodes, label: '' }).sum(ocupacao).value ?? 0) > 0),\n [nodes],\n );\n\n const retangulos = useMemo(() => {\n const visiveis = nodes.filter((grupo) => !isHidden(grupo.label));\n\n if (width === 0 || alturaDoDesenho === 0 || visiveis.length === 0) {\n return [];\n }\n\n const arvore = hierarchy<ChartTreemapNode>({ children: visiveis, label: '' })\n .sum(ocupacao)\n .sort((a, b) => (b.value ?? 0) - (a.value ?? 0));\n\n const posicionar = treemap<ChartTreemapNode>()\n .size([width, alturaDoDesenho])\n .paddingInner(gap)\n .round(true);\n\n return posicionar(arvore).leaves();\n }, [alturaDoDesenho, gap, isHidden, nodes, width]);\n\n /** A folha herda a cor do grupo, e a intencao propria vence a herdada. */\n function corDa(folha: (typeof retangulos)[number]) {\n const proprio = folha.data;\n\n if (proprio.color) {\n return proprio.color;\n }\n\n if (proprio.intent) {\n return INTENT_TOKENS[proprio.intent];\n }\n\n const grupo = folha.ancestors().find((ancestral) => ancestral.depth === 1)?.data;\n\n return coresDeGrupo[nodes.findIndex((no) => no.label === grupo?.label)] ?? INTENT_TOKENS.neutral;\n }\n\n const entradasDaLegenda = intentLabels\n ? (Object.entries(intentLabels) as [SeriesIntent, string][]).map(([intencao, rotulo]) => ({\n color: INTENT_TOKENS[intencao],\n label: rotulo,\n }))\n : nodes.map((grupo, indice) => ({\n color: coresDeGrupo[indice],\n hidden: isHidden(grupo.label),\n label: grupo.label,\n }));\n\n return (\n <ChartFrame\n containerRef={ref}\n empty={nodes.length === 0 || semValor}\n emptyMessage={emptyMessage}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legend={entradasDaLegenda}\n legendAlign={legendAlign}\n legendPosition={legend}\n onToggleSeries={intentLabels ? undefined : toggle}\n title={title}\n width={width}\n >\n {retangulos.map((folha) => {\n const largura = folha.x1 - folha.x0;\n const altura = folha.y1 - folha.y0;\n const disponivel = largura - CHART_LABEL_OFFSET * 2;\n const cabeORotulo = showDataLabels && disponivel > 0 && altura >= font.lineHeight + CHART_LABEL_OFFSET;\n const cabeOValor = cabeORotulo && altura >= font.lineHeight * 2 + CHART_LABEL_OFFSET;\n const descricao = `${folha.data.label}: ${formatValue(folha.value ?? 0)}`;\n const cor = corDa(folha);\n\n return (\n <g className={styles.cell} key={`${folha.data.label}-${folha.x0}-${folha.y0}`}>\n <rect\n aria-label={descricao}\n className={styles.tile}\n fill={cor}\n height={altura}\n width={largura}\n x={folha.x0}\n y={folha.y0}\n >\n <title>{descricao}</title>\n </rect>\n\n {cabeORotulo && (\n <text\n className={styles.label}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 0.6}\n >\n {truncateToWidth(folha.data.label, font, disponivel)}\n </text>\n )}\n\n {cabeOValor && (\n <text\n className={styles.value}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 1.6}\n >\n {truncateToWidth(formatValue(folha.value ?? 0), font, disponivel)}\n </text>\n )}\n </g>\n );\n })}\n </ChartFrame>\n );\n}\n"],"names":["ocupacao","no","ChartTreemap","accent","defaultHiddenGroups","emptyMessage","formatValue","formatarNumero","gap","height","hiddenGroups","intentLabels","legend","legendAlign","nodes","onHiddenGroupsChange","showDataLabels","title","font","alturaMedida","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","isHidden","toggle","useSeriesToggle","coresDeGrupo","useMemo","resolveSeriesColors","semValor","hierarchy","retangulos","visiveis","grupo","arvore","a","b","treemap","corDa","folha","proprio","INTENT_TOKENS","_a","ancestral","entradasDaLegenda","intencao","rotulo","indice","jsx","ChartFrame","largura","altura","disponivel","CHART_LABEL_OFFSET","cabeORotulo","cabeOValor","descricao","cor","jsxs","styles","textColorOn","truncateToWidth"],"mappings":";;;;;;;;;;;;AAsDA,SAASA,EAASC,GAAsB;AACtC,SAAO,OAAO,SAASA,EAAG,KAAK,IAAI,KAAK,IAAIA,EAAG,SAAS,GAAG,CAAC,IAAI;AAClE;AAEO,SAASC,GAAa;AAAA,EAC3B,QAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,aAAAC,IAAcC;AAAA,EACd,KAAAC,IAAM;AAAA,EACN,QAAAC,IAAS;AAAA,EACT,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,OAAAC;AACF,GAAsB;AACpB,QAAM,EAAE,MAAAC,GAAM,QAAQC,GAAc,KAAAC,GAAK,OAAAC,EAAA,IAAUC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AA;AAAA,cACC,cAAYQ;AAAA,cACZ,WAAWG,EAAO;AAAA,cAClB,MAAMF;AAAA,cACN,QAAQN;AAAA,cACR,OAAOD;AAAA,cACP,GAAGX,EAAM;AAAA,cACT,GAAGA,EAAM;AAAA,cAET,UAAA,gBAAAS,EAAC,WAAO,UAAAQ,EAAA,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,UAGnBF,KACC,gBAAAN;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWW,EAAO;AAAA,cAClB,MAAMC,EAAYH,CAAG;AAAA,cACrB,GAAGlB,EAAM,KAAKc;AAAA,cACd,GAAGd,EAAM,KAAKc,IAAqBtC,EAAK,aAAa;AAAA,cAEpD,UAAA8C,EAAgBtB,EAAM,KAAK,OAAOxB,GAAMqC,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,UAItDG,KACC,gBAAAP;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWW,EAAO;AAAA,cAClB,MAAMC,EAAYH,CAAG;AAAA,cACrB,GAAGlB,EAAM,KAAKc;AAAA,cACd,GAAGd,EAAM,KAAKc,IAAqBtC,EAAK,aAAa;AAAA,cAEpD,YAAgBZ,EAAYoC,EAAM,SAAS,CAAC,GAAGxB,GAAMqC,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QAClE,EAAA,GAhC4B,GAAGb,EAAM,KAAK,KAAK,IAAIA,EAAM,EAAE,IAAIA,EAAM,EAAE,EAkC3E;AAAA,MAEJ,CAAC;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"ChartTreemap.js","sources":["../../../../src/components/charts/ChartTreemap/ChartTreemap.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { hierarchy, treemap } from 'd3-hierarchy';\nimport {\n CHART_LABEL_OFFSET,\n ChartFrame,\n chartHeight,\n hoverPath,\n pathTooltip,\n truncateToWidth,\n useChartMetrics,\n useSeriesToggle,\n type ChartHeight,\n type ChartHoveredNode,\n type ChartLegendAlign,\n type ChartLegendPosition,\n} from '../core';\nimport {\n INTENT_TOKENS,\n resolveSeriesColors,\n textColorOn,\n type SeriesAppearance,\n type SeriesIntent,\n} from '../palette';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartTreemap.module.css';\n\nexport interface ChartTreemapNode extends SeriesAppearance {\n children?: readonly ChartTreemapNode[];\n label: string;\n value?: number;\n}\n\nexport interface ChartTreemapProps {\n accent?: string;\n defaultHiddenGroups?: readonly string[];\n emptyMessage?: string;\n /** Formato dos valores no balao. Sem ele, vale o `formatValue`: o eixo pode sair compacto e o balao, exato. */\n formatTooltipValue?: (value: number) => string;\n formatValue?: (value: number) => string;\n /** Folga entre dois retangulos vizinhos. */\n gap?: number;\n height?: ChartHeight;\n hiddenGroups?: readonly string[];\n /**\n * Nome de cada intencao na legenda. Informado, a legenda deixa de listar os\n * grupos e passa a nomear as cores: e o caso do mapa colorido por status,\n * onde o que a legenda explica e o significado da cor, nao a categoria.\n */\n intentLabels?: Partial<Record<SeriesIntent, string>>;\n legend?: ChartLegendPosition;\n legendAlign?: ChartLegendAlign;\n nodes: readonly ChartTreemapNode[];\n onHiddenGroupsChange?: (hidden: readonly string[]) => void;\n /** Caminho ate o no sob o ponteiro, do grupo ao no, cada nivel com o valor somado, ou `null` ao sair. */\n onHoverNode?: (path: readonly ChartHoveredNode[] | null) => void;\n showDataLabels?: boolean;\n /**\n * Balao com o caminho ate o no sob o ponteiro. Desligue para montar o proprio `ChartTooltip`\n * pela costura; sem balao nem costura, o no volta a ter o `<title>`.\n */\n showTooltip?: boolean;\n title: string;\n}\n\n\n/** Area que o no ocupa. Invalido ou negativo nao ocupa nada. */\nfunction ocupacao(no: ChartTreemapNode) {\n return Number.isFinite(no.value) ? Math.max(no.value ?? 0, 0) : 0;\n}\n\nexport function ChartTreemap({\n accent,\n defaultHiddenGroups,\n emptyMessage = 'Sem dados no período',\n formatTooltipValue,\n formatValue = formatarNumero,\n gap = 5,\n height = 280,\n hiddenGroups,\n intentLabels,\n legend = 'bottom',\n legendAlign,\n nodes,\n onHiddenGroupsChange,\n onHoverNode,\n showDataLabels = true,\n showTooltip = true,\n title,\n}: ChartTreemapProps) {\n const { font, height: alturaMedida, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { isHidden, toggle } = useSeriesToggle({\n defaultHiddenSeries: defaultHiddenGroups,\n hiddenSeries: hiddenGroups,\n onHiddenSeriesChange: onHiddenGroupsChange,\n });\n\n // A cor sai da lista inteira, e nao das visiveis: desligar um grupo nao pode\n // repintar os demais.\n const coresDeGrupo = useMemo(() => resolveSeriesColors(nodes, { accent }), [accent, nodes]);\n\n // Sem valor positivo nao ha area a repartir: anuncia vazio. Desligar todos os grupos, nao: a legenda e a volta.\n const semValor = useMemo(\n () => !((hierarchy<ChartTreemapNode>({ children: nodes, label: '' }).sum(ocupacao).value ?? 0) > 0),\n [nodes],\n );\n\n const retangulos = useMemo(() => {\n const visiveis = nodes.filter((grupo) => !isHidden(grupo.label));\n\n if (width === 0 || alturaDoDesenho === 0 || visiveis.length === 0) {\n return [];\n }\n\n const arvore = hierarchy<ChartTreemapNode>({ children: visiveis, label: '' })\n .sum(ocupacao)\n .sort((a, b) => (b.value ?? 0) - (a.value ?? 0));\n\n const posicionar = treemap<ChartTreemapNode>()\n .size([width, alturaDoDesenho])\n .paddingInner(gap)\n .round(true);\n\n return posicionar(arvore).leaves();\n }, [alturaDoDesenho, gap, isHidden, nodes, width]);\n\n const [emFoco, setEmFoco] = useState<(typeof retangulos)[number] | null>(null);\n // A folha guardada deixa de existir quando o mapa e remontado; sem conferir, o balao falaria de um no que saiu.\n const foco = emFoco && retangulos.includes(emFoco) ? emFoco : null;\n\n function focar(folha: (typeof retangulos)[number] | null) {\n setEmFoco(folha);\n onHoverNode?.(folha && hoverPath(folha));\n }\n\n /** A folha herda a cor do grupo, e a intencao propria vence a herdada. */\n function corDa(folha: (typeof retangulos)[number]) {\n const proprio = folha.data;\n\n if (proprio.color) {\n return proprio.color;\n }\n\n if (proprio.intent) {\n return INTENT_TOKENS[proprio.intent];\n }\n\n const grupo = folha.ancestors().find((ancestral) => ancestral.depth === 1)?.data;\n\n return coresDeGrupo[nodes.findIndex((no) => no.label === grupo?.label)] ?? INTENT_TOKENS.neutral;\n }\n\n const entradasDaLegenda = intentLabels\n ? (Object.entries(intentLabels) as [SeriesIntent, string][]).map(([intencao, rotulo]) => ({\n color: INTENT_TOKENS[intencao],\n label: rotulo,\n }))\n : nodes.map((grupo, indice) => ({\n color: coresDeGrupo[indice],\n hidden: isHidden(grupo.label),\n label: grupo.label,\n }));\n\n return (\n <ChartFrame\n containerRef={ref}\n empty={nodes.length === 0 || semValor}\n emptyMessage={emptyMessage}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legend={entradasDaLegenda}\n legendAlign={legendAlign}\n legendPosition={legend}\n onToggleSeries={intentLabels ? undefined : toggle}\n title={title}\n tooltip={\n showTooltip\n ? pathTooltip({ color: foco ? corDa(foco) : undefined, format: formatTooltipValue ?? formatValue, path: foco && hoverPath(foco) })\n : undefined\n }\n width={width}\n >\n {retangulos.map((folha) => {\n const largura = folha.x1 - folha.x0;\n const altura = folha.y1 - folha.y0;\n const disponivel = largura - CHART_LABEL_OFFSET * 2;\n const cabeORotulo = showDataLabels && disponivel > 0 && altura >= font.lineHeight + CHART_LABEL_OFFSET;\n const cabeOValor = cabeORotulo && altura >= font.lineHeight * 2 + CHART_LABEL_OFFSET;\n const descricao = `${folha.data.label}: ${formatValue(folha.value ?? 0)}`;\n const cor = corDa(folha);\n\n return (\n <g className={styles.cell} key={`${folha.data.label}-${folha.x0}-${folha.y0}`}>\n <rect\n aria-label={descricao}\n className={styles.tile}\n fill={cor}\n height={altura}\n width={largura}\n onMouseEnter={() => focar(folha)}\n onMouseLeave={() => focar(null)}\n x={folha.x0}\n y={folha.y0}\n >\n {!showTooltip && !onHoverNode && <title>{descricao}</title>}\n </rect>\n\n {cabeORotulo && (\n <text\n className={styles.label}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 0.6}\n >\n {truncateToWidth(folha.data.label, font, disponivel)}\n </text>\n )}\n\n {cabeOValor && (\n <text\n className={styles.value}\n fill={textColorOn(cor)}\n x={folha.x0 + CHART_LABEL_OFFSET}\n y={folha.y0 + CHART_LABEL_OFFSET + font.lineHeight * 1.6}\n >\n {truncateToWidth(formatValue(folha.value ?? 0), font, disponivel)}\n </text>\n )}\n </g>\n );\n })}\n </ChartFrame>\n );\n}\n"],"names":["ocupacao","no","ChartTreemap","accent","defaultHiddenGroups","emptyMessage","formatTooltipValue","formatValue","formatarNumero","gap","height","hiddenGroups","intentLabels","legend","legendAlign","nodes","onHiddenGroupsChange","onHoverNode","showDataLabels","showTooltip","title","font","alturaMedida","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","isHidden","toggle","useSeriesToggle","coresDeGrupo","useMemo","resolveSeriesColors","semValor","hierarchy","retangulos","visiveis","grupo","arvore","a","b","treemap","emFoco","setEmFoco","useState","foco","focar","folha","hoverPath","corDa","proprio","INTENT_TOKENS","_a","ancestral","entradasDaLegenda","intencao","rotulo","indice","jsx","ChartFrame","pathTooltip","largura","altura","disponivel","CHART_LABEL_OFFSET","cabeORotulo","cabeOValor","descricao","cor","jsxs","styles","textColorOn","truncateToWidth"],"mappings":";;;;;;;;;;;;;;AAkEA,SAASA,EAASC,GAAsB;AACtC,SAAO,OAAO,SAASA,EAAG,KAAK,IAAI,KAAK,IAAIA,EAAG,SAAS,GAAG,CAAC,IAAI;AAClE;AAEO,SAASC,GAAa;AAAA,EAC3B,QAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,oBAAAC;AAAA,EACA,aAAAC,IAAcC;AAAA,EACd,KAAAC,IAAM;AAAA,EACN,QAAAC,IAAS;AAAA,EACT,cAAAC;AAAA,EACA,cAA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A,YAAA;AAAA,UAAA;AAAA,UAItDG,KACC,gBAAAR;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWY,EAAO;AAAA,cAClB,MAAMC,EAAYH,CAAG;AAAA,cACrB,GAAGrB,EAAM,KAAKiB;AAAA,cACd,GAAGjB,EAAM,KAAKiB,IAAqB7C,EAAK,aAAa;AAAA,cAEpD,YAAgBd,EAAY0C,EAAM,SAAS,CAAC,GAAG5B,GAAM4C,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QAClE,EAAA,GAlC4B,GAAGhB,EAAM,KAAK,KAAK,IAAIA,EAAM,EAAE,IAAIA,EAAM,EAAE,EAoC3E;AAAA,MAEJ,CAAC;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),h=require("react"),C=require("./ChartWaterfall.module.css.cjs"),K=require("../core/useChartMetrics.cjs"),Q=require("../core/useHoveredBand.cjs"),U=require("../palette/seriesColor.cjs"),f=require("../scales/scales.cjs"),y=require("../core/cartesianLayout.cjs"),V=require("../core/spacing.cjs"),X=require("../core/useTweenedNumbers.cjs"),Y=require("../../../utils/formatters/formatarNumero.cjs"),Z=require("../core/CartesianFrame.cjs"),ee=require("../core/BandCursor.cjs"),te=require("../core/shapes.cjs");function ne(n){let a=0;return n.map(d=>{if(!Number.isFinite(d.value))return null;const b=d.total?0:a,g=b+d.value;return a=g,{inicio:b,fim:g}})}function oe(n){return n.intent?n.intent:n.total?"neutral":n.value<0?"negative":"positive"}function re(n,a){return n===0?a(0):`${n<0?"-":"+"}${a(Math.abs(n))}`}function ae({emptyMessage:n="Sem dados no período",formatValue:a=Y.formatarNumero,height:d=280,labelAngle:b="auto",onHoverStep:g,showDataLabels:L=!0,steps:r,title:W,xAxis:S="visible",yAxis:w="visible",yAxisRight:j="hidden"}){const{font:D,height:z,radius:v,ref:A,width:N}=K.useChartMetrics(),{fillHeight:E,value:M}=y.chartHeight(d,z),{hover:p,hovered:F}=Q.useHoveredBand(g),s=h.useMemo(()=>ne(r),[r]),O=h.useMemo(()=>U.resolveSeriesColors(r.map(e=>({color:e.color,intent:oe(e)}))),[r]),x=h.useMemo(()=>f.domainOf(s.flatMap(e=>e?[e.inicio,e.fim]:[])),[s]),P=y.valueLabelsFor(x,M,a),{margins:_,plot:l,rotation:G}=y.cartesianLayout({bottomLabels:r.map(e=>e.label),font:D,height:M,labelAngle:b,leftLabels:P,rightLabels:P,topRoom:L?V.valueLabelRoom(D):0,width:N,xAxis:S,yAxis:w,yAxisRight:j}),u=h.useMemo(()=>f.bandScale({domain:r.map((e,t)=>String(t)),range:[0,l.width]}),[l.width,r]),c=e=>u(String(e))??0,B=h.useMemo(()=>f.linearScale({domain:x,range:[l.height,0]}),[x,l.height]),[R,k]=X.useTweenedNumbers(B.domain()),i=h.useMemo(()=>f.linearScale({domain:{min:R,max:k},nice:!1,range:[l.height,0]}),[k,R,l.height]),H=f.ticksFor(B,l.height),I=r.map((e,t)=>({label:e.label,position:c(t)+u.bandwidth()/2})),$=H.map(e=>({label:a(e),position:i(e)}));function T(e){return e.total?a(e.value):re(e.value,a)}return m.jsxs(Z.CartesianFrame,{containerRef:A,empty:r.length===0,emptyMessage:n,grid:[{baseline:i(0),lines:H.map(e=>i(e)),orientation:"horizontal"}],fillHeight:E,height:M,legendPosition:"none",margins:_,plot:l,title:W,width:N,xAxis:{labelRotation:G,ticks:I,visibility:S},yAxis:{hideLine:!0,ticks:$,visibility:w},yAxisRight:{hideLine:!0,ticks:$,visibility:j},children:[F!==null&&m.jsx(ee.BandCursor,{offset:c(F),plot:l,size:u.bandwidth()}),m.jsx("g",{"aria-hidden":"true",children:s.slice(0,-1).map((e,t)=>{if(!e||!s[t+1])return null;const o=i(e.fim);return m.jsx("line",{className:C.default.connector,x1:c(t)+u.bandwidth(),x2:c(t+1),y1:o,y2:o},t)})}),r.map((e,t)=>{const o=s[t];if(!o)return null;const q=Math.min(i(o.inicio),i(o.fim)),J=Math.abs(i(o.fim)-i(o.inicio));return m.jsx("path",{"aria-label":`${e.label}: ${T(e)}`,className:C.default.bar,d:te.roundedBarPath(c(t),q,u.bandwidth(),J,[v,v,v,v]),fill:O[t],onMouseEnter:()=>p(t),onMouseLeave:()=>p(null)},t)}),L&&r.map((e,t)=>{const o=s[t];if(!o)return null;const q=Math.min(i(o.inicio),i(o.fim));return m.jsx("text",{className:C.default.valueLabel,textAnchor:"middle",x:c(t)+u.bandwidth()/2,y:q-6,children:T(e)},t)})]})}exports.ChartWaterfall=ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),f=require("react"),x=require("./ChartWaterfall.module.css.cjs"),V=require("../core/useChartMetrics.cjs"),ee=require("../core/useHoveredBand.cjs"),te=require("../palette/seriesColor.cjs"),b=require("../scales/scales.cjs"),w=require("../core/cartesianLayout.cjs"),oe=require("../core/useCartesianLayout.cjs"),ae=require("../core/spacing.cjs"),ne=require("../core/useTweenedNumbers.cjs"),re=require("../../../utils/formatters/formatarNumero.cjs"),ie=require("../core/CartesianFrame.cjs"),le=require("../core/BandCursor.cjs"),se=require("../core/shapes.cjs");function ue(n){let s=0;return n.map(r=>{if(!Number.isFinite(r.value))return null;const v=r.total?0:s,g=v+r.value;return s=g,{inicio:v,fim:g}})}function ce(n){return n.intent?n.intent:n.total?"neutral":n.value<0?"negative":"positive"}function z(n,s){return n===0?s(0):`${n<0?"-":"+"}${s(Math.abs(n))}`}function me({emptyMessage:n="Sem dados no período",formatTooltipValue:s,formatValue:r=re.formatarNumero,height:v=280,labelAngle:g="auto",onHoverStep:E,showDataLabels:q="visible",showTooltip:O=!0,steps:a,title:_,xAxis:j="visible",yAxis:D="visible",yAxisRight:N="hidden"}){var W;const{font:p,height:G,radius:M,ref:I,width:B}=V.useChartMetrics(),{fillHeight:J,value:C}=w.chartHeight(v,G),{hover:F,hovered:c}=ee.useHoveredBand(E),u=f.useMemo(()=>ue(a),[a]),y=f.useMemo(()=>te.resolveSeriesColors(a.map(e=>({color:e.color,intent:ce(e)}))),[a]),L=f.useMemo(()=>b.domainOf(u.flatMap(e=>e?[e.inicio,e.fim]:[])),[u]),P=w.valueLabelsFor(L,C,r),{axisReveal:K,margins:Q,plot:l,rotation:U}=oe.useCartesianLayout({bottomLabels:a.map(e=>e.label),font:p,height:C,labelAngle:g,leftLabels:P,rightLabels:P,topRoom:q==="hidden"?0:ae.valueLabelRoom(p),width:B,xAxis:j,yAxis:D,yAxisRight:N}),m=f.useMemo(()=>b.bandScale({domain:a.map((e,t)=>String(t)),range:[0,l.width]}),[l.width,a]),h=e=>m(String(e))??0,R=f.useMemo(()=>b.linearScale({domain:L,range:[l.height,0]}),[L,l.height]),[$,k]=ne.useTweenedNumbers(R.domain()),i=f.useMemo(()=>b.linearScale({domain:{min:$,max:k},nice:!1,range:[l.height,0]}),[k,$,l.height]),H=b.ticksFor(R,l.height),X=a.map((e,t)=>({label:e.label,position:h(t)+m.bandwidth()/2})),A=H.map(e=>({label:r(e),position:i(e)}));function T(e){return e.total?r(e.value):z(e.value,r)}function Y(e){if(e===null||!u[e])return[];const t=a[e];return t.total?[{color:y[e],label:"Total",values:[t.value]}]:[{color:y[e],format:o=>z(o,s??r),label:"Variação",values:[t.value]},{label:"Acumulado",values:[u[e].fim]}]}return d.jsxs(ie.CartesianFrame,{axisReveal:K,containerRef:I,empty:a.length===0,emptyMessage:n,grid:[{baseline:i(0),lines:H.map(e=>i(e)),orientation:"horizontal"}],fillHeight:J,height:C,legendPosition:"none",margins:Q,plot:l,title:_,tooltip:O?{columns:[{format:s??r}],computed:"none",rows:Y(c),title:c===null||(W=a[c])==null?void 0:W.label}:void 0,width:B,xAxis:{labelRotation:U,ticks:X,visibility:j},yAxis:{hideLine:!0,ticks:A,visibility:D},yAxisRight:{hideLine:!0,ticks:A,visibility:N},children:[c!==null&&d.jsx(le.BandCursor,{offset:h(c),plot:l,size:m.bandwidth()}),d.jsx("g",{"aria-hidden":"true",children:u.slice(0,-1).map((e,t)=>{if(!e||!u[t+1])return null;const o=i(e.fim);return d.jsx("line",{className:x.default.connector,x1:h(t)+m.bandwidth(),x2:h(t+1),y1:o,y2:o},t)})}),a.map((e,t)=>{const o=u[t];if(!o)return null;const S=Math.min(i(o.inicio),i(o.fim)),Z=Math.abs(i(o.fim)-i(o.inicio));return d.jsx("path",{"aria-label":`${e.label}: ${T(e)}`,className:x.default.bar,d:se.roundedBarPath(h(t),S,m.bandwidth(),Z,[M,M,M,M]),fill:y[t],onMouseEnter:()=>F(t),onMouseLeave:()=>F(null)},t)}),q!=="hidden"&&a.map((e,t)=>{const o=u[t];if(!o)return null;const S=Math.min(i(o.inicio),i(o.fim));return d.jsx("text",{className:`${x.default.valueLabel} ${w.markShown(q,t===c)?"":x.default.valueLabelHidden}`,textAnchor:"middle",x:h(t)+m.bandwidth()/2,y:S-6,children:T(e)},t)})]})}exports.ChartWaterfall=me;
2
2
  //# sourceMappingURL=ChartWaterfall.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartWaterfall.cjs","sources":["../../../../src/components/charts/ChartWaterfall/ChartWaterfall.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n BandCursor,\n CartesianFrame,\n cartesianLayout,\n chartHeight,\n roundedBarPath,\n useChartMetrics,\n useHoveredBand,\n useTweenedNumbers,\n valueLabelRoom,\n valueLabelsFor,\n type AxisLabelAngle,\n type AxisTick,\n type AxisVisibility,\n type ChartHeight,\n} from '../core';\nimport { resolveSeriesColors, type SeriesIntent } from '../palette';\nimport { bandScale, domainOf, linearScale, ticksFor } from '../scales';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartWaterfall.module.css';\n\nexport interface ChartWaterfallStep {\n color?: string;\n intent?: SeriesIntent;\n label: string;\n total?: boolean;\n value: number;\n}\n\nexport interface ChartWaterfallProps {\n emptyMessage?: string;\n formatValue?: (value: number) => string;\n height?: ChartHeight;\n labelAngle?: AxisLabelAngle;\n /** Indice do passo sob o ponteiro, ou `null` ao sair dele. */\n onHoverStep?: (index: number | null) => void;\n showDataLabels?: boolean;\n steps: readonly ChartWaterfallStep[];\n title: string;\n xAxis?: AxisVisibility;\n yAxis?: AxisVisibility;\n yAxisRight?: AxisVisibility;\n}\n\ninterface Trecho {\n fim: number;\n inicio: number;\n}\n\n/**\n * Cada passo ocupa a faixa entre o acumulado anterior e o novo acumulado; o total parte do zero, porque\n * fecha a conta. Passo invalido e ausente: nao se desenha nem move o acumulado.\n */\nfunction trechosDe(steps: readonly ChartWaterfallStep[]): (Trecho | null)[] {\n let acumulado = 0;\n\n return steps.map((passo) => {\n if (!Number.isFinite(passo.value)) {\n return null;\n }\n\n const inicio = passo.total ? 0 : acumulado;\n const fim = inicio + passo.value;\n acumulado = fim;\n\n return { inicio, fim };\n });\n}\n\n/** Passo sem intencao declarada recebe a do seu sinal. Total e fechamento, nao aporte. */\nfunction intencaoDe(step: ChartWaterfallStep): SeriesIntent {\n if (step.intent) {\n return step.intent;\n }\n\n if (step.total) {\n return 'neutral';\n }\n\n return step.value < 0 ? 'negative' : 'positive';\n}\n\n/**\n * O sinal e do grafico, nao do formatador: ele formata a magnitude. Delegar o\n * sinal perderia a variacao com qualquer formatador que exiba apenas o valor.\n */\nfunction comSinal(value: number, formatValue: (value: number) => string) {\n if (value === 0) {\n return formatValue(0);\n }\n\n return `${value < 0 ? '-' : '+'}${formatValue(Math.abs(value))}`;\n}\n\nexport function ChartWaterfall({\n emptyMessage = 'Sem dados no período',\n formatValue = formatarNumero,\n height = 280,\n labelAngle = 'auto',\n onHoverStep,\n showDataLabels = true,\n steps,\n title,\n xAxis = 'visible',\n yAxis = 'visible',\n yAxisRight = 'hidden',\n}: ChartWaterfallProps) {\n const { font, height: alturaMedida, radius: raioDoCanto, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { hover: focarPasso, hovered: passoEmFoco } = useHoveredBand(onHoverStep);\n\n const trechos = useMemo(() => trechosDe(steps), [steps]);\n\n const cores = useMemo(\n () => resolveSeriesColors(steps.map((passo) => ({ color: passo.color, intent: intencaoDe(passo) }))),\n [steps],\n );\n\n const dominio = useMemo(\n () => domainOf(trechos.flatMap((trecho) => (trecho ? [trecho.inicio, trecho.fim] : []))),\n [trechos],\n );\n\n const rotulosDeValor = valueLabelsFor(dominio, alturaDoDesenho, formatValue);\n\n const { margins, plot, rotation } = cartesianLayout({\n bottomLabels: steps.map((passo) => passo.label),\n font,\n height: alturaDoDesenho,\n labelAngle,\n leftLabels: rotulosDeValor,\n rightLabels: rotulosDeValor,\n topRoom: showDataLabels ? valueLabelRoom(font) : 0,\n width,\n xAxis,\n yAxis,\n yAxisRight,\n });\n\n // A faixa e indexada pela posicao, nao pelo rotulo: numa sequencia de passos o\n // mesmo rotulo pode repetir, e a escala categorica funde dominios iguais.\n const escalaPassos = useMemo(\n () => bandScale({ domain: steps.map((_, indice) => String(indice)), range: [0, plot.width] }),\n [plot.width, steps],\n );\n\n const faixaDe = (indice: number) => escalaPassos(String(indice)) ?? 0;\n\n // A escala alvo fixa as marcas; a animada posiciona o desenho. Sem separar as\n // duas, as marcas exibiriam valores quebrados durante a transicao.\n const escalaAlvo = useMemo(\n () => linearScale({ domain: dominio, range: [plot.height, 0] }),\n [dominio, plot.height],\n );\n\n const [minimo, maximo] = useTweenedNumbers(escalaAlvo.domain());\n\n const escalaValores = useMemo(\n () => linearScale({ domain: { min: minimo, max: maximo }, nice: false, range: [plot.height, 0] }),\n [maximo, minimo, plot.height],\n );\n\n const marcasDeValor = ticksFor(escalaAlvo, plot.height);\n\n const marcasPassos: AxisTick[] = steps.map((passo, indice) => ({\n label: passo.label,\n position: faixaDe(indice) + escalaPassos.bandwidth() / 2,\n }));\n\n const marcasValor: AxisTick[] = marcasDeValor.map((valor) => ({\n label: formatValue(valor),\n position: escalaValores(valor),\n }));\n\n function rotuloDe(passo: ChartWaterfallStep) {\n return passo.total ? formatValue(passo.value) : comSinal(passo.value, formatValue);\n }\n\n return (\n <CartesianFrame\n containerRef={ref}\n empty={steps.length === 0}\n emptyMessage={emptyMessage}\n grid={[\n {\n baseline: escalaValores(0),\n lines: marcasDeValor.map((valor) => escalaValores(valor)),\n orientation: 'horizontal',\n },\n ]}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legendPosition=\"none\"\n margins={margins}\n plot={plot}\n title={title}\n width={width}\n xAxis={{ labelRotation: rotation, ticks: marcasPassos, visibility: xAxis }}\n yAxis={{ hideLine: true, ticks: marcasValor, visibility: yAxis }}\n yAxisRight={{ hideLine: true, ticks: marcasValor, visibility: yAxisRight }}\n >\n {passoEmFoco !== null && (\n <BandCursor offset={faixaDe(passoEmFoco)} plot={plot} size={escalaPassos.bandwidth()} />\n )}\n\n <g aria-hidden=\"true\">\n {trechos.slice(0, -1).map((trecho, indice) => {\n if (!trecho || !trechos[indice + 1]) {\n return null;\n }\n\n const nivel = escalaValores(trecho.fim);\n\n return (\n <line\n className={styles.connector}\n key={indice}\n x1={faixaDe(indice) + escalaPassos.bandwidth()}\n x2={faixaDe(indice + 1)}\n y1={nivel}\n y2={nivel}\n />\n );\n })}\n </g>\n\n {steps.map((passo, indice) => {\n const trecho = trechos[indice];\n\n if (!trecho) {\n return null;\n }\n\n const topo = Math.min(escalaValores(trecho.inicio), escalaValores(trecho.fim));\n const altura = Math.abs(escalaValores(trecho.fim) - escalaValores(trecho.inicio));\n\n return (\n <path\n aria-label={`${passo.label}: ${rotuloDe(passo)}`}\n className={styles.bar}\n d={roundedBarPath(faixaDe(indice), topo, escalaPassos.bandwidth(), altura, [\n raioDoCanto,\n raioDoCanto,\n raioDoCanto,\n raioDoCanto,\n ])}\n fill={cores[indice]}\n key={indice}\n onMouseEnter={() => focarPasso(indice)}\n onMouseLeave={() => focarPasso(null)}\n />\n );\n })}\n\n {showDataLabels &&\n steps.map((passo, indice) => {\n const trecho = trechos[indice];\n\n if (!trecho) {\n return null;\n }\n\n const topo = Math.min(escalaValores(trecho.inicio), escalaValores(trecho.fim));\n\n return (\n <text\n className={styles.valueLabel}\n key={indice}\n textAnchor=\"middle\"\n x={faixaDe(indice) + escalaPassos.bandwidth() / 2}\n y={topo - 6}\n >\n {rotuloDe(passo)}\n </text>\n );\n })}\n </CartesianFrame>\n );\n}\n"],"names":["trechosDe","steps","acumulado","passo","inicio","fim","intencaoDe","step","comSinal","value","formatValue","ChartWaterfall","emptyMessage","formatarNumero","height","labelAngle","onHoverStep","showDataLabels","title","xAxis","yAxis","yAxisRight","font","alturaMedida","raioDoCanto","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","focarPasso","passoEmFoco","useHoveredBand","trechos","useMemo","cores","resolveSeriesColors","dominio","domainOf","trecho","rotulosDeValor","valueLabelsFor","margins","plot","rotation","cartesianLayout","valueLabelRoom","escalaPassos","bandScale","_","indice","faixaDe","escalaAlvo","linearScale","minimo","maximo","useTweenedNumbers","escalaValores","marcasDeValor","ticksFor","marcasPassos","marcasValor","valor","rotuloDe","jsxs","CartesianFrame","jsx","BandCursor","nivel","styles","topo","altura","roundedBarPath"],"mappings":"6mBAsDA,SAASA,GAAUC,EAAyD,CAC1E,IAAIC,EAAY,EAEhB,OAAOD,EAAM,IAAKE,GAAU,CAC1B,GAAI,CAAC,OAAO,SAASA,EAAM,KAAK,EAC9B,OAAO,KAGT,MAAMC,EAASD,EAAM,MAAQ,EAAID,EAC3BG,EAAMD,EAASD,EAAM,MAC3B,OAAAD,EAAYG,EAEL,CAAE,OAAAD,EAAQ,IAAAC,CAAA,CACnB,CAAC,CACH,CAGA,SAASC,GAAWC,EAAwC,CAC1D,OAAIA,EAAK,OACAA,EAAK,OAGVA,EAAK,MACA,UAGFA,EAAK,MAAQ,EAAI,WAAa,UACvC,CAMA,SAASC,GAASC,EAAeC,EAAwC,CACvE,OAAID,IAAU,EACLC,EAAY,CAAC,EAGf,GAAGD,EAAQ,EAAI,IAAM,GAAG,GAAGC,EAAY,KAAK,IAAID,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UAAWmE,EAAAA,QAAO,IAClB,EAAGG,GAAAA,eAAerB,EAAQD,CAAM,EAAGoB,EAAMvB,EAAa,UAAA,EAAawB,EAAQ,CACzEhD,EACAA,EACAA,EACAA,CAAA,CACD,EACD,KAAMY,EAAMe,CAAM,EAElB,aAAc,IAAMpB,EAAWoB,CAAM,EACrC,aAAc,IAAMpB,EAAW,IAAI,CAAA,EAF9BoB,CAAA,CAKX,CAAC,EAEAlC,GACChB,EAAM,IAAI,CAACE,EAAOgD,IAAW,CAC3B,MAAMX,EAASN,EAAQiB,CAAM,EAE7B,GAAI,CAACX,EACH,OAAO,KAGT,MAAM+B,EAAO,KAAK,IAAIb,EAAclB,EAAO,MAAM,EAAGkB,EAAclB,EAAO,GAAG,CAAC,EAE7E,OACE2B,EAAAA,IAAC,OAAA,CACC,UAAWG,EAAAA,QAAO,WAElB,WAAW,SACX,EAAGlB,EAAQD,CAAM,EAAIH,EAAa,YAAc,EAChD,EAAGuB,EAAO,EAET,WAASpE,CAAK,CAAA,EALVgD,CAAA,CAQX,CAAC,CAAA,CAAA,CAAA,CAGT"}
1
+ {"version":3,"file":"ChartWaterfall.cjs","sources":["../../../../src/components/charts/ChartWaterfall/ChartWaterfall.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n BandCursor,\n markShown,\n CartesianFrame,\n useCartesianLayout,\n chartHeight,\n roundedBarPath,\n useChartMetrics,\n useHoveredBand,\n useTweenedNumbers,\n valueLabelRoom,\n valueLabelsFor,\n type AxisLabelAngle,\n type AxisTick,\n type AxisVisibility,\n type MarkVisibility,\n type ChartHeight,\n} from '../core';\nimport { resolveSeriesColors, type SeriesIntent } from '../palette';\nimport { bandScale, domainOf, linearScale, ticksFor } from '../scales';\nimport { formatarNumero } from '../../../utils/formatters';\nimport styles from './ChartWaterfall.module.css';\n\nexport interface ChartWaterfallStep {\n color?: string;\n intent?: SeriesIntent;\n label: string;\n total?: boolean;\n value: number;\n}\n\nexport interface ChartWaterfallProps {\n emptyMessage?: string;\n /** Formato dos valores no balao. Sem ele, vale o `formatValue`: o eixo pode sair compacto e o balao, exato. */\n formatTooltipValue?: (value: number) => string;\n formatValue?: (value: number) => string;\n height?: ChartHeight;\n labelAngle?: AxisLabelAngle;\n /** Indice do passo sob o ponteiro, ou `null` ao sair dele. */\n onHoverStep?: (index: number | null) => void;\n /** Variacao acima de cada passo. Em `onHover`, so a do passo sob o ponteiro. */\n showDataLabels?: MarkVisibility;\n /** Balao com a variacao do passo sob o ponteiro e o acumulado ate ele. Desligue para montar o proprio `ChartTooltip`. */\n showTooltip?: boolean;\n steps: readonly ChartWaterfallStep[];\n title: string;\n xAxis?: AxisVisibility;\n yAxis?: AxisVisibility;\n yAxisRight?: AxisVisibility;\n}\n\ninterface Trecho {\n fim: number;\n inicio: number;\n}\n\n/**\n * Cada passo ocupa a faixa entre o acumulado anterior e o novo acumulado; o total parte do zero, porque\n * fecha a conta. Passo invalido e ausente: nao se desenha nem move o acumulado.\n */\nfunction trechosDe(steps: readonly ChartWaterfallStep[]): (Trecho | null)[] {\n let acumulado = 0;\n\n return steps.map((passo) => {\n if (!Number.isFinite(passo.value)) {\n return null;\n }\n\n const inicio = passo.total ? 0 : acumulado;\n const fim = inicio + passo.value;\n acumulado = fim;\n\n return { inicio, fim };\n });\n}\n\n/** Passo sem intencao declarada recebe a do seu sinal. Total e fechamento, nao aporte. */\nfunction intencaoDe(step: ChartWaterfallStep): SeriesIntent {\n if (step.intent) {\n return step.intent;\n }\n\n if (step.total) {\n return 'neutral';\n }\n\n return step.value < 0 ? 'negative' : 'positive';\n}\n\n/**\n * O sinal e do grafico, nao do formatador: ele formata a magnitude. Delegar o\n * sinal perderia a variacao com qualquer formatador que exiba apenas o valor.\n */\nfunction comSinal(value: number, formatValue: (value: number) => string) {\n if (value === 0) {\n return formatValue(0);\n }\n\n return `${value < 0 ? '-' : '+'}${formatValue(Math.abs(value))}`;\n}\n\nexport function ChartWaterfall({\n emptyMessage = 'Sem dados no período',\n formatTooltipValue,\n formatValue = formatarNumero,\n height = 280,\n labelAngle = 'auto',\n onHoverStep,\n showDataLabels = 'visible',\n showTooltip = true,\n steps,\n title,\n xAxis = 'visible',\n yAxis = 'visible',\n yAxisRight = 'hidden',\n}: ChartWaterfallProps) {\n const { font, height: alturaMedida, radius: raioDoCanto, ref, width } = useChartMetrics();\n const { fillHeight, value: alturaDoDesenho } = chartHeight(height, alturaMedida);\n const { hover: focarPasso, hovered: passoEmFoco } = useHoveredBand(onHoverStep);\n\n const trechos = useMemo(() => trechosDe(steps), [steps]);\n\n const cores = useMemo(\n () => resolveSeriesColors(steps.map((passo) => ({ color: passo.color, intent: intencaoDe(passo) }))),\n [steps],\n );\n\n const dominio = useMemo(\n () => domainOf(trechos.flatMap((trecho) => (trecho ? [trecho.inicio, trecho.fim] : []))),\n [trechos],\n );\n\n const rotulosDeValor = valueLabelsFor(dominio, alturaDoDesenho, formatValue);\n\n const { axisReveal, margins, plot, rotation } = useCartesianLayout({\n bottomLabels: steps.map((passo) => passo.label),\n font,\n height: alturaDoDesenho,\n labelAngle,\n leftLabels: rotulosDeValor,\n rightLabels: rotulosDeValor,\n topRoom: showDataLabels === 'hidden' ? 0 : valueLabelRoom(font),\n width,\n xAxis,\n yAxis,\n yAxisRight,\n });\n\n // A faixa e indexada pela posicao, nao pelo rotulo: numa sequencia de passos o\n // mesmo rotulo pode repetir, e a escala categorica funde dominios iguais.\n const escalaPassos = useMemo(\n () => bandScale({ domain: steps.map((_, indice) => String(indice)), range: [0, plot.width] }),\n [plot.width, steps],\n );\n\n const faixaDe = (indice: number) => escalaPassos(String(indice)) ?? 0;\n\n // A escala alvo fixa as marcas; a animada posiciona o desenho. Sem separar as\n // duas, as marcas exibiriam valores quebrados durante a transicao.\n const escalaAlvo = useMemo(\n () => linearScale({ domain: dominio, range: [plot.height, 0] }),\n [dominio, plot.height],\n );\n\n const [minimo, maximo] = useTweenedNumbers(escalaAlvo.domain());\n\n const escalaValores = useMemo(\n () => linearScale({ domain: { min: minimo, max: maximo }, nice: false, range: [plot.height, 0] }),\n [maximo, minimo, plot.height],\n );\n\n const marcasDeValor = ticksFor(escalaAlvo, plot.height);\n\n const marcasPassos: AxisTick[] = steps.map((passo, indice) => ({\n label: passo.label,\n position: faixaDe(indice) + escalaPassos.bandwidth() / 2,\n }));\n\n const marcasValor: AxisTick[] = marcasDeValor.map((valor) => ({\n label: formatValue(valor),\n position: escalaValores(valor),\n }));\n\n function rotuloDe(passo: ChartWaterfallStep) {\n return passo.total ? formatValue(passo.value) : comSinal(passo.value, formatValue);\n }\n\n /** O passo diz quanto mudou; o acumulado, onde a conta ficou. O total ja e o proprio acumulado. */\n function linhasDoBalao(indice: number | null) {\n if (indice === null || !trechos[indice]) {\n return [];\n }\n\n const passo = steps[indice];\n\n if (passo.total) {\n return [{ color: cores[indice], label: 'Total', values: [passo.value] }];\n }\n\n return [\n { color: cores[indice], format: (valor: number) => comSinal(valor, formatTooltipValue ?? formatValue), label: 'Variação', values: [passo.value] },\n { label: 'Acumulado', values: [trechos[indice].fim] },\n ];\n }\n\n return (\n <CartesianFrame\n axisReveal={axisReveal}\n containerRef={ref}\n empty={steps.length === 0}\n emptyMessage={emptyMessage}\n grid={[\n {\n baseline: escalaValores(0),\n lines: marcasDeValor.map((valor) => escalaValores(valor)),\n orientation: 'horizontal',\n },\n ]}\n fillHeight={fillHeight}\n height={alturaDoDesenho}\n legendPosition=\"none\"\n margins={margins}\n plot={plot}\n title={title}\n tooltip={\n showTooltip\n ? {\n columns: [{ format: formatTooltipValue ?? formatValue }],\n computed: 'none',\n rows: linhasDoBalao(passoEmFoco),\n title: passoEmFoco === null ? undefined : steps[passoEmFoco]?.label,\n }\n : undefined\n }\n width={width}\n xAxis={{ labelRotation: rotation, ticks: marcasPassos, visibility: xAxis }}\n yAxis={{ hideLine: true, ticks: marcasValor, visibility: yAxis }}\n yAxisRight={{ hideLine: true, ticks: marcasValor, visibility: yAxisRight }}\n >\n {passoEmFoco !== null && (\n <BandCursor offset={faixaDe(passoEmFoco)} plot={plot} size={escalaPassos.bandwidth()} />\n )}\n\n <g aria-hidden=\"true\">\n {trechos.slice(0, -1).map((trecho, indice) => {\n if (!trecho || !trechos[indice + 1]) {\n return null;\n }\n\n const nivel = escalaValores(trecho.fim);\n\n return (\n <line\n className={styles.connector}\n key={indice}\n x1={faixaDe(indice) + escalaPassos.bandwidth()}\n x2={faixaDe(indice + 1)}\n y1={nivel}\n y2={nivel}\n />\n );\n })}\n </g>\n\n {steps.map((passo, indice) => {\n const trecho = trechos[indice];\n\n if (!trecho) {\n return null;\n }\n\n const topo = Math.min(escalaValores(trecho.inicio), escalaValores(trecho.fim));\n const altura = Math.abs(escalaValores(trecho.fim) - escalaValores(trecho.inicio));\n\n return (\n <path\n aria-label={`${passo.label}: ${rotuloDe(passo)}`}\n className={styles.bar}\n d={roundedBarPath(faixaDe(indice), topo, escalaPassos.bandwidth(), altura, [\n raioDoCanto,\n raioDoCanto,\n raioDoCanto,\n raioDoCanto,\n ])}\n fill={cores[indice]}\n key={indice}\n onMouseEnter={() => focarPasso(indice)}\n onMouseLeave={() => focarPasso(null)}\n />\n );\n })}\n\n {showDataLabels !== 'hidden' &&\n steps.map((passo, indice) => {\n const trecho = trechos[indice];\n\n if (!trecho) {\n return null;\n }\n\n const topo = Math.min(escalaValores(trecho.inicio), escalaValores(trecho.fim));\n\n return (\n <text\n className={`${styles.valueLabel} ${markShown(showDataLabels, indice === passoEmFoco) ? '' : styles.valueLabelHidden}`}\n key={indice}\n textAnchor=\"middle\"\n x={faixaDe(indice) + escalaPassos.bandwidth() / 2}\n y={topo - 6}\n >\n {rotuloDe(passo)}\n </text>\n );\n })}\n </CartesianFrame>\n );\n}\n"],"names":["trechosDe","steps","acumulado","passo","inicio","fim","intencaoDe","step","comSinal","value","formatValue","ChartWaterfall","emptyMessage","formatTooltipValue","formatarNumero","height","labelAngle","onHoverStep","showDataLabels","showTooltip","title","xAxis","yAxis","yAxisRight","font","alturaMedida","raioDoCanto","ref","width","useChartMetrics","fillHeight","alturaDoDesenho","chartHeight","focarPasso","passoEmFoco","useHoveredBand","trechos","useMemo","cores","resolveSeriesColors","dominio","domainOf","trecho","rotulosDeValor","valueLabelsFor","axisReveal","margins","plot","rotation","useCartesianLayout","valueLabelRoom","escalaPassos","bandScale","_","indice","faixaDe","escalaAlvo","linearScale","minimo","maximo","useTweenedNumbers","escalaValores","marcasDeValor","ticksFor","marcasPassos","marcasValor","valor","rotuloDe","linhasDoBalao","jsxs","CartesianFrame","_a","jsx","BandCursor","nivel","styles","topo","altura","roundedBarPath","markShown"],"mappings":"gqBA6DA,SAASA,GAAUC,EAAyD,CAC1E,IAAIC,EAAY,EAEhB,OAAOD,EAAM,IAAKE,GAAU,CAC1B,GAAI,CAAC,OAAO,SAASA,EAAM,KAAK,EAC9B,OAAO,KAGT,MAAMC,EAASD,EAAM,MAAQ,EAAID,EAC3BG,EAAMD,EAASD,EAAM,MAC3B,OAAAD,EAAYG,EAEL,CAAE,OAAAD,EAAQ,IAAAC,CAAA,CACnB,CAAC,CACH,CAGA,SAASC,GAAWC,EAAwC,CAC1D,OAAIA,EAAK,OACAA,EAAK,OAGVA,EAAK,MACA,UAGFA,EAAK,MAAQ,EAAI,WAAa,UACvC,CAMA,SAASC,EAASC,EAAeC,EAAwC,CACvE,OAAID,IAAU,EACLC,EAAY,CAAC,EAGf,GAAGD,EAAQ,EAAI,IAAM,GAAG,GAAGC,EAAY,KAAK,IAAID,CAAK,CAAC,CAAC,EAChE,CAEO,SAASE,GAAe,CAC7B,aAAAC,EAAe,uBACf,mBAAAC,EACA,YAAAH,EAAcI,GAAAA,eACd,OAAAC,EAAS,IACT,WAAAC,EAAa,OACb,YAAAC,EACA,eAAAC,EAAiB,UACjB,YAAAC,EAAc,GACd,MAAAlB,EACA,MAAAmB,EACA,MAAAC,EAAQ,UACR,MAAAC,EAAQ,UACR,WAAAC,EAAa,QACf,EAAwB,OACtB,KAAM,CAAE,KAAAC,EAAM,OAAQC,EAAc,OAAQC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