{"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":[]}