{"version":3,"file":"SparkLineChart.mjs","names":["ReChartsLineChart"],"sources":["../../src/SparkChart/SparkLineChart.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox } from '@lobehub/ui';\nimport { Skeleton } from '@lobehub/ui/base-ui';\nimport { css, cssVar, cx } from 'antd-style';\nimport { forwardRef } from 'react';\nimport { Line, LineChart as ReChartsLineChart, ResponsiveContainer, XAxis, YAxis } from 'recharts';\nimport { AxisDomain } from 'recharts/types/util/types';\n\nimport BaseSparkChartProps from '@/common/BaseSparkChartProps';\nimport NoData from '@/common/NoData';\nimport { constructCategoryColors, getYAxisDomain } from '@/common/utils';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { CurveType } from '@/types/charts';\n\nexport interface SparkLineChartProps extends BaseSparkChartProps {\n  connectNulls?: boolean;\n  curveType?: CurveType;\n  loading?: boolean;\n}\n\nconst SparkLineChart = forwardRef<HTMLDivElement, SparkLineChartProps>((props, ref) => {\n  const themeColorRange = useThemeColorRange();\n  const {\n    data = [],\n    categories = [],\n    index,\n    colors = themeColorRange,\n    animationDuration = 900,\n    showAnimation = false,\n    curveType = 'linear',\n    connectNulls = false,\n    noDataText = <div />,\n    autoMinValue = false,\n    minValue,\n    maxValue,\n    className,\n    width = 112,\n    height = 48,\n    style,\n    loading,\n    ...rest\n  } = props;\n\n  if (loading || !data) return <Skeleton height={height} width={width} />;\n\n  const categoryColors = constructCategoryColors(categories, colors);\n  const yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);\n\n  return (\n    <Flexbox\n      className={className}\n      height={height}\n      ref={ref}\n      style={{ position: 'relative', ...style }}\n      width={width}\n      {...rest}\n    >\n      <ResponsiveContainer>\n        {data?.length ? (\n          <ReChartsLineChart data={data} margin={{ bottom: 1, left: 1, right: 1, top: 1 }}>\n            <YAxis domain={yAxisDomain as AxisDomain} hide />\n            <XAxis dataKey={index} hide />\n            {categories.map((category) => (\n              <Line\n                animationDuration={animationDuration}\n                className={cx(css`\n                  stroke: ${categoryColors.get(category) ?? cssVar.colorPrimary};\n                `)}\n                connectNulls={connectNulls}\n                dataKey={category}\n                dot={false}\n                isAnimationActive={showAnimation}\n                key={category}\n                name={category}\n                stroke=\"\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                strokeOpacity={1}\n                strokeWidth={2}\n                type={curveType}\n              />\n            ))}\n          </ReChartsLineChart>\n        ) : (\n          <NoData noDataText={noDataText} />\n        )}\n      </ResponsiveContainer>\n    </Flexbox>\n  );\n});\n\nSparkLineChart.displayName = 'SparkLineChart';\n\nexport default SparkLineChart;\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,iBAAiB,YAAiD,OAAO,QAAQ;CACrF,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,OAAO,CAAC,GACR,aAAa,CAAC,GACd,OACA,SAAS,iBACT,oBAAoB,KACpB,gBAAgB,OAChB,YAAY,UACZ,eAAe,OACf,aAAa,oBAAC,OAAD,CAAM,CAAA,GACnB,eAAe,OACf,UACA,UACA,WACA,QAAQ,KACR,SAAS,IACT,OACA,SACA,GAAG,SACD;CAEJ,IAAI,WAAW,CAAC,MAAM,OAAO,oBAAC,UAAD;EAAkB;EAAe;CAAQ,CAAA;CAEtE,MAAM,iBAAiB,wBAAwB,YAAY,MAAM;CACjE,MAAM,cAAc,eAAe,cAAc,UAAU,QAAQ;CAEnE,OACE,oBAAC,SAAD;EACa;EACH;EACH;EACL,OAAO;GAAE,UAAU;GAAY,GAAG;EAAM;EACjC;EACP,GAAI;EAEJ,UAAA,oBAAC,qBAAD,EAAA,UACG,MAAM,SACL,qBAACA,WAAD;GAAyB;GAAM,QAAQ;IAAE,QAAQ;IAAG,MAAM;IAAG,OAAO;IAAG,KAAK;GAAE;GAA9E,UAAA;IACE,oBAAC,OAAD;KAAO,QAAQ;KAA2B,MAAA;IAAM,CAAA;IAChD,oBAAC,OAAD;KAAO,SAAS;KAAO,MAAA;IAAM,CAAA;IAC5B,WAAW,KAAK,aACf,o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