{"version":3,"sources":["../src/bar-chart.tsx"],"sourcesContent":["import type { HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { UseBarChartOptions } from \"./use-bar-chart\"\nimport type { UseChartProps } from \"./use-chart\"\nimport type { UseChartAxisOptions } from \"./use-chart-axis\"\nimport type { UseChartGridOptions } from \"./use-chart-grid\"\nimport type { UseChartLegendProps } from \"./use-chart-legend\"\nimport type { UseChartReferenceLineOptions } from \"./use-chart-reference-line\"\nimport type { UseChartTooltipOptions } from \"./use-chart-tooltip\"\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  CartesianGrid,\n  Label,\n  Legend,\n  BarChart as ReChartsBarChart,\n  ReferenceLine,\n  ResponsiveContainer,\n  Tooltip,\n  XAxis,\n  YAxis,\n} from \"recharts\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport { useBarChart } from \"./use-bar-chart\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport { useChartAxis } from \"./use-chart-axis\"\nimport { useChartGrid } from \"./use-chart-grid\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport { useChartReferenceLine } from \"./use-chart-reference-line\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\n\ninterface BarChartOptions {\n  /**\n   * If `true`, legend is visible.\n   *\n   * @default false\n   */\n  withLegend?: boolean\n  /**\n   * If `true`, tooltip is visible.\n   *\n   * @default true\n   */\n  withTooltip?: boolean\n}\n\nexport type BarChartProps = BarChartOptions &\n  HTMLUIProps &\n  ThemeProps<\"BarChart\"> &\n  UseBarChartOptions &\n  UseChartAxisOptions &\n  UseChartGridOptions &\n  UseChartLegendProps &\n  UseChartProps &\n  UseChartReferenceLineOptions &\n  UseChartTooltipOptions\n\n/**\n * `BarChart` is a component for drawing bar charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/data-display/bar-chart\n */\nexport const BarChart = forwardRef<BarChartProps, \"div\">((props, ref) => {\n  const [styles, mergedProps] = useComponentMultiStyle(\"BarChart\", props)\n  const {\n    type = \"default\",\n    className,\n    cell,\n    data,\n    dataKey,\n    fillOpacity,\n    gridAxis,\n    labelFormatter,\n    layoutType,\n    series,\n    strokeDasharray,\n    syncId,\n    tickLine,\n    tooltipAnimationDuration,\n    unit,\n    valueFormatter,\n    withLegend = false,\n    withTooltip = true,\n    withXAxis,\n    withYAxis,\n    xAxisLabel,\n    xAxisTickFormatter,\n    yAxisLabel,\n    yAxisTickFormatter,\n    barProps,\n    chartProps,\n    containerProps,\n    gridProps,\n    legendProps,\n    referenceLineProps = [],\n    tooltipProps,\n    xAxisLabelProps,\n    xAxisProps,\n    yAxisLabelProps,\n    yAxisProps,\n    ...rest\n  } = omitThemeProps(mergedProps)\n\n  const { bars, barVars, setHighlightedArea, getBarChartProps } = useBarChart({\n    type,\n    cell,\n    data,\n    fillOpacity,\n    layoutType,\n    series,\n    styles,\n    syncId,\n    xAxisLabel,\n    yAxisLabel,\n    barProps,\n    chartProps,\n    referenceLineProps,\n  })\n  const { getContainerProps } = useChart({ containerProps })\n  const {\n    getXAxisLabelProps,\n    getXAxisProps,\n    getYAxisLabelProps,\n    getYAxisProps,\n  } = useChartAxis({\n    type,\n    dataKey,\n    gridAxis,\n    layoutType,\n    styles,\n    tickLine,\n    unit,\n    withXAxis,\n    withYAxis,\n    xAxisLabel,\n    xAxisTickFormatter,\n    yAxisLabel,\n    yAxisTickFormatter,\n    xAxisLabelProps,\n    xAxisProps,\n    yAxisLabelProps,\n    yAxisProps,\n  })\n  const { getReferenceLineProps } = useChartReferenceLine({\n    styles,\n    referenceLineProps,\n  })\n  const { getGridProps } = useChartGrid({\n    gridAxis,\n    strokeDasharray,\n    styles,\n    gridProps,\n  })\n  const { getTooltipProps, tooltipProps: computedTooltipProps } =\n    useChartTooltip({\n      styles,\n      tooltipAnimationDuration,\n      tooltipProps,\n    })\n  const { getLegendProps, legendProps: computedLegendProps } = useChartLegend({\n    legendProps,\n  })\n\n  const referenceLinesItems = useMemo(\n    () =>\n      referenceLineProps.map((_, index) => (\n        <ReferenceLine\n          key={`referenceLine-${index}`}\n          {...getReferenceLineProps({\n            className: \"ui-bar-chart__reference-line\",\n            index,\n          })}\n        />\n      )),\n    [getReferenceLineProps, referenceLineProps],\n  )\n\n  return (\n    <ChartProvider value={{ styles }}>\n      <ui.div\n        ref={ref}\n        className={cx(\"ui-bar-chart\", className)}\n        __css={{ maxW: \"full\", vars: barVars, ...styles.container }}\n        {...rest}\n      >\n        <ResponsiveContainer\n          {...getContainerProps({ className: \"ui-bar-chart__container\" })}\n        >\n          <ReChartsBarChart\n            {...getBarChartProps({ className: \"ui-bar-chart__chart\" })}\n          >\n            <CartesianGrid\n              {...getGridProps({ className: \"ui-bar-chart__grid\" })}\n            />\n\n            <XAxis {...getXAxisProps({ className: \"ui-bar-chart__x-axis\" })}>\n              <Label\n                {...getXAxisLabelProps({\n                  className: \"ui-bar-chart__x-axis-label\",\n                })}\n              />\n            </XAxis>\n\n            <YAxis {...getYAxisProps({ className: \"ui-bar-chart__y-axis\" })}>\n              <Label\n                {...getYAxisLabelProps({\n                  className: \"ui-bar-chart__y-axis-label\",\n                })}\n              />\n            </YAxis>\n\n            {withLegend ? (\n              <Legend\n                content={({ payload }) => (\n                  <ChartLegend\n                    className=\"ui-bar-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-bar-chart__tooltip\"\n                    label={label}\n                    labelFormatter={labelFormatter}\n                    payload={payload}\n                    unit={unit}\n                    valueFormatter={valueFormatter}\n                    {...computedTooltipProps}\n                  />\n                )}\n                {...getTooltipProps()}\n              />\n            ) : null}\n\n            {bars}\n            {referenceLinesItems}\n          </ReChartsBarChart>\n        </ResponsiveContainer>\n      </ui.div>\n    </ChartProvider>\n  )\n})\n\nBarChart.displayName = \"BarChart\"\nBarChart.__ui__ = \"BarChart\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;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,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkJC,cAsBE,YAtBF;AAxGD,IAAM,WAAW,WAAiC,CAAC,OAAO,QAAQ;AACvE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,YAAY,KAAK;AACtE,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB,CAAC;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAE9B,QAAM,EAAE,MAAM,SAAS,oBAAoB,iBAAiB,IAAI,YAAY;AAAA,IAC1E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,EAAE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