{"version":3,"sources":["../src/use-chart-grid.ts"],"sourcesContent":["import type { CSSUIObject, PropGetter } from \"@yamada-ui/core\"\nimport type { Dict } from \"@yamada-ui/utils\"\nimport type { CartesianGridProps } from \"recharts\"\nimport type { ChartAxisType, GridProps } from \"./chart.types\"\nimport { useTheme } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useCallback } from \"react\"\nimport { getComponentProps } from \"./chart-utils\"\nimport { gridProperties } from \"./rechart-properties\"\n\nexport interface UseChartGridOptions {\n  /**\n   * Specifies which lines should be displayed in the grid.\n   *\n   * @default 'x'\n   */\n  gridAxis?: ChartAxisType\n  /**\n   * Dash array for the grid lines and cursor. The first number is the length of the solid line section and the second number is the length of the interval.\n   *\n   * @default '5 5'\n   */\n  strokeDasharray?: number | string\n  /**\n   * Props passed down to recharts 'CartesianGrid' component.\n   */\n  gridProps?: GridProps\n}\n\ninterface UseChartGridProps extends UseChartGridOptions {\n  styles: Dict<CSSUIObject | undefined>\n}\n\nexport const useChartGrid = ({\n  gridAxis = \"x\",\n  strokeDasharray = \"5 5\",\n  styles,\n  gridProps = {},\n}: UseChartGridProps) => {\n  const { theme } = useTheme()\n  const [reChartsProps, propClassName] = getComponentProps(\n    [gridProps, gridProperties],\n    styles.grid,\n  )(theme)\n\n  const getGridProps: PropGetter<\n    Partial<CartesianGridProps>,\n    CartesianGridProps\n  > = useCallback(\n    ({ className, ...props } = {}, ref = null) => ({\n      ref,\n      className: cx(\"ui-chart__grid\", className, propClassName),\n      horizontal: gridAxis === \"x\" || gridAxis === \"xy\",\n      strokeDasharray: strokeDasharray,\n      vertical: gridAxis === \"y\" || gridAxis === \"xy\",\n      ...props,\n      ...reChartsProps,\n    }),\n    [propClassName, strokeDasharray, gridAxis, reChartsProps],\n  )\n\n  return { getGridProps }\n}\n"],"mappings":";;;;;;;;;AAIA,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,SAAS,mBAAmB;AA2BrB,IAAM,eAAe,CAAC;AAAA,EAC3B,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB;AAAA,EACA,YAAY,CAAC;AACf,MAAyB;AACvB,QAAM,EAAE,MAAM,IAAI,SAAS;AAC3B,QAAM,CAAC,eAAe,aAAa,IAAI;AAAA,IACrC,CAAC,WAAW,cAAc;AAAA,IAC1B,OAAO;AAAA,EACT,EAAE,KAAK;AAEP,QAAM,eAGF;AAAA,IACF,CAAC,EAAE,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MAC7C;AAAA,MACA,WAAW,GAAG,kBAAkB,WAAW,aAAa;AAAA,MACxD,YAAY,aAAa,OAAO,aAAa;AAAA,MAC7C;AAAA,MACA,UAAU,aAAa,OAAO,aAAa;AAAA,MAC3C,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA,CAAC,eAAe,iBAAiB,UAAU,aAAa;AAAA,EAC1D;AAEA,SAAO,EAAE,aAAa;AACxB;","names":[]}