@wello-dev/charts 0.0.0-stage → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["#style-inject:#style-inject","../src/styles.css","../src/charts/area-chart.tsx","../src/shared/cartesian.tsx","../src/lib/colors.ts","../src/lib/utils.ts","../src/components/chart-legend.tsx","../src/components/chart-tooltip.tsx","../src/components/chart-canvas.tsx","../src/charts/bar-chart.tsx","../src/charts/line-chart.tsx","../src/shared/pie-base.tsx","../src/components/floating-tooltip.tsx","../src/charts/pie-chart.tsx","../src/charts/donut-chart.tsx","../src/charts/radial-bar-chart.tsx","../src/charts/heatmap.tsx"],"sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".wello-chart {\\n --wello-chart-primary: var(--wello-primary-color, var(--primary, #26372c));\\n --wello-chart-bg: var(--wello-color-surface, var(--card, #ffffff));\\n --wello-chart-text-color: color-mix(in srgb, currentColor 50%, transparent);\\n --wello-chart-legend-color: color-mix(in srgb, currentColor 85%, transparent);\\n --wello-chart-bright-color: currentColor;\\n --wello-chart-dimmed-color: color-mix(in srgb, currentColor 50%, transparent);\\n --wello-chart-grid-color: color-mix(in srgb, currentColor 22%, transparent);\\n --wello-chart-cursor-fill: color-mix(in srgb, var(--wello-chart-primary) 8%, transparent);\\n --wello-chart-label-line-color: var(--wello-color-border-strong, var(--input, #cbd5e1));\\n --wello-chart-tooltip-bg: var(--wello-color-bright, var(--foreground, #0f172a));\\n --wello-chart-tooltip-fg: var(--wello-color-body, var(--background, #ffffff));\\n --wello-chart-heatmap-empty: color-mix(in srgb, var(--wello-chart-text-color) 15%, transparent);\\n --wello-chart-radial-bg: color-mix(in srgb, var(--wello-chart-text-color) 12%, transparent);\\n --wello-chart-muted: color-mix(in srgb, var(--wello-chart-text-color) 35%, transparent);\\n --wello-chart-font: inherit;\\n box-sizing: border-box;\\n position: relative;\\n font-family: var(--wello-chart-font);\\n}\\n.dark .wello-chart,\\n[data-theme=dark] .wello-chart,\\n.wello-chart[data-theme=dark] {\\n --wello-chart-primary: var(--wello-primary-color, var(--primary, #9fbfa8));\\n --wello-chart-bg: var(--wello-color-surface, var(--card, #0f172a));\\n --wello-chart-label-line-color: var(--wello-color-border-strong, var(--input, #475569));\\n --wello-chart-tooltip-bg: var(--wello-color-bright, var(--foreground, #f8fafc));\\n --wello-chart-tooltip-fg: var(--wello-color-body, var(--background, #0f172a));\\n}\\n.wello-chart .recharts-cartesian-grid line {\\n shape-rendering: crispEdges;\\n}\\n.wello-chart .recharts-surface,\\n.wello-heatmap svg {\\n direction: ltr;\\n}\\n.wello-chart .recharts-wrapper:focus,\\n.wello-chart .recharts-surface:focus,\\n.wello-chart *:focus:not(:focus-visible) {\\n outline: none;\\n}\\n.wello-tooltip {\\n min-width: 8.5rem;\\n padding: 10px 12px;\\n border-radius: 12px;\\n background: color-mix(in srgb, var(--wello-chart-tooltip-bg) 94%, transparent);\\n color: var(--wello-chart-tooltip-fg);\\n box-shadow: 0 12px 32px rgb(0 0 0 / 0.24);\\n font-size: 12px;\\n line-height: 1.4;\\n pointer-events: none;\\n}\\n.wello-tooltip-label {\\n display: flex;\\n align-items: center;\\n gap: 8px;\\n margin-bottom: 4px;\\n opacity: 0.8;\\n}\\n.wello-tooltip--slice .wello-tooltip-label {\\n margin-bottom: 6px;\\n font-weight: 600;\\n opacity: 1;\\n}\\n.wello-tooltip-body {\\n display: flex;\\n flex-direction: column;\\n gap: 4px;\\n}\\n.wello-tooltip-item {\\n display: flex;\\n align-items: center;\\n gap: 8px;\\n}\\n.wello-tooltip-swatch,\\n.wello-legend-swatch {\\n flex-shrink: 0;\\n width: 8px;\\n height: 8px;\\n border-radius: 999px;\\n}\\n.wello-tooltip .wello-tooltip-swatch {\\n box-shadow: 0 0 0 1px color-mix(in srgb, var(--wello-chart-tooltip-fg) 45%, transparent);\\n}\\n.wello-tooltip-item-name {\\n flex: 1;\\n opacity: 0.8;\\n}\\n.wello-tooltip-item-value {\\n margin-inline-start: 16px;\\n font-variant-numeric: tabular-nums;\\n font-weight: 700;\\n}\\n.wello-legend {\\n display: flex;\\n flex-wrap: wrap;\\n gap: 4px 12px;\\n box-sizing: border-box;\\n max-width: 100%;\\n padding-bottom: 14px;\\n font-size: 12.5px;\\n font-weight: 500;\\n color: var(--wello-chart-legend-color);\\n}\\n.wello-legend--start,\\n.wello-legend--left {\\n justify-content: flex-start;\\n}\\n.wello-legend--center {\\n justify-content: center;\\n}\\n.wello-legend--end,\\n.wello-legend--right {\\n justify-content: flex-end;\\n}\\n[dir=rtl] .wello-legend--left {\\n justify-content: flex-end;\\n}\\n[dir=rtl] .wello-legend--right {\\n justify-content: flex-start;\\n}\\n.wello-legend .wello-legend-swatch {\\n width: 10px;\\n height: 10px;\\n}\\n.wello-legend-item {\\n display: flex;\\n align-items: center;\\n gap: 8px;\\n padding: 3px 8px;\\n border-radius: 999px;\\n cursor: default;\\n transition: background-color 120ms ease;\\n}\\n.wello-legend-item:hover {\\n background: var(--wello-chart-cursor-fill);\\n}\\n.wello-chart-skeleton {\\n border-radius: 12px;\\n background: color-mix(in srgb, var(--wello-chart-text-color) 14%, transparent);\\n animation: wello-pulse 1.6s ease-in-out infinite;\\n}\\n.wello-chart-empty {\\n display: flex;\\n align-items: center;\\n justify-content: center;\\n padding: 16px;\\n color: var(--wello-chart-text-color);\\n font-size: 14px;\\n font-weight: 500;\\n text-align: center;\\n}\\n@keyframes wello-pulse {\\n 50% {\\n opacity: 0.5;\\n }\\n}\\n@media (prefers-reduced-motion: reduce) {\\n .wello-chart-skeleton {\\n animation: none;\\n }\\n}\\n.wello-pie .wello-legend {\\n padding: 8px 0 0;\\n}\\n.wello-pie-area {\\n position: relative;\\n}\\n.wello-floating-tooltip {\\n z-index: 9999;\\n pointer-events: none;\\n white-space: nowrap;\\n font-family: var(--wello-chart-font, inherit);\\n}\\n.wello-donut-label {\\n position: absolute;\\n inset: 0;\\n display: flex;\\n align-items: center;\\n justify-content: center;\\n pointer-events: none;\\n text-align: center;\\n}\\n.wello-donut-label-inner {\\n display: flex;\\n flex-direction: column;\\n align-items: center;\\n line-height: 1;\\n}\\n.wello-donut-label-main {\\n color: var(--wello-chart-bright-color);\\n font-size: 24px;\\n font-weight: 900;\\n font-variant-numeric: tabular-nums;\\n letter-spacing: -0.025em;\\n}\\n.wello-donut-label-sub {\\n margin-top: 6px;\\n color: var(--wello-chart-text-color);\\n font-size: 12px;\\n font-weight: 600;\\n}\\n.wello-radial-bar .wello-legend {\\n padding: 8px 0 0;\\n}\\n.wello-heatmap {\\n display: inline-block;\\n}\\n.wello-heatmap svg {\\n display: block;\\n overflow: visible;\\n}\\n.wello-heatmap-label {\\n fill: var(--wello-chart-text-color);\\n}\\n.wello-heatmap-rect--outside {\\n opacity: 0.4;\\n}\\n.wello-heatmap-tooltip {\\n min-width: 0;\\n}\\n.wello-heatmap-legend {\\n display: flex;\\n align-items: center;\\n justify-content: flex-end;\\n gap: 3px;\\n margin-top: 8px;\\n color: var(--wello-chart-text-color);\\n}\\n.wello-heatmap-legend > span:first-child {\\n margin-inline-end: 4px;\\n}\\n.wello-heatmap-legend > span:last-child {\\n margin-inline-start: 4px;\\n}\\n\")","import { Area, AreaChart as ReAreaChart, LabelList, ResponsiveContainer } from \"recharts\";\nimport { useRef } from \"react\";\nimport {\n cartesianElements,\n isDimmed,\n resolveSeries,\n useHighlight,\n withLabelPadding,\n} from \"../shared/cartesian\";\nimport { ChartCanvas, isCartesianEmpty } from \"../components/chart-canvas\";\nimport { getThemeColor, type ChartColor } from \"../lib/colors\";\nimport type { BaseCartesianChartProps, ChartCurveType } from \"../lib/types\";\nimport { cx, useIsRtl, useSvgId } from \"../lib/utils\";\n\nexport type AreaChartType = \"default\" | \"stacked\" | \"percent\" | \"split\";\n\nexport interface AreaChartProps extends BaseCartesianChartProps {\n /** Default: `'default'` */\n type?: AreaChartType;\n /** Default: `'monotone'` */\n curveType?: ChartCurveType;\n /** Fade the fill from the line color to transparent. Default: true */\n withGradient?: boolean;\n /** Fill opacity (solid fill, or the top of the gradient). Default: 0.2 */\n fillOpacity?: number;\n /** Default: 2 */\n strokeWidth?: number;\n /** Default: true */\n withDots?: boolean;\n dotProps?: Record<string, any>;\n activeDotProps?: Record<string, any>;\n /** Default: true */\n connectNulls?: boolean;\n /** Value labels above every point */\n withPointLabels?: boolean;\n /** `type=\"split\"`: colors above and below zero. Default: `['green-700', 'red-700']` */\n splitColors?: [ChartColor, ChartColor];\n /** `type=\"split\"`: gradient offset, computed from the data when omitted */\n splitOffset?: number;\n /** Passed to recharts `AreaChart` (e.g. `syncId`) */\n areaChartProps?: Record<string, any>;\n /** Passed to every recharts `Area`, or a function per series */\n areaProps?:\n | Record<string, any>\n | ((series: BaseCartesianChartProps[\"series\"][number]) => Record<string, any>);\n}\n\n/** Offset (0–1) where the split gradient switches from the positive to the negative color. */\nexport function getSplitOffset(data: Record<string, any>[], key: string): number {\n const values = data.map((item) => Number(item[key])).filter((value) => Number.isFinite(value));\n if (!values.length) return 0.5;\n const max = Math.max(...values);\n const min = Math.min(...values);\n if (max <= 0) return 0;\n if (min >= 0) return 1;\n return max / (max - min);\n}\n\n/**\n * Area chart.\n *\n * @example\n * <AreaChart h={300} data={data} dataKey=\"date\" type=\"stacked\" withLegend\n * series={[{ name: 'Apples', color: 'indigo-600' }, { name: 'Oranges', color: 'blue-600' }]} />\n */\nexport function AreaChart(props: AreaChartProps) {\n const {\n data,\n series,\n h = 300,\n w = \"100%\",\n className,\n classNames,\n style,\n orientation = \"horizontal\",\n type = \"default\",\n curveType = \"monotone\",\n withGradient = true,\n fillOpacity = 0.2,\n strokeWidth = 2,\n withDots = true,\n dotProps,\n activeDotProps,\n connectNulls = true,\n withPointLabels = false,\n splitColors = [\"green-700\", \"red-700\"],\n splitOffset,\n areaChartProps,\n areaProps,\n textColor,\n animationDuration = 650,\n loading,\n emptyLabel,\n children,\n } = props;\n const ref = useRef<HTMLDivElement>(null);\n const rtl = useIsRtl(ref);\n const resolved = resolveSeries(props);\n const chartProps = { ...props, series: resolved };\n const [highlighted, setHighlighted] = useHighlight();\n const id = useSvgId(\"wello-area\");\n const stacked = type === \"stacked\" || type === \"percent\";\n\n const areas = resolved.map((item, index) => {\n const color = getThemeColor(item.color);\n const gradientId = `${id}-${index}`;\n const dimmed = isDimmed(highlighted, item.name);\n const extra = typeof areaProps === \"function\" ? areaProps(item) : areaProps;\n const split = type === \"split\";\n const offset = splitOffset ?? getSplitOffset(data, item.name);\n\n return [\n <defs key={`defs-${item.name}`}>\n <linearGradient id={gradientId} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n {split ? (\n <>\n <stop\n offset={offset}\n stopColor={getThemeColor(splitColors[0])}\n stopOpacity={fillOpacity}\n />\n <stop\n offset={offset}\n stopColor={getThemeColor(splitColors[1])}\n stopOpacity={fillOpacity}\n />\n </>\n ) : withGradient ? (\n <>\n <stop offset=\"0%\" stopColor={color} stopOpacity={fillOpacity} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={0.01} />\n </>\n ) : (\n <stop offset=\"0%\" stopColor={color} stopOpacity={fillOpacity} />\n )}\n </linearGradient>\n </defs>,\n <Area\n key={item.name}\n yAxisId={item.yAxisId ?? \"left\"}\n name={item.name}\n dataKey={item.name}\n type={curveType}\n stroke={color}\n strokeWidth={strokeWidth}\n strokeDasharray={item.strokeDasharray}\n fill={`url(#${gradientId})`}\n fillOpacity={dimmed ? 0.1 : 1}\n strokeOpacity={dimmed ? 0.3 : 1}\n stackId={stacked ? \"stack\" : undefined}\n connectNulls={connectNulls}\n dot={\n withDots\n ? {\n fill: color,\n fillOpacity: dimmed ? 0 : 1,\n strokeWidth: 2,\n r: 4,\n // Solid dot in the series color (no surface-colored ring), as in Mantine.\n stroke: color,\n strokeOpacity: dimmed ? 0 : 1,\n ...dotProps,\n }\n : false\n }\n activeDot={{\n fill: \"#fff\",\n stroke: color,\n strokeWidth: 2,\n r: 4,\n ...activeDotProps,\n }}\n isAnimationActive={animationDuration > 0}\n animationDuration={animationDuration}\n animationEasing=\"ease-out\"\n {...extra}\n >\n {withPointLabels && (\n <LabelList\n position=\"top\"\n fontSize={12}\n fill=\"var(--wello-chart-text-color)\"\n formatter={props.valueFormatter as any}\n />\n )}\n </Area>,\n ];\n });\n\n return (\n <ChartCanvas\n empty={isCartesianEmpty(\n data,\n series.map((item) => item.name),\n )}\n loading={loading}\n emptyLabel={emptyLabel}\n height={h}\n className={cx(className, classNames?.root)}\n style={style}\n >\n <div\n ref={ref}\n className={cx(\"wello-chart\", className, classNames?.root)}\n style={{\n height: h,\n width: w,\n color: textColor ? getThemeColor(textColor) : undefined,\n ...style,\n }}\n >\n <ResponsiveContainer className={classNames?.chart}>\n <ReAreaChart\n data={data}\n layout={orientation}\n stackOffset={type === \"percent\" ? \"expand\" : undefined}\n margin={{ top: 10, right: 10, bottom: props.xAxisLabel ? 20 : 0, left: 0 }}\n {...areaChartProps}\n >\n {cartesianElements(withPointLabels ? withLabelPadding(chartProps) : chartProps, {\n highlighted,\n onHighlight: setHighlighted,\n cursor: \"line\",\n rtl,\n valueTickFormatter:\n type === \"percent\" ? (value) => `${Math.round(value * 100)}%` : undefined,\n })}\n {areas}\n {children}\n </ReAreaChart>\n </ResponsiveContainer>\n </div>\n </ChartCanvas>\n );\n}\n","import { useState, type ReactNode } from \"react\";\nimport { CartesianGrid, Legend, ReferenceLine, Tooltip, XAxis, YAxis } from \"recharts\";\nimport type { LabelProps } from \"recharts\";\nimport { ChartLegend } from \"../components/chart-legend\";\nimport { renderCartesianTooltip } from \"../components/chart-tooltip\";\nimport { getThemeColor, seriesColor } from \"../lib/colors\";\nimport type { BaseCartesianChartProps } from \"../lib/types\";\n\n/** Series with every `color` filled in from `colors`, so legend, tooltip and shapes agree. */\nexport function resolveSeries(props: BaseCartesianChartProps): BaseCartesianChartProps[\"series\"] {\n return props.series.map((item, index) => ({\n ...item,\n color: seriesColor(item.color, index, props.colors),\n }));\n}\n\n/** Which series the legend is hovering, for dimming the others. */\nexport function useHighlight() {\n return useState<string | null>(null);\n}\n\nexport function isDimmed(highlighted: string | null, name: string): boolean {\n return highlighted !== null && highlighted !== name;\n}\n\n/** Pads the category axis so labels on the first/last point clear the y-axis ticks. */\nexport function withLabelPadding<T extends BaseCartesianChartProps>(props: T): T {\n const vertical = props.orientation === \"vertical\";\n const key = vertical ? \"yAxisProps\" : \"xAxisProps\";\n const padding = vertical ? { top: 20, bottom: 20 } : { left: 30, right: 30 };\n return { ...props, [key]: { padding, ...props[key] } };\n}\n\ninterface CartesianOptions {\n highlighted: string | null;\n onHighlight: (name: string | null) => void;\n /** Bar charts shade the hovered category instead of drawing a line */\n cursor: \"line\" | \"fill\";\n /** y-axis tick formatter override (percent charts) */\n valueTickFormatter?: (value: number) => string;\n /** Right-to-left layout: category axis reversed, value axis on the right */\n rtl?: boolean;\n}\n\n/**\n * One grid line, snapped to the pixel grid. Tick spacing is rarely a whole number of pixels, so\n * every other 1px line would land between two pixel rows, render at half strength and vanish.\n * Rounding here (not only in CSS) also holds when the stylesheet is cached or overridden.\n */\nfunction renderGridLine(props: any) {\n const snap = (value: number) => Math.round(value) + 0.5;\n const horizontal = props.y1 === props.y2;\n return (\n <line\n key={props.key}\n x1={horizontal ? props.x1 : snap(props.x1)}\n x2={horizontal ? props.x2 : snap(props.x2)}\n y1={horizontal ? snap(props.y1) : props.y1}\n y2={horizontal ? snap(props.y2) : props.y2}\n stroke={props.stroke}\n strokeWidth={props.strokeWidth}\n strokeOpacity={props.strokeOpacity}\n strokeDasharray={props.strokeDasharray}\n fill=\"none\"\n shapeRendering=\"crispEdges\"\n />\n );\n}\n\nfunction tickFormatter(props: BaseCartesianChartProps) {\n return (value: number) =>\n `${props.valueFormatter ? props.valueFormatter(value) : value}${props.unit ?? \"\"}`;\n}\n\nfunction axisLabel(value: string | undefined, axis: \"x\" | \"y\" | \"right\"): LabelProps | undefined {\n if (!value) return undefined;\n if (axis === \"x\")\n return {\n value,\n position: \"insideBottom\",\n offset: -16,\n fontSize: 12,\n fill: \"var(--wello-chart-text-color)\",\n };\n return {\n value,\n angle: axis === \"y\" ? -90 : 90,\n position: axis === \"y\" ? \"insideLeft\" : \"insideRight\",\n fontSize: 12,\n fill: \"var(--wello-chart-text-color)\",\n style: { textAnchor: \"middle\" },\n };\n}\n\n/** Grid, axes, tooltip, legend and reference lines as direct children for a recharts chart. */\nexport function cartesianElements(\n props: BaseCartesianChartProps,\n { onHighlight, cursor, valueTickFormatter, rtl = false }: CartesianOptions,\n): ReactNode[] {\n const {\n dataKey,\n series,\n orientation = \"horizontal\",\n withLegend = false,\n legendProps,\n withTooltip = true,\n tooltipProps,\n tooltipAnimationDuration = 0,\n withXAxis = true,\n withYAxis = true,\n xAxisProps,\n yAxisProps,\n xAxisLabel,\n yAxisLabel,\n withRightYAxis = false,\n rightYAxisProps,\n rightYAxisLabel,\n gridAxis = \"x\",\n gridProps,\n tickLine = \"none\",\n strokeDasharray = \"5 5\",\n gridColor,\n unit,\n valueFormatter,\n referenceLines,\n } = props;\n\n const vertical = orientation === \"vertical\";\n const gridStroke = getThemeColor(gridColor, \"var(--wello-chart-grid-color)\");\n const valueTicks = valueTickFormatter ?? tickFormatter(props);\n // Mantine-style ticks: 12px, set 10px off the plot so they never touch the grid.\n const tickBase = { fill: \"var(--wello-chart-text-color)\", fontSize: 12 };\n const xTick = { ...tickBase, transform: \"translate(0, 10)\" };\n // The value axis sits on the right in RTL, so push its labels outward the other way.\n const yTick = { ...tickBase, transform: rtl ? \"translate(10, 0)\" : \"translate(-10, 0)\" };\n const rightYTick = { ...tickBase, transform: rtl ? \"translate(-10, 0)\" : \"translate(10, 0)\" };\n const xTickLine =\n tickLine === \"x\" || tickLine === \"xy\" ? { stroke: \"var(--wello-chart-grid-color)\" } : false;\n const yTickLine =\n tickLine === \"y\" || tickLine === \"xy\" ? { stroke: \"var(--wello-chart-grid-color)\" } : false;\n\n // In vertical charts the category axis is y and the value axis is x.\n const categoryAxis = { dataKey, type: \"category\" as const };\n // 7 ticks: finer, rounder steps (0, 0.5, 1 … rather than 0, 0.75, 1.5 …), one grid line each.\n const valueAxis = {\n type: \"number\" as const,\n tickFormatter: valueTicks,\n unit: undefined,\n tickCount: 7,\n // Keep every tick. With recharts' default (\"preserveEnd\") the grid re-thins the ticks using\n // its own label-size guess, so a short chart shows 7 labels but only every other grid line.\n interval: 0,\n };\n\n const valueGrid = gridAxis === \"x\" || gridAxis === \"xy\";\n const categoryGrid = gridAxis === \"y\" || gridAxis === \"xy\";\n\n const elements: ReactNode[] = [\n <CartesianGrid\n key=\"grid\"\n // Bind to the value axis (id \"left\"); otherwise recharts finds no ticks and\n // draws only the top and bottom lines instead of one line per tick.\n yAxisId=\"left\"\n strokeDasharray={strokeDasharray}\n stroke={gridStroke}\n // `'x'` = lines that mark the values. In a vertical chart the values run along the\n // bottom, so those lines turn vertical (one per value tick) instead of one per category.\n horizontal={(vertical ? categoryGrid : valueGrid) ? renderGridLine : false}\n vertical={(vertical ? valueGrid : categoryGrid) ? renderGridLine : false}\n {...gridProps}\n />,\n <XAxis\n key=\"x\"\n hide={!withXAxis}\n {...(vertical ? valueAxis : categoryAxis)}\n reversed={rtl}\n tick={xTick}\n tickLine={xTickLine}\n axisLine={false}\n minTickGap={5}\n interval=\"preserveStartEnd\"\n label={axisLabel(xAxisLabel, \"x\")}\n {...xAxisProps}\n />,\n <YAxis\n key=\"y\"\n yAxisId=\"left\"\n orientation={rtl ? \"right\" : \"left\"}\n hide={!withYAxis}\n {...(vertical ? categoryAxis : valueAxis)}\n tick={yTick}\n tickLine={yTickLine}\n axisLine={false}\n width={vertical ? 80 : 60}\n label={axisLabel(yAxisLabel, \"y\")}\n {...yAxisProps}\n />,\n ];\n\n if (withRightYAxis) {\n elements.push(\n <YAxis\n key=\"y-right\"\n yAxisId=\"right\"\n orientation={rtl ? \"left\" : \"right\"}\n {...(vertical ? categoryAxis : valueAxis)}\n tick={rightYTick}\n tickLine={yTickLine}\n axisLine={false}\n width={60}\n label={axisLabel(rightYAxisLabel, \"right\")}\n {...rightYAxisProps}\n />,\n );\n }\n\n if (withTooltip) {\n elements.push(\n <Tooltip\n key=\"tooltip\"\n isAnimationActive={tooltipAnimationDuration !== 0}\n animationDuration={tooltipAnimationDuration}\n cursor={\n cursor === \"fill\"\n ? { fill: \"var(--wello-chart-cursor-fill)\" }\n : // Dashed like the grid (Mantine style).\n { stroke: gridStroke, strokeWidth: 1, strokeDasharray }\n }\n // Stays inside the chart (flipping at the edges), so cards with overflow: hidden don't clip it.\n wrapperStyle={{ zIndex: 50, outline: \"none\" }}\n offset={14}\n content={renderCartesianTooltip({ series, unit, valueFormatter })}\n {...tooltipProps}\n />,\n );\n }\n\n if (withLegend) {\n elements.push(\n <Legend\n key=\"legend\"\n verticalAlign={legendProps?.verticalAlign ?? \"top\"}\n content={() => (\n <ChartLegend\n series={series}\n align={legendProps?.align}\n className={props.classNames?.legend}\n onHighlight={legendProps?.highlightOnHover === false ? undefined : onHighlight}\n />\n )}\n />,\n );\n }\n\n referenceLines?.forEach((line, index) => {\n const color = getThemeColor(line.color, \"var(--wello-chart-text-color)\");\n elements.push(\n <ReferenceLine\n key={`ref-${index}`}\n yAxisId={line.yAxisId ?? \"left\"}\n x={line.x}\n y={line.y}\n stroke={color}\n strokeDasharray={line.strokeDasharray}\n label={\n line.label === undefined\n ? undefined\n : {\n value: line.label as string,\n fill: color,\n fontSize: 12,\n position: line.y !== undefined ? \"insideBottomLeft\" : \"insideTopRight\",\n }\n }\n ifOverflow=\"extendDomain\"\n />,\n );\n });\n\n return elements;\n}\n","/** Tailwind CSS default palette (v3 hex values, MIT); shades 50–950. */\nexport const DEFAULT_CHART_COLORS = {\n slate: [\n \"#f8fafc\",\n \"#f1f5f9\",\n \"#e2e8f0\",\n \"#cbd5e1\",\n \"#94a3b8\",\n \"#64748b\",\n \"#475569\",\n \"#334155\",\n \"#1e293b\",\n \"#0f172a\",\n \"#020617\",\n ],\n gray: [\n \"#f9fafb\",\n \"#f3f4f6\",\n \"#e5e7eb\",\n \"#d1d5db\",\n \"#9ca3af\",\n \"#6b7280\",\n \"#4b5563\",\n \"#374151\",\n \"#1f2937\",\n \"#111827\",\n \"#030712\",\n ],\n zinc: [\n \"#fafafa\",\n \"#f4f4f5\",\n \"#e4e4e7\",\n \"#d4d4d8\",\n \"#a1a1aa\",\n \"#71717a\",\n \"#52525b\",\n \"#3f3f46\",\n \"#27272a\",\n \"#18181b\",\n \"#09090b\",\n ],\n neutral: [\n \"#fafafa\",\n \"#f5f5f5\",\n \"#e5e5e5\",\n \"#d4d4d4\",\n \"#a3a3a3\",\n \"#737373\",\n \"#525252\",\n \"#404040\",\n \"#262626\",\n \"#171717\",\n \"#0a0a0a\",\n ],\n stone: [\n \"#fafaf9\",\n \"#f5f5f4\",\n \"#e7e5e4\",\n \"#d6d3d1\",\n \"#a8a29e\",\n \"#78716c\",\n \"#57534e\",\n \"#44403c\",\n \"#292524\",\n \"#1c1917\",\n \"#0c0a09\",\n ],\n red: [\n \"#fef2f2\",\n \"#fee2e2\",\n \"#fecaca\",\n \"#fca5a5\",\n \"#f87171\",\n \"#ef4444\",\n \"#dc2626\",\n \"#b91c1c\",\n \"#991b1b\",\n \"#7f1d1d\",\n \"#450a0a\",\n ],\n orange: [\n \"#fff7ed\",\n \"#ffedd5\",\n \"#fed7aa\",\n \"#fdba74\",\n \"#fb923c\",\n \"#f97316\",\n \"#ea580c\",\n \"#c2410c\",\n \"#9a3412\",\n \"#7c2d12\",\n \"#431407\",\n ],\n amber: [\n \"#fffbeb\",\n \"#fef3c7\",\n \"#fde68a\",\n \"#fcd34d\",\n \"#fbbf24\",\n \"#f59e0b\",\n \"#d97706\",\n \"#b45309\",\n \"#92400e\",\n \"#78350f\",\n \"#451a03\",\n ],\n yellow: [\n \"#fefce8\",\n \"#fef9c3\",\n \"#fef08a\",\n \"#fde047\",\n \"#facc15\",\n \"#eab308\",\n \"#ca8a04\",\n \"#a16207\",\n \"#854d0e\",\n \"#713f12\",\n \"#422006\",\n ],\n lime: [\n \"#f7fee7\",\n \"#ecfccb\",\n \"#d9f99d\",\n \"#bef264\",\n \"#a3e635\",\n \"#84cc16\",\n \"#65a30d\",\n \"#4d7c0f\",\n \"#3f6212\",\n \"#365314\",\n \"#1a2e05\",\n ],\n green: [\n \"#f0fdf4\",\n \"#dcfce7\",\n \"#bbf7d0\",\n \"#86efac\",\n \"#4ade80\",\n \"#22c55e\",\n \"#16a34a\",\n \"#15803d\",\n \"#166534\",\n \"#14532d\",\n \"#052e16\",\n ],\n emerald: [\n \"#ecfdf5\",\n \"#d1fae5\",\n \"#a7f3d0\",\n \"#6ee7b7\",\n \"#34d399\",\n \"#10b981\",\n \"#059669\",\n \"#047857\",\n \"#065f46\",\n \"#064e3b\",\n \"#022c22\",\n ],\n teal: [\n \"#f0fdfa\",\n \"#ccfbf1\",\n \"#99f6e4\",\n \"#5eead4\",\n \"#2dd4bf\",\n \"#14b8a6\",\n \"#0d9488\",\n \"#0f766e\",\n \"#115e59\",\n \"#134e4a\",\n \"#042f2e\",\n ],\n cyan: [\n \"#ecfeff\",\n \"#cffafe\",\n \"#a5f3fc\",\n \"#67e8f9\",\n \"#22d3ee\",\n \"#06b6d4\",\n \"#0891b2\",\n \"#0e7490\",\n \"#155e75\",\n \"#164e63\",\n \"#083344\",\n ],\n sky: [\n \"#f0f9ff\",\n \"#e0f2fe\",\n \"#bae6fd\",\n \"#7dd3fc\",\n \"#38bdf8\",\n \"#0ea5e9\",\n \"#0284c7\",\n \"#0369a1\",\n \"#075985\",\n \"#0c4a6e\",\n \"#082f49\",\n ],\n blue: [\n \"#eff6ff\",\n \"#dbeafe\",\n \"#bfdbfe\",\n \"#93c5fd\",\n \"#60a5fa\",\n \"#3b82f6\",\n \"#2563eb\",\n \"#1d4ed8\",\n \"#1e40af\",\n \"#1e3a8a\",\n \"#172554\",\n ],\n indigo: [\n \"#eef2ff\",\n \"#e0e7ff\",\n \"#c7d2fe\",\n \"#a5b4fc\",\n \"#818cf8\",\n \"#6366f1\",\n \"#4f46e5\",\n \"#4338ca\",\n \"#3730a3\",\n \"#312e81\",\n \"#1e1b4b\",\n ],\n violet: [\n \"#f5f3ff\",\n \"#ede9fe\",\n \"#ddd6fe\",\n \"#c4b5fd\",\n \"#a78bfa\",\n \"#8b5cf6\",\n \"#7c3aed\",\n \"#6d28d9\",\n \"#5b21b6\",\n \"#4c1d95\",\n \"#2e1065\",\n ],\n purple: [\n \"#faf5ff\",\n \"#f3e8ff\",\n \"#e9d5ff\",\n \"#d8b4fe\",\n \"#c084fc\",\n \"#a855f7\",\n \"#9333ea\",\n \"#7e22ce\",\n \"#6b21a8\",\n \"#581c87\",\n \"#3b0764\",\n ],\n fuchsia: [\n \"#fdf4ff\",\n \"#fae8ff\",\n \"#f5d0fe\",\n \"#f0abfc\",\n \"#e879f9\",\n \"#d946ef\",\n \"#c026d3\",\n \"#a21caf\",\n \"#86198f\",\n \"#701a75\",\n \"#4a044e\",\n ],\n pink: [\n \"#fdf2f8\",\n \"#fce7f3\",\n \"#fbcfe8\",\n \"#f9a8d4\",\n \"#f472b6\",\n \"#ec4899\",\n \"#db2777\",\n \"#be185d\",\n \"#9d174d\",\n \"#831843\",\n \"#500724\",\n ],\n rose: [\n \"#fff1f2\",\n \"#ffe4e6\",\n \"#fecdd3\",\n \"#fda4af\",\n \"#fb7185\",\n \"#f43f5e\",\n \"#e11d48\",\n \"#be123c\",\n \"#9f1239\",\n \"#881337\",\n \"#4c0519\",\n ],\n} as const;\n\nexport type ChartColorName = keyof typeof DEFAULT_CHART_COLORS;\nexport type ChartColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;\n\n/** `'blue-600'`, `'blue'` (= 500), `'dimmed'`, `'bright'`, or any CSS color / variable. */\nexport type ChartColor =\n | `${ChartColorName}-${ChartColorShade}`\n | ChartColorName\n | \"dimmed\"\n | \"bright\"\n | (string & {});\n\nconst SHADES: readonly number[] = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];\nconst DEFAULT_SHADE = 500;\n\n/**\n * Resolves a Tailwind color name to a CSS color: `'blue-600'` → `var(--color-blue-600, #2563eb)`,\n * so a Tailwind v4 theme's own values win and the hex is the fallback. Anything else is returned unchanged.\n */\nexport function getThemeColor(\n color: ChartColor | undefined,\n fallback = \"var(--wello-chart-text-color)\",\n): string {\n if (!color) return fallback;\n if (color === \"dimmed\") return \"var(--wello-chart-dimmed-color)\";\n if (color === \"bright\") return \"var(--wello-chart-bright-color)\";\n const match = /^([a-z]+)(?:-(\\d{2,3}))?$/.exec(color);\n if (!match) return color;\n const palette = DEFAULT_CHART_COLORS[match[1] as ChartColorName];\n if (!palette) return color;\n const shade = match[2] === undefined ? DEFAULT_SHADE : Number(match[2]);\n const index = SHADES.indexOf(shade);\n if (index === -1) return color;\n return `var(--color-${match[1]}-${shade}, ${palette[index]})`;\n}\n\n/** Colors given to series and slices without their own `color`, in order. */\nexport const CHART_COLORS: readonly ChartColor[] = [\n \"emerald-500\",\n \"amber-500\",\n \"violet-500\",\n \"orange-500\",\n \"cyan-500\",\n \"pink-500\",\n \"red-500\",\n \"lime-500\",\n \"slate-500\",\n \"indigo-500\",\n \"slate-400\",\n];\n\n/** `color` if set, otherwise the palette color for this position. */\nexport function seriesColor(\n color: ChartColor | undefined,\n index: number,\n palette: readonly ChartColor[] = CHART_COLORS,\n): string {\n return getThemeColor(color ?? palette[index % palette.length]);\n}\n","import { useId, useLayoutEffect, useState, type RefObject } from \"react\";\n\nexport function cx(...classes: Array<string | false | null | undefined>): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport function formatValue(value: unknown, formatter?: (value: number) => string): string {\n if (typeof value === \"number\") return formatter ? formatter(value) : String(value);\n if (Array.isArray(value)) return value.map((v) => formatValue(v, formatter)).join(\" – \");\n return value === undefined || value === null ? \"\" : String(value);\n}\n\n/** SSR-stable id usable in `url(#id)`: React's ids contain `:` / `«»`, which break SVG references. */\nexport function useSvgId(prefix: string): string {\n return `${prefix}-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n}\n\nconst useIsomorphicLayoutEffect = typeof window === \"undefined\" ? () => {} : useLayoutEffect;\n\n/** `true` when the element is laid out right-to-left (`dir=\"rtl\"` on it or any ancestor). */\nexport function useIsRtl(ref: RefObject<HTMLElement | null>): boolean {\n const [rtl, setRtl] = useState(false);\n useIsomorphicLayoutEffect(() => {\n if (ref.current) setRtl(getComputedStyle(ref.current).direction === \"rtl\");\n });\n return rtl;\n}\n","import { getThemeColor } from \"../lib/colors\";\nimport type { ChartSeries } from \"../lib/types\";\nimport { cx } from \"../lib/utils\";\n\nexport interface ChartLegendProps {\n series: Pick<ChartSeries, \"name\" | \"color\" | \"label\">[];\n /** Called with the hovered series name, or `null` when the pointer leaves */\n onHighlight?: (name: string | null) => void;\n /** `start`/`end` follow the text direction; `left`/`right` are physical. Default: `'start'` */\n align?: \"start\" | \"end\" | \"left\" | \"center\" | \"right\";\n /** Additional class name for the legend container */\n className?: string;\n}\n\n/** Legend rendered above or below every chart. */\nexport function ChartLegend({ series, onHighlight, align = \"start\", className }: ChartLegendProps) {\n return (\n <div className={cx(\"wello-legend\", `wello-legend--${align}`, className)}>\n {series.map((item) => (\n <div\n key={item.name}\n className=\"wello-legend-item\"\n onMouseEnter={() => onHighlight?.(item.name)}\n onMouseLeave={() => onHighlight?.(null)}\n >\n <span className=\"wello-legend-swatch\" style={{ background: getThemeColor(item.color) }} />\n <span>{item.label ?? item.name}</span>\n </div>\n ))}\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { getThemeColor } from \"../lib/colors\";\nimport type { ChartSeries } from \"../lib/types\";\nimport { cx, formatValue } from \"../lib/utils\";\n\nexport interface ChartTooltipItem {\n name: string;\n value: unknown;\n color?: string;\n}\n\nexport interface ChartTooltipProps {\n label?: ReactNode;\n items: ChartTooltipItem[];\n series?: ChartSeries[];\n unit?: string;\n valueFormatter?: (value: number) => string;\n className?: string;\n}\n\n/** Tooltip body used by every chart; also usable in `tooltipProps.content`. */\nexport function ChartTooltip({\n label,\n items,\n series,\n unit,\n valueFormatter,\n className,\n}: ChartTooltipProps) {\n const visible = items.filter((item) => item.value !== undefined && item.value !== null);\n if (!visible.length) return null;\n\n return (\n <div className={cx(\"wello-tooltip\", className)}>\n {label !== undefined && label !== null && label !== \"\" && (\n <div className=\"wello-tooltip-label\">{label}</div>\n )}\n <div className=\"wello-tooltip-body\">\n {visible.map((item) => {\n const config = series?.find((s) => s.name === item.name);\n return (\n <div key={item.name} className=\"wello-tooltip-item\">\n <span\n className=\"wello-tooltip-swatch\"\n style={{ background: config ? getThemeColor(config.color) : item.color }}\n />\n <span className=\"wello-tooltip-item-name\">{config?.label ?? item.name}</span>\n <span className=\"wello-tooltip-item-value\">\n {formatValue(item.value, valueFormatter)}\n {unit}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** Adapts the recharts tooltip `content` props to `ChartTooltip`. */\nexport function renderCartesianTooltip(\n options: Omit<ChartTooltipProps, \"label\" | \"items\">,\n labelFormatter?: (label: any) => ReactNode,\n) {\n // recharts' content props are loosely typed; only these three are read.\n return ({ active, label, payload }: any) => {\n if (!active || !payload?.length) return null;\n return (\n <ChartTooltip\n {...options}\n label={labelFormatter ? labelFormatter(label) : label}\n // Read from the data item: stacked/percent charts report transformed values,\n // and waterfall rows keep their step in `__value` (the bar itself is a range).\n items={payload.map((entry: any) => ({\n name: String(entry.dataKey ?? entry.name),\n value: entry.payload?.__value ?? entry.payload?.[entry.dataKey] ?? entry.value,\n color: entry.color,\n }))}\n />\n );\n };\n}\n\nexport interface ChartSliceTooltipProps {\n name: string;\n value: number;\n color: string;\n /** 0–100 */\n percent: number;\n valueFormatter?: (value: number) => string;\n}\n\n/** Pie / donut tooltip: the slice name, then its share and value. */\nexport function ChartSliceTooltip({\n name,\n value,\n color,\n percent,\n valueFormatter,\n}: ChartSliceTooltipProps) {\n return (\n <div className=\"wello-tooltip wello-tooltip--slice\">\n <div className=\"wello-tooltip-label\">\n <span className=\"wello-tooltip-swatch\" style={{ background: color }} />\n <span>{name}</span>\n </div>\n <div className=\"wello-tooltip-item\">\n <span className=\"wello-tooltip-item-name\">{percent.toFixed(1)}%</span>\n <span className=\"wello-tooltip-item-value\">{formatValue(value, valueFormatter)}</span>\n </div>\n </div>\n );\n}\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { cx } from \"../lib/utils\";\n\nexport interface ChartStateProps {\n /** Show a loading skeleton instead of the chart */\n loading?: boolean;\n /** Shown when there is nothing to draw. Default: `'No data'` */\n emptyLabel?: ReactNode;\n}\n\ninterface ChartCanvasProps extends ChartStateProps {\n empty: boolean;\n height: number | string;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\n/** Chart shell: fixed height, loading skeleton, empty state. */\nexport function ChartCanvas({\n empty,\n loading = false,\n emptyLabel = \"No data\",\n height,\n className,\n style,\n children,\n}: ChartCanvasProps) {\n if (loading)\n return (\n <div\n className={cx(\"wello-chart\", \"wello-chart-skeleton\", className)}\n style={{ height, ...style }}\n aria-busy\n />\n );\n if (empty)\n return (\n <div\n className={cx(\"wello-chart\", \"wello-chart-empty\", className)}\n style={{ height, ...style }}\n >\n {emptyLabel}\n </div>\n );\n return <>{children}</>;\n}\n\nexport function isCartesianEmpty(data: Record<string, any>[], keys: string[]): boolean {\n return (\n !data.length ||\n !keys.length ||\n !data.some((row) => keys.some((key) => Number(row[key]) !== 0 && row[key] != null))\n );\n}\n","import { useMemo, useRef } from \"react\";\nimport { Bar, BarChart as ReBarChart, Cell, LabelList, ResponsiveContainer } from \"recharts\";\nimport { cartesianElements, isDimmed, resolveSeries, useHighlight } from \"../shared/cartesian\";\nimport { ChartCanvas, isCartesianEmpty } from \"../components/chart-canvas\";\nimport { getThemeColor, type ChartColor } from \"../lib/colors\";\nimport type { BaseCartesianChartProps, ChartData, ChartSeries } from \"../lib/types\";\nimport { cx, useIsRtl } from \"../lib/utils\";\n\nexport type BarChartType = \"default\" | \"stacked\" | \"percent\" | \"waterfall\";\n\nexport interface BarChartProps extends BaseCartesianChartProps {\n /** `'waterfall'` uses the first series; items with `standalone: true` start at 0 (totals). Default: `'default'` */\n type?: BarChartType;\n /** Default: 1 */\n fillOpacity?: number;\n /** Maximum bar width in px. Default: 26 */\n maxBarWidth?: number;\n /** Minimum bar height in px, so small values stay visible */\n minBarSize?: number;\n /** Value labels on bars */\n withBarValueLabel?: boolean;\n /** Passed to the value `LabelList` */\n valueLabelProps?: Record<string, any>;\n /** Color per bar, e.g. red for negative values. Overrides the series color */\n getBarColor?: (value: number, series: ChartSeries) => ChartColor;\n /** Passed to recharts `BarChart` */\n barChartProps?: Record<string, any>;\n /** Passed to every recharts `Bar`, or a function per series */\n barProps?: Record<string, any> | ((series: ChartSeries) => Record<string, any>);\n}\n\n/** Turns waterfall rows into `[start, end]` ranges; `standalone` rows start at 0 and reset the running total. */\nexport function getWaterfallData(data: ChartData, key: string): ChartData {\n let total = 0;\n return data.map((item) => {\n const value = Number(item[key]) || 0;\n if (item.standalone) {\n total = value;\n return { ...item, [key]: [0, value], __value: value };\n }\n const start = total;\n total += value;\n return { ...item, [key]: [start, total], __value: value };\n });\n}\n\n/**\n * Bar chart.\n *\n * @example\n * <BarChart h={300} data={data} dataKey=\"month\" type=\"stacked\" withLegend\n * series={[{ name: 'Smartphones', color: 'violet-600' }, { name: 'Laptops', color: 'blue-600' }]} />\n */\nexport function BarChart(props: BarChartProps) {\n const {\n data,\n series,\n h = 300,\n w = \"100%\",\n className,\n classNames,\n style,\n orientation = \"horizontal\",\n type = \"default\",\n fillOpacity = 1,\n maxBarWidth = 26,\n minBarSize,\n withBarValueLabel = false,\n valueLabelProps,\n getBarColor,\n barChartProps,\n barProps,\n valueFormatter,\n textColor,\n animationDuration = 650,\n loading,\n emptyLabel,\n children,\n } = props;\n const ref = useRef<HTMLDivElement>(null);\n const rtl = useIsRtl(ref);\n const [highlighted, setHighlighted] = useHighlight();\n const waterfall = type === \"waterfall\";\n const stacked = type === \"stacked\" || type === \"percent\";\n const resolved = resolveSeries(props);\n const visibleSeries = waterfall ? resolved.slice(0, 1) : resolved;\n\n const chartData = useMemo(\n () => (waterfall && series[0] ? getWaterfallData(data, series[0].name) : data),\n [waterfall, data, series],\n );\n\n const bars = visibleSeries.map((item) => {\n const color = getThemeColor(item.color);\n const dimmed = isDimmed(highlighted, item.name);\n const extra = typeof barProps === \"function\" ? barProps(item) : barProps;\n const radius = orientation === \"vertical\" ? [0, 7, 7, 0] : [7, 7, 0, 0];\n\n return (\n <Bar\n key={item.name}\n yAxisId={item.yAxisId ?? \"left\"}\n name={item.name}\n dataKey={item.name}\n fill={color}\n fillOpacity={dimmed ? 0.2 : fillOpacity}\n stroke={color}\n strokeOpacity={dimmed ? 0.2 : fillOpacity}\n strokeWidth={0}\n stackId={stacked ? \"stack\" : undefined}\n maxBarSize={maxBarWidth}\n minPointSize={minBarSize}\n // Stacked and waterfall bars stay square so segments meet cleanly.\n radius={stacked || waterfall ? 0 : (radius as [number, number, number, number])}\n isAnimationActive={animationDuration > 0}\n animationDuration={animationDuration}\n animationEasing=\"ease-out\"\n {...extra}\n >\n {(waterfall || getBarColor) &&\n chartData.map((row, index) => {\n const value = waterfall ? row.__value : row[item.name];\n const custom = getBarColor?.(value, item) ?? (waterfall ? row.color : undefined);\n return (\n <Cell\n key={index}\n fill={custom ? getThemeColor(custom) : color}\n stroke={custom ? getThemeColor(custom) : color}\n />\n );\n })}\n {withBarValueLabel && (\n <LabelList\n position={orientation === \"vertical\" ? \"right\" : \"top\"}\n fontSize={12}\n fill=\"var(--wello-chart-text-color)\"\n // Waterfall bars hold [start, end]; label the step itself.\n valueAccessor={(entry: any) => (waterfall ? entry.payload.__value : entry.value)}\n formatter={(value: any) =>\n valueFormatter && typeof value === \"number\" ? valueFormatter(value) : value\n }\n {...valueLabelProps}\n />\n )}\n </Bar>\n );\n });\n\n return (\n <ChartCanvas\n empty={isCartesianEmpty(\n data,\n visibleSeries.map((item) => item.name),\n )}\n loading={loading}\n emptyLabel={emptyLabel}\n height={h}\n className={cx(className, classNames?.root)}\n style={style}\n >\n <div\n ref={ref}\n className={cx(\"wello-chart\", className, classNames?.root)}\n style={{\n height: h,\n width: w,\n color: textColor ? getThemeColor(textColor) : undefined,\n ...style,\n }}\n >\n <ResponsiveContainer className={classNames?.chart}>\n <ReBarChart\n data={chartData}\n layout={orientation}\n stackOffset={type === \"percent\" ? \"expand\" : undefined}\n margin={{\n top: withBarValueLabel ? 20 : 10,\n right: 10,\n bottom: props.xAxisLabel ? 20 : 0,\n left: 0,\n }}\n {...barChartProps}\n >\n {cartesianElements(\n { ...props, series: visibleSeries },\n {\n highlighted,\n onHighlight: setHighlighted,\n cursor: \"fill\",\n rtl,\n valueTickFormatter:\n type === \"percent\" ? (value) => `${Math.round(value * 100)}%` : undefined,\n },\n )}\n {bars}\n {children}\n </ReBarChart>\n </ResponsiveContainer>\n </div>\n </ChartCanvas>\n );\n}\n","import { LabelList, Line, LineChart as ReLineChart, ResponsiveContainer } from \"recharts\";\nimport { useRef } from \"react\";\nimport {\n cartesianElements,\n isDimmed,\n resolveSeries,\n useHighlight,\n withLabelPadding,\n} from \"../shared/cartesian\";\nimport { ChartCanvas, isCartesianEmpty } from \"../components/chart-canvas\";\nimport { getThemeColor, type ChartColor } from \"../lib/colors\";\nimport type { BaseCartesianChartProps, ChartCurveType, ChartSeries } from \"../lib/types\";\nimport { cx, useIsRtl, useSvgId } from \"../lib/utils\";\n\nexport type LineChartType = \"default\" | \"gradient\";\n\nexport interface LineChartGradientStop {\n /** 0–100, from the top of the chart */\n offset: number;\n color: ChartColor;\n}\n\nexport interface LineChartProps extends BaseCartesianChartProps {\n /** `'gradient'` colors the line by `gradientStops` (first series only). Default: `'default'` */\n type?: LineChartType;\n /** Default: red → yellow → teal from top to bottom */\n gradientStops?: LineChartGradientStop[];\n /** Default: `'monotone'` */\n curveType?: ChartCurveType;\n /** Default: 2.75 */\n strokeWidth?: number;\n /** Default: false */\n withDots?: boolean;\n dotProps?: Record<string, any>;\n activeDotProps?: Record<string, any>;\n /** Default: true */\n connectNulls?: boolean;\n /** Value labels above every point */\n withPointLabels?: boolean;\n /** Passed to recharts `LineChart` (e.g. `syncId`) */\n lineChartProps?: Record<string, any>;\n /** Passed to every recharts `Line`, or a function per series */\n lineProps?: Record<string, any> | ((series: ChartSeries) => Record<string, any>);\n}\n\nconst DEFAULT_GRADIENT: LineChartGradientStop[] = [\n { offset: 0, color: \"red\" },\n { offset: 50, color: \"yellow\" },\n { offset: 100, color: \"teal\" },\n];\n\n/**\n * Line chart.\n *\n * @example\n * <LineChart h={300} data={data} dataKey=\"date\" withLegend curveType=\"linear\"\n * series={[{ name: 'Apples', color: 'indigo-600' }, { name: 'Oranges', color: 'teal-600', strokeDasharray: '5 5' }]} />\n */\nexport function LineChart(props: LineChartProps) {\n const {\n data,\n series,\n h = 300,\n w = \"100%\",\n className,\n classNames,\n style,\n orientation = \"horizontal\",\n type = \"default\",\n gradientStops = DEFAULT_GRADIENT,\n curveType = \"monotone\",\n strokeWidth = 2.75,\n withDots = false,\n dotProps,\n activeDotProps,\n connectNulls = true,\n withPointLabels = false,\n lineChartProps,\n lineProps,\n valueFormatter,\n textColor,\n animationDuration = 650,\n loading,\n emptyLabel,\n children,\n } = props;\n const ref = useRef<HTMLDivElement>(null);\n const rtl = useIsRtl(ref);\n const [highlighted, setHighlighted] = useHighlight();\n const gradientId = useSvgId(\"wello-line\");\n const gradient = type === \"gradient\";\n const resolved = resolveSeries(props);\n const visibleSeries = gradient ? resolved.slice(0, 1) : resolved;\n\n const lines = visibleSeries.map((item) => {\n const color = gradient ? `url(#${gradientId})` : getThemeColor(item.color);\n const dotColor = gradient ? \"var(--wello-chart-text-color)\" : color;\n const dimmed = isDimmed(highlighted, item.name);\n const extra = typeof lineProps === \"function\" ? lineProps(item) : lineProps;\n\n return (\n <Line\n key={item.name}\n yAxisId={item.yAxisId ?? \"left\"}\n name={item.name}\n dataKey={item.name}\n type={curveType}\n stroke={color}\n strokeWidth={strokeWidth}\n strokeDasharray={item.strokeDasharray}\n strokeOpacity={dimmed ? 0.2 : 1}\n connectNulls={connectNulls}\n dot={\n withDots\n ? {\n fill: dotColor,\n fillOpacity: dimmed ? 0 : 1,\n strokeWidth: 2,\n r: 4,\n stroke: \"var(--wello-chart-bg)\",\n ...dotProps,\n }\n : false\n }\n activeDot={{\n fill: \"var(--wello-chart-bg)\",\n stroke: dotColor,\n strokeWidth: 2,\n r: 4,\n ...activeDotProps,\n }}\n isAnimationActive={animationDuration > 0}\n animationDuration={animationDuration}\n animationEasing=\"ease-out\"\n {...extra}\n >\n {withPointLabels && (\n <LabelList\n position=\"top\"\n fontSize={12}\n fill=\"var(--wello-chart-text-color)\"\n formatter={(value: any) =>\n valueFormatter && typeof value === \"number\" ? valueFormatter(value) : value\n }\n />\n )}\n </Line>\n );\n });\n\n return (\n <ChartCanvas\n empty={isCartesianEmpty(\n data,\n visibleSeries.map((item) => item.name),\n )}\n loading={loading}\n emptyLabel={emptyLabel}\n height={h}\n className={cx(className, classNames?.root)}\n style={style}\n >\n <div\n ref={ref}\n className={cx(\"wello-chart\", className, classNames?.root)}\n style={{\n height: h,\n width: w,\n color: textColor ? getThemeColor(textColor) : undefined,\n ...style,\n }}\n >\n <ResponsiveContainer className={classNames?.chart}>\n <ReLineChart\n data={data}\n layout={orientation}\n margin={{\n top: withPointLabels ? 20 : 10,\n right: 10,\n bottom: props.xAxisLabel ? 20 : 0,\n left: 0,\n }}\n {...lineChartProps}\n >\n {gradient && (\n <defs>\n {/* Chart-relative, not bounding-box: a flat line has a zero-height box and would draw nothing. */}\n <linearGradient\n id={gradientId}\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0\"\n y1=\"0%\"\n x2=\"0\"\n y2=\"100%\"\n >\n {gradientStops.map((stop) => (\n <stop\n key={stop.offset}\n offset={`${stop.offset}%`}\n stopColor={getThemeColor(stop.color)}\n />\n ))}\n </linearGradient>\n </defs>\n )}\n {cartesianElements(\n withPointLabels\n ? withLabelPadding({ ...props, series: visibleSeries })\n : { ...props, series: visibleSeries },\n { highlighted, onHighlight: setHighlighted, cursor: \"line\", rtl },\n )}\n {lines}\n {children}\n </ReLineChart>\n </ResponsiveContainer>\n </div>\n </ChartCanvas>\n );\n}\n","import { useMemo, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { Cell, Pie, PieChart as RePieChart, ResponsiveContainer, Sector, Tooltip } from \"recharts\";\nimport { ChartCanvas, type ChartStateProps } from \"../components/chart-canvas\";\nimport { ChartLegend } from \"../components/chart-legend\";\nimport { ChartSliceTooltip, ChartTooltip } from \"../components/chart-tooltip\";\nimport { getThemeColor, seriesColor, type ChartColor } from \"../lib/colors\";\nimport type { ChartClassNames } from \"../lib/types\";\nimport { PointerTooltip, createPointerStore } from \"../components/floating-tooltip\";\nimport { cx, formatValue } from \"../lib/utils\";\n\nexport interface PieChartCell {\n name: string;\n value: number;\n /** Default: the next `CHART_COLORS` entry */\n color?: ChartColor;\n}\n\nexport type PieLabelsType = \"value\" | \"percent\";\n\n/** Props shared by PieChart and DonutChart. */\nexport interface BasePieChartProps extends ChartStateProps {\n data: PieChartCell[];\n /** Diameter in px. Default: 160 */\n size?: number;\n /** Colors for cells without their own `color`. Default: `CHART_COLORS` */\n colors?: readonly ChartColor[];\n /** Segment labels. Default: false */\n withLabels?: boolean;\n /** Lines from segments to outside labels. Default: true */\n withLabelsLine?: boolean;\n /** Default: `'value'` */\n labelsType?: PieLabelsType;\n labelColor?: ChartColor;\n /** Gap between segments in degrees (shows the card behind, on any background). Default: 2 */\n paddingAngle?: number;\n /** Default: 0 */\n startAngle?: number;\n /** Default: 360 */\n endAngle?: number;\n /** Segment corner radius in px. Default: 6 */\n cornerRadius?: number;\n /** Segment border width, used with `strokeColor`. Default: 3 */\n strokeWidth?: number;\n /**\n * Segment border color. Default: none — segments are separated by `paddingAngle` gaps instead,\n * so they read on light and dark cards alike (a fixed border color only matches one of them).\n */\n strokeColor?: ChartColor;\n withTooltip?: boolean;\n /** `'segment'` shows the hovered slice with its share, `'all'` lists every slice. Default: `'segment'` */\n tooltipDataSource?: \"all\" | \"segment\";\n tooltipProps?: Record<string, any>;\n /** Default: 0 */\n tooltipAnimationDuration?: number;\n /** Legend with hover highlight. Default: false */\n withLegend?: boolean;\n /** Default: `'bottom'` */\n legendPosition?: \"top\" | \"bottom\";\n valueFormatter?: (value: number) => string;\n /** Default: 650 (0 disables) */\n animationDuration?: number;\n /** Passed to recharts `Pie` */\n pieProps?: Record<string, any>;\n /** Passed to recharts `PieChart` */\n pieChartProps?: Record<string, any>;\n className?: string;\n /** Classes for the chart wrapper, plot area, and legend */\n classNames?: ChartClassNames;\n style?: CSSProperties;\n children?: ReactNode;\n}\n\ninterface InternalProps extends BasePieChartProps {\n innerRadius: number;\n labelsPosition: \"inside\" | \"outside\";\n /** Rendered in the center (donut label) */\n center?: ReactNode;\n /** Draw a muted ring instead of the empty state when every value is 0 */\n emptyRing?: boolean;\n rootClassName: string;\n}\n\nconst RADIAN = Math.PI / 180;\nconst OUTSIDE_LABEL_SPACE = 80;\n/** Hovered slices grow by this many px. */\nconst HOVER_GROWTH = 6;\n\nexport function getPercent(value: number, data: Pick<PieChartCell, \"value\">[]): number {\n const total = data.reduce((sum, item) => sum + (Number(item.value) || 0), 0);\n return total > 0 ? (value / total) * 100 : 0;\n}\n\n/** Hovered slice: same fill, a little larger, with a soft glow in its own color. */\nfunction ActiveSlice(props: any) {\n return (\n <Sector\n {...props}\n outerRadius={props.outerRadius + HOVER_GROWTH}\n stroke={props.fill}\n strokeWidth={2}\n style={{ filter: `drop-shadow(0 0 7px color-mix(in srgb, ${props.fill} 45%, transparent))` }}\n />\n );\n}\n\nexport function PieBase({\n data,\n size = 160,\n colors,\n withLabels = false,\n withLabelsLine = true,\n labelsType = \"value\",\n labelColor,\n labelsPosition,\n paddingAngle = 2,\n startAngle = 0,\n endAngle = 360,\n cornerRadius = 6,\n strokeWidth = 3,\n strokeColor,\n withTooltip = false,\n tooltipDataSource = \"segment\",\n tooltipProps,\n tooltipAnimationDuration = 0,\n withLegend = false,\n legendPosition = \"bottom\",\n valueFormatter,\n animationDuration = 650,\n pieProps,\n pieChartProps,\n loading,\n emptyLabel,\n className,\n classNames,\n style,\n children,\n innerRadius,\n center,\n emptyRing = false,\n rootClassName,\n}: InternalProps) {\n const [highlighted, setHighlighted] = useState<string | null>(null);\n // Not React state: re-rendering the chart on every move breaks the slice's mouseleave.\n const [pointer] = useState(createPointerStore);\n\n // Colors follow the original order; zero slices are not drawn.\n const cells = useMemo(\n () =>\n data\n .map((item, index) => ({ ...item, color: seriesColor(item.color, index, colors) }))\n .filter((item) => Number(item.value) > 0),\n [data, colors],\n );\n const total = cells.reduce((sum, item) => sum + Number(item.value), 0);\n const ring = total <= 0 && emptyRing && data.length > 0;\n\n const outside = withLabels && labelsPosition === \"outside\";\n // Room for outside labels, and for hovered slices to grow without clipping.\n const height = size + (outside ? OUTSIDE_LABEL_SPACE : 0) + HOVER_GROWTH * 2;\n const outerRadius = size / 2;\n const text = (value: number) =>\n labelsType === \"percent\"\n ? `${getPercent(value, cells).toFixed(0)}%`\n : formatValue(value, valueFormatter);\n\n const renderLabel = (entry: any) => {\n const { cx: x0, cy: y0, midAngle, outerRadius: r, innerRadius: ri, value } = entry;\n const radius = outside ? r + 16 : ri + (r - ri) / 2 || r / 2;\n const x = x0 + radius * Math.cos(-midAngle * RADIAN);\n const y = y0 + radius * Math.sin(-midAngle * RADIAN);\n return (\n <text\n x={x}\n y={y}\n fill={\n outside ? getThemeColor(labelColor, \"var(--wello-chart-text-color)\") : getThemeColor(labelColor, \"#fff\")\n }\n textAnchor={outside ? (x > x0 ? \"start\" : \"end\") : \"middle\"}\n dominantBaseline=\"central\"\n fontSize={11}\n fontWeight={outside ? 500 : 700}\n >\n {text(value)}\n </text>\n );\n };\n\n const legend = withLegend && !ring && (\n <ChartLegend\n series={cells.map(({ name, color }) => ({ name, color }))}\n align=\"center\"\n className={classNames?.legend}\n onHighlight={setHighlighted}\n />\n );\n\n return (\n <ChartCanvas\n empty={!cells.length && !ring}\n loading={loading}\n emptyLabel={emptyLabel}\n height={height}\n className={cx(className, classNames?.root)}\n style={style}\n >\n <div className={cx(\"wello-chart\", \"wello-pie\", rootClassName, className, classNames?.root)} style={{ minWidth: height, ...style }}>\n {legendPosition === \"top\" && legend}\n <div\n className={cx(\"wello-pie-area\", classNames?.chart)}\n style={{ height }}\n onMouseMove={(event) => {\n const area = event.currentTarget;\n const box = area.getBoundingClientRect();\n // Outward from the center: right half → right of the pointer, left half → left.\n const side = event.clientX >= box.left + box.width / 2 ? \"right\" : \"left\";\n pointer.set({ clientX: event.clientX, clientY: event.clientY, side, source: area });\n }}\n onMouseLeave={() => pointer.set(null)}\n >\n <ResponsiveContainer>\n <RePieChart {...pieChartProps}>\n <Pie\n data={ring ? [{ name: \"empty\", value: 1 }] : cells}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={innerRadius}\n outerRadius={outerRadius}\n paddingAngle={ring ? 0 : paddingAngle}\n startAngle={startAngle}\n endAngle={endAngle}\n cornerRadius={cornerRadius}\n stroke={strokeColor ? getThemeColor(strokeColor) : \"none\"}\n // A single full-circle slice would show its border as a seam.\n strokeWidth={ring || !strokeColor ? 0 : strokeWidth}\n label={withLabels && !ring ? renderLabel : false}\n labelLine={\n outside && withLabelsLine && !ring\n ? { stroke: \"var(--wello-chart-label-line-color)\" }\n : false\n }\n activeShape={ring ? undefined : ActiveSlice}\n isAnimationActive={animationDuration > 0}\n animationDuration={animationDuration}\n animationEasing=\"ease-out\"\n {...pieProps}\n >\n {ring ? (\n <Cell fill=\"var(--wello-chart-muted)\" />\n ) : (\n cells.map((item) => (\n <Cell\n key={item.name}\n fill={item.color}\n fillOpacity={highlighted !== null && highlighted !== item.name ? 0.2 : 1}\n />\n ))\n )}\n </Pie>\n {withTooltip && !ring && (\n <Tooltip\n cursor={false}\n isAnimationActive={false}\n // recharts decides which slice is active (the same state that enlarges it), so the\n // tooltip can't get stuck; the content itself is portaled next to the pointer.\n content={({ active, payload }: any) => {\n const hovered = payload?.[0]?.payload as\n | (PieChartCell & { color: string })\n | undefined;\n if (!active || !hovered) return null;\n return (\n <PointerTooltip store={pointer}>\n {tooltipDataSource === \"all\" ? (\n <ChartTooltip\n valueFormatter={valueFormatter}\n items={cells.map((item) => ({\n name: item.name,\n value: item.value,\n color: item.color,\n }))}\n />\n ) : (\n <ChartSliceTooltip\n name={hovered.name}\n value={hovered.value}\n color={hovered.color}\n percent={getPercent(hovered.value, cells)}\n valueFormatter={valueFormatter}\n />\n )}\n </PointerTooltip>\n );\n }}\n {...tooltipProps}\n />\n )}\n {children}\n </RePieChart>\n </ResponsiveContainer>\n {center !== undefined && center !== null && (\n <div className=\"wello-donut-label\">{center}</div>\n )}\n </div>\n {legendPosition === \"bottom\" && legend}\n </div>\n </ChartCanvas>\n );\n}\n","import {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport interface FloatingTooltipProps {\n /** Pointer position in viewport coordinates */\n clientX: number;\n clientY: number;\n /** Side to try first; `'top'` centers the tooltip above the anchor and flips below it */\n side: \"left\" | \"right\" | \"top\";\n /** Distance from the anchor in px. Default: 18 */\n gap?: number;\n /** Height of the anchored element, so a flipped `'top'` tooltip clears it. Default: 0 */\n anchorHeight?: number;\n /** Element whose `--wello-chart-tooltip-*` variables the tooltip copies (it renders outside it) */\n themeSource: HTMLElement | null;\n children: ReactNode;\n}\n\nconst GAP = 18;\nconst EDGE = 8;\nconst THEME_VARS = [\"--wello-chart-tooltip-bg\", \"--wello-chart-tooltip-fg\", \"--wello-chart-font\"];\n\n/**\n * Tooltip rendered into `document.body` with fixed positioning, so cards with\n * `overflow: hidden` can't clip it. Flips to the other side at the viewport edge.\n */\nexport function FloatingTooltip({\n clientX,\n clientY,\n side,\n gap = GAP,\n anchorHeight = 0,\n themeSource,\n children,\n}: FloatingTooltipProps) {\n const ref = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number } | null>(null);\n // Fixed positioning does not follow the page: hide on scroll until the pointer moves again.\n const [scrolledAt, setScrolledAt] = useState<{ x: number; y: number } | null>(null);\n const hidden = scrolledAt !== null && scrolledAt.x === clientX && scrolledAt.y === clientY;\n\n useEffect(() => {\n const onScroll = () => setScrolledAt({ x: clientX, y: clientY });\n window.addEventListener(\"scroll\", onScroll, { capture: true, passive: true });\n return () => window.removeEventListener(\"scroll\", onScroll, { capture: true });\n }, [clientX, clientY]);\n\n // Measure before paint, so the tooltip never flashes at the wrong spot.\n useLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n const { width, height } = element.getBoundingClientRect();\n const clampX = (value: number) =>\n Math.min(Math.max(value, EDGE), Math.max(EDGE, window.innerWidth - width - EDGE));\n const clampY = (value: number) =>\n Math.min(Math.max(value, EDGE), Math.max(EDGE, window.innerHeight - height - EDGE));\n let x: number;\n let y: number;\n if (side === \"top\") {\n const above = clientY - gap - height;\n x = clampX(clientX - width / 2);\n y = above >= EDGE ? above : clampY(clientY + anchorHeight + gap);\n } else {\n const right = clientX + gap;\n const left = clientX - gap - width;\n const fitsRight = right + width <= window.innerWidth - EDGE;\n const fitsLeft = left >= EDGE;\n x = clampX(\n side === \"right\"\n ? fitsRight || !fitsLeft\n ? right\n : left\n : fitsLeft || !fitsRight\n ? left\n : right,\n );\n y = clampY(clientY - height / 2);\n }\n setPosition((current) =>\n current && current.left === x && current.top === y ? current : { left: x, top: y },\n );\n }, [clientX, clientY, side, gap, anchorHeight, children]);\n\n const theme: Record<string, string> = {};\n if (themeSource) {\n const styles = getComputedStyle(themeSource);\n for (const name of THEME_VARS) theme[name] = styles.getPropertyValue(name);\n }\n\n const style: CSSProperties = {\n ...(theme as CSSProperties),\n position: \"fixed\",\n left: position?.left ?? 0,\n top: position?.top ?? 0,\n visibility: position && !hidden ? \"visible\" : \"hidden\",\n };\n\n return createPortal(\n <div ref={ref} className=\"wello-floating-tooltip\" style={style}>\n {children}\n </div>,\n document.body,\n );\n}\n\nexport interface PointerState {\n clientX: number;\n clientY: number;\n side: FloatingTooltipProps[\"side\"];\n /** Element the tooltip copies its theme from */\n source: HTMLElement;\n}\n\nexport interface PointerStore {\n get: () => PointerState | null;\n set: (next: PointerState | null) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\n/**\n * Pointer position kept outside React state. Re-rendering a recharts chart on every mouse\n * move replaces the hovered slice's DOM node, so the browser never fires its mouseleave and\n * the slice (and tooltip) stays active. With a store, only the tooltip re-renders.\n */\nexport function createPointerStore(): PointerStore {\n let state: PointerState | null = null;\n const listeners = new Set<() => void>();\n return {\n get: () => state,\n set: (next) => {\n state = next;\n listeners.forEach((listener) => listener());\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n/** `FloatingTooltip` that follows a `PointerStore`. */\nexport function PointerTooltip({ store, children }: { store: PointerStore; children: ReactNode }) {\n const pointer = useSyncExternalStore(store.subscribe, store.get, () => null);\n if (!pointer) return null;\n return (\n <FloatingTooltip\n clientX={pointer.clientX}\n clientY={pointer.clientY}\n side={pointer.side}\n themeSource={pointer.source}\n >\n {children}\n </FloatingTooltip>\n );\n}\n","import { PieBase, type BasePieChartProps } from \"../shared/pie-base\";\n\nexport interface PieChartProps extends BasePieChartProps {\n /** Default: `'outside'` */\n labelsPosition?: \"inside\" | \"outside\";\n}\n\n/**\n * Pie chart.\n *\n * @example\n * <PieChart withLabels labelsType=\"percent\" withTooltip\n * data={[{ name: 'USA', value: 400, color: 'indigo-600' }, { name: 'India', value: 300, color: 'yellow-600' }]} />\n */\nexport function PieChart({ labelsPosition = \"outside\", ...props }: PieChartProps) {\n return (\n <PieBase\n {...props}\n innerRadius={0}\n labelsPosition={labelsPosition}\n rootClassName=\"wello-pie-chart\"\n />\n );\n}\n","import type { ReactNode } from \"react\";\nimport { PieBase, type BasePieChartProps } from \"../shared/pie-base\";\n\nexport interface DonutChartProps extends BasePieChartProps {\n /** Ring width in px. Default: about a quarter of the radius (20 at the default size) */\n thickness?: number;\n /** Large text in the center, e.g. a total */\n chartLabel?: ReactNode;\n /** Small muted text under `chartLabel` */\n chartSubLabel?: ReactNode;\n /** Keep a muted ring when every value is 0 instead of the empty state */\n emptyRing?: boolean;\n}\n\n/**\n * Donut chart.\n *\n * @example\n * <DonutChart chartLabel=\"1,000\" chartSubLabel=\"Users\"\n * data={[{ name: 'USA', value: 400 }, { name: 'India', value: 300 }]} />\n */\nexport function DonutChart({\n thickness,\n chartLabel,\n chartSubLabel,\n emptyRing,\n withTooltip = true,\n ...props\n}: DonutChartProps) {\n const size = props.size ?? 160;\n const radius = size / 2;\n const ring = thickness ?? Math.round(radius * 0.26);\n const hasCenter = (chartLabel ?? null) !== null || (chartSubLabel ?? null) !== null;\n\n return (\n <PieBase\n {...props}\n withTooltip={withTooltip}\n innerRadius={Math.max(radius - ring, 0)}\n // Inside labels would not fit a thin ring; donut labels always sit outside.\n labelsPosition=\"outside\"\n emptyRing={emptyRing}\n center={\n hasCenter ? (\n <div className=\"wello-donut-label-inner\">\n {chartLabel !== undefined && <span className=\"wello-donut-label-main\">{chartLabel}</span>}\n {chartSubLabel !== undefined && (\n <span className=\"wello-donut-label-sub\">{chartSubLabel}</span>\n )}\n </div>\n ) : undefined\n }\n rootClassName=\"wello-donut-chart\"\n />\n );\n}\n","import { useMemo, useState, type CSSProperties, type ReactNode } from \"react\";\nimport {\n LabelList,\n RadialBar,\n RadialBarChart as ReRadialBarChart,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\";\nimport { ChartLegend } from \"../components/chart-legend\";\nimport { ChartTooltip } from \"../components/chart-tooltip\";\nimport { getThemeColor, seriesColor, type ChartColor } from \"../lib/colors\";\nimport type { ChartClassNames } from \"../lib/types\";\nimport { cx } from \"../lib/utils\";\n\nexport interface RadialBarChartProps {\n /** Items with `name`, `color` and the value under `dataKey` */\n data: Record<string, any>[];\n /** Key holding each bar's value */\n dataKey: string;\n /** Chart height. Default: 300 */\n h?: number | string;\n /** Chart width. Default: 100% */\n w?: number | string;\n /** Colors for items without their own `color`. Default: `CHART_COLORS` */\n colors?: readonly ChartColor[];\n /** Default: 650 (0 disables) */\n animationDuration?: number;\n /** Bar thickness in px. Default: 20 */\n barSize?: number;\n /** Draw the empty part of each track. Default: true */\n withBackground?: boolean;\n /** Track color. Default: `--wello-chart-radial-bg` */\n emptyBackgroundColor?: ChartColor;\n /** Default: 90 (top) */\n startAngle?: number;\n /** Default: -270 (full circle, clockwise) */\n endAngle?: number;\n /** Item names at the start of each bar */\n withLabels?: boolean;\n /** Default: false */\n withLegend?: boolean;\n /** Default: `'bottom'` */\n legendPosition?: \"top\" | \"bottom\";\n /** Default: true */\n withTooltip?: boolean;\n tooltipProps?: Record<string, any>;\n valueFormatter?: (value: number) => string;\n /** Passed to recharts `RadialBar` */\n radialBarProps?: Record<string, any>;\n /** Passed to recharts `RadialBarChart` */\n radialBarChartProps?: Record<string, any>;\n className?: string;\n /** Classes for the chart wrapper, plot area, and legend */\n classNames?: ChartClassNames;\n style?: CSSProperties;\n children?: ReactNode;\n}\n\n/**\n * Radial bar chart.\n *\n * @example\n * <RadialBarChart h={260} dataKey=\"value\" withLegend\n * data={[{ name: '18-24', value: 31.47, color: 'blue-700' }, { name: '25-29', value: 26.69, color: 'orange-600' }]} />\n */\nexport function RadialBarChart({\n data,\n dataKey,\n h = 300,\n w = \"100%\",\n colors,\n animationDuration = 650,\n barSize = 20,\n withBackground = true,\n emptyBackgroundColor,\n startAngle = 90,\n endAngle = -270,\n withLabels = false,\n withLegend = false,\n legendPosition = \"bottom\",\n withTooltip = true,\n tooltipProps,\n valueFormatter,\n radialBarProps,\n radialBarChartProps,\n className,\n classNames,\n style,\n children,\n}: RadialBarChartProps) {\n const [highlighted, setHighlighted] = useState<string | null>(null);\n\n // recharts reads each bar's color from `fill`.\n const chartData = useMemo(\n () =>\n data.map((item, index) => ({\n ...item,\n fill: seriesColor(item.color, index, colors),\n fillOpacity: highlighted !== null && highlighted !== item.name ? 0.2 : 1,\n })),\n [data, colors, highlighted],\n );\n\n const legend = withLegend && (\n <ChartLegend\n series={chartData.map((item, index) => ({\n name: String(data[index].name),\n color: item.fill,\n }))}\n align=\"center\"\n className={classNames?.legend}\n onHighlight={setHighlighted}\n />\n );\n\n return (\n <div\n className={cx(\"wello-chart\", \"wello-radial-bar\", className, classNames?.root)}\n style={{ width: w, ...style }}\n >\n {legendPosition === \"top\" && legend}\n <div className={classNames?.chart} style={{ height: h }}>\n <ResponsiveContainer>\n <ReRadialBarChart\n data={chartData}\n barSize={barSize}\n startAngle={startAngle}\n endAngle={endAngle}\n innerRadius=\"10%\"\n outerRadius=\"100%\"\n {...radialBarChartProps}\n >\n <RadialBar\n dataKey={dataKey}\n background={\n withBackground\n ? { fill: getThemeColor(emptyBackgroundColor, \"var(--wello-chart-radial-bg)\") }\n : false\n }\n cornerRadius={barSize / 2}\n isAnimationActive={animationDuration > 0}\n animationDuration={animationDuration}\n animationEasing=\"ease-out\"\n {...radialBarProps}\n >\n {withLabels && (\n <LabelList\n position=\"insideStart\"\n dataKey=\"name\"\n fill=\"#fff\"\n fontSize={12}\n fontWeight={600}\n />\n )}\n </RadialBar>\n {withTooltip && (\n <Tooltip\n isAnimationActive={false}\n cursor={false}\n content={({ active, payload }: any) => {\n if (!active || !payload?.length) return null;\n const item = payload[0].payload;\n return (\n <ChartTooltip\n valueFormatter={valueFormatter}\n items={[{ name: String(item.name), value: item[dataKey], color: item.fill }]}\n />\n );\n }}\n {...tooltipProps}\n />\n )}\n {children}\n </ReRadialBarChart>\n </ResponsiveContainer>\n </div>\n {legendPosition === \"bottom\" && legend}\n </div>\n );\n}\n","import { useMemo, useState, type CSSProperties, type ReactNode, type SVGProps } from \"react\";\nimport { getThemeColor, type ChartColor } from \"../lib/colors\";\nimport type { ChartClassNames } from \"../lib/types\";\nimport { FloatingTooltip } from \"../components/floating-tooltip\";\nimport { cx } from \"../lib/utils\";\n\nexport interface HeatmapRectData {\n /** `YYYY-MM-DD` */\n date: string;\n /** `null` when the date has no value */\n value: number | null;\n}\n\nexport interface HeatmapProps {\n /** Values by UTC day: `{ '2025-02-14': 2 }` */\n data: Record<string, number>;\n /** First day shown. Default: one year before `endDate` */\n startDate?: string | Date;\n /** Last day shown. Default: today */\n endDate?: string | Date;\n /** Colors from low to high. Default: 4 green shades */\n colors?: ChartColor[];\n /** `[min, max]` mapped to the first and last color. Default: from the data */\n domain?: [number, number];\n /** 0 = Sunday … 6 = Saturday. Default: 1 (Monday) */\n firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n /** Square size in px. Default: 10 */\n rectSize?: number;\n /** Space between squares in px. Default: 1 */\n gap?: number;\n /** Default: 2 */\n rectRadius?: number;\n /** Label font size in px. Default: 12 */\n fontSize?: number;\n withMonthLabels?: boolean;\n /** 12 names, January first. Default: `Jan` … `Dec` */\n monthLabels?: string[];\n /** Default: `'top'` */\n monthLabelsPosition?: \"top\" | \"bottom\";\n /** Default: 14 */\n monthsLabelsHeight?: number;\n withWeekdayLabels?: boolean;\n /** 7 names, Sunday first; empty strings hide rows. Default: Mon, Wed, Fri */\n weekdayLabels?: string[];\n /** Default: 30 */\n weekdaysLabelsWidth?: number;\n /** Empty column between months */\n splitMonths?: boolean;\n /** Show the days around the range (in the first/last week) as empty squares */\n withOutsideDates?: boolean;\n withTooltip?: boolean;\n /** Tooltip content; required for the tooltip to show */\n getTooltipLabel?: (rect: HeatmapRectData) => ReactNode;\n /** Extra props for each square */\n getRectProps?: (rect: HeatmapRectData) => SVGProps<SVGRectElement>;\n /** Color scale below the grid */\n withLegend?: boolean;\n /** Default: `['Less', 'More']` */\n legendLabels?: [string, string];\n className?: string;\n /** Classes for the chart wrapper, plot area, and legend */\n classNames?: ChartClassNames;\n style?: CSSProperties;\n \"aria-label\"?: string;\n}\n\nconst DAY = 86_400_000;\nconst DEFAULT_COLORS: ChartColor[] = [\"green-200\", \"green-400\", \"green-600\", \"green-800\"];\nconst DEFAULT_MONTHS = [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n];\nconst DEFAULT_WEEKDAYS = [\"\", \"Mon\", \"\", \"Wed\", \"\", \"Fri\", \"\"];\n\n/** UTC midnight for a `YYYY-MM-DD` string or a Date (its local calendar day). */\nexport function toUtcDay(value: string | Date): number {\n if (typeof value === \"string\") {\n const [y, m, d] = value.slice(0, 10).split(\"-\").map(Number);\n return Date.UTC(y, m - 1, d);\n }\n return Date.UTC(value.getFullYear(), value.getMonth(), value.getDate());\n}\n\nexport function formatUtcDay(time: number): string {\n return new Date(time).toISOString().slice(0, 10);\n}\n\nexport interface HeatmapCell {\n date: string;\n /** Outside `startDate`–`endDate` (only present with `withOutsideDates`) */\n outside: boolean;\n}\n\nexport interface HeatmapColumn {\n /** 7 slots ordered from `firstDayOfWeek`; `null` = nothing drawn */\n cells: (HeatmapCell | null)[];\n /** Empty spacer between months */\n spacer?: boolean;\n /** Month index (0–11) whose label starts in this column */\n monthLabel?: number;\n}\n\n/** Lays the date range out in week columns, like a contribution calendar. */\nexport function getHeatmapColumns({\n startDate,\n endDate,\n firstDayOfWeek = 1,\n splitMonths = false,\n withOutsideDates = false,\n}: {\n startDate: number;\n endDate: number;\n firstDayOfWeek?: number;\n splitMonths?: boolean;\n withOutsideDates?: boolean;\n}): HeatmapColumn[] {\n const columns: HeatmapColumn[] = [];\n if (endDate < startDate) return columns;\n const row = (time: number) => (new Date(time).getUTCDay() - firstDayOfWeek + 7) % 7;\n const month = (time: number) => new Date(time).getUTCMonth();\n\n let column: HeatmapColumn = { cells: Array(7).fill(null) };\n const push = () => {\n if (column.cells.some(Boolean)) columns.push(column);\n column = { cells: Array(7).fill(null) };\n };\n\n // Pad the first and last week so whole columns are drawn.\n const first = withOutsideDates ? startDate - row(startDate) * DAY : startDate;\n const last = withOutsideDates ? endDate + (6 - row(endDate)) * DAY : endDate;\n let previousMonth: number | null = null;\n\n for (let time = first; time <= last; time += DAY) {\n const outside = time < startDate || time > endDate;\n const currentMonth = month(time);\n if (time !== first && row(time) === 0) push();\n if (splitMonths && !outside && previousMonth !== null && currentMonth !== previousMonth) {\n push();\n columns.push({ cells: Array(7).fill(null), spacer: true });\n }\n if (!outside && previousMonth !== currentMonth) {\n column.monthLabel = currentMonth;\n previousMonth = currentMonth;\n }\n column.cells[row(time)] = { date: formatUtcDay(time), outside };\n }\n push();\n\n // A label needs ~3 columns of room; drop the one that would collide with the next.\n let lastLabel = -Infinity;\n columns.forEach((item, index) => {\n if (item.monthLabel === undefined) return;\n if (index - lastLabel < 3) {\n const previous = columns[lastLabel];\n if (previous) delete previous.monthLabel;\n }\n lastLabel = index;\n });\n return columns;\n}\n\n/** Index into `colors` for a value; `-1` for no value. */\nexport function getHeatColorIndex(\n value: number | null | undefined,\n domain: [number, number],\n count: number,\n): number {\n if (value === null || value === undefined || !Number.isFinite(value)) return -1;\n const [min, max] = domain;\n if (max <= min) return count - 1;\n const ratio = Math.min(Math.max((value - min) / (max - min), 0), 1);\n return Math.min(count - 1, Math.floor(ratio * count));\n}\n\n/**\n * Calendar heatmap (contributions-style).\n *\n * @example\n * <Heatmap data={{ '2025-02-14': 2, '2025-02-11': 3 }} startDate=\"2025-01-01\" endDate=\"2025-03-31\"\n * withMonthLabels withWeekdayLabels withTooltip getTooltipLabel={({ date, value }) => `${date}: ${value ?? 0}`} />\n */\nexport function Heatmap({\n data,\n startDate,\n endDate,\n colors = DEFAULT_COLORS,\n domain,\n firstDayOfWeek = 1,\n rectSize = 10,\n gap = 1,\n rectRadius = 2,\n fontSize = 12,\n withMonthLabels = false,\n monthLabels = DEFAULT_MONTHS,\n monthLabelsPosition = \"top\",\n monthsLabelsHeight = 14,\n withWeekdayLabels = false,\n weekdayLabels = DEFAULT_WEEKDAYS,\n weekdaysLabelsWidth = 30,\n splitMonths = false,\n withOutsideDates = false,\n withTooltip = false,\n getTooltipLabel,\n getRectProps,\n withLegend = false,\n legendLabels = [\"Less\", \"More\"],\n className,\n classNames,\n style,\n \"aria-label\": ariaLabel = \"Heatmap\",\n}: HeatmapProps) {\n const [hover, setHover] = useState<{\n rect: HeatmapRectData;\n x: number;\n y: number;\n size: number;\n source: HTMLElement;\n } | null>(null);\n\n const end = endDate !== undefined ? toUtcDay(endDate) : toUtcDay(new Date());\n const start =\n startDate !== undefined\n ? toUtcDay(startDate)\n : Date.UTC(\n new Date(end).getUTCFullYear() - 1,\n new Date(end).getUTCMonth(),\n new Date(end).getUTCDate() + 1,\n );\n\n const columns = useMemo(\n () =>\n getHeatmapColumns({\n startDate: start,\n endDate: end,\n firstDayOfWeek,\n splitMonths,\n withOutsideDates,\n }),\n [start, end, firstDayOfWeek, splitMonths, withOutsideDates],\n );\n\n const resolvedDomain = useMemo<[number, number]>(() => {\n if (domain) return domain;\n const values = Object.values(data).filter((value) => Number.isFinite(value));\n return values.length ? [Math.min(...values), Math.max(...values)] : [0, 0];\n }, [data, domain]);\n\n const palette = colors.map((color) => getThemeColor(color));\n const step = rectSize + gap;\n const left = withWeekdayLabels ? weekdaysLabelsWidth : 0;\n const top = withMonthLabels && monthLabelsPosition === \"top\" ? monthsLabelsHeight : 0;\n const gridHeight = 7 * step - gap;\n const width = left + columns.length * step - gap;\n const height =\n top +\n gridHeight +\n (withMonthLabels && monthLabelsPosition === \"bottom\" ? monthsLabelsHeight : 0);\n const tooltipEnabled = withTooltip && !!getTooltipLabel;\n // Weekday labels follow the row order, which starts at `firstDayOfWeek`.\n const rowLabels = Array.from(\n { length: 7 },\n (_, rowIndex) => weekdayLabels[(rowIndex + firstDayOfWeek) % 7],\n );\n\n return (\n <div className={cx(\"wello-chart\", \"wello-heatmap\", className, classNames?.root)} style={style}>\n <svg\n className={classNames?.chart}\n width={width}\n height={height}\n role=\"img\"\n aria-label={ariaLabel}\n onMouseLeave={() => setHover(null)}\n >\n {withWeekdayLabels &&\n rowLabels.map((label, rowIndex) =>\n label ? (\n <text\n key={rowIndex}\n className=\"wello-heatmap-label\"\n x={0}\n y={top + rowIndex * step + rectSize / 2}\n dominantBaseline=\"central\"\n fontSize={fontSize}\n >\n {label}\n </text>\n ) : null,\n )}\n\n {withMonthLabels &&\n columns.map((column, index) =>\n column.monthLabel !== undefined ? (\n <text\n key={`m-${index}`}\n className=\"wello-heatmap-label\"\n x={left + index * step}\n y={\n monthLabelsPosition === \"top\"\n ? monthsLabelsHeight - 4\n : top + gridHeight + monthsLabelsHeight - 2\n }\n fontSize={fontSize}\n >\n {monthLabels[column.monthLabel]}\n </text>\n ) : null,\n )}\n\n {columns.map((column, columnIndex) =>\n column.cells.map((cell, rowIndex) => {\n if (!cell) return null;\n const value = cell.outside ? null : (data[cell.date] ?? null);\n const rect = { date: cell.date, value };\n const colorIndex = getHeatColorIndex(value, resolvedDomain, palette.length);\n return (\n <rect\n key={cell.date}\n className={cx(\"wello-heatmap-rect\", cell.outside && \"wello-heatmap-rect--outside\")}\n x={left + columnIndex * step}\n y={top + rowIndex * step}\n width={rectSize}\n height={rectSize}\n rx={rectRadius}\n fill={colorIndex === -1 ? \"var(--wello-chart-heatmap-empty)\" : palette[colorIndex]}\n data-date={cell.date}\n data-value={value ?? undefined}\n onMouseEnter={\n tooltipEnabled && !cell.outside\n ? (event) => {\n // Viewport coordinates of the square: the tooltip is portaled to <body>.\n const own = event.currentTarget.getBoundingClientRect();\n setHover({\n rect,\n x: own.left + own.width / 2,\n y: own.top,\n size: own.height,\n source: event.currentTarget.ownerSVGElement!.parentElement!,\n });\n }\n : undefined\n }\n {...getRectProps?.(rect)}\n />\n );\n }),\n )}\n </svg>\n\n {tooltipEnabled && hover && (\n <FloatingTooltip\n clientX={hover.x}\n clientY={hover.y}\n side=\"top\"\n gap={6}\n anchorHeight={hover.size}\n themeSource={hover.source}\n >\n <div className=\"wello-tooltip wello-heatmap-tooltip\">{getTooltipLabel!(hover.rect)}</div>\n </FloatingTooltip>\n )}\n\n {withLegend && (\n <div\n className={cx(\"wello-heatmap-legend\", classNames?.legend)}\n style={{ paddingInlineStart: left, fontSize }}\n >\n <span>{legendLabels[0]}</span>\n {palette.map((color) => (\n <span\n key={color}\n className=\"wello-heatmap-legend-rect\"\n style={{\n width: rectSize,\n height: rectSize,\n borderRadius: rectRadius,\n background: color,\n }}\n />\n ))}\n <span>{legendLabels[1]}</span>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;AACyB,SAAR,YAA6B,KAAK,EAAE,SAAS,IAAI,CAAC,GAAG;AAC1D,MAAI,CAAC,OAAO,OAAO,aAAa,YAAa;AAE7C,QAAM,OAAO,SAAS,QAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC;AACrE,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,OAAO;AAEb,MAAI,aAAa,OAAO;AACtB,QAAI,KAAK,YAAY;AACnB,WAAK,aAAa,OAAO,KAAK,UAAU;AAAA,IAC1C,OAAO;AACL,WAAK,YAAY,KAAK;AAAA,IACxB;AAAA,EACF,OAAO;AACL,SAAK,YAAY,KAAK;AAAA,EACxB;AAEA,MAAI,MAAM,YAAY;AACpB,UAAM,WAAW,UAAU;AAAA,EAC7B,OAAO;AACL,UAAM,YAAY,SAAS,eAAe,GAAG,CAAC;AAAA,EAChD;AACF;;;ACvB8B,YAAY,ooMAAooM;;;ACAxrM,SAAS,MAAM,aAAa,aAAa,WAAW,2BAA2B;AAC/E,SAAS,cAAc;;;ACD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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,E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cACd;AAAA;AAAA,YAPK;AAAA,UAQP,CACD;AAAA,UACD,gBAAAA,MAAC,UAAM,uBAAa,CAAC,GAAE;AAAA;AAAA;AAAA,IACzB;AAAA,KAEJ;AAEJ;","names":["useState","jsx","jsxs","jsx","useState","jsx","Fragment","jsx","jsxs","useRef","LabelList","ResponsiveContainer","jsx","jsxs","useRef","LabelList","ResponsiveContainer","LabelList","ResponsiveContainer","useRef","jsx","jsxs","useRef","LabelList","ResponsiveContainer","useMemo","useState","Cell","ResponsiveContainer","Tooltip","useLayoutEffect","useRef","useState","jsx","jsx","jsxs","useState","useMemo","ResponsiveContainer","Cell","Tooltip","jsx","jsx","jsxs","useMemo","useState","LabelList","ResponsiveContainer","Tooltip","jsx","jsxs","useState","useMemo","ResponsiveContainer","LabelList","Tooltip","useMemo","useState","jsx","jsxs","useState","useMemo"]}
@@ -0,0 +1,321 @@
1
+ /*
2
+ * @wello-dev/charts styles. Import once: import "@wello-dev/charts/styles.css";
3
+ * Light by default; dark inside `.dark` or `[data-theme="dark"]`. Override any --wello-chart-* variable.
4
+ */
5
+
6
+ /*
7
+ * Colors follow @wello-dev/core when it is on the page (its primary color, and neutrals tinted by it),
8
+ * then shadcn/ui-style app tokens (--primary, --card, --border…), then the values here.
9
+ */
10
+ .wello-chart {
11
+ --wello-chart-primary: var(--wello-primary-color, var(--primary, #26372c));
12
+ --wello-chart-bg: var(--wello-color-surface, var(--card, #ffffff));
13
+ /*
14
+ * Axis text, grid and legend follow the text color of the surface the chart sits on,
15
+ * so the same chart reads on a white card and on a dark hero panel with no overrides.
16
+ * `currentColor` resolves where each token is used (the chart root keeps the inherited color).
17
+ */
18
+ --wello-chart-text-color: color-mix(in srgb, currentColor 50%, transparent);
19
+ --wello-chart-legend-color: color-mix(in srgb, currentColor 85%, transparent);
20
+ --wello-chart-bright-color: currentColor;
21
+ --wello-chart-dimmed-color: color-mix(in srgb, currentColor 50%, transparent);
22
+ /* ≈ Mantine's rgba(gray, .6) grid: visible as a dashed line on light and dark cards. */
23
+ --wello-chart-grid-color: color-mix(in srgb, currentColor 22%, transparent);
24
+ --wello-chart-cursor-fill: color-mix(in srgb, var(--wello-chart-primary) 8%, transparent);
25
+ --wello-chart-label-line-color: var(--wello-color-border-strong, var(--input, #cbd5e1));
26
+ --wello-chart-tooltip-bg: var(--wello-color-bright, var(--foreground, #0f172a));
27
+ --wello-chart-tooltip-fg: var(--wello-color-body, var(--background, #ffffff));
28
+ --wello-chart-heatmap-empty: color-mix(in srgb, var(--wello-chart-text-color) 15%, transparent);
29
+ --wello-chart-radial-bg: color-mix(in srgb, var(--wello-chart-text-color) 12%, transparent);
30
+ --wello-chart-muted: color-mix(in srgb, var(--wello-chart-text-color) 35%, transparent);
31
+ --wello-chart-font: inherit;
32
+
33
+ box-sizing: border-box;
34
+ position: relative;
35
+ /* No card of its own: transparent, sits on the app's surface and keeps its text color. */
36
+ font-family: var(--wello-chart-font);
37
+ }
38
+
39
+ .dark .wello-chart,
40
+ [data-theme="dark"] .wello-chart,
41
+ .wello-chart[data-theme="dark"] {
42
+ --wello-chart-primary: var(--wello-primary-color, var(--primary, #9fbfa8));
43
+ --wello-chart-bg: var(--wello-color-surface, var(--card, #0f172a));
44
+ --wello-chart-label-line-color: var(--wello-color-border-strong, var(--input, #475569));
45
+ --wello-chart-tooltip-bg: var(--wello-color-bright, var(--foreground, #f8fafc));
46
+ --wello-chart-tooltip-fg: var(--wello-color-body, var(--background, #0f172a));
47
+ }
48
+
49
+ /*
50
+ * Snap grid lines to whole pixels. Tick spacing is rarely a whole number, so without this every
51
+ * other 1px line lands between two pixel rows, renders at half strength and all but vanishes.
52
+ */
53
+ .wello-chart .recharts-cartesian-grid line {
54
+ shape-rendering: crispEdges;
55
+ }
56
+
57
+ /*
58
+ * Recharts lays out every label in left-to-right coordinates. Under an RTL page the SVG inherits
59
+ * `direction: rtl`, which flips `text-anchor: start/end`, so axis labels (e.g. Arabic day names
60
+ * on a vertical chart) grow into the plot. Arabic words still shape correctly in an LTR box;
61
+ * the HTML legend and tooltip keep the page direction.
62
+ */
63
+ .wello-chart .recharts-surface,
64
+ .wello-heatmap svg {
65
+ direction: ltr;
66
+ }
67
+
68
+ /* Recharts draws a focus outline around the whole chart on click. */
69
+ .wello-chart .recharts-wrapper:focus,
70
+ .wello-chart .recharts-surface:focus,
71
+ .wello-chart *:focus:not(:focus-visible) {
72
+ outline: none;
73
+ }
74
+
75
+ /* Tooltip: inverted colors (foreground background, card text) */
76
+
77
+ .wello-tooltip {
78
+ min-width: 8.5rem;
79
+ padding: 10px 12px;
80
+ border-radius: 12px;
81
+ background: color-mix(in srgb, var(--wello-chart-tooltip-bg) 94%, transparent);
82
+ color: var(--wello-chart-tooltip-fg);
83
+ box-shadow: 0 12px 32px rgb(0 0 0 / 0.24);
84
+ font-size: 12px;
85
+ line-height: 1.4;
86
+ pointer-events: none;
87
+ }
88
+
89
+ .wello-tooltip-label {
90
+ display: flex;
91
+ align-items: center;
92
+ gap: 8px;
93
+ margin-bottom: 4px;
94
+ opacity: 0.8;
95
+ }
96
+
97
+ .wello-tooltip--slice .wello-tooltip-label {
98
+ margin-bottom: 6px;
99
+ font-weight: 600;
100
+ opacity: 1;
101
+ }
102
+
103
+ .wello-tooltip-body {
104
+ display: flex;
105
+ flex-direction: column;
106
+ gap: 4px;
107
+ }
108
+
109
+ .wello-tooltip-item {
110
+ display: flex;
111
+ align-items: center;
112
+ gap: 8px;
113
+ }
114
+
115
+ .wello-tooltip-swatch,
116
+ .wello-legend-swatch {
117
+ flex-shrink: 0;
118
+ width: 8px;
119
+ height: 8px;
120
+ border-radius: 999px;
121
+ }
122
+
123
+ /* Dark series colors stay visible on the inverted tooltip. */
124
+ .wello-tooltip .wello-tooltip-swatch {
125
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--wello-chart-tooltip-fg) 45%, transparent);
126
+ }
127
+
128
+ .wello-tooltip-item-name {
129
+ flex: 1;
130
+ opacity: 0.8;
131
+ }
132
+
133
+ .wello-tooltip-item-value {
134
+ margin-inline-start: 16px;
135
+ font-variant-numeric: tabular-nums;
136
+ font-weight: 700;
137
+ }
138
+
139
+ /* Legend */
140
+
141
+ .wello-legend {
142
+ display: flex;
143
+ flex-wrap: wrap;
144
+ gap: 4px 12px;
145
+ box-sizing: border-box;
146
+ max-width: 100%;
147
+ padding-bottom: 14px;
148
+ font-size: 12.5px;
149
+ font-weight: 500;
150
+ color: var(--wello-chart-legend-color);
151
+ }
152
+
153
+ /* start/end follow the text direction (start = right in Arabic). */
154
+ .wello-legend--start,
155
+ .wello-legend--left {
156
+ justify-content: flex-start;
157
+ }
158
+
159
+ .wello-legend--center {
160
+ justify-content: center;
161
+ }
162
+
163
+ .wello-legend--end,
164
+ .wello-legend--right {
165
+ justify-content: flex-end;
166
+ }
167
+
168
+ /* left/right stay physical in RTL. */
169
+ [dir="rtl"] .wello-legend--left {
170
+ justify-content: flex-end;
171
+ }
172
+
173
+ [dir="rtl"] .wello-legend--right {
174
+ justify-content: flex-start;
175
+ }
176
+
177
+ .wello-legend .wello-legend-swatch {
178
+ width: 10px;
179
+ height: 10px;
180
+ }
181
+
182
+ .wello-legend-item {
183
+ display: flex;
184
+ align-items: center;
185
+ gap: 8px;
186
+ padding: 3px 8px;
187
+ border-radius: 999px;
188
+ cursor: default;
189
+ transition: background-color 120ms ease;
190
+ }
191
+
192
+ .wello-legend-item:hover {
193
+ background: var(--wello-chart-cursor-fill);
194
+ }
195
+
196
+ /* Loading & empty states */
197
+
198
+ .wello-chart-skeleton {
199
+ border-radius: 12px;
200
+ background: color-mix(in srgb, var(--wello-chart-text-color) 14%, transparent);
201
+ animation: wello-pulse 1.6s ease-in-out infinite;
202
+ }
203
+
204
+ .wello-chart-empty {
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ padding: 16px;
209
+ color: var(--wello-chart-text-color);
210
+ font-size: 14px;
211
+ font-weight: 500;
212
+ text-align: center;
213
+ }
214
+
215
+ @keyframes wello-pulse {
216
+ 50% {
217
+ opacity: 0.5;
218
+ }
219
+ }
220
+
221
+ @media (prefers-reduced-motion: reduce) {
222
+ .wello-chart-skeleton {
223
+ animation: none;
224
+ }
225
+ }
226
+
227
+ /* Pie & donut */
228
+
229
+ .wello-pie .wello-legend {
230
+ padding: 8px 0 0;
231
+ }
232
+
233
+ .wello-pie-area {
234
+ position: relative;
235
+ }
236
+
237
+ .wello-floating-tooltip {
238
+ z-index: 9999;
239
+ pointer-events: none;
240
+ white-space: nowrap;
241
+ font-family: var(--wello-chart-font, inherit);
242
+ }
243
+
244
+ .wello-donut-label {
245
+ position: absolute;
246
+ inset: 0;
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ pointer-events: none;
251
+ text-align: center;
252
+ }
253
+
254
+ .wello-donut-label-inner {
255
+ display: flex;
256
+ flex-direction: column;
257
+ align-items: center;
258
+ line-height: 1;
259
+ }
260
+
261
+ .wello-donut-label-main {
262
+ /* The card's own text color: readable on light and dark cards (the brand primary may not be). */
263
+ color: var(--wello-chart-bright-color);
264
+ font-size: 24px;
265
+ font-weight: 900;
266
+ font-variant-numeric: tabular-nums;
267
+ letter-spacing: -0.025em;
268
+ }
269
+
270
+ .wello-donut-label-sub {
271
+ margin-top: 6px;
272
+ color: var(--wello-chart-text-color);
273
+ font-size: 12px;
274
+ font-weight: 600;
275
+ }
276
+
277
+ /* Radial bar */
278
+
279
+ .wello-radial-bar .wello-legend {
280
+ padding: 8px 0 0;
281
+ }
282
+
283
+ /* Heatmap */
284
+
285
+ .wello-heatmap {
286
+ display: inline-block;
287
+ }
288
+
289
+ .wello-heatmap svg {
290
+ display: block;
291
+ overflow: visible;
292
+ }
293
+
294
+ .wello-heatmap-label {
295
+ fill: var(--wello-chart-text-color);
296
+ }
297
+
298
+ .wello-heatmap-rect--outside {
299
+ opacity: 0.4;
300
+ }
301
+
302
+ .wello-heatmap-tooltip {
303
+ min-width: 0;
304
+ }
305
+
306
+ .wello-heatmap-legend {
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: flex-end;
310
+ gap: 3px;
311
+ margin-top: 8px;
312
+ color: var(--wello-chart-text-color);
313
+ }
314
+
315
+ .wello-heatmap-legend > span:first-child {
316
+ margin-inline-end: 4px;
317
+ }
318
+
319
+ .wello-heatmap-legend > span:last-child {
320
+ margin-inline-start: 4px;
321
+ }