@bison-lab/ui 5.11.0 → 5.13.0
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.
- package/dist/charts.d.mts +157 -4
- package/dist/charts.d.mts.map +1 -1
- package/dist/charts.mjs +751 -149
- package/dist/charts.mjs.map +1 -1
- package/dist/index.d.mts +53 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +288 -157
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/charts.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.mjs","names":["RechartsAreaChart","RechartsBarChart"],"sources":["../src/lib/chart-utils.ts","../src/components/area-chart.tsx","../src/components/bar-chart.tsx","../src/components/donut-chart.tsx"],"sourcesContent":["/**\n * Shared utilities for chart components.\n * Reads theme CSS custom properties to provide Recharts-compatible color strings.\n */\n\n/** Default chart color tokens mapped to CSS custom properties */\nexport const chartColorTokens = [\n \"--primary\",\n \"--secondary\",\n \"--brand-accent\",\n \"--highlight\",\n \"--destructive\",\n] as const;\n\n/**\n * Resolves a CSS custom property value to an `hsl(...)` string.\n * Falls back to the raw token name if resolution fails (e.g. SSR).\n */\nexport function resolveHslToken(token: string, el?: Element | null): string {\n if (typeof window === \"undefined\") return `hsl(var(${token}))`;\n const target = el ?? document.documentElement;\n const raw = getComputedStyle(target).getPropertyValue(token).trim();\n if (!raw) return `hsl(var(${token}))`;\n // If already in hsl() format, return as-is\n if (raw.startsWith(\"hsl\")) return raw;\n // Otherwise wrap the raw HSL values\n return `hsl(${raw})`;\n}\n\n/**\n * Returns an array of resolved theme colors for chart series.\n * Consumers can override with explicit `colors` prop.\n */\nexport function getThemeColors(el?: Element | null): string[] {\n return chartColorTokens.map((token) => resolveHslToken(token, el));\n}\n\n/** Chart size presets (height in px) */\nexport const chartSizeMap = {\n sm: 200,\n md: 300,\n lg: 400,\n} as const;\n\nexport type ChartSize = keyof typeof chartSizeMap;\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n AreaChart as RechartsAreaChart,\n Area,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { cn } from \"../lib/utils\";\nimport {\n getThemeColors,\n resolveHslToken,\n chartSizeMap,\n type ChartSize,\n} from \"../lib/chart-utils\";\n\nexport interface AreaChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /** Fill opacity for the area (0–1). Default: 0.15 */\n fillOpacity?: number;\n}\n\nexport interface AreaChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — array of objects with keys matching `categories`/`series` */\n data: Record<string, unknown>[];\n /** Key used for the X-axis category labels */\n index: string;\n /** Quick setup: data keys to render as area series (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: AreaChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show cartesian grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show Y-axis. Default: true */\n showYAxis?: boolean;\n /** Area curve type. Default: \"monotone\" */\n curveType?: \"monotone\" | \"linear\" | \"step\" | \"natural\";\n /** Stack areas. Default: false */\n stacked?: boolean;\n}\n\nconst AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n showYAxis = true,\n curveType = \"monotone\",\n stacked = false,\n ...props\n },\n ref,\n ) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const [themeColors, setThemeColors] = React.useState<string[]>([]);\n\n React.useEffect(() => {\n const el = containerRef.current;\n setThemeColors(colors ?? getThemeColors(el));\n }, [colors]);\n\n const resolvedSeries: AreaChartSeries[] = React.useMemo(() => {\n if (series) return series;\n return (categories ?? []).map((key) => ({ dataKey: key, name: key }));\n }, [series, categories]);\n\n const chartHeight = height ?? chartSizeMap[size];\n\n const gridColor =\n themeColors.length > 0\n ? undefined\n : \"hsl(var(--border-subtle))\";\n\n return (\n <div\n ref={(node) => {\n (containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsAreaChart data={data}>\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={gridColor}\n className=\"stroke-border-subtle\"\n />\n )}\n <XAxis\n dataKey={index}\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n className=\"[&_text]:fill-content-secondary\"\n />\n {showYAxis && (\n <YAxis\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n width={40}\n className=\"[&_text]:fill-content-secondary\"\n />\n )}\n {showTooltip && (\n <Tooltip\n contentStyle={{\n backgroundColor: \"hsl(var(--popover))\",\n border: \"1px solid hsl(var(--border))\",\n borderRadius: \"var(--radius-md)\",\n color: \"hsl(var(--popover-foreground))\",\n fontSize: 12,\n }}\n />\n )}\n {showLegend && <Legend />}\n {resolvedSeries.map((s, i) => {\n const color =\n s.color ?? themeColors[i % themeColors.length] ?? `hsl(var(--primary))`;\n return (\n <Area\n key={s.dataKey}\n type={curveType}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={s.fillOpacity ?? 0.15}\n stackId={stacked ? \"stack\" : undefined}\n />\n );\n })}\n </RechartsAreaChart>\n </ResponsiveContainer>\n </div>\n );\n },\n);\nAreaChart.displayName = \"AreaChart\";\n\nexport { AreaChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n BarChart as RechartsBarChart,\n Bar,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { cn } from \"../lib/utils\";\nimport {\n getThemeColors,\n chartSizeMap,\n type ChartSize,\n} from \"../lib/chart-utils\";\n\nexport interface BarChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /** Bar radius. Default: [4, 4, 0, 0] */\n radius?: [number, number, number, number];\n}\n\nexport interface BarChartProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"children\"\n> {\n /** Chart data — array of objects with keys matching `categories`/`series` */\n data: Record<string, unknown>[];\n /** Key used for the X-axis category labels */\n index: string;\n /** Quick setup: data keys to render as bar series (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: BarChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show cartesian grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show Y-axis. Default: true */\n showYAxis?: boolean;\n /** Stack bars. Default: false */\n stacked?: boolean;\n /** Horizontal layout (bars go left-to-right). Default: false */\n horizontal?: boolean;\n /** Clamp the numeric axis to [0, maxValue] instead of auto-scaling */\n maxValue?: number;\n}\n\nconst BarChart = React.forwardRef<HTMLDivElement, BarChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n showYAxis = true,\n stacked = false,\n horizontal = false,\n maxValue,\n ...props\n },\n ref,\n ) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const [themeColors, setThemeColors] = React.useState<string[]>([]);\n\n React.useEffect(() => {\n const el = containerRef.current;\n setThemeColors(colors ?? getThemeColors(el));\n }, [colors]);\n\n const resolvedSeries: BarChartSeries[] = React.useMemo(() => {\n if (series) return series;\n return (categories ?? []).map((key) => ({ dataKey: key, name: key }));\n }, [series, categories]);\n\n const chartHeight = height ?? chartSizeMap[size];\n const layout = horizontal ? \"vertical\" : \"horizontal\";\n\n return (\n <div\n ref={(node) => {\n (\n containerRef as React.MutableRefObject<HTMLDivElement | null>\n ).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref)\n (ref as React.MutableRefObject<HTMLDivElement | null>).current =\n node;\n }}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsBarChart data={data} layout={layout}>\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n className=\"stroke-border-subtle\"\n />\n )}\n {horizontal ? (\n <>\n <XAxis\n type=\"number\"\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n className=\"[&_text]:fill-content-secondary\"\n {...(maxValue != null && { domain: [0, maxValue] })}\n />\n <YAxis\n dataKey={index}\n type=\"category\"\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n width={80}\n className=\"[&_text]:fill-content-secondary\"\n />\n </>\n ) : (\n <>\n <XAxis\n dataKey={index}\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n className=\"[&_text]:fill-content-secondary\"\n />\n {showYAxis && (\n <YAxis\n tick={{ fontSize: 12 }}\n tickLine={false}\n axisLine={false}\n {...(maxValue != null && { domain: [0, maxValue] })}\n width={40}\n className=\"[&_text]:fill-content-secondary\"\n />\n )}\n </>\n )}\n {showTooltip && (\n <Tooltip\n contentStyle={{\n backgroundColor: \"hsl(var(--popover))\",\n border: \"1px solid hsl(var(--border))\",\n borderRadius: \"var(--radius-md)\",\n color: \"hsl(var(--popover-foreground))\",\n fontSize: 12,\n }}\n />\n )}\n {showLegend && <Legend />}\n {resolvedSeries.map((s, i) => {\n const color =\n s.color ??\n themeColors[i % themeColors.length] ??\n `hsl(var(--primary))`;\n return (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={color}\n radius={s.radius ?? [4, 4, 0, 0]}\n stackId={stacked ? \"stack\" : undefined}\n />\n );\n })}\n </RechartsBarChart>\n </ResponsiveContainer>\n </div>\n );\n },\n);\nBarChart.displayName = \"BarChart\";\n\nexport { BarChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n PieChart,\n Pie,\n Cell,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { cn } from \"../lib/utils\";\nimport {\n getThemeColors,\n chartSizeMap,\n type ChartSize,\n} from \"../lib/chart-utils\";\n\nexport interface DonutChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — array of objects with `name` and `value` keys (or custom keys via `nameKey`/`dataKey`) */\n data: Record<string, unknown>[];\n /** Key for segment labels. Default: \"name\" */\n nameKey?: string;\n /** Key for segment values. Default: \"value\" */\n dataKey?: string;\n /** Override theme colors (applied in order to segments) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show labels on segments. Default: false */\n showLabels?: boolean;\n /** Inner radius ratio (0 = pie, >0 = donut). Default: \"60%\" */\n innerRadius?: string | number;\n /** Outer radius. Default: \"80%\" */\n outerRadius?: string | number;\n /** Padding angle between segments in degrees. Default: 2 */\n paddingAngle?: number;\n /** Center label content */\n centerLabel?: React.ReactNode;\n}\n\nconst DonutChart = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (\n {\n className,\n data,\n nameKey = \"name\",\n dataKey = \"value\",\n colors,\n size = \"md\",\n height,\n showLegend = false,\n showTooltip = true,\n showLabels = false,\n innerRadius = \"60%\",\n outerRadius = \"80%\",\n paddingAngle = 2,\n centerLabel,\n ...props\n },\n ref,\n ) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const [themeColors, setThemeColors] = React.useState<string[]>([]);\n\n React.useEffect(() => {\n const el = containerRef.current;\n setThemeColors(colors ?? getThemeColors(el));\n }, [colors]);\n\n const chartHeight = height ?? chartSizeMap[size];\n\n return (\n <div\n ref={(node) => {\n (containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }}\n className={cn(\"relative w-full\", className)}\n {...props}\n >\n {centerLabel && (\n <div\n className=\"pointer-events-none absolute inset-0 flex items-center justify-center\"\n aria-hidden=\"true\"\n >\n <div className=\"text-center\">{centerLabel}</div>\n </div>\n )}\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <PieChart>\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n outerRadius={outerRadius}\n paddingAngle={paddingAngle}\n label={showLabels}\n strokeWidth={0}\n >\n {data.map((_, i) => {\n const color =\n themeColors[i % themeColors.length] ?? `hsl(var(--primary))`;\n return <Cell key={i} fill={color} />;\n })}\n </Pie>\n {showTooltip && (\n <Tooltip\n contentStyle={{\n backgroundColor: \"hsl(var(--popover))\",\n border: \"1px solid hsl(var(--border))\",\n borderRadius: \"var(--radius-md)\",\n color: \"hsl(var(--popover-foreground))\",\n fontSize: 12,\n }}\n />\n )}\n {showLegend && <Legend />}\n </PieChart>\n </ResponsiveContainer>\n </div>\n );\n },\n);\nDonutChart.displayName = \"DonutChart\";\n\nexport { DonutChart };\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACD;;;;;AAMD,SAAgB,gBAAgB,OAAe,IAA6B;AAC1E,KAAI,OAAO,WAAW,YAAa,QAAO,WAAW,MAAM;CAC3D,M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KAAK,KAAK,GAAG,MAAM;AAGlB,aAAO,oBAAC,MAAD,EAAc,MADnB,YAAY,IAAI,YAAY,WAAW,uBACL,EAAlB,EAAkB;OACpC;KACE,CAAA;IACL,eACC,oBAAC,SAAD,EACE,cAAc;KACZ,iBAAiB;KACjB,QAAQ;KACR,cAAc;KACd,OAAO;KACP,UAAU;KACX,EACD,CAAA;IAEH,cAAc,oBAAC,QAAD,EAAU,CAAA;IAChB,EAAA,CAAA;GACS,CAAA,CAClB;;EAGX;AACD,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"charts.mjs","names":["RechartsAreaChart","formatPercent","RechartsBarChart","RechartsLineChart","RechartsRadarChart"],"sources":["../src/lib/chart-utils.ts","../src/components/chart-parts.tsx","../src/components/area-chart.tsx","../src/components/bar-chart.tsx","../src/components/donut-chart.tsx","../src/components/line-chart.tsx","../src/components/radar-chart.tsx","../src/components/heatmap-grid.tsx"],"sourcesContent":["/**\n * Shared utilities for chart components.\n * Reads theme CSS custom properties to provide Recharts-compatible color strings.\n */\n\n/** Default chart color tokens mapped to CSS custom properties */\nexport const chartColorTokens = [\n \"--primary\",\n \"--secondary\",\n \"--brand-accent\",\n \"--highlight\",\n \"--destructive\",\n] as const;\n\n/**\n * Resolves a CSS custom property value to an `hsl(...)` string.\n * Falls back to the raw token name if resolution fails (e.g. SSR).\n */\nexport function resolveHslToken(token: string, el?: Element | null): string {\n if (typeof window === \"undefined\") return `hsl(var(${token}))`;\n const target = el ?? document.documentElement;\n const raw = getComputedStyle(target).getPropertyValue(token).trim();\n if (!raw) return `hsl(var(${token}))`;\n // If already in hsl() format, return as-is\n if (raw.startsWith(\"hsl\")) return raw;\n // Otherwise wrap the raw HSL values\n return `hsl(${raw})`;\n}\n\n/**\n * Returns an array of resolved theme colors for chart series.\n * Consumers can override with explicit `colors` prop.\n */\nexport function getThemeColors(el?: Element | null): string[] {\n return chartColorTokens.map((token) => resolveHslToken(token, el));\n}\n\n/** Chart size presets (height in px) */\nexport const chartSizeMap = {\n sm: 200,\n md: 300,\n lg: 400,\n} as const;\n\nexport type ChartSize = keyof typeof chartSizeMap;\n\n/** An sRGB color, each channel 0–255. */\nexport type Rgb = [number, number, number];\n\nfunction hslToRgb(h: number, s: number, l: number): Rgb {\n const chroma = (1 - Math.abs(2 * l - 1)) * s;\n const hue = (((h % 360) + 360) % 360) / 60;\n const x = chroma * (1 - Math.abs((hue % 2) - 1));\n const [r, g, b] =\n hue < 1 ? [chroma, x, 0]\n : hue < 2 ? [x, chroma, 0]\n : hue < 3 ? [0, chroma, x]\n : hue < 4 ? [0, x, chroma]\n : hue < 5 ? [x, 0, chroma]\n : [chroma, 0, x];\n const m = l - chroma / 2;\n return [r, g, b].map((c) => Math.round((c + m) * 255)) as Rgb;\n}\n\n/**\n * Reads `#rgb`, `#rrggbb`, `rgb(…)`, `hsl(…)` or a bare `h s% l%` triplet\n * (the form theme tokens hold). Returns null for anything else, such as a\n * `var()` that has not resolved yet.\n */\nexport function parseCssColor(input: string): Rgb | null {\n const value = input.trim();\n const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(value);\n if (hex) {\n const digits =\n hex[1].length === 3 ? hex[1].split(\"\").map((d) => d + d).join(\"\") : hex[1];\n const n = parseInt(digits, 16);\n return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n }\n const rgb = /^rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)/i.exec(value);\n if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];\n const hsl = /^(?:hsla?\\()?\\s*(-?[\\d.]+)(?:deg)?[\\s,]+([\\d.]+)%[\\s,]+([\\d.]+)%/i.exec(value);\n if (hsl) {\n return hslToRgb(Number(hsl[1]), Number(hsl[2]) / 100, Number(hsl[3]) / 100);\n }\n return null;\n}\n\n/** `amount` of `color` over `base`, as an opaque color. */\nexport function mixRgb(color: Rgb, base: Rgb, amount: number): Rgb {\n return color.map((c, i) => Math.round(c * amount + base[i] * (1 - amount))) as Rgb;\n}\n\nexport function rgbToHex([r, g, b]: Rgb): string {\n return `#${[r, g, b].map((c) => c.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { getThemeColors } from \"../lib/chart-utils\";\n\n/*\n * The pieces every chart shares, so the axis, cursor, tooltip and screen\n * reader fixes (#384) live in one place instead of five copies.\n */\n\n/**\n * Axis tick text. The fill is an attribute, not a class, because recharts\n * writes its own `fill=\"#666\"` on each tick and that default misses AA in\n * dark mode.\n */\nexport const chartAxisTick = {\n fontSize: 12,\n fill: \"hsl(var(--muted-foreground))\",\n} as const;\n\nexport const chartAxisProps = {\n tick: chartAxisTick,\n tickLine: false,\n axisLine: false,\n} as const;\n\n/**\n * The hover highlight behind a bar category. Recharts' default is a `#ccc`\n * block, which reads as a bright slab in dark mode.\n */\nexport const chartBarCursor = {\n fill: \"hsl(var(--muted))\",\n fillOpacity: 0.6,\n} as const;\n\n/** The hover guide line on line, area and radar charts. */\nexport const chartLineCursor = {\n stroke: \"hsl(var(--border))\",\n strokeWidth: 1,\n} as const;\n\n/**\n * Puts recharts' items back in the order the series were passed. Recharts\n * sorts the legend by label and the tooltip by name by default.\n */\nexport function orderBySeries<T extends { dataKey?: unknown }>(\n items: ReadonlyArray<T>,\n order: ReadonlyArray<string> | undefined,\n): T[] {\n if (!order || order.length === 0) return [...items];\n const rank = (item: T) => {\n const i = order.indexOf(String(item.dataKey));\n return i === -1 ? order.length : i;\n };\n return [...items].sort((a, b) => rank(a) - rank(b));\n}\n\n/** One legend entry recharts hands a legend. Loose on purpose: v2 and v3 differ. */\nexport interface ChartLegendItem {\n value?: React.ReactNode;\n color?: string;\n dataKey?: unknown;\n inactive?: boolean;\n}\n\nexport interface ChartLegendContentProps {\n payload?: ReadonlyArray<ChartLegendItem>;\n /** Series data keys in the order the legend lists them */\n order?: ReadonlyArray<string>;\n}\n\n/**\n * The legend every chart uses: labels in the foreground color with the\n * series color as a swatch. The swatch is hidden from assistive tech;\n * recharts' own icons are named \"<label> legend icon\", which reads as\n * \"[object Object] legend icon\" once a label is an element.\n */\nexport function ChartLegendContent({\n payload,\n order,\n}: ChartLegendContentProps) {\n if (!payload || payload.length === 0) return null;\n return (\n <ul className=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 pt-3 text-xs text-foreground\">\n {orderBySeries(payload, order).map((item, i) => (\n <li\n key={`${String(item.dataKey ?? item.value)}-${i}`}\n className=\"flex items-center gap-1.5\"\n >\n <span\n aria-hidden=\"true\"\n data-chart-swatch=\"\"\n className=\"size-2.5 shrink-0 rounded-sm\"\n style={{ backgroundColor: item.color ?? \"currentColor\" }}\n />\n <span>{item.value}</span>\n </li>\n ))}\n </ul>\n );\n}\n\n/** One row recharts hands a tooltip. Loose on purpose: v2 and v3 differ. */\nexport interface ChartTooltipItem {\n name?: React.ReactNode;\n value?: unknown;\n color?: string;\n fill?: string;\n stroke?: string;\n dataKey?: unknown;\n payload?: unknown;\n}\n\nexport interface ChartTooltipContentProps {\n active?: boolean;\n payload?: ReadonlyArray<ChartTooltipItem>;\n label?: React.ReactNode;\n /** Formats each value. Default: the value as text. */\n valueFormatter?: (value: number) => string;\n /** Series data keys in the order the rows are listed */\n order?: ReadonlyArray<string>;\n}\n\nfunction itemColor(item: ChartTooltipItem): string {\n const fromPayload =\n item.payload && typeof item.payload === \"object\" && \"fill\" in item.payload\n ? (item.payload as { fill?: unknown }).fill\n : undefined;\n return (\n item.color ??\n item.fill ??\n (typeof fromPayload === \"string\" ? fromPayload : undefined) ??\n item.stroke ??\n \"currentColor\"\n );\n}\n\n/**\n * The tooltip body every chart uses. Rows are in the foreground color with\n * the series color as a swatch: the series color as small text is too faint.\n */\nexport function ChartTooltipContent({\n active,\n payload,\n label,\n valueFormatter,\n order,\n}: ChartTooltipContentProps) {\n if (!active || !payload || payload.length === 0) return null;\n return (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className=\"min-w-32 rounded-md border border-border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md\"\n >\n {label != null && label !== \"\" && (\n <p className=\"mb-1 font-medium\">{label}</p>\n )}\n <ul className=\"flex flex-col gap-1\">\n {orderBySeries(payload, order).map((item, i) => {\n const value =\n typeof item.value === \"number\" && valueFormatter\n ? valueFormatter(item.value)\n : item.value == null\n ? \"–\"\n : String(item.value);\n return (\n <li\n key={`${String(item.dataKey ?? item.name)}-${i}`}\n className=\"flex items-center gap-2\"\n >\n <span\n aria-hidden=\"true\"\n data-chart-swatch=\"\"\n className=\"size-2.5 shrink-0 rounded-sm\"\n style={{ backgroundColor: itemColor(item) }}\n />\n <span>{item.name}</span>\n <span className=\"ml-auto pl-3 font-medium tabular-nums\">\n {value}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n );\n}\n\n/** The accessible name a chart region gets when no `summary` is passed. */\nexport function chartLabel(\n summary: string | undefined,\n props: { title?: string; \"aria-label\"?: string },\n fallback: string,\n): string {\n return summary ?? props[\"aria-label\"] ?? props.title ?? fallback;\n}\n\nexport interface ChartDataTableProps {\n caption: string;\n /** Header for the first column (the category). */\n indexHeader: string;\n rows: ReadonlyArray<{ label: React.ReactNode; values: React.ReactNode[] }>;\n columns: ReadonlyArray<React.ReactNode>;\n}\n\n/**\n * The chart's data as a visually hidden table, so a screen reader can read\n * every value without the hover tooltip.\n */\nexport function ChartDataTable({\n caption,\n indexHeader,\n rows,\n columns,\n}: ChartDataTableProps) {\n return (\n // The clip sits on a wrapper: a table sizes to its content even when\n // clipped, and would widen the page on a narrow screen.\n <div className=\"sr-only\">\n <table data-chart-table=\"\">\n <caption>{caption}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{indexHeader}</th>\n {columns.map((c, i) => (\n <th key={i} scope=\"col\">\n {c}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, r) => (\n <tr key={r}>\n <th scope=\"row\">{row.label}</th>\n {row.values.map((v, c) => (\n <td key={c}>{v}</td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\n/** Formats a raw cell for the hidden data table. */\nexport function formatChartValue(\n value: unknown,\n valueFormatter?: (value: number) => string,\n): string {\n if (typeof value === \"number\") {\n return valueFormatter ? valueFormatter(value) : String(value);\n }\n if (value == null || value === \"\") return \"No data\";\n return String(value);\n}\n\n/**\n * A counter that ticks when the root element's class, style or `data-theme`\n * changes, so colors read from theme tokens are read again after a light or\n * dark switch instead of keeping the values from mount.\n */\nexport function useThemeVersion(): number {\n const [version, setVersion] = React.useState(0);\n React.useEffect(() => {\n if (typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(() => setVersion((v) => v + 1));\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\", \"style\", \"data-theme\"],\n });\n return () => observer.disconnect();\n }, []);\n return version;\n}\n\n/**\n * The resolved series colors (theme tokens unless `colors` is passed) and a\n * ref callback that also forwards the consumer's ref.\n */\nexport function useChartColors(\n colors: string[] | undefined,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const [themeColors, setThemeColors] = React.useState<string[]>([]);\n const themeVersion = useThemeVersion();\n\n React.useEffect(() => {\n setThemeColors(colors ?? getThemeColors(containerRef.current));\n }, [colors, themeVersion]);\n\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n containerRef.current = node;\n if (typeof forwardedRef === \"function\") forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n },\n [forwardedRef],\n );\n\n const colorAt = React.useCallback(\n (i: number, override?: string) =>\n override ?? themeColors[i % themeColors.length] ?? \"hsl(var(--primary))\",\n [themeColors],\n );\n\n return { setRef, themeColors, colorAt, containerRef, themeVersion };\n}\n\nexport interface ChartFrameProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The accessible name of the chart region. */\n label: string;\n}\n\n/** The chart region: a named figure around the drawing and its data table. */\nexport const ChartFrame = React.forwardRef<HTMLDivElement, ChartFrameProps>(\n ({ label, className, children, ...props }, ref) => (\n <div\n ref={ref}\n role=\"figure\"\n className={cn(\"w-full\", className)}\n {...props}\n aria-label={label}\n >\n {children}\n </div>\n ),\n);\nChartFrame.displayName = \"ChartFrame\";\n\n/** A series config every cartesian chart accepts in its quick form. */\nexport function seriesFromCategories<\n T extends { dataKey: string; name?: string },\n>(series: T[] | undefined, categories: string[] | undefined): T[] {\n if (series) return series;\n return (categories ?? []).map((key) => ({ dataKey: key, name: key }) as T);\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n AreaChart as RechartsAreaChart,\n Area,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { chartSizeMap, type ChartSize } from \"../lib/chart-utils\";\nimport {\n ChartDataTable,\n ChartFrame,\n ChartTooltipContent,\n chartAxisProps,\n chartLabel,\n ChartLegendContent,\n chartLineCursor,\n formatChartValue,\n seriesFromCategories,\n useChartColors,\n} from \"./chart-parts\";\n\nexport interface AreaChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /** Fill opacity for the area (0–1). Default: 0.15 */\n fillOpacity?: number;\n}\n\nexport interface AreaChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — array of objects with keys matching `categories`/`series` */\n data: Record<string, unknown>[];\n /** Key used for the X-axis category labels */\n index: string;\n /** Quick setup: data keys to render as area series (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: AreaChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show cartesian grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show Y-axis. Default: true */\n showYAxis?: boolean;\n /** Area curve type. Default: \"monotone\" */\n curveType?: \"monotone\" | \"linear\" | \"step\" | \"natural\";\n /** Stack areas. Default: false */\n stacked?: boolean;\n /** Text summary for screen readers: the chart region's accessible name. Default: `title`, else \"Area chart\" */\n summary?: string;\n /** Formats values in the tooltip and the screen reader table */\n valueFormatter?: (value: number) => string;\n}\n\nconst AreaChart = React.forwardRef<HTMLDivElement, AreaChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n showYAxis = true,\n curveType = \"monotone\",\n stacked = false,\n summary,\n valueFormatter,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt } = useChartColors(colors, ref);\n const resolvedSeries = React.useMemo(\n () => seriesFromCategories<AreaChartSeries>(series, categories),\n [series, categories],\n );\n const order = React.useMemo(() => resolvedSeries.map((s) => s.dataKey), [resolvedSeries]);\n const chartHeight = height ?? chartSizeMap[size];\n const label = chartLabel(summary, props, \"Area chart\");\n\n return (\n <ChartFrame ref={setRef} label={label} className={className} {...props}>\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsAreaChart data={data} accessibilityLayer title={label}>\n {showGrid && (\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"hsl(var(--border-subtle))\" />\n )}\n <XAxis dataKey={index} {...chartAxisProps} />\n {showYAxis && <YAxis {...chartAxisProps} width={40} />}\n {showTooltip && (\n <Tooltip\n cursor={chartLineCursor}\n content={<ChartTooltipContent valueFormatter={valueFormatter} order={order} />}\n />\n )}\n {showLegend && <Legend itemSorter={null} content={<ChartLegendContent order={order} />} />}\n {resolvedSeries.map((s, i) => {\n const color = colorAt(i, s.color);\n return (\n <Area\n key={s.dataKey}\n type={curveType}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n fill={color}\n fillOpacity={s.fillOpacity ?? 0.15}\n stackId={stacked ? \"stack\" : undefined}\n />\n );\n })}\n </RechartsAreaChart>\n </ResponsiveContainer>\n <ChartDataTable\n caption={label}\n indexHeader={index}\n columns={resolvedSeries.map((s) => s.name ?? s.dataKey)}\n rows={data.map((row) => ({\n label: String(row[index] ?? \"\"),\n values: resolvedSeries.map((s) => formatChartValue(row[s.dataKey], valueFormatter)),\n }))}\n />\n </ChartFrame>\n );\n },\n);\nAreaChart.displayName = \"AreaChart\";\n\nexport { AreaChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n BarChart as RechartsBarChart,\n Bar,\n Cell,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { chartSizeMap, type ChartSize } from \"../lib/chart-utils\";\nimport {\n ChartDataTable,\n ChartFrame,\n ChartTooltipContent,\n chartAxisProps,\n chartBarCursor,\n chartLabel,\n ChartLegendContent,\n formatChartValue,\n seriesFromCategories,\n useChartColors,\n} from \"./chart-parts\";\n\ntype Radius = [number, number, number, number];\n\nexport interface BarChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /**\n * Corner radius of the bar's outer end. Default: rounded outer end\n * (`[4, 4, 0, 0]` upright, `[0, 4, 4, 0]` horizontal). In a stack only the\n * outermost segment gets it.\n */\n radius?: Radius;\n}\n\nexport interface BarChartProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"children\"\n> {\n /** Chart data — array of objects with keys matching `categories`/`series` */\n data: Record<string, unknown>[];\n /** Key used for the X-axis category labels */\n index: string;\n /** Quick setup: data keys to render as bar series (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: BarChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show cartesian grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show Y-axis. Default: true */\n showYAxis?: boolean;\n /** Stack bars. Same as `stackMode=\"normal\"`. Default: false */\n stacked?: boolean;\n /**\n * `\"normal\"` stacks the raw values; `\"percent\"` stacks each category's\n * share so every bar sums to 100%. Default: unstacked unless `stacked`.\n */\n stackMode?: \"normal\" | \"percent\";\n /** Horizontal layout (bars go left-to-right). Default: false */\n horizontal?: boolean;\n /** Width in px of the category axis in the horizontal layout. Default: 80 */\n categoryAxisWidth?: number;\n /** Clamp the numeric axis to [0, maxValue] instead of auto-scaling */\n maxValue?: number;\n /** Text summary for screen readers: the chart region's accessible name. Default: `title`, else \"Bar chart\" */\n summary?: string;\n /** Formats values in the tooltip and the screen reader table. Percent mode defaults to \"n%\" */\n valueFormatter?: (value: number) => string;\n}\n\nconst formatPercent = (value: number) => `${Math.round(value * 10) / 10}%`;\n\nconst numberAt = (row: Record<string, unknown>, key: string) => {\n const v = row[key];\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0;\n};\n\nconst BarChart = React.forwardRef<HTMLDivElement, BarChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n showYAxis = true,\n stacked = false,\n stackMode,\n horizontal = false,\n categoryAxisWidth = 80,\n maxValue,\n summary,\n valueFormatter,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt } = useChartColors(colors, ref);\n const resolvedSeries = React.useMemo(\n () => seriesFromCategories<BarChartSeries>(series, categories),\n [series, categories],\n );\n\n const mode = stackMode ?? (stacked ? \"normal\" : undefined);\n const isStacked = mode !== undefined;\n const isPercent = mode === \"percent\";\n const format = valueFormatter ?? (isPercent ? formatPercent : undefined);\n\n const chartData = React.useMemo(() => {\n if (!isPercent) return data;\n return data.map((row) => {\n const total = resolvedSeries.reduce((sum, s) => sum + Math.max(0, numberAt(row, s.dataKey)), 0);\n const next: Record<string, unknown> = { ...row };\n for (const s of resolvedSeries) {\n next[s.dataKey] = total > 0 ? (Math.max(0, numberAt(row, s.dataKey)) / total) * 100 : 0;\n }\n return next;\n });\n }, [data, isPercent, resolvedSeries]);\n\n // In a stack, the outermost segment is the last series with a value in\n // that row; it alone takes the rounded end.\n const outerSeriesByRow = React.useMemo(() => {\n if (!isStacked) return null;\n return chartData.map((row) => {\n for (let i = resolvedSeries.length - 1; i >= 0; i--) {\n if (numberAt(row, resolvedSeries[i].dataKey) > 0) return i;\n }\n return -1;\n });\n }, [chartData, isStacked, resolvedSeries]);\n\n const order = React.useMemo(() => resolvedSeries.map((s) => s.dataKey), [resolvedSeries]);\n const chartHeight = height ?? chartSizeMap[size];\n const layout = horizontal ? \"vertical\" : \"horizontal\";\n const outerRadius: Radius = horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0];\n const flat: Radius = [0, 0, 0, 0];\n const label = chartLabel(summary, props, \"Bar chart\");\n\n const numericDomain = isPercent\n ? { domain: [0, 100] as [number, number], allowDataOverflow: true, ticks: [0, 25, 50, 75, 100], tickFormatter: (v: number) => `${v}%` }\n : maxValue != null\n ? { domain: [0, maxValue] as [number, number] }\n : {};\n\n return (\n <ChartFrame ref={setRef} label={label} className={className} {...props}>\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsBarChart data={chartData} layout={layout} accessibilityLayer title={label}>\n {showGrid && (\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"hsl(var(--border-subtle))\" />\n )}\n {horizontal ? (\n <>\n <XAxis type=\"number\" {...chartAxisProps} {...numericDomain} />\n <YAxis\n dataKey={index}\n type=\"category\"\n {...chartAxisProps}\n width={categoryAxisWidth}\n />\n </>\n ) : (\n <>\n <XAxis dataKey={index} {...chartAxisProps} />\n {showYAxis && (\n <YAxis {...chartAxisProps} {...numericDomain} width={isPercent ? 48 : 40} />\n )}\n </>\n )}\n {showTooltip && (\n <Tooltip\n cursor={chartBarCursor}\n content={<ChartTooltipContent valueFormatter={format} order={order} />}\n />\n )}\n {showLegend && <Legend itemSorter={null} content={<ChartLegendContent order={order} />} />}\n {resolvedSeries.map((s, i) => {\n const color = colorAt(i, s.color);\n const rounded = s.radius ?? outerRadius;\n return (\n <Bar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n fill={color}\n radius={outerSeriesByRow ? flat : rounded}\n stackId={isStacked ? \"stack\" : undefined}\n >\n {outerSeriesByRow?.map((outer, row) => (\n <Cell\n key={row}\n fill={color}\n // Cell props are merged onto the bar's rectangle.\n {...({ radius: outer === i ? rounded : flat } as object)}\n />\n ))}\n </Bar>\n );\n })}\n </RechartsBarChart>\n </ResponsiveContainer>\n <ChartDataTable\n caption={label}\n indexHeader={index}\n columns={resolvedSeries.map((s) => s.name ?? s.dataKey)}\n rows={chartData.map((row) => ({\n label: String(row[index] ?? \"\"),\n values: resolvedSeries.map((s) => formatChartValue(row[s.dataKey], format)),\n }))}\n />\n </ChartFrame>\n );\n },\n);\nBarChart.displayName = \"BarChart\";\n\nexport { BarChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n PieChart,\n Pie,\n Cell,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { cn } from \"../lib/utils\";\nimport { chartSizeMap, type ChartSize } from \"../lib/chart-utils\";\nimport {\n ChartDataTable,\n ChartFrame,\n ChartTooltipContent,\n chartLabel,\n ChartLegendContent,\n formatChartValue,\n useChartColors,\n} from \"./chart-parts\";\n\nexport interface DonutChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — array of objects with `name` and `value` keys (or custom keys via `nameKey`/`dataKey`) */\n data: Record<string, unknown>[];\n /** Key for segment labels. Default: \"name\" */\n nameKey?: string;\n /** Key for segment values. Default: \"value\" */\n dataKey?: string;\n /** Override theme colors (applied in order to segments) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show labels on segments. Default: false */\n showLabels?: boolean;\n /** Inner radius ratio (0 = pie, >0 = donut). Default: \"60%\" */\n innerRadius?: string | number;\n /** Outer radius. Default: \"80%\" */\n outerRadius?: string | number;\n /** Padding angle between segments in degrees. Default: 2 */\n paddingAngle?: number;\n /** Center label content */\n centerLabel?: React.ReactNode;\n /** Text summary for screen readers: the chart region's accessible name. Default: `title`, else \"Donut chart\" */\n summary?: string;\n /** Formats values in the tooltip and the screen reader table */\n valueFormatter?: (value: number) => string;\n}\n\nconst DonutChart = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (\n {\n className,\n data,\n nameKey = \"name\",\n dataKey = \"value\",\n colors,\n size = \"md\",\n height,\n showLegend = false,\n showTooltip = true,\n showLabels = false,\n innerRadius = \"60%\",\n outerRadius = \"80%\",\n paddingAngle = 2,\n centerLabel,\n summary,\n valueFormatter,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt } = useChartColors(colors, ref);\n const chartHeight = height ?? chartSizeMap[size];\n const label = chartLabel(summary, props, \"Donut chart\");\n\n return (\n <ChartFrame\n ref={setRef}\n label={label}\n className={cn(\"relative\", className)}\n {...props}\n >\n {centerLabel && (\n <div\n className=\"pointer-events-none absolute inset-0 flex items-center justify-center\"\n aria-hidden=\"true\"\n >\n <div className=\"text-center\">{centerLabel}</div>\n </div>\n )}\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <PieChart accessibilityLayer title={label}>\n <Pie\n data={data}\n nameKey={nameKey}\n dataKey={dataKey}\n innerRadius={innerRadius}\n outerRadius={outerRadius}\n paddingAngle={paddingAngle}\n label={showLabels}\n strokeWidth={0}\n >\n {data.map((_, i) => (\n <Cell key={i} fill={colorAt(i)} />\n ))}\n </Pie>\n {showTooltip && (\n <Tooltip content={<ChartTooltipContent valueFormatter={valueFormatter} />} />\n )}\n {showLegend && <Legend itemSorter={null} content={<ChartLegendContent />} />}\n </PieChart>\n </ResponsiveContainer>\n {/* A pie has no keyboard path through its segments, so the table is how its values are reached. */}\n <ChartDataTable\n caption={label}\n indexHeader={nameKey}\n columns={[dataKey]}\n rows={data.map((row) => ({\n label: String(row[nameKey] ?? \"\"),\n values: [formatChartValue(row[dataKey], valueFormatter)],\n }))}\n />\n </ChartFrame>\n );\n },\n);\nDonutChart.displayName = \"DonutChart\";\n\nexport { DonutChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n LineChart as RechartsLineChart,\n Line,\n XAxis,\n YAxis,\n CartesianGrid,\n ReferenceLine,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { chartSizeMap, type ChartSize } from \"../lib/chart-utils\";\nimport {\n ChartDataTable,\n ChartFrame,\n ChartTooltipContent,\n chartAxisProps,\n chartAxisTick,\n chartLabel,\n ChartLegendContent,\n chartLineCursor,\n formatChartValue,\n seriesFromCategories,\n useChartColors,\n} from \"./chart-parts\";\n\nexport interface LineChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /** Draw the line dashed (e.g. a comparison or a target). Default: false */\n dashed?: boolean;\n /** Show point markers on this series. Default: the chart's `showDots` */\n showDots?: boolean;\n}\n\nexport interface LineChartReferenceLine {\n /** Value on the numeric axis where the line sits */\n value: number;\n /** Text drawn beside the line, e.g. \"Average\" */\n label?: string;\n /** Override color (any CSS color string). Default: muted foreground */\n color?: string;\n}\n\nexport interface LineChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — array of objects with keys matching `categories`/`series` */\n data: Record<string, unknown>[];\n /** Key used for the X-axis category labels */\n index: string;\n /** Quick setup: data keys to render as line series (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: LineChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show cartesian grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Show Y-axis. Default: true */\n showYAxis?: boolean;\n /** Show point markers on every series. Default: false */\n showDots?: boolean;\n /** Line curve type. Default: \"monotone\" */\n curveType?: \"monotone\" | \"linear\" | \"step\" | \"natural\";\n /** A dashed horizontal line across the plot, e.g. an average */\n referenceLine?: LineChartReferenceLine;\n /** Numeric axis range. Default: recharts' automatic range */\n yDomain?: [number, number];\n /** Text summary for screen readers: the chart region's accessible name. Default: `title`, else \"Line chart\" */\n summary?: string;\n /** Formats values in the tooltip and the screen reader table */\n valueFormatter?: (value: number) => string;\n}\n\nconst isValue = (v: unknown) => typeof v === \"number\" && Number.isFinite(v);\n\n/** True when no two neighboring rows both have a value, so no segment can be drawn. */\nfunction cannotDrawLine(data: Record<string, unknown>[], key: string): boolean {\n for (let i = 1; i < data.length; i++) {\n if (isValue(data[i - 1][key]) && isValue(data[i][key])) return false;\n }\n return true;\n}\n\nconst LineChart = React.forwardRef<HTMLDivElement, LineChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n showYAxis = true,\n showDots = false,\n curveType = \"monotone\",\n referenceLine,\n yDomain,\n summary,\n valueFormatter,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt } = useChartColors(colors, ref);\n const resolvedSeries = React.useMemo(\n () => seriesFromCategories<LineChartSeries>(series, categories),\n [series, categories],\n );\n const order = React.useMemo(() => resolvedSeries.map((s) => s.dataKey), [resolvedSeries]);\n const chartHeight = height ?? chartSizeMap[size];\n const label = chartLabel(summary, props, \"Line chart\");\n\n return (\n <ChartFrame ref={setRef} label={label} className={className} {...props}>\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsLineChart data={data} accessibilityLayer title={label}>\n {showGrid && (\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"hsl(var(--border-subtle))\" />\n )}\n <XAxis dataKey={index} {...chartAxisProps} />\n {showYAxis && (\n <YAxis {...chartAxisProps} width={40} {...(yDomain && { domain: yDomain })} />\n )}\n {showTooltip && (\n <Tooltip\n cursor={chartLineCursor}\n content={<ChartTooltipContent valueFormatter={valueFormatter} order={order} />}\n />\n )}\n {showLegend && <Legend itemSorter={null} content={<ChartLegendContent order={order} />} />}\n {referenceLine && (\n <ReferenceLine\n y={referenceLine.value}\n stroke={referenceLine.color ?? \"hsl(var(--muted-foreground))\"}\n strokeDasharray=\"4 4\"\n ifOverflow=\"extendDomain\"\n label={\n referenceLine.label\n ? { value: referenceLine.label, position: \"insideTopRight\", ...chartAxisTick }\n : undefined\n }\n />\n )}\n {resolvedSeries.map((s, i) => {\n const color = colorAt(i, s.color);\n const dots = (s.showDots ?? showDots) || cannotDrawLine(data, s.dataKey);\n return (\n <Line\n key={s.dataKey}\n type={curveType}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n strokeDasharray={s.dashed ? \"6 4\" : undefined}\n dot={dots ? { r: 3, fill: color, stroke: color, strokeWidth: 1, strokeDasharray: \"none\" } : false}\n activeDot={{ r: 4, fill: color, stroke: \"hsl(var(--background))\", strokeWidth: 2 }}\n />\n );\n })}\n </RechartsLineChart>\n </ResponsiveContainer>\n <ChartDataTable\n caption={label}\n indexHeader={index}\n columns={resolvedSeries.map((s) => s.name ?? s.dataKey)}\n rows={data.map((row) => ({\n label: String(row[index] ?? \"\"),\n values: resolvedSeries.map((s) => formatChartValue(row[s.dataKey], valueFormatter)),\n }))}\n />\n </ChartFrame>\n );\n },\n);\nLineChart.displayName = \"LineChart\";\n\nexport { LineChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport {\n RadarChart as RechartsRadarChart,\n Radar,\n PolarGrid,\n PolarAngleAxis,\n PolarRadiusAxis,\n Tooltip,\n ResponsiveContainer,\n Legend,\n} from \"recharts\";\nimport { chartSizeMap, type ChartSize } from \"../lib/chart-utils\";\nimport {\n ChartDataTable,\n ChartFrame,\n ChartTooltipContent,\n chartAxisTick,\n chartLabel,\n ChartLegendContent,\n chartLineCursor,\n formatChartValue,\n seriesFromCategories,\n useChartColors,\n} from \"./chart-parts\";\n\nexport interface RadarChartSeries {\n /** Data key corresponding to a field in the data array */\n dataKey: string;\n /** Display name for legend/tooltip */\n name?: string;\n /** Override color (any CSS color string) */\n color?: string;\n /** Draw the outline dashed, e.g. a comparison. Default: false */\n dashed?: boolean;\n /** Fill opacity of the polygon (0–1). Default: 0.2, or 0 when dashed */\n fillOpacity?: number;\n}\n\nexport interface RadarChartProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Chart data — one object per axis (spoke), with a value per series */\n data: Record<string, unknown>[];\n /** Key used for the axis (spoke) labels */\n index: string;\n /** Quick setup: data keys to render as polygons (uses theme colors) */\n categories?: string[];\n /** Advanced setup: full series config (takes precedence over `categories`) */\n series?: RadarChartSeries[];\n /** Override theme colors (applied in order to series) */\n colors?: string[];\n /** Chart height preset */\n size?: ChartSize;\n /** Explicit height in px (overrides `size`) */\n height?: number;\n /** Show the polar grid. Default: true */\n showGrid?: boolean;\n /** Show legend. Default: false */\n showLegend?: boolean;\n /** Show tooltip. Default: true */\n showTooltip?: boolean;\n /** Fix the outer ring at this value instead of auto-scaling (e.g. 100) */\n maxValue?: number;\n /** Text summary for screen readers: the chart region's accessible name. Default: `title`, else \"Radar chart\" */\n summary?: string;\n /** Formats values in the tooltip and the screen reader table */\n valueFormatter?: (value: number) => string;\n}\n\nconst RadarChart = React.forwardRef<HTMLDivElement, RadarChartProps>(\n (\n {\n className,\n data,\n index,\n categories,\n series,\n colors,\n size = \"md\",\n height,\n showGrid = true,\n showLegend = false,\n showTooltip = true,\n maxValue,\n summary,\n valueFormatter,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt } = useChartColors(colors, ref);\n const resolvedSeries = React.useMemo(\n () => seriesFromCategories<RadarChartSeries>(series, categories),\n [series, categories],\n );\n const order = React.useMemo(() => resolvedSeries.map((s) => s.dataKey), [resolvedSeries]);\n const chartHeight = height ?? chartSizeMap[size];\n const label = chartLabel(summary, props, \"Radar chart\");\n\n return (\n <ChartFrame ref={setRef} label={label} className={className} {...props}>\n <ResponsiveContainer width=\"100%\" height={chartHeight}>\n <RechartsRadarChart data={data} outerRadius=\"72%\" accessibilityLayer title={label}>\n {showGrid && <PolarGrid stroke=\"hsl(var(--border))\" />}\n <PolarAngleAxis dataKey={index} tick={chartAxisTick} />\n <PolarRadiusAxis\n domain={[0, maxValue ?? \"auto\"]}\n tick={false}\n axisLine={false}\n />\n {showTooltip && (\n <Tooltip\n cursor={chartLineCursor}\n content={<ChartTooltipContent valueFormatter={valueFormatter} order={order} />}\n />\n )}\n {showLegend && <Legend itemSorter={null} content={<ChartLegendContent order={order} />} />}\n {resolvedSeries.map((s, i) => {\n const color = colorAt(i, s.color);\n return (\n <Radar\n key={s.dataKey}\n dataKey={s.dataKey}\n name={s.name ?? s.dataKey}\n stroke={color}\n strokeWidth={2}\n strokeDasharray={s.dashed ? \"6 4\" : undefined}\n fill={color}\n fillOpacity={s.fillOpacity ?? (s.dashed ? 0 : 0.2)}\n />\n );\n })}\n </RechartsRadarChart>\n </ResponsiveContainer>\n <ChartDataTable\n caption={label}\n indexHeader={index}\n columns={resolvedSeries.map((s) => s.name ?? s.dataKey)}\n rows={data.map((row) => ({\n label: String(row[index] ?? \"\"),\n values: resolvedSeries.map((s) => formatChartValue(row[s.dataKey], valueFormatter)),\n }))}\n />\n </ChartFrame>\n );\n },\n);\nRadarChart.displayName = \"RadarChart\";\n\nexport { RadarChart };\n","\"use client\";\n\nimport * as React from \"react\";\nimport { contrastRatio } from \"@bison-lab/tokens\";\nimport { cn } from \"../lib/utils\";\nimport {\n mixRgb,\n parseCssColor,\n resolveHslToken,\n rgbToHex,\n type Rgb,\n} from \"../lib/chart-utils\";\nimport { chartLabel, useChartColors } from \"./chart-parts\";\n\nexport interface HeatmapGridRow {\n /** Row header text */\n label: string;\n /** One value per column (0 to `max`); `null` is a cell with no data */\n values: ReadonlyArray<number | null | undefined>;\n /** Override the row's color (hex, `rgb()` or `hsl()`) */\n color?: string;\n}\n\nexport interface HeatmapGridProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Column headers, in order */\n columns: ReadonlyArray<string>;\n /** One row per series; each is tinted in its own color */\n rows: ReadonlyArray<HeatmapGridRow>;\n /** Override theme colors (applied in order to rows; hex, `rgb()` or `hsl()`) */\n colors?: string[];\n /** The value that gets the deepest tint. Default: 100 */\n max?: number;\n /** Header of the row-label column, read by screen readers. Default: \"Row\" */\n rowHeader?: string;\n /** Text summary for screen readers: the table's accessible name. Default: `title`, else \"Heatmap\" */\n summary?: string;\n /** Formats each printed value. Default: rounded percent, \"42%\" */\n valueFormatter?: (value: number) => string;\n}\n\nconst MIN_TINT = 0.08;\nconst MAX_TINT = 0.9;\nconst AA = 4.5;\nconst WHITE: Rgb = [255, 255, 255];\nconst BLACK: Rgb = [0, 0, 0];\n\nconst formatPercent = (value: number) => `${Math.round(value)}%`;\n\n/**\n * The first candidate that reaches AA on `background`. Pure black or white\n * always gets there (one of them is at least 4.58:1 on any color), so the\n * printed value never drops below AA.\n */\nfunction readableText(background: Rgb, preferred: Rgb[]): Rgb {\n const bg = rgbToHex(background);\n for (const candidate of preferred) {\n if (contrastRatio(rgbToHex(candidate), bg) >= AA) return candidate;\n }\n return contrastRatio(\"#000000\", bg) >= contrastRatio(\"#ffffff\", bg) ? BLACK : WHITE;\n}\n\ninterface ResolvedPalette {\n surface: Rgb;\n foreground: Rgb;\n}\n\nconst HeatmapGrid = React.forwardRef<HTMLDivElement, HeatmapGridProps>(\n (\n {\n className,\n columns,\n rows,\n colors,\n max = 100,\n rowHeader = \"Row\",\n summary,\n valueFormatter = formatPercent,\n ...props\n },\n ref,\n ) => {\n const { setRef, colorAt, containerRef, themeVersion } = useChartColors(colors, ref);\n const [palette, setPalette] = React.useState<ResolvedPalette | null>(null);\n\n React.useEffect(() => {\n const el = containerRef.current;\n const surface = parseCssColor(resolveHslToken(\"--background\", el));\n const foreground = parseCssColor(resolveHslToken(\"--foreground\", el));\n setPalette({ surface: surface ?? WHITE, foreground: foreground ?? BLACK });\n }, [containerRef, themeVersion]);\n\n const label = chartLabel(summary, props, \"Heatmap\");\n\n const cellStyle = (rowColor: string, value: number): React.CSSProperties => {\n const share = Math.min(1, Math.max(0, max > 0 ? value / max : 0));\n const tint = MIN_TINT + (MAX_TINT - MIN_TINT) * share;\n const rgb = parseCssColor(rowColor);\n if (!palette || !rgb) {\n // Before the theme resolves (or for a color this cannot read), let\n // CSS blend it; the text keeps the theme foreground.\n return {\n backgroundColor: `color-mix(in srgb, ${rowColor} ${Math.round(tint * 100)}%, hsl(var(--background)))`,\n color: \"hsl(var(--foreground))\",\n };\n }\n const background = mixRgb(rgb, palette.surface, tint);\n const text = readableText(background, [palette.foreground, palette.surface]);\n return { backgroundColor: rgbToHex(background), color: rgbToHex(text) };\n };\n\n return (\n <div ref={setRef} className={cn(\"w-full overflow-x-auto\", className)} {...props}>\n <table className=\"w-full border-separate border-spacing-1 text-xs\">\n <caption className=\"sr-only\">{label}</caption>\n <thead>\n <tr>\n <th scope=\"col\" className=\"text-left font-normal\">\n <span className=\"sr-only\">{rowHeader}</span>\n </th>\n {columns.map((column) => (\n <th\n key={column}\n scope=\"col\"\n className=\"px-1 pb-1 text-center font-medium text-muted-foreground\"\n >\n {column}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, r) => {\n const rowColor = colorAt(r, row.color);\n return (\n <tr key={`${row.label}-${r}`}>\n <th\n scope=\"row\"\n className=\"whitespace-nowrap pr-2 text-left font-medium text-muted-foreground\"\n >\n {row.label}\n </th>\n {columns.map((column, c) => {\n const value = row.values[c];\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return (\n <td\n key={column}\n className=\"rounded-sm border border-dashed border-border px-2 py-2 text-center text-muted-foreground\"\n >\n <span aria-hidden=\"true\">–</span>\n <span className=\"sr-only\">No data</span>\n </td>\n );\n }\n return (\n <td\n key={column}\n className=\"rounded-sm px-2 py-2 text-center font-medium tabular-nums\"\n style={cellStyle(rowColor, value)}\n >\n {valueFormatter(value)}\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n },\n);\nHeatmapGrid.displayName = \"HeatmapGrid\";\n\nexport { HeatmapGrid };\n"],"mappings":";;;;;;;;;;;;AAMA,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACD;;;;;AAMD,SAAgB,gBAAgB,OAAe,IAA6B;AAC1E,KAAI,OAAO,WAAW,YAAa,QAAO,WAAW,MAAM;CAC3D,MAAM,SAAS,MAAM,SAAS;CAC9B,MAAM,MAAM,iBAAiB,OAAO,CAAC,iBAAiB,MAAM,CAAC,MAAM;AACnE,KAAI,CAAC,IAAK,QAAO,WAAW,MAAM;AAElC,KAAI,IAAI,WAAW,MAAM,CAAE,QAAO;AAElC,QAAO,OAAO,IAAI;;;;;;AAOpB,SAAgB,eAAe,IAA+B;AAC5D,QAAO,iBAAiB,KAAK,UAAU,gBAAgB,OAAO,GAAG,CAAC;;;AAIpE,MAAa,eAAe;CAC1B,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAOD,SAAS,SAAS,GAAW,GAAW,GAAgB;CACtD,MAAM,UAAU,IAAI,KAAK,IAAI,IAAI,IAAI,EAAE,IAAI;CAC3C,MAAM,OAAS,IAAI,MAAO,OAAO,MAAO;CACxC,MAAM,IAAI,UAAU,IAAI,KAAK,IAAK,MAAM,IAAK,EAAE;CAC/C,MAAM,CAAC,GAAG,GAAG,KACX,MAAM,IAAI;EAAC;EAAQ;EAAG;EAAE,GACtB,MAAM,IAAI;EAAC;EAAG;EAAQ;EAAE,GACxB,MAAM,IAAI;EAAC;EAAG;EAAQ;EA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AD,EAAA,UAAA,CACE,oBAAC,MAAD;KAAI,OAAM;KAAM,WAAU;eACxB,oBAAC,QAAD;MAAM,WAAU;gBAAW;MAAiB,CAAA;KACzC,CAAA,EACJ,QAAQ,KAAK,WACZ,oBAAC,MAAD;KAEE,OAAM;KACN,WAAU;eAET;KACE,EALE,OAKF,CACL,CACC,EAAA,CAAA,EACC,CAAA;IACR,oBAAC,SAAD,EAAA,UACG,KAAK,KAAK,KAAK,MAAM;KACpB,MAAM,WAAW,QAAQ,GAAG,IAAI,MAAM;AACtC,YACE,qBAAC,MAAD,EAAA,UAAA,CACE,oBAAC,MAAD;MACE,OAAM;MACN,WAAU;gBAET,IAAI;MACF,CAAA,EACJ,QAAQ,KAAK,QAAQ,MAAM;MAC1B,MAAM,QAAQ,IAAI,OAAO;AACzB,UAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,MAAM,CACtD,QACE,qBAAC,MAAD;OAEE,WAAU;iBAFZ,CAIE,oBAAC,QAAD;QAAM,eAAY;kBAAO;QAAQ,CAAA,EACjC,oBAAC,QAAD;QAAM,WAAU;kBAAU;QAAc,CAAA,CACrC;SALE,OAKF;AAGT,aACE,oBAAC,MAAD;OAEE,WAAU;OACV,OAAO,UAAU,UAAU,MAAM;iBAEhC,eAAe,MAAM;OACnB,EALE,OAKF;OAEP,CACC,EAAA,EA9BI,GAAG,IAAI,MAAM,GAAG,IA8BpB;MAEP,EACI,CAAA;IACF;;EACJ,CAAA;EAGX;AACD,YAAY,cAAc"}
|
package/dist/index.d.mts
CHANGED
|
@@ -503,17 +503,40 @@ interface FormProps extends Omit<React$1.FormHTMLAttributes<HTMLFormElement>, 'o
|
|
|
503
503
|
* When the schema judges a field.
|
|
504
504
|
*
|
|
505
505
|
* `submit` (default): only on submit.
|
|
506
|
-
* `blur`: also when a field
|
|
507
|
-
*
|
|
508
|
-
*
|
|
506
|
+
* `blur`: also when focus leaves a field, typed in or not, so a required
|
|
507
|
+
* field tabbed past empty shows its error as it is left; then on every
|
|
508
|
+
* edit while it shows an error, so the message clears as soon as the
|
|
509
|
+
* value is fixed. Each of those checks also re-judges every field
|
|
509
510
|
* already showing an error, so a cross-field rule (a confirmation that must
|
|
510
|
-
* match) clears when the other field is fixed.
|
|
511
|
-
*
|
|
512
|
-
*
|
|
511
|
+
* match) clears when the other field is fixed. Nothing is judged on mount,
|
|
512
|
+
* when focus moves to another part of the same field (a password's
|
|
513
|
+
* show/hide toggle, the next box of a checkbox group, a Select's list or a
|
|
514
|
+
* picker's calendar it opens), or when the window
|
|
515
|
+
* rather than the field loses focus. A field left by a mouse or touch
|
|
516
|
+
* press is judged once the press has landed, so its error line cannot
|
|
517
|
+
* push the pressed link or button out from under the pointer; a press
|
|
518
|
+
* that submits the form leaves the judging to the submit. Submit
|
|
519
|
+
* behaves exactly as with `submit` (focus moves to the first
|
|
513
520
|
* invalid control, the summary is announced). Needs `schema`; a field
|
|
514
521
|
* is known by its control's `name`, the key it is submitted under.
|
|
522
|
+
* See `validateUntouched` to keep untouched fields quiet.
|
|
515
523
|
*/
|
|
516
524
|
validateOn?: 'submit' | 'blur';
|
|
525
|
+
/**
|
|
526
|
+
* With `validateOn="blur"`, whether leaving a field the visitor has not
|
|
527
|
+
* typed in judges it.
|
|
528
|
+
*
|
|
529
|
+
* `true` (default): it does, so an empty required field shows its error
|
|
530
|
+
* as soon as it is left.
|
|
531
|
+
* `false`: a field only tabbed past stays quiet until submit or until it
|
|
532
|
+
* is typed in. A field that was typed in is still checked on leaving,
|
|
533
|
+
* with the same exceptions as `blur` above (moving within the field or
|
|
534
|
+
* into its popup, the window losing focus, a press in progress), so this
|
|
535
|
+
* is close to, not exactly, the behavior before #387. Has no effect with
|
|
536
|
+
* `validateOn="submit"`.
|
|
537
|
+
* @default true
|
|
538
|
+
*/
|
|
539
|
+
validateUntouched?: boolean;
|
|
517
540
|
children: React$1.ReactNode;
|
|
518
541
|
}
|
|
519
542
|
declare const Form: React$1.ForwardRefExoticComponent<FormProps & React$1.RefAttributes<HTMLFormElement>>;
|
|
@@ -2559,9 +2582,15 @@ interface SignInBlockProps {
|
|
|
2559
2582
|
schema?: ZodSchema;
|
|
2560
2583
|
/**
|
|
2561
2584
|
* When fields are checked: `blur` (default here) as the person leaves a
|
|
2562
|
-
* field
|
|
2585
|
+
* field, typed in or not, then again on submit; `submit` only on submit.
|
|
2563
2586
|
*/
|
|
2564
2587
|
validateOn?: 'submit' | 'blur';
|
|
2588
|
+
/**
|
|
2589
|
+
* With `validateOn="blur"`, whether leaving a field the person has not
|
|
2590
|
+
* typed in checks it. Pass `false` to keep such a field quiet until submit.
|
|
2591
|
+
* @default true
|
|
2592
|
+
*/
|
|
2593
|
+
validateUntouched?: boolean;
|
|
2565
2594
|
disabled?: boolean;
|
|
2566
2595
|
title?: string;
|
|
2567
2596
|
description?: string;
|
|
@@ -2610,6 +2639,7 @@ declare function SignInBlock({
|
|
|
2610
2639
|
errors,
|
|
2611
2640
|
schema,
|
|
2612
2641
|
validateOn,
|
|
2642
|
+
validateUntouched,
|
|
2613
2643
|
disabled,
|
|
2614
2644
|
title,
|
|
2615
2645
|
description,
|
|
@@ -2657,9 +2687,15 @@ interface SignUpBlockProps {
|
|
|
2657
2687
|
schema?: ZodSchema;
|
|
2658
2688
|
/**
|
|
2659
2689
|
* When fields are checked: `blur` (default here) as the person leaves a
|
|
2660
|
-
* field
|
|
2690
|
+
* field, typed in or not, then again on submit; `submit` only on submit.
|
|
2661
2691
|
*/
|
|
2662
2692
|
validateOn?: "submit" | "blur";
|
|
2693
|
+
/**
|
|
2694
|
+
* With `validateOn="blur"`, whether leaving a field the person has not
|
|
2695
|
+
* typed in checks it. Pass `false` to keep such a field quiet until submit.
|
|
2696
|
+
* @default true
|
|
2697
|
+
*/
|
|
2698
|
+
validateUntouched?: boolean;
|
|
2663
2699
|
disabled?: boolean;
|
|
2664
2700
|
title?: string;
|
|
2665
2701
|
description?: string;
|
|
@@ -2693,6 +2729,7 @@ declare function SignUpBlock({
|
|
|
2693
2729
|
errors,
|
|
2694
2730
|
schema,
|
|
2695
2731
|
validateOn,
|
|
2732
|
+
validateUntouched,
|
|
2696
2733
|
disabled,
|
|
2697
2734
|
title,
|
|
2698
2735
|
description,
|
|
@@ -3463,6 +3500,14 @@ interface InquiryFormBlockProps extends Omit<React$1.HTMLAttributes<HTMLElement>
|
|
|
3463
3500
|
register?: InquiryFormRegister;
|
|
3464
3501
|
/** react-hook-form's `trigger`, used when `formMode` is `rhf`. Without it, `rhf` mode does not validate. */
|
|
3465
3502
|
trigger?: InquiryFormTrigger;
|
|
3503
|
+
/**
|
|
3504
|
+
* Fields are checked as the visitor leaves them. Whether leaving a field
|
|
3505
|
+
* they have not typed in checks it too: `true` (default) shows an empty
|
|
3506
|
+
* required field's error as soon as it is left; `false` keeps it quiet
|
|
3507
|
+
* until Send.
|
|
3508
|
+
* @default true
|
|
3509
|
+
*/
|
|
3510
|
+
validateUntouched?: boolean;
|
|
3466
3511
|
containerClassName?: string;
|
|
3467
3512
|
}
|
|
3468
3513
|
/**
|