@yamada-ui/charts 1.5.4-next-20241005220055 → 1.5.4-next-20241008193728

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. package/dist/area-chart-gradient.d.mts +2 -2
  2. package/dist/area-chart-gradient.d.ts +2 -2
  3. package/dist/area-chart-gradient.js +7 -5
  4. package/dist/area-chart-gradient.js.map +1 -1
  5. package/dist/area-chart-gradient.mjs +1 -1
  6. package/dist/area-chart-split.d.mts +2 -2
  7. package/dist/area-chart-split.d.ts +2 -2
  8. package/dist/area-chart-split.js +4 -2
  9. package/dist/area-chart-split.js.map +1 -1
  10. package/dist/area-chart-split.mjs +1 -1
  11. package/dist/area-chart.d.mts +8 -8
  12. package/dist/area-chart.d.ts +8 -8
  13. package/dist/area-chart.js +190 -175
  14. package/dist/area-chart.js.map +1 -1
  15. package/dist/area-chart.mjs +13 -13
  16. package/dist/bar-chart.d.mts +8 -8
  17. package/dist/bar-chart.d.ts +8 -8
  18. package/dist/bar-chart.js +143 -127
  19. package/dist/bar-chart.js.map +1 -1
  20. package/dist/bar-chart.mjs +11 -11
  21. package/dist/chart-legend.d.mts +1 -1
  22. package/dist/chart-legend.d.ts +1 -1
  23. package/dist/chart-legend.js +4 -2
  24. package/dist/chart-legend.js.map +1 -1
  25. package/dist/chart-legend.mjs +3 -3
  26. package/dist/chart-tooltip.d.mts +4 -4
  27. package/dist/chart-tooltip.d.ts +4 -4
  28. package/dist/chart-tooltip.js +9 -7
  29. package/dist/chart-tooltip.js.map +1 -1
  30. package/dist/chart-tooltip.mjs +3 -3
  31. package/dist/chart-utils.js.map +1 -1
  32. package/dist/chart-utils.mjs +1 -1
  33. package/dist/chart.types.d.mts +14 -14
  34. package/dist/chart.types.d.ts +14 -14
  35. package/dist/chart.types.js.map +1 -1
  36. package/dist/{chunk-UANITMH7.mjs → chunk-5VLSGWQD.mjs} +10 -8
  37. package/dist/chunk-5VLSGWQD.mjs.map +1 -0
  38. package/dist/{chunk-XYUYAHJX.mjs → chunk-6JRMEI6J.mjs} +2 -2
  39. package/dist/chunk-6JRMEI6J.mjs.map +1 -0
  40. package/dist/{chunk-VKBRU4Z4.mjs → chunk-AYVTBRCS.mjs} +29 -28
  41. package/dist/chunk-AYVTBRCS.mjs.map +1 -0
  42. package/dist/{chunk-6O5G3WYP.mjs → chunk-EZG52466.mjs} +29 -21
  43. package/dist/chunk-EZG52466.mjs.map +1 -0
  44. package/dist/{chunk-VEFEKDMH.mjs → chunk-FDALM73K.mjs} +15 -14
  45. package/dist/chunk-FDALM73K.mjs.map +1 -0
  46. package/dist/{chunk-2GQHI23M.mjs → chunk-GU4SGNWX.mjs} +5 -5
  47. package/dist/chunk-GU4SGNWX.mjs.map +1 -0
  48. package/dist/{chunk-MVRWZTQ5.mjs → chunk-NLXYCM5J.mjs} +2 -2
  49. package/dist/chunk-NLXYCM5J.mjs.map +1 -0
  50. package/dist/{chunk-EXBYAVSP.mjs → chunk-NMPNNSBN.mjs} +76 -74
  51. package/dist/chunk-NMPNNSBN.mjs.map +1 -0
  52. package/dist/{chunk-AL4MDJ4U.mjs → chunk-NQPC5LPY.mjs} +84 -82
  53. package/dist/chunk-NQPC5LPY.mjs.map +1 -0
  54. package/dist/{chunk-MN7T76SY.mjs → chunk-OG5CVPPV.mjs} +5 -3
  55. package/dist/chunk-OG5CVPPV.mjs.map +1 -0
  56. package/dist/{chunk-LLOU2WIV.mjs → chunk-OUIKA4AX.mjs} +5 -3
  57. package/dist/chunk-OUIKA4AX.mjs.map +1 -0
  58. package/dist/{chunk-3EHZJFIA.mjs → chunk-PKQB4BFG.mjs} +28 -28
  59. package/dist/chunk-PKQB4BFG.mjs.map +1 -0
  60. package/dist/{chunk-C3ZYUDXE.mjs → chunk-QPMW56KA.mjs} +52 -48
  61. package/dist/chunk-QPMW56KA.mjs.map +1 -0
  62. package/dist/{chunk-IJRYXT4V.mjs → chunk-R2LOTDR3.mjs} +2 -2
  63. package/dist/{chunk-IJRYXT4V.mjs.map → chunk-R2LOTDR3.mjs.map} +1 -1
  64. package/dist/{chunk-LSCPL7PM.mjs → chunk-SCY5V45W.mjs} +58 -56
  65. package/dist/chunk-SCY5V45W.mjs.map +1 -0
  66. package/dist/{chunk-VGNCWS23.mjs → chunk-SYBJTMPL.mjs} +92 -90
  67. package/dist/chunk-SYBJTMPL.mjs.map +1 -0
  68. package/dist/{chunk-ZGXEF3LO.mjs → chunk-TA7YJAW4.mjs} +49 -47
  69. package/dist/chunk-TA7YJAW4.mjs.map +1 -0
  70. package/dist/{chunk-O3LMKYXK.mjs → chunk-TU6MKMMV.mjs} +29 -28
  71. package/dist/chunk-TU6MKMMV.mjs.map +1 -0
  72. package/dist/{chunk-QL3DB7OJ.mjs → chunk-TXNC7GLT.mjs} +1 -1
  73. package/dist/{chunk-QL3DB7OJ.mjs.map → chunk-TXNC7GLT.mjs.map} +1 -1
  74. package/dist/{chunk-NHHJ5XFF.mjs → chunk-U325CYNR.mjs} +8 -6
  75. package/dist/chunk-U325CYNR.mjs.map +1 -0
  76. package/dist/{chunk-OPPMMNGP.mjs → chunk-UER5GW4M.mjs} +33 -24
  77. package/dist/chunk-UER5GW4M.mjs.map +1 -0
  78. package/dist/{chunk-FYAC4RRZ.mjs → chunk-UTD4XZDM.mjs} +11 -10
  79. package/dist/chunk-UTD4XZDM.mjs.map +1 -0
  80. package/dist/{chunk-A3IWA366.mjs → chunk-VK65X6Q2.mjs} +4 -4
  81. package/dist/chunk-VK65X6Q2.mjs.map +1 -0
  82. package/dist/{chunk-OJ2MLZZ7.mjs → chunk-X6PIY2M3.mjs} +7 -7
  83. package/dist/chunk-X6PIY2M3.mjs.map +1 -0
  84. package/dist/{chunk-MSG3WFBO.mjs → chunk-YIAK5DIM.mjs} +7 -6
  85. package/dist/chunk-YIAK5DIM.mjs.map +1 -0
  86. package/dist/{chunk-ZXBE4ERW.mjs → chunk-YTUEG4IY.mjs} +47 -45
  87. package/dist/chunk-YTUEG4IY.mjs.map +1 -0
  88. package/dist/{chunk-VUTCH2CU.mjs → chunk-YX23LEQ7.mjs} +13 -13
  89. package/dist/chunk-YX23LEQ7.mjs.map +1 -0
  90. package/dist/{chunk-BQT5TIKZ.mjs → chunk-ZRV4LO67.mjs} +44 -42
  91. package/dist/chunk-ZRV4LO67.mjs.map +1 -0
  92. package/dist/donut-chart.js +97 -89
  93. package/dist/donut-chart.js.map +1 -1
  94. package/dist/donut-chart.mjs +10 -10
  95. package/dist/index.d.mts +14 -14
  96. package/dist/index.d.ts +14 -14
  97. package/dist/index.js +2084 -2036
  98. package/dist/index.js.map +1 -1
  99. package/dist/index.mjs +28 -28
  100. package/dist/index.mjs.map +1 -1
  101. package/dist/line-chart.d.mts +7 -7
  102. package/dist/line-chart.d.ts +7 -7
  103. package/dist/line-chart.js +146 -138
  104. package/dist/line-chart.js.map +1 -1
  105. package/dist/line-chart.mjs +11 -11
  106. package/dist/pie-chart-label.d.mts +9 -9
  107. package/dist/pie-chart-label.d.ts +9 -9
  108. package/dist/pie-chart-label.js +14 -13
  109. package/dist/pie-chart-label.js.map +1 -1
  110. package/dist/pie-chart-label.mjs +1 -1
  111. package/dist/pie-chart.d.mts +11 -11
  112. package/dist/pie-chart.d.ts +11 -11
  113. package/dist/pie-chart.js +95 -87
  114. package/dist/pie-chart.js.map +1 -1
  115. package/dist/pie-chart.mjs +9 -9
  116. package/dist/radar-chart.d.mts +11 -11
  117. package/dist/radar-chart.d.ts +11 -11
  118. package/dist/radar-chart.js +87 -73
  119. package/dist/radar-chart.js.map +1 -1
  120. package/dist/radar-chart.mjs +9 -9
  121. package/dist/radial-chart.d.mts +10 -10
  122. package/dist/radial-chart.d.ts +10 -10
  123. package/dist/radial-chart.js +69 -62
  124. package/dist/radial-chart.js.map +1 -1
  125. package/dist/radial-chart.mjs +10 -10
  126. package/dist/use-area-chart.d.mts +53 -53
  127. package/dist/use-area-chart.d.ts +53 -53
  128. package/dist/use-area-chart.js +50 -46
  129. package/dist/use-area-chart.js.map +1 -1
  130. package/dist/use-area-chart.mjs +2 -2
  131. package/dist/use-bar-chart.d.mts +32 -32
  132. package/dist/use-bar-chart.d.ts +32 -32
  133. package/dist/use-bar-chart.js +30 -21
  134. package/dist/use-bar-chart.js.map +1 -1
  135. package/dist/use-bar-chart.mjs +2 -2
  136. package/dist/use-chart-axis.d.mts +27 -27
  137. package/dist/use-chart-axis.d.ts +27 -27
  138. package/dist/use-chart-axis.js +26 -26
  139. package/dist/use-chart-axis.js.map +1 -1
  140. package/dist/use-chart-axis.mjs +2 -2
  141. package/dist/use-chart-grid.d.mts +8 -8
  142. package/dist/use-chart-grid.d.ts +8 -8
  143. package/dist/use-chart-grid.js +3 -3
  144. package/dist/use-chart-grid.js.map +1 -1
  145. package/dist/use-chart-grid.mjs +2 -2
  146. package/dist/use-chart-label-list.d.mts +4 -4
  147. package/dist/use-chart-label-list.d.ts +4 -4
  148. package/dist/use-chart-label-list.js +5 -4
  149. package/dist/use-chart-label-list.js.map +1 -1
  150. package/dist/use-chart-label-list.mjs +2 -2
  151. package/dist/use-chart-label.d.mts +1 -1
  152. package/dist/use-chart-label.d.ts +1 -1
  153. package/dist/use-chart-label.js.map +1 -1
  154. package/dist/use-chart-label.mjs +2 -2
  155. package/dist/use-chart-legend.d.mts +1 -1
  156. package/dist/use-chart-legend.d.ts +1 -1
  157. package/dist/use-chart-legend.js +1 -1
  158. package/dist/use-chart-legend.js.map +1 -1
  159. package/dist/use-chart-legend.mjs +1 -1
  160. package/dist/use-chart-reference-line.d.mts +4 -4
  161. package/dist/use-chart-reference-line.d.ts +4 -4
  162. package/dist/use-chart-reference-line.js +8 -7
  163. package/dist/use-chart-reference-line.js.map +1 -1
  164. package/dist/use-chart-reference-line.mjs +2 -2
  165. package/dist/use-chart-tooltip.d.mts +7 -7
  166. package/dist/use-chart-tooltip.d.ts +7 -7
  167. package/dist/use-chart-tooltip.js +4 -4
  168. package/dist/use-chart-tooltip.js.map +1 -1
  169. package/dist/use-chart-tooltip.mjs +2 -2
  170. package/dist/use-chart.d.mts +6 -10
  171. package/dist/use-chart.d.ts +6 -10
  172. package/dist/use-chart.js +2 -2
  173. package/dist/use-chart.js.map +1 -1
  174. package/dist/use-chart.mjs +2 -2
  175. package/dist/use-line-chart.d.mts +43 -43
  176. package/dist/use-line-chart.d.ts +43 -43
  177. package/dist/use-line-chart.js +26 -25
  178. package/dist/use-line-chart.js.map +1 -1
  179. package/dist/use-line-chart.mjs +2 -2
  180. package/dist/use-pie-chart.d.mts +47 -47
  181. package/dist/use-pie-chart.d.ts +47 -47
  182. package/dist/use-pie-chart.js +40 -38
  183. package/dist/use-pie-chart.js.map +1 -1
  184. package/dist/use-pie-chart.mjs +3 -3
  185. package/dist/use-polar-grid.d.mts +5 -5
  186. package/dist/use-polar-grid.d.ts +5 -5
  187. package/dist/use-polar-grid.js.map +1 -1
  188. package/dist/use-polar-grid.mjs +2 -2
  189. package/dist/use-radar-chart.d.mts +41 -41
  190. package/dist/use-radar-chart.d.ts +41 -41
  191. package/dist/use-radar-chart.js +27 -19
  192. package/dist/use-radar-chart.js.map +1 -1
  193. package/dist/use-radar-chart.mjs +2 -2
  194. package/dist/use-radial-chart.d.mts +17 -17
  195. package/dist/use-radial-chart.d.ts +17 -17
  196. package/dist/use-radial-chart.js +11 -11
  197. package/dist/use-radial-chart.js.map +1 -1
  198. package/dist/use-radial-chart.mjs +2 -2
  199. package/package.json +3 -3
  200. package/dist/chunk-2GQHI23M.mjs.map +0 -1
  201. package/dist/chunk-3EHZJFIA.mjs.map +0 -1
  202. package/dist/chunk-6O5G3WYP.mjs.map +0 -1
  203. package/dist/chunk-A3IWA366.mjs.map +0 -1
  204. package/dist/chunk-AL4MDJ4U.mjs.map +0 -1
  205. package/dist/chunk-BQT5TIKZ.mjs.map +0 -1
  206. package/dist/chunk-C3ZYUDXE.mjs.map +0 -1
  207. package/dist/chunk-EXBYAVSP.mjs.map +0 -1
  208. package/dist/chunk-FYAC4RRZ.mjs.map +0 -1
  209. package/dist/chunk-LLOU2WIV.mjs.map +0 -1
  210. package/dist/chunk-LSCPL7PM.mjs.map +0 -1
  211. package/dist/chunk-MN7T76SY.mjs.map +0 -1
  212. package/dist/chunk-MSG3WFBO.mjs.map +0 -1
  213. package/dist/chunk-MVRWZTQ5.mjs.map +0 -1
  214. package/dist/chunk-NHHJ5XFF.mjs.map +0 -1
  215. package/dist/chunk-O3LMKYXK.mjs.map +0 -1
  216. package/dist/chunk-OJ2MLZZ7.mjs.map +0 -1
  217. package/dist/chunk-OPPMMNGP.mjs.map +0 -1
  218. package/dist/chunk-UANITMH7.mjs.map +0 -1
  219. package/dist/chunk-VEFEKDMH.mjs.map +0 -1
  220. package/dist/chunk-VGNCWS23.mjs.map +0 -1
  221. package/dist/chunk-VKBRU4Z4.mjs.map +0 -1
  222. package/dist/chunk-VUTCH2CU.mjs.map +0 -1
  223. package/dist/chunk-XYUYAHJX.mjs.map +0 -1
  224. package/dist/chunk-ZGXEF3LO.mjs.map +0 -1
  225. package/dist/chunk-ZXBE4ERW.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-pie-chart.ts"],"sourcesContent":["import type {\n CSSUIObject,\n CSSUIProps,\n PropGetter,\n RequiredPropGetter,\n} from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type { ComponentPropsWithoutRef } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport type { CellProps, PieChartProps, PieProps } from \"./chart.types\"\nimport { getVar, useTheme } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport { getClassName, getComponentProps } from \"./chart-utils\"\nimport { pieChartLabel, pieChartLabelLine } from \"./pie-chart-label\"\nimport { pieChartProperties, pieProperties } from \"./rechart-properties\"\n\nexport interface UsePieChartOptions {\n /**\n * Chart data.\n */\n data: CellProps[]\n /**\n * Controls angle at which chart ends.\n *\n * @default -270\n */\n endAngle?: number\n /**\n * Controls fill opacity of all pies.\n *\n * @default 1\n */\n fillOpacity?: [number, number] | number\n /**\n * Controls innerRadius of the chart segments.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '0%'\n */\n innerRadius?: number | string\n /**\n * Determines whether labels should be displayed as percentages.\n *\n * @default false\n */\n isPercent?: boolean\n /**\n * A function to format labels.\n */\n labelFormatter?: (value: number) => string\n /**\n * Distance between chart and label.\n */\n labelOffset?: number\n /**\n * Controls thickness of the chart segments. If it is a number, it is calculated as px.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '80%'\n */\n outerRadius?: number | string\n /**\n * Controls padding between segments.\n *\n * @default 0\n */\n paddingAngle?: number\n /**\n * Controls angle at which chart starts.\n *\n * @default 90\n */\n startAngle?: number\n /**\n * Stroke width for the chart pies.\n *\n * @default 1\n */\n strokeWidth?: number\n /**\n * Determines whether segments labels should have lines that connect the segment with the label.\n *\n * @default false\n */\n withLabelLines?: boolean\n /**\n * Determines whether each segment should have associated label.\n *\n * @default false\n */\n withLabels?: boolean\n /**\n * Props for the cell.\n */\n cellProps?: Partial<CellProps>\n /**\n * Props passed down to recharts `PieChart` component.\n */\n chartProps?: PieChartProps\n /**\n * Props for the pie.\n */\n pieProps?: Partial<PieProps>\n}\n\ninterface UsePieChartProps extends UsePieChartOptions {\n styles: Dict<CSSUIObject | undefined>\n}\n\nexport const usePieChart = ({\n data,\n endAngle = -270,\n fillOpacity = 1,\n innerRadius = \"0%\",\n isPercent = false,\n labelFormatter,\n labelOffset,\n withLabels = false,\n outerRadius = withLabels ? \"80%\" : \"100%\",\n paddingAngle = 0,\n startAngle = 90,\n strokeWidth = 1,\n styles,\n withLabelLines = false,\n ...rest\n}: UsePieChartProps) => {\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<null | string>(null)\n const shouldHighlight = highlightedArea !== null\n const { dimCell, ...computedCellProps } = rest.cellProps ?? {}\n const {\n activeShape = {},\n inactiveShape = {},\n label: labelProps,\n labelLine: labelLineProps,\n ...computedPieProps\n } = rest.pieProps ?? {}\n\n const cellColors: CSSUIProps[\"vars\"] = useMemo(\n () =>\n data.map(({ color }, index) => ({\n name: `cell-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [data],\n )\n\n const pieVars: CSSUIProps[\"vars\"] = useMemo(\n () =>\n [\n ...cellColors,\n { name: \"fill-opacity\", value: fillOpacity },\n ] as Required<CSSUIProps>[\"vars\"],\n [fillOpacity, cellColors],\n )\n\n const [chartProps, chartClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [rest.chartProps ?? {}, pieChartProperties],\n styles.chart,\n )(theme),\n [rest.chartProps, styles.chart, theme],\n )\n\n const [pieProps, pieClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [computedPieProps, pieProperties],\n styles.pie,\n )(theme),\n [computedPieProps, styles.pie, theme],\n )\n\n const cellClassName = useMemo(() => {\n const resolvedCellProps = {\n fillOpacity: \"$fill-opacity\",\n ...styles.cell,\n ...computedCellProps,\n }\n\n return getClassName(resolvedCellProps)(theme)\n }, [computedCellProps, styles.cell, theme])\n\n const dimCellClassName = useMemo(() => {\n const resolvedDimCell = { fillOpacity: 0.3, strokeOpacity: 0, ...dimCell }\n\n return getClassName(resolvedDimCell)(theme)\n }, [dimCell, theme])\n\n const activeShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [{ _focus: { outline: \"none\" }, ...activeShape }, pieProperties],\n styles.activeShape,\n )(theme, true),\n [activeShape, styles.activeShape, theme],\n )\n\n const inactiveShapeProps = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [inactiveShape, pieProperties],\n styles.inactiveShape,\n )(theme, true),\n [inactiveShape, styles.inactiveShape, theme],\n )\n\n const label: Recharts.PieLabel = useCallback(\n (props: any) =>\n pieChartLabel({\n isPercent,\n labelFormatter,\n labelOffset,\n styles: styles.label,\n labelProps,\n ...props,\n }),\n [isPercent, labelOffset, labelProps, styles.label, labelFormatter],\n )\n\n const labelLine = useCallback(\n (props: any) => {\n return pieChartLabelLine({\n labelOffset,\n styles: styles.labelLine,\n labelLineProps,\n ...props,\n })\n },\n [labelLineProps, labelOffset, styles.labelLine],\n )\n\n const cellPropList = useMemo(\n () =>\n data.map((props, index) => {\n const { name, dimCell = {}, ...computedProps } = props\n const color = getVar(`cell-${index}`)(theme)\n const dimmed = shouldHighlight && highlightedArea !== name\n const resolvedProps = {\n ...computedProps,\n ...(dimmed ? dimCell : {}),\n }\n\n const className = getClassName(\n {\n cellClassName,\n ...resolvedProps,\n },\n dimmed ? dimCellClassName : undefined,\n )(theme)\n\n return {\n className,\n color,\n }\n }),\n [\n cellClassName,\n data,\n dimCellClassName,\n highlightedArea,\n shouldHighlight,\n theme,\n ],\n )\n\n const getPieChartProps: PropGetter<\n ComponentPropsWithoutRef<typeof Recharts.PieChart>,\n ComponentPropsWithoutRef<typeof Recharts.PieChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, chartClassName),\n ...props,\n ...chartProps,\n }),\n [chartProps, chartClassName],\n )\n\n const getPieProps: RequiredPropGetter<\n Partial<Recharts.PieProps>,\n Omit<Recharts.PieProps, \"ref\">\n > = useCallback(\n ({ className, ...props }, ref = null) => ({\n ref,\n className: cx(className, pieClassName),\n activeShape: activeShapeProps,\n data,\n dataKey: \"value\",\n endAngle,\n inactiveShape: inactiveShapeProps,\n innerRadius,\n isAnimationActive: false,\n label: withLabels ? label : false,\n labelLine: withLabelLines ? labelLine : false,\n outerRadius,\n paddingAngle,\n rootTabIndex: -1,\n startAngle,\n ...(props as Omit<Recharts.PieProps, \"dataKey\">),\n ...pieProps,\n }),\n [\n pieClassName,\n data,\n outerRadius,\n innerRadius,\n paddingAngle,\n startAngle,\n endAngle,\n withLabels,\n label,\n withLabelLines,\n labelLine,\n activeShapeProps,\n inactiveShapeProps,\n pieProps,\n ],\n )\n\n const getCellProps: RequiredPropGetter<\n { index: number } & Omit<Recharts.CellProps, \"ref\">,\n Recharts.CellProps\n > = useCallback(\n ({ className: classNameProp, index, ...props }, ref = null) => {\n const { className, color } = cellPropList[index] ?? {}\n\n return {\n ref,\n className: cx(classNameProp, className),\n fill: color,\n stroke: color,\n strokeWidth,\n ...(props as Recharts.CellProps),\n }\n },\n [cellPropList, strokeWidth],\n )\n\n return {\n pieVars,\n setHighlightedArea,\n getCellProps,\n getPieChartProps,\n getPieProps,\n }\n}\n\nexport type UsePieChartReturn = ReturnType<typeof usePieChart>\n"],"mappings":";;;;;;;;;;;;;;;AAUA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,UAAU;AACnB,SAAS,aAAa,SAAS,gBAAgB;AAoGxC,IAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,cAAc,aAAa,QAAQ;AAAA,EACnC,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd;AAAA,EACA,iBAAiB;AAAA,EACjB,GAAG;AACL,MAAwB;AAhIxB;AAiIE,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAwB,IAAI;AAC1E,QAAM,kBAAkB,oBAAoB;AAC5C,QAAM,EAAE,SAAS,GAAG,kBAAkB,KAAI,UAAK,cAAL,YAAkB,CAAC;AAC7D,QAAM;AAAA,IACJ,cAAc,CAAC;AAAA,IACf,gBAAgB,CAAC;AAAA,IACjB,OAAO;AAAA,IACP,WAAW;AAAA,IACX,GAAG;AAAA,EACL,KAAI,UAAK,aAAL,YAAiB,CAAC;AAEtB,QAAM,aAAiC;AAAA,IACrC,MACE,KAAK,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;AAAA,MAC9B,MAAM,QAAQ,KAAK;AAAA,MACnB,OAAO;AAAA,MACP,OAAO,wBAAS;AAAA,IAClB,EAAE;AAAA,IACJ,CAAC,IAA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18
  getClassName,
19
19
  getComponentProps
20
20
  };
21
- //# sourceMappingURL=chunk-QL3DB7OJ.mjs.map
21
+ //# sourceMappingURL=chunk-TXNC7GLT.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/chart-utils.ts"],"sourcesContent":["import type { StyledTheme } from \"@yamada-ui/core\"\nimport { getCSS } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { cx, isString, splitObject } from \"@yamada-ui/utils\"\n\nexport const getClassName =\n (...styles: (Dict | string | undefined)[]) =>\n (theme: StyledTheme) =>\n cx(\n ...styles.map((style) =>\n isString(style) ? style : getCSS(style)(theme),\n ),\n )\n\nexport const getComponentProps =\n <T extends Dict, K extends keyof T>(\n [obj, keys]: [T, K[]],\n ...props: (Dict | string | undefined)[]\n ) =>\n <P extends boolean = false>(theme: StyledTheme, isContain?: P) => {\n const [pickedProps, omittedProps] = splitObject<T, K>(obj, keys)\n const className = getClassName(...props, omittedProps)(theme)\n\n return (\n !isContain ? [pickedProps, className] : { ...pickedProps, className }\n ) as P extends false\n ? [{ [P in K]: T[P] }, string]\n : { [P in K]: T[P] } & { className: string }\n }\n"],"mappings":";;;AACA,SAAS,cAAc;AAEvB,SAAS,IAAI,UAAU,mBAAmB;AAEnC,IAAM,eACX,IAAI,WACJ,CAAC,UACC;AAAA,EACE,GAAG,OAAO;AAAA,IAAI,CAAC,UACb,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK,EAAE,KAAK;AAAA,EAC/C;AACF;AAEG,IAAM,oBACX,CACE,CAAC,KAAK,IAAI,MACP,UAEL,CAA4B,OAAoB,cAAkB;AAChE,QAAM,CAAC,aAAa,YAAY,IAAI,YAAkB,KAAK,IAAI;AAC/D,QAAM,YAAY,aAAa,GAAG,OAAO,YAAY,EAAE,KAAK;AAE5D,SACE,CAAC,YAAY,CAAC,aAAa,SAAS,IAAI,EAAE,GAAG,aAAa,UAAU;AAIxE;","names":[]}
1
+ {"version":3,"sources":["../src/chart-utils.ts"],"sourcesContent":["import type { StyledTheme } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport { getCSS } from \"@yamada-ui/core\"\nimport { cx, isString, splitObject } from \"@yamada-ui/utils\"\n\nexport const getClassName =\n (...styles: (Dict | string | undefined)[]) =>\n (theme: StyledTheme) =>\n cx(\n ...styles.map((style) =>\n isString(style) ? style : getCSS(style)(theme),\n ),\n )\n\nexport const getComponentProps =\n <T extends Dict, K extends keyof T>(\n [obj, keys]: [T, K[]],\n ...props: (Dict | string | undefined)[]\n ) =>\n <P extends boolean = false>(theme: StyledTheme, isContain?: P) => {\n const [pickedProps, omittedProps] = splitObject<T, K>(obj, keys)\n const className = getClassName(...props, omittedProps)(theme)\n\n return (\n !isContain ? [pickedProps, className] : { ...pickedProps, className }\n ) as P extends false\n ? [{ [P in K]: T[P] }, string]\n : { [P in K]: T[P] } & { className: string }\n }\n"],"mappings":";;;AAEA,SAAS,cAAc;AACvB,SAAS,IAAI,UAAU,mBAAmB;AAEnC,IAAM,eACX,IAAI,WACJ,CAAC,UACC;AAAA,EACE,GAAG,OAAO;AAAA,IAAI,CAAC,UACb,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK,EAAE,KAAK;AAAA,EAC/C;AACF;AAEG,IAAM,oBACX,CACE,CAAC,KAAK,IAAI,MACP,UAEL,CAA4B,OAAoB,cAAkB;AAChE,QAAM,CAAC,aAAa,YAAY,IAAI,YAAkB,KAAK,IAAI;AAC/D,QAAM,YAAY,aAAa,GAAG,OAAO,YAAY,EAAE,KAAK;AAE5D,SACE,CAAC,YAAY,CAAC,aAAa,SAAS,IAAI,EAAE,GAAG,aAAa,UAAU;AAIxE;","names":[]}
@@ -3,22 +3,24 @@
3
3
  // src/area-chart-gradient.tsx
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  var AreaGradient = ({
6
- color,
7
6
  id,
8
- withGradient,
9
- fillOpacity
7
+ color,
8
+ fillOpacity,
9
+ withGradient
10
10
  }) => {
11
11
  if (withGradient) {
12
- return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
12
+ return /* @__PURE__ */ jsxs("linearGradient", { id, x1: "0", x2: "0", y1: "0", y2: "1", children: [
13
13
  /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: fillOpacity }),
14
14
  /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.01 })
15
15
  ] });
16
16
  } else {
17
- return /* @__PURE__ */ jsx("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: /* @__PURE__ */ jsx("stop", { stopColor: color, stopOpacity: fillOpacity }) });
17
+ return /* @__PURE__ */ jsx("linearGradient", { id, x1: "0", x2: "0", y1: "0", y2: "1", children: /* @__PURE__ */ jsx("stop", { stopColor: color, stopOpacity: fillOpacity }) });
18
18
  }
19
19
  };
20
+ AreaGradient.displayName = "AreaGradient";
21
+ AreaGradient.__ui__ = "AreaGradient";
20
22
 
21
23
  export {
22
24
  AreaGradient
23
25
  };
24
- //# sourceMappingURL=chunk-NHHJ5XFF.mjs.map
26
+ //# sourceMappingURL=chunk-U325CYNR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/area-chart-gradient.tsx"],"sourcesContent":["import type { FC } from \"@yamada-ui/core\"\n\nexport interface AreaGradientProps {\n fillOpacity: number | string\n id?: string\n color?: string\n withGradient?: boolean\n}\n\nexport const AreaGradient: FC<AreaGradientProps> = ({\n id,\n color,\n fillOpacity,\n withGradient,\n}) => {\n if (withGradient) {\n return (\n <linearGradient id={id} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={color} stopOpacity={fillOpacity} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0.01} />\n </linearGradient>\n )\n } else {\n return (\n <linearGradient id={id} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n <stop stopColor={color} stopOpacity={fillOpacity} />\n </linearGradient>\n )\n }\n}\n\nAreaGradient.displayName = \"AreaGradient\"\nAreaGradient.__ui__ = \"AreaGradient\"\n"],"mappings":";;;AAiBM,SACE,KADF;AARC,IAAM,eAAsC,CAAC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,MAAI,cAAc;AAChB,WACE,qBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C;AAAA,0BAAC,UAAK,QAAO,MAAK,WAAW,OAAO,aAAa,aAAa;AAAA,MAC9D,oBAAC,UAAK,QAAO,QAAO,WAAW,OAAO,aAAa,MAAM;AAAA,OAC3D;AAAA,EAEJ,OAAO;AACL,WACE,oBAAC,oBAAe,IAAQ,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,KAC9C,8BAAC,UAAK,WAAW,OAAO,aAAa,aAAa,GACpD;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;AAC3B,aAAa,SAAS;","names":[]}
@@ -5,26 +5,26 @@ import {
5
5
  } from "./chunk-6YUJLLGN.mjs";
6
6
  import {
7
7
  getComponentProps
8
- } from "./chunk-QL3DB7OJ.mjs";
8
+ } from "./chunk-TXNC7GLT.mjs";
9
9
 
10
10
  // src/use-bar-chart.tsx
11
11
  import { getVar, useTheme } from "@yamada-ui/core";
12
12
  import { cx, runIfFunc } from "@yamada-ui/utils";
13
- import { useCallback, useState, useId, useMemo } from "react";
13
+ import { useCallback, useId, useMemo, useState } from "react";
14
14
  import { Bar, Cell } from "recharts";
15
15
  import { jsx } from "react/jsx-runtime";
16
16
  var useBarChart = ({
17
- data,
18
- series,
19
17
  type = "default",
20
- layoutType = "horizontal",
21
- referenceLineProps = [],
18
+ cell = defaultBarCell,
19
+ data,
22
20
  fillOpacity = 1,
21
+ layoutType = "horizontal",
22
+ series,
23
+ styles,
23
24
  syncId,
24
25
  xAxisLabel,
25
26
  yAxisLabel,
26
- styles,
27
- cell = defaultBarCell,
27
+ referenceLineProps = [],
28
28
  ...rest
29
29
  }) => {
30
30
  var _a;
@@ -103,9 +103,9 @@ var useBarChart = ({
103
103
  const barPropsList = useMemo(
104
104
  () => series.map((props, index) => {
105
105
  const {
106
- dataKey,
107
106
  activeBar: activeBar2 = {},
108
107
  background: background2 = {},
108
+ dataKey,
109
109
  dimBar: dimBar2 = {},
110
110
  ...computedProps
111
111
  } = props;
@@ -159,20 +159,29 @@ var useBarChart = ({
159
159
  ]
160
160
  );
161
161
  const getBarProps = useCallback(
162
- ({ index, className: classNameProp, ...props }, ref = null) => {
163
- const { id, className, activeBar: activeBar2, background: background2, color, dataKey, ...rest2 } = barPropsList[index];
162
+ ({ className: classNameProp, index, ...props }, ref = null) => {
163
+ var _a2;
164
+ const {
165
+ id,
166
+ className,
167
+ activeBar: activeBar2,
168
+ background: background2,
169
+ color,
170
+ dataKey = "",
171
+ ...rest2
172
+ } = (_a2 = barPropsList[index]) != null ? _a2 : {};
164
173
  return {
174
+ id,
165
175
  ref,
176
+ name: dataKey,
166
177
  className: cx(classNameProp, className),
167
178
  activeBar: activeBar2,
168
179
  background: background2,
169
- id,
170
- name: dataKey,
171
180
  dataKey,
172
181
  fill: color,
173
- stroke: color,
174
182
  isAnimationActive: false,
175
183
  stackId: stacked ? "stack" : void 0,
184
+ stroke: color,
176
185
  ...props,
177
186
  ...rest2
178
187
  };
@@ -186,9 +195,9 @@ var useBarChart = ({
186
195
  return /* @__PURE__ */ jsx(
187
196
  Bar,
188
197
  {
189
- ...getBarProps({ index, className: "ui-bar-chart__bar" }),
198
+ ...getBarProps({ className: "ui-bar-chart__bar", index }),
190
199
  children: data.map(
191
- (data2, index2) => runIfFunc(cell, { series: series2, data: data2, index: index2, hasStack })
200
+ (data2, index2) => runIfFunc(cell, { data: data2, hasStack, index: index2, series: series2 })
192
201
  )
193
202
  },
194
203
  `bar-${dataKey}`
@@ -200,14 +209,14 @@ var useBarChart = ({
200
209
  ref,
201
210
  className: cx(className, barChartClassName),
202
211
  data,
203
- stackOffset: type === "percent" ? "expand" : void 0,
204
212
  layout: layoutType,
205
- syncId,
206
213
  margin: {
207
214
  bottom: xAxisLabel ? 30 : void 0,
208
215
  left: yAxisLabel ? 10 : void 0,
209
216
  right: yAxisLabel ? 5 : void 0
210
217
  },
218
+ stackOffset: type === "percent" ? "expand" : void 0,
219
+ syncId,
211
220
  ...props,
212
221
  ...chartProps
213
222
  }),
@@ -225,16 +234,16 @@ var useBarChart = ({
225
234
  return {
226
235
  bars,
227
236
  barVars,
228
- getBarProps,
237
+ setHighlightedArea,
229
238
  getBarChartProps,
230
- setHighlightedArea
239
+ getBarProps
231
240
  };
232
241
  };
233
242
  var defaultBarCell = ({
234
- hasStack,
235
- series,
236
243
  data,
237
- index
244
+ hasStack,
245
+ index,
246
+ series
238
247
  }) => {
239
248
  const { dataKey } = series;
240
249
  const key = `cell-${dataKey}-${index}`;
@@ -250,4 +259,4 @@ var defaultBarCell = ({
250
259
  export {
251
260
  useBarChart
252
261
  };
253
- //# sourceMappingURL=chunk-OPPMMNGP.mjs.map
262
+ //# sourceMappingURL=chunk-UER5GW4M.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-bar-chart.tsx"],"sourcesContent":["import type {\n CSSUIObject,\n CSSUIProps,\n PropGetter,\n RequiredPropGetter,\n} from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type { ComponentPropsWithoutRef, FC, ReactNode } from \"react\"\nimport type * as Recharts from \"recharts\"\nimport type {\n BarChartProps,\n BarChartType,\n BarProps,\n ChartLayoutType,\n ReferenceLineProps,\n} from \"./chart.types\"\nimport { getVar, useTheme } from \"@yamada-ui/core\"\nimport { cx, runIfFunc } from \"@yamada-ui/utils\"\nimport { useCallback, useId, useMemo, useState } from \"react\"\nimport { Bar, Cell } from \"recharts\"\nimport { getComponentProps } from \"./chart-utils\"\nimport { barChartProperties, barProperties } from \"./rechart-properties\"\n\nexport interface UseBarChartOptions {\n /**\n * Chart data.\n */\n data: Dict[]\n /**\n * An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array.\n */\n series: BarProps[]\n /**\n * Controls how chart bars are positioned relative to each other.\n *\n * @default `default`\n */\n type?: BarChartType\n /**\n * A function that returns a component that renders the bar cells.\n */\n cell?: FC<BarCellProps> | ReactNode\n /**\n * Controls fill opacity of all bars.\n *\n * @default 1\n */\n fillOpacity?: [number, number] | number\n /**\n * Chart orientation.\n *\n * @default 'horizontal'\n */\n layoutType?: ChartLayoutType\n /**\n * If any two categorical charts have the same syncId,\n * these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.\n */\n syncId?: number | string\n /**\n * A label to display below the X axis.\n */\n xAxisLabel?: string\n /**\n * A label to display below the Y axis.\n */\n yAxisLabel?: string\n /**\n * Props for the bars.\n */\n barProps?: Partial<BarProps>\n /**\n * Props passed down to recharts `BarChart` component.\n */\n chartProps?: BarChartProps\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n}\n\nexport interface UseBarChartProps extends UseBarChartOptions {\n styles: Dict<CSSUIObject | undefined>\n}\n\nexport const useBarChart = ({\n type = \"default\",\n cell = defaultBarCell,\n data,\n fillOpacity = 1,\n layoutType = \"horizontal\",\n series,\n styles,\n syncId,\n xAxisLabel,\n yAxisLabel,\n referenceLineProps = [],\n ...rest\n}: UseBarChartProps) => {\n const uuid = useId()\n const { theme } = useTheme()\n const [highlightedArea, setHighlightedArea] = useState<null | string>(null)\n const stacked = type === \"stacked\" || type === \"percent\"\n const shouldHighlight = highlightedArea !== null\n const {\n activeBar = {},\n background = {},\n dimBar,\n ...computedBarProps\n } = rest.barProps ?? {}\n\n const barColors: CSSUIProps[\"vars\"] = useMemo(\n () =>\n series.map(({ color }, index) => ({\n name: `bar-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [series],\n )\n\n const referenceLineColors: CSSUIProps[\"vars\"] = useMemo(\n () =>\n referenceLineProps.map(({ color }, index) => ({\n name: `reference-line-${index}`,\n token: \"colors\",\n value: color ?? \"transparent\",\n })),\n [referenceLineProps],\n )\n\n const barVars: CSSUIProps[\"vars\"] = useMemo(() => {\n return [\n ...barColors,\n ...referenceLineColors,\n { name: \"fill-opacity\", value: fillOpacity },\n ]\n }, [barColors, fillOpacity, referenceLineColors])\n\n const [chartProps, barChartClassName] = useMemo(() => {\n const resolvedBarChartProps = { barGap: 8, ...rest.chartProps }\n\n return getComponentProps<Dict, string>(\n [resolvedBarChartProps, barChartProperties],\n styles.chart,\n )(theme)\n }, [rest.chartProps, styles.chart, theme])\n\n const [barProps, barClassName] = useMemo(() => {\n const resolvedBarProps = {\n fillOpacity: \"$fill-opacity\",\n strokeOpacity: 1,\n ...computedBarProps,\n }\n\n return getComponentProps<Dict, string>(\n [resolvedBarProps, barProperties],\n styles.bar,\n )(theme)\n }, [computedBarProps, styles.bar, theme])\n\n const [dimBarProps, dimBarClassName] = useMemo(() => {\n const resolvedDimBar = { fillOpacity: 0.3, strokeOpacity: 0, ...dimBar }\n\n return getComponentProps<Dict, string>([resolvedDimBar, barProperties])(\n theme,\n )\n }, [dimBar, theme])\n\n const [activeBarProps, activeBarClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [activeBar, barProperties],\n styles.activeBar,\n )(theme),\n [activeBar, styles.activeBar, theme],\n )\n\n const [backgroundProps, backgroundClassName] = useMemo(\n () =>\n getComponentProps<Dict, string>(\n [background, barProperties],\n styles.background,\n )(theme),\n [background, styles.background, theme],\n )\n\n const barPropsList = useMemo(\n () =>\n series.map((props, index) => {\n const {\n activeBar = {},\n background = {},\n dataKey,\n dimBar = {},\n ...computedProps\n } = props\n const id = `${uuid}-${dataKey}`\n const color = getVar(`bar-${index}`)(theme)\n const dimmed = shouldHighlight && highlightedArea !== dataKey\n const computedDimBar = { ...dimBarProps, ...dimBar }\n const resolvedProps = {\n ...barProps,\n ...computedProps,\n ...(dimmed ? computedDimBar : {}),\n }\n\n const rest = getComponentProps<Dict, string>(\n [resolvedProps, barProperties],\n barClassName,\n dimmed ? dimBarClassName : undefined,\n )(theme, true)\n\n const computedActiveBar = { ...activeBarProps, ...activeBar }\n\n const resolvedActiveBar = getComponentProps<Dict, string>(\n [computedActiveBar, barProperties],\n activeBarClassName,\n )(theme, true)\n\n const computedBackground = { ...backgroundProps, ...background }\n\n const resolvedBackground = getComponentProps<Dict, string>(\n [computedBackground, barProperties],\n backgroundClassName,\n )(theme, true)\n\n return {\n ...rest,\n id,\n activeBar: resolvedActiveBar,\n background: resolvedBackground,\n color,\n dataKey,\n }\n }),\n [\n activeBarClassName,\n activeBarProps,\n backgroundClassName,\n backgroundProps,\n barClassName,\n barProps,\n dimBarClassName,\n dimBarProps,\n highlightedArea,\n series,\n shouldHighlight,\n theme,\n uuid,\n ],\n )\n\n const getBarProps: RequiredPropGetter<\n { index: number } & Partial<Recharts.BarProps>,\n Omit<Recharts.BarProps, \"ref\">\n > = useCallback(\n ({ className: classNameProp, index, ...props }, ref = null) => {\n const {\n id,\n className,\n activeBar,\n background,\n color,\n dataKey = \"\",\n ...rest\n } = barPropsList[index] ?? {}\n\n return {\n id,\n ref,\n name: dataKey,\n className: cx(classNameProp, className),\n activeBar,\n background,\n dataKey,\n fill: color,\n isAnimationActive: false,\n stackId: stacked ? \"stack\" : undefined,\n stroke: color,\n ...(props as Omit<Recharts.BarProps, \"dataKey\">),\n ...rest,\n } as Recharts.BarProps\n },\n [barPropsList, stacked],\n )\n\n const bars = useMemo(() => {\n const hasStack = series.some((entry) => entry.stackId)\n\n return series.map((series, index) => {\n const { dataKey } = series\n\n return (\n <Bar\n key={`bar-${dataKey}`}\n {...getBarProps({ className: \"ui-bar-chart__bar\", index })}\n >\n {data.map((data, index) =>\n runIfFunc(cell, { data, hasStack, index, series }),\n )}\n </Bar>\n )\n })\n }, [series, getBarProps, cell, data])\n\n const getBarChartProps: PropGetter<\n ComponentPropsWithoutRef<typeof Recharts.BarChart>,\n ComponentPropsWithoutRef<typeof Recharts.BarChart>\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(className, barChartClassName),\n data,\n layout: layoutType,\n margin: {\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n },\n stackOffset: type === \"percent\" ? \"expand\" : undefined,\n syncId,\n ...props,\n ...chartProps,\n }),\n [\n barChartClassName,\n data,\n type,\n layoutType,\n syncId,\n xAxisLabel,\n yAxisLabel,\n chartProps,\n ],\n )\n\n return {\n bars,\n barVars,\n setHighlightedArea,\n getBarChartProps,\n getBarProps,\n }\n}\n\nexport type UseBarChartReturn = ReturnType<typeof useBarChart>\n\nexport interface BarCellProps {\n data: Dict\n hasStack: boolean\n index: number\n series: BarProps\n}\n\nconst defaultBarCell: FC<BarCellProps> = ({\n data,\n hasStack,\n index,\n series,\n}) => {\n const { dataKey } = series\n const key = `cell-${dataKey}-${index}`\n\n if (!hasStack) return <Cell key={key} />\n\n const keys = Object.keys(data)\n const values = Object.values(data)\n\n const currentIndex = keys.findIndex((key) => key === dataKey)\n const lastIndex = values.findLastIndex((value) => value !== 0)\n\n if (currentIndex === lastIndex) return <Cell key={key} />\n\n return <Cell key={key} radius={0} />\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,IAAI,iBAAiB;AAC9B,SAAS,aAAa,OAAO,SAAS,gBAAgB;AACtD,SAAS,KAAK,YAAY;AAmRlB;AAjND,IAAM,cAAc,CAAC;AAAA,EAC1B,OAAO;AAAA,EACP,OAAO;AAAA,EACP;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB,CAAC;AAAA,EACtB,GAAG;AACL,MAAwB;AAlGxB;AAmGE,QAAM,OAAO,MAAM;AACnB,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,iBAAiB,kBAA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A;AACF,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,MAAM,QAAQ,OAAO,IAAI,KAAK;AAEpC,MAAI,CAAC,SAAU,QAAO,oBAAC,UAAU,GAAK;AAEtC,QAAM,OAAO,OAAO,KAAK,IAAI;AAC7B,QAAM,SAAS,OAAO,OAAO,IAAI;AAEjC,QAAM,eAAe,KAAK,UAAU,CAACG,SAAQA,SAAQ,OAAO;AAC5D,QAAM,YAAY,OAAO,cAAc,CAAC,UAAU,UAAU,CAAC;AAE7D,MAAI,iBAAiB,UAAW,QAAO,oBAAC,UAAU,GAAK;AAEvD,SAAO,oBAAC,QAAe,QAAQ,KAAb,GAAgB;AACpC;","names":["activeBar","background","dimBar","rest","_a","series","data","index","key"]}
@@ -4,15 +4,15 @@ import {
4
4
  } from "./chunk-6YUJLLGN.mjs";
5
5
  import {
6
6
  getComponentProps
7
- } from "./chunk-QL3DB7OJ.mjs";
7
+ } from "./chunk-TXNC7GLT.mjs";
8
8
 
9
9
  // src/use-chart-reference-line.ts
10
10
  import { getCSS, getVar, useTheme } from "@yamada-ui/core";
11
- import { isObject, cx } from "@yamada-ui/utils";
11
+ import { cx, isObject } from "@yamada-ui/utils";
12
12
  import { useCallback, useMemo } from "react";
13
13
  var useChartReferenceLine = ({
14
- referenceLineProps = [],
15
- styles
14
+ styles,
15
+ referenceLineProps = []
16
16
  }) => {
17
17
  const { theme } = useTheme();
18
18
  const styleClassName = getCSS(styles.referenceLine)(theme);
@@ -24,23 +24,24 @@ var useChartReferenceLine = ({
24
24
  )(theme);
25
25
  const color = getVar(`reference-line-${index}`)(theme);
26
26
  const label = {
27
- value: labelProp,
28
27
  fill: color,
29
28
  position: "insideBottomLeft",
29
+ value: labelProp,
30
30
  ...isObject(labelProp) ? labelProp : {}
31
31
  };
32
- return { propClassName, color, label, ...rest };
32
+ return { color, label, propClassName, ...rest };
33
33
  }),
34
34
  [referenceLineProps, styleClassName, theme]
35
35
  );
36
36
  const getReferenceLineProps = useCallback(
37
- ({ index, className, ...props }, ref = null) => {
38
- const { propClassName, color, label, ...rest } = propList[index];
37
+ ({ className, index, ...props }, ref = null) => {
38
+ var _a;
39
+ const { color, label, propClassName, ...rest } = (_a = propList[index]) != null ? _a : {};
39
40
  return {
40
41
  ref,
41
42
  className: cx(className, propClassName),
42
- stroke: color,
43
43
  label,
44
+ stroke: color,
44
45
  ...props,
45
46
  ...rest
46
47
  };
@@ -53,4 +54,4 @@ var useChartReferenceLine = ({
53
54
  export {
54
55
  useChartReferenceLine
55
56
  };
56
- //# sourceMappingURL=chunk-FYAC4RRZ.mjs.map
57
+ //# sourceMappingURL=chunk-UTD4XZDM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-chart-reference-line.ts"],"sourcesContent":["import type { CSSUIObject, RequiredPropGetter } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type * as Recharts from \"recharts\"\nimport type { ReferenceLineProps } from \"./chart.types\"\nimport { getCSS, getVar, useTheme } from \"@yamada-ui/core\"\nimport { cx, isObject } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport { getComponentProps } from \"./chart-utils\"\nimport { referenceLineProperties } from \"./rechart-properties\"\n\nexport interface UseChartReferenceLineOptions {\n /**\n * Reference lines that should be displayed on the chart.\n */\n referenceLineProps?: ReferenceLineProps[]\n}\n\ninterface UseChartReferenceLineProps extends UseChartReferenceLineOptions {\n styles: Dict<CSSUIObject | undefined>\n}\n\nexport const useChartReferenceLine = ({\n styles,\n referenceLineProps = [],\n}: UseChartReferenceLineProps) => {\n const { theme } = useTheme()\n const styleClassName = getCSS(styles.referenceLine)(theme)\n const propList = useMemo(\n () =>\n referenceLineProps.map((props, index) => {\n const [{ label: labelProp, ...rest }, propClassName] =\n getComponentProps(\n [props, referenceLineProperties],\n styleClassName,\n )(theme)\n\n const color = getVar(`reference-line-${index}`)(theme)\n const label: Recharts.ReferenceLineProps[\"label\"] = {\n fill: color,\n position: \"insideBottomLeft\",\n value: labelProp as string,\n ...(isObject(labelProp) ? labelProp : {}),\n }\n\n return { color, label, propClassName, ...rest }\n }),\n [referenceLineProps, styleClassName, theme],\n )\n\n const getReferenceLineProps: RequiredPropGetter<\n { index: number } & Partial<Recharts.ReferenceLineProps>,\n Omit<Recharts.ReferenceLineProps, \"ref\">\n > = useCallback(\n ({ className, index, ...props }, ref = null) => {\n const { color, label, propClassName, ...rest } = propList[index] ?? {}\n\n return {\n ref,\n className: cx(className, propClassName),\n label,\n stroke: color,\n ...(props as Recharts.ReferenceLineProps),\n ...rest,\n }\n },\n [propList],\n )\n\n return { getReferenceLineProps }\n}\n"],"mappings":";;;;;;;;;AAIA,SAAS,QAAQ,QAAQ,gBAAgB;AACzC,SAAS,IAAI,gBAAgB;AAC7B,SAAS,aAAa,eAAe;AAe9B,IAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA,qBAAqB,CAAC;AACxB,MAAkC;AAChC,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,iBAAiB,OAAO,OAAO,aAAa,EAAE,KAAK;AACzD,QAAM,WAAW;AAAA,IACf,MACE,mBAAmB,IAAI,CAAC,OAAO,UAAU;AACvC,YAAM,CAAC,EAAE,OAAO,WAAW,GAAG,KAAK,GAAG,aAAa,IACjD;AAAA,QACE,CAAC,OAAO,uBAAuB;AAAA,QAC/B;AAAA,MACF,EAAE,KAAK;AAET,YAAM,QAAQ,OAAO,kBAAkB,KAAK,EAAE,EAAE,KAAK;AACrD,YAAM,QAA8C;AAAA,QAClD,MAAM;AAAA,QACN,UAAU;AAAA,QACV,OAAO;AAAA,QACP,GAAI,SAAS,SAAS,IAAI,YAAY,CAAC;AAAA,MACzC;AAEA,aAAO,EAAE,OAAO,OAAO,eAAe,GAAG,KAAK;AAAA,IAChD,CAAC;AAAA,IACH,CAAC,oBAAoB,gBAAgB,KAAK;AAAA,EAC5C;AAEA,QAAM,wBAGF;AAAA,IACF,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG,MAAM,SAAS;AArDpD;AAsDM,YAAM,EAAE,OAAO,OAAO,eAAe,GAAG,KAAK,KAAI,cAAS,KAAK,MAAd,YAAmB,CAAC;AAErE,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,WAAW,aAAa;AAAA,QACtC;AAAA,QACA,QAAQ;AAAA,QACR,GAAI;AAAA,QACJ,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,sBAAsB;AACjC;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-6YUJLLGN.mjs";
5
5
  import {
6
6
  getComponentProps
7
- } from "./chunk-QL3DB7OJ.mjs";
7
+ } from "./chunk-TXNC7GLT.mjs";
8
8
 
9
9
  // src/use-chart.ts
10
10
  import { useTheme } from "@yamada-ui/core";
@@ -33,13 +33,13 @@ var useChart = ({ containerProps = {} }) => {
33
33
  getContainerProps
34
34
  };
35
35
  };
36
- var useLegend = ({} = {}) => {
36
+ var useLegend = () => {
37
37
  const { styles } = useChartContext();
38
38
  return {
39
39
  styles
40
40
  };
41
41
  };
42
- var useTooltip = ({} = {}) => {
42
+ var useTooltip = () => {
43
43
  const { styles } = useChartContext();
44
44
  return {
45
45
  styles
@@ -53,4 +53,4 @@ export {
53
53
  useLegend,
54
54
  useTooltip
55
55
  };
56
- //# sourceMappingURL=chunk-A3IWA366.mjs.map
56
+ //# sourceMappingURL=chunk-VK65X6Q2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-chart.ts"],"sourcesContent":["import type { CSSUIObject, PropGetter } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type * as Recharts from \"recharts\"\nimport type { ResponsiveContainerProps } from \"./chart.types\"\nimport { useTheme } from \"@yamada-ui/core\"\nimport { createContext, cx } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport { getComponentProps } from \"./chart-utils\"\nimport { containerProperties } from \"./rechart-properties\"\n\ninterface ChartContext {\n styles: { [key: string]: CSSUIObject | undefined }\n}\n\nexport const [ChartProvider, useChartContext] = createContext<ChartContext>({\n name: \"ChartContext\",\n errorMessage: `useChartContext returned is 'undefined'. Seems you forgot to wrap the components in \"<LineChart />\" or \"<BarChart />\" etc.`,\n})\n\nexport interface UseChartProps {\n /**\n * Props passed down to recharts `ResponsiveContainer` component.\n */\n containerProps?: ResponsiveContainerProps\n}\n\nexport const useChart = ({ containerProps = {} }: UseChartProps) => {\n const { theme } = useTheme()\n const [reChartsProps, propClassName] = getComponentProps<Dict, string>([\n containerProps,\n containerProperties,\n ])(theme)\n\n const getContainerProps: PropGetter<\n Partial<Omit<Recharts.ResponsiveContainerProps, \"children\">>,\n Omit<Recharts.ResponsiveContainerProps, \"children\">\n > = useCallback(\n ({ className, ...props } = {}, ref = null) => ({\n ref,\n className: cx(\"ui-chart__container\", className as string, propClassName),\n ...props,\n ...reChartsProps,\n }),\n [propClassName, reChartsProps],\n )\n\n return {\n getContainerProps,\n }\n}\n\nexport type UseChartReturn = ReturnType<typeof useChart>\n\nexport const useLegend = () => {\n const { styles } = useChartContext()\n\n return {\n styles,\n }\n}\n\nexport type UseLegendReturn = ReturnType<typeof useLegend>\n\nexport const useTooltip = () => {\n const { styles } = useChartContext()\n\n return {\n styles,\n }\n}\n\nexport type UseTooltipReturn = ReturnType<typeof useTooltip>\n"],"mappings":";;;;;;;;;AAIA,SAAS,gBAAgB;AACzB,SAAS,eAAe,UAAU;AAClC,SAAS,mBAAmB;AAQrB,IAAM,CAAC,eAAe,eAAe,IAAI,cAA4B;AAAA,EAC1E,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AASM,IAAM,WAAW,CAAC,EAAE,iBAAiB,CAAC,EAAE,MAAqB;AAClE,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,eAAe,aAAa,IAAI,kBAAgC;AAAA,IACrE;AAAA,IACA;AAAA,EACF,CAAC,EAAE,KAAK;AAER,QAAM,oBAGF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,uBAAuB,WAAqB,aAAa;AAAA,MACvE,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;AAIO,IAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,IAAI,gBAAgB;AAEnC,SAAO;AAAA,IACL;AAAA,EACF;AACF;AAIO,IAAM,aAAa,MAAM;AAC9B,QAAM,EAAE,OAAO,IAAI,gBAAgB;AAEnC,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -4,16 +4,16 @@ import {
4
4
  } from "./chunk-6YUJLLGN.mjs";
5
5
  import {
6
6
  getClassName
7
- } from "./chunk-QL3DB7OJ.mjs";
7
+ } from "./chunk-TXNC7GLT.mjs";
8
8
 
9
9
  // src/use-chart-tooltip.ts
10
10
  import { useTheme } from "@yamada-ui/core";
11
- import { splitObject, cx } from "@yamada-ui/utils";
11
+ import { cx, splitObject } from "@yamada-ui/utils";
12
12
  import { useCallback, useMemo } from "react";
13
13
  var useChartTooltip = ({
14
- tooltipProps: _tooltipProps = {},
14
+ styles,
15
15
  tooltipAnimationDuration = 0,
16
- styles
16
+ tooltipProps: _tooltipProps = {}
17
17
  }) => {
18
18
  const { theme } = useTheme();
19
19
  const { cursor, ...rest } = _tooltipProps;
@@ -29,19 +29,19 @@ var useChartTooltip = ({
29
29
  (props, ref = null) => ({
30
30
  ref,
31
31
  animationDuration: tooltipAnimationDuration,
32
- isAnimationActive: (tooltipAnimationDuration || 0) > 0,
33
32
  cursor: {
34
33
  className: cx("ui-chart__cursor", cursorClassName)
35
34
  },
35
+ isAnimationActive: (tooltipAnimationDuration || 0) > 0,
36
36
  ...props,
37
37
  ...tooltipProps
38
38
  }),
39
39
  [cursorClassName, tooltipAnimationDuration, tooltipProps]
40
40
  );
41
- return { tooltipProps: tooltipUIProps, getTooltipProps };
41
+ return { getTooltipProps, tooltipProps: tooltipUIProps };
42
42
  };
43
43
 
44
44
  export {
45
45
  useChartTooltip
46
46
  };
47
- //# sourceMappingURL=chunk-OJ2MLZZ7.mjs.map
47
+ //# sourceMappingURL=chunk-X6PIY2M3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-chart-tooltip.ts"],"sourcesContent":["import type { CSSUIObject, PropGetter } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type * as Recharts from \"recharts\"\nimport type { TooltipProps } from \"./chart.types\"\nimport { useTheme } from \"@yamada-ui/core\"\nimport { cx, splitObject } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport { getClassName } from \"./chart-utils\"\nimport { tooltipProperties } from \"./rechart-properties\"\n\nexport interface UseChartTooltipOptions {\n /**\n * A function to format labels on inside the tooltip.\n */\n labelFormatter?: (label: string) => string\n /**\n * Specifies the duration of animation, the unit of this option is ms.\n *\n * @default 0\n */\n tooltipAnimationDuration?: number\n /**\n * A function to format values on inside the tooltip.\n */\n valueFormatter?: (value: any) => string\n /**\n * Props passed down to recharts 'Tooltip' component.\n */\n tooltipProps?: TooltipProps\n}\n\ninterface UseChartTooltipProps extends UseChartTooltipOptions {\n styles: Dict<CSSUIObject | undefined>\n}\n\nexport const useChartTooltip = ({\n styles,\n tooltipAnimationDuration = 0,\n tooltipProps: _tooltipProps = {},\n}: UseChartTooltipProps) => {\n const { theme } = useTheme()\n const { cursor, ...rest } = _tooltipProps\n const cursorClassName = useMemo(\n () => getClassName({ ...styles.cursor, ...cursor })(theme),\n [cursor, styles.cursor, theme],\n )\n\n const [tooltipProps, tooltipUIProps] = splitObject<Dict, string>(\n rest,\n tooltipProperties,\n )\n\n const getTooltipProps: PropGetter<\n Partial<Recharts.TooltipProps<any, any>>,\n Recharts.TooltipProps<any, any>\n > = useCallback(\n (props, ref = null) => ({\n ref,\n animationDuration: tooltipAnimationDuration,\n cursor: {\n className: cx(\"ui-chart__cursor\", cursorClassName),\n },\n isAnimationActive: (tooltipAnimationDuration || 0) > 0,\n ...props,\n ...tooltipProps,\n }),\n [cursorClassName, tooltipAnimationDuration, tooltipProps],\n )\n\n return { getTooltipProps, tooltipProps: tooltipUIProps }\n}\n"],"mappings":";;;;;;;;;AAIA,SAAS,gBAAgB;AACzB,SAAS,IAAI,mBAAmB;AAChC,SAAS,aAAa,eAAe;AA6B9B,IAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA,2BAA2B;AAAA,EAC3B,cAAc,gBAAgB,CAAC;AACjC,MAA4B;AAC1B,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,EAAE,QAAQ,GAAG,KAAK,IAAI;AAC5B,QAAM,kBAAkB;AAAA,IACtB,MAAM,aAAa,EAAE,GAAG,OAAO,QAAQ,GAAG,OAAO,CAAC,EAAE,KAAK;AAAA,IACzD,CAAC,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC/B;AAEA,QAAM,CAAC,cAAc,cAAc,IAAI;AAAA,IACrC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,kBAGF;AAAA,IACF,CAAC,OAAO,MAAM,UAAU;AAAA,MACtB;AAAA,MACA,mBAAmB;AAAA,MACnB,QAAQ;AAAA,QACN,WAAW,GAAG,oBAAoB,eAAe;AAAA,MACnD;AAAA,MACA,oBAAoB,4BAA4B,KAAK;AAAA,MACrD,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,iBAAiB,0BAA0B,YAAY;AAAA,EAC1D;AAEA,SAAO,EAAE,iBAAiB,cAAc,eAAe;AACzD;","names":[]}
@@ -4,15 +4,15 @@ import {
4
4
  } from "./chunk-6YUJLLGN.mjs";
5
5
  import {
6
6
  getComponentProps
7
- } from "./chunk-QL3DB7OJ.mjs";
7
+ } from "./chunk-TXNC7GLT.mjs";
8
8
 
9
9
  // src/use-chart-label-list.ts
10
10
  import { getCSS, useTheme } from "@yamada-ui/core";
11
11
  import { cx } from "@yamada-ui/utils";
12
12
  import { useCallback, useMemo } from "react";
13
13
  var useChartLabelList = ({
14
- labelListProps = [],
15
- styles
14
+ styles,
15
+ labelListProps = []
16
16
  }) => {
17
17
  const { theme } = useTheme();
18
18
  const styleClassName = getCSS(styles.labelList)(theme);
@@ -26,8 +26,9 @@ var useChartLabelList = ({
26
26
  [labelListProps, styleClassName, theme]
27
27
  );
28
28
  const getLabelLineProps = useCallback(
29
- ({ index, className, ...props }, ref = null) => {
30
- const { className: propClassName, ...rest } = propList[index];
29
+ ({ className, index, ...props }, ref = null) => {
30
+ var _a;
31
+ const { className: propClassName, ...rest } = (_a = propList[index]) != null ? _a : {};
31
32
  return {
32
33
  ref,
33
34
  className: cx(className, propClassName),
@@ -43,4 +44,4 @@ var useChartLabelList = ({
43
44
  export {
44
45
  useChartLabelList
45
46
  };
46
- //# sourceMappingURL=chunk-MSG3WFBO.mjs.map
47
+ //# sourceMappingURL=chunk-YIAK5DIM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-chart-label-list.ts"],"sourcesContent":["import type { CSSUIObject, RequiredPropGetter } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type * as Recharts from \"recharts\"\nimport type { LabelListProps } from \"./chart.types\"\nimport { getCSS, useTheme } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport { getComponentProps } from \"./chart-utils\"\nimport { labelListProperties } from \"./rechart-properties\"\n\nexport interface UseChartLabelListOptions {\n /**\n * Props passed down to recharts `LabelList` components.\n */\n labelListProps?: LabelListProps[]\n}\n\ninterface UseChartLabelListProps extends UseChartLabelListOptions {\n styles: Dict<CSSUIObject | undefined>\n}\n\nexport const useChartLabelList = ({\n styles,\n labelListProps = [],\n}: UseChartLabelListProps) => {\n const { theme } = useTheme()\n const styleClassName = getCSS(styles.labelList)(theme)\n\n const propList = useMemo(\n () =>\n labelListProps.map((props) =>\n getComponentProps<Dict, string>(\n [props, labelListProperties],\n styleClassName,\n )(theme, true),\n ),\n [labelListProps, styleClassName, theme],\n )\n\n const getLabelLineProps: RequiredPropGetter<\n { index: number } & Partial<Recharts.LabelListProps<Dict>>,\n Omit<Recharts.LabelListProps<Dict>, \"ref\">\n > = useCallback(\n ({ className, index, ...props }, ref = null) => {\n const { className: propClassName, ...rest } = propList[index] ?? {}\n\n return {\n ref,\n className: cx(className, propClassName),\n ...(props as Recharts.LabelListProps<Dict>),\n ...rest,\n }\n },\n [propList],\n )\n\n return { getLabelLineProps }\n}\n"],"mappings":";;;;;;;;;AAIA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,UAAU;AACnB,SAAS,aAAa,eAAe;AAe9B,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA,iBAAiB,CAAC;AACpB,MAA8B;AAC5B,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,iBAAiB,OAAO,OAAO,SAAS,EAAE,KAAK;AAErD,QAAM,WAAW;AAAA,IACf,MACE,eAAe;AAAA,MAAI,CAAC,UAClB;AAAA,QACE,CAAC,OAAO,mBAAmB;AAAA,QAC3B;AAAA,MACF,EAAE,OAAO,IAAI;AAAA,IACf;AAAA,IACF,CAAC,gBAAgB,gBAAgB,KAAK;AAAA,EACxC;AAEA,QAAM,oBAGF;AAAA,IACF,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG,MAAM,SAAS;AA3CpD;AA4CM,YAAM,EAAE,WAAW,eAAe,GAAG,KAAK,KAAI,cAAS,KAAK,MAAd,YAAmB,CAAC;AAElE,aAAO;AAAA,QACL;AAAA,QACA,WAAW,GAAG,WAAW,aAAa;AAAA,QACtC,GAAI;AAAA,QACJ,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,kBAAkB;AAC7B;","names":[]}
@@ -1,26 +1,26 @@
1
1
  "use client"
2
2
  import {
3
3
  useChartLabel
4
- } from "./chunk-MVRWZTQ5.mjs";
4
+ } from "./chunk-NLXYCM5J.mjs";
5
5
  import {
6
6
  usePieChart
7
- } from "./chunk-O3LMKYXK.mjs";
7
+ } from "./chunk-TU6MKMMV.mjs";
8
8
  import {
9
9
  useChartTooltip
10
- } from "./chunk-OJ2MLZZ7.mjs";
10
+ } from "./chunk-X6PIY2M3.mjs";
11
11
  import {
12
12
  useChartLegend
13
- } from "./chunk-IJRYXT4V.mjs";
13
+ } from "./chunk-R2LOTDR3.mjs";
14
14
  import {
15
15
  ChartLegend
16
- } from "./chunk-LLOU2WIV.mjs";
16
+ } from "./chunk-OUIKA4AX.mjs";
17
17
  import {
18
18
  ChartTooltip
19
- } from "./chunk-UANITMH7.mjs";
19
+ } from "./chunk-5VLSGWQD.mjs";
20
20
  import {
21
21
  ChartProvider,
22
22
  useChart
23
- } from "./chunk-A3IWA366.mjs";
23
+ } from "./chunk-VK65X6Q2.mjs";
24
24
 
25
25
  // src/donut-chart.tsx
26
26
  import {
@@ -46,71 +46,71 @@ var DonutChart = forwardRef((props, ref) => {
46
46
  const {
47
47
  className,
48
48
  data,
49
- pieProps,
50
- chartProps,
51
- cellProps,
52
- containerProps,
53
- withTooltip = true,
54
- withLegend = false,
55
- tooltipProps,
56
- tooltipAnimationDuration,
57
- tooltipDataSource = "all",
58
- valueFormatter,
59
- labelFormatter,
60
- unit,
61
- paddingAngle,
62
- startAngle,
63
49
  endAngle,
64
50
  withLabels,
65
- withLabelLines,
66
- labelOffset,
67
- isPercent,
68
51
  innerRadius = withLabels ? "60%" : "80%",
52
+ isPercent,
53
+ labelFormatter,
54
+ labelOffset,
69
55
  outerRadius,
56
+ paddingAngle,
57
+ startAngle,
70
58
  strokeWidth,
71
- legendProps,
59
+ tooltipAnimationDuration,
60
+ tooltipDataSource = "all",
61
+ unit,
62
+ valueFormatter,
63
+ withLabelLines,
64
+ withLegend = false,
65
+ withTooltip = true,
66
+ cellProps,
67
+ chartProps,
68
+ containerProps,
72
69
  labelProps,
70
+ legendProps,
71
+ pieProps,
72
+ tooltipProps,
73
73
  ...rest
74
74
  } = omitThemeProps(mergedProps);
75
75
  const {
76
76
  pieVars,
77
- getPieProps,
78
- getPieChartProps,
77
+ setHighlightedArea,
79
78
  getCellProps,
80
- setHighlightedArea
79
+ getPieChartProps,
80
+ getPieProps
81
81
  } = usePieChart({
82
82
  data,
83
- pieProps,
84
- chartProps,
85
- cellProps,
83
+ endAngle,
86
84
  innerRadius,
85
+ isPercent,
86
+ labelFormatter,
87
+ labelOffset,
87
88
  outerRadius,
88
89
  paddingAngle,
89
90
  startAngle,
90
- endAngle,
91
91
  strokeWidth,
92
- withLabels,
92
+ styles,
93
93
  withLabelLines,
94
- labelOffset,
95
- isPercent,
96
- labelFormatter,
97
- styles
94
+ withLabels,
95
+ cellProps,
96
+ chartProps,
97
+ pieProps
98
98
  });
99
99
  const { getContainerProps } = useChart({ containerProps });
100
- const { tooltipProps: computedTooltipProps, getTooltipProps } = useChartTooltip({
101
- tooltipProps,
100
+ const { getTooltipProps, tooltipProps: computedTooltipProps } = useChartTooltip({
101
+ styles,
102
102
  tooltipAnimationDuration,
103
- styles
103
+ tooltipProps
104
104
  });
105
- const { legendProps: computedLegendProps, getLegendProps } = useChartLegend({
105
+ const { getLegendProps, legendProps: computedLegendProps } = useChartLegend({
106
106
  legendProps
107
107
  });
108
- const { getLabelProps } = useChartLabel({ labelProps, styles });
108
+ const { getLabelProps } = useChartLabel({ styles, labelProps });
109
109
  const cells = useMemo(
110
110
  () => data.map(({ name }, index) => /* @__PURE__ */ jsx(
111
111
  Cell,
112
112
  {
113
- ...getCellProps({ index, className: "ui-donut-chart__cell" })
113
+ ...getCellProps({ className: "ui-donut-chart__cell", index })
114
114
  },
115
115
  `donut-cell-${name}`
116
116
  )),
@@ -173,8 +173,8 @@ var DonutChart = forwardRef((props, ref) => {
173
173
  className: "ui-donut-chart__tooltip",
174
174
  label,
175
175
  payload: tooltipDataSource === "segment" ? payload : data,
176
- valueFormatter,
177
176
  unit,
177
+ valueFormatter,
178
178
  ...computedTooltipProps
179
179
  }
180
180
  ),
@@ -189,8 +189,10 @@ var DonutChart = forwardRef((props, ref) => {
189
189
  }
190
190
  ) });
191
191
  });
192
+ DonutChart.displayName = "DonutChart";
193
+ DonutChart.__ui__ = "DonutChart";
192
194
 
193
195
  export {
194
196
  DonutChart
195
197
  };
196
- //# sourceMappingURL=chunk-ZXBE4ERW.mjs.map
198
+ //# sourceMappingURL=chunk-YTUEG4IY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/donut-chart.tsx"],"sourcesContent":["import type { PieChartProps } from \"./pie-chart\"\nimport type { UseChartLabelOptions } from \"./use-chart-label\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport {\n Cell,\n Label,\n Legend,\n Pie,\n PieChart as RechartsPieChart,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport { useChartLabel } from \"./use-chart-label\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\nimport { usePieChart } from \"./use-pie-chart\"\n\ninterface DonutChartOptions {\n /**\n * Controls innerRadius of the chart segments.\n * If it is a number, it is the width of the radius.\n * For example, `60` means the radius is `60px` and the diameter is `120px`.\n *\n * @default '60%'\n */\n innerRadius?: number | string\n}\n\nexport interface DonutChartProps\n extends PieChartProps,\n DonutChartOptions,\n UseChartLabelOptions {}\n\n/**\n * `DonutChart` is a component for drawing donut charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/data-display/donut-chart\n */\nexport const DonutChart = forwardRef<DonutChartProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"DonutChart\", props)\n const {\n className,\n data,\n endAngle,\n withLabels,\n innerRadius = withLabels ? \"60%\" : \"80%\",\n isPercent,\n labelFormatter,\n labelOffset,\n outerRadius,\n paddingAngle,\n startAngle,\n strokeWidth,\n tooltipAnimationDuration,\n tooltipDataSource = \"all\",\n unit,\n valueFormatter,\n withLabelLines,\n withLegend = false,\n withTooltip = true,\n cellProps,\n chartProps,\n containerProps,\n labelProps,\n legendProps,\n pieProps,\n tooltipProps,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const {\n pieVars,\n setHighlightedArea,\n getCellProps,\n getPieChartProps,\n getPieProps,\n } = usePieChart({\n data,\n endAngle,\n innerRadius,\n isPercent,\n labelFormatter,\n labelOffset,\n outerRadius,\n paddingAngle,\n startAngle,\n strokeWidth,\n styles,\n withLabelLines,\n withLabels,\n cellProps,\n chartProps,\n pieProps,\n })\n const { getContainerProps } = useChart({ containerProps })\n const { getTooltipProps, tooltipProps: computedTooltipProps } =\n useChartTooltip({\n styles,\n tooltipAnimationDuration,\n tooltipProps,\n })\n const { getLegendProps, legendProps: computedLegendProps } = useChartLegend({\n legendProps,\n })\n const { getLabelProps } = useChartLabel({ styles, labelProps })\n\n const cells = useMemo(\n () =>\n data.map(({ name }, index) => (\n <Cell\n key={`donut-cell-${name}`}\n {...getCellProps({ className: \"ui-donut-chart__cell\", index })}\n />\n )),\n [data, getCellProps],\n )\n\n return (\n <ChartProvider value={{ styles }}>\n <ui.div\n ref={ref}\n className={cx(\"ui-donut-chart\", className)}\n __css={{ maxW: \"full\", vars: pieVars, ...styles.container }}\n {...rest}\n >\n <ResponsiveContainer\n {...getContainerProps({ className: \"ui-donut-chart__container\" })}\n >\n <RechartsPieChart\n {...getPieChartProps({ className: \"ui-donut-chart__chart\" })}\n >\n <Pie\n {...getPieProps({\n className: \"ui-donut-chart__donut\",\n })}\n >\n {cells}\n <Label\n {...getLabelProps({ className: \"ui-donut-chart__label\" })}\n />\n </Pie>\n\n {withLegend ? (\n <Legend\n content={({ payload }) => (\n <ChartLegend\n className=\"ui-donut-chart__legend\"\n payload={payload}\n onHighlight={setHighlightedArea}\n {...computedLegendProps}\n />\n )}\n {...getLegendProps()}\n />\n ) : null}\n\n {withTooltip ? (\n <Tooltip\n content={({ label, payload }) => (\n <ChartTooltip\n className=\"ui-donut-chart__tooltip\"\n label={label}\n payload={tooltipDataSource === \"segment\" ? payload : data}\n unit={unit}\n valueFormatter={valueFormatter}\n {...computedTooltipProps}\n />\n )}\n {...getTooltipProps()}\n />\n ) : null}\n </RechartsPieChart>\n </ResponsiveContainer>\n </ui.div>\n </ChartProvider>\n )\n})\n\nDonutChart.displayName = \"DonutChart\"\nDonutChart.__ui__ = \"DonutChart\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,OACK;AAqGC,cAsBI,YAtBJ;AAvED,IAAM,aAAa,WAAmC,CAAC,OAAO,QAAQ;AAC3E,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,cAAc,KAAK;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,aAAa,QAAQ;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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