@craftzbay/ui 0.11.4 → 1.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","names":[],"sources":["../../../src/components/ui/Chart.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\nimport { Skeleton } from './Skeleton';\n\n/**\n * Tiny, dependency-free chart primitives for inline dashboards — sparklines,\n * KPI cards, at-a-glance trends. For heavy interactive visualisations reach for\n * a charting library. The SVG is drawn in real pixels: a ResizeObserver\n * measures the container width, so points and bars are never distorted.\n *\n * Keyboard: one tab stop per series; ←/→ (Home/End) move between points and\n * the active point is announced via a polite live region.\n */\n\nexport interface ChartPoint {\n x: string | number;\n /** `null` breaks the line (a gap) and is skipped in bars/tables. */\n y: number | null;\n}\n\nexport interface ChartSeries {\n /** Name used in the accessible summary, table header and tooltips. */\n name?: string;\n data: ChartPoint[];\n}\n\nexport type ChartState = 'loading' | 'empty' | 'error';\n\n/** Text builders for the accessible summary + point labels (i18n). */\nexport interface ChartLabels {\n /** `<desc>` sentence per series. */\n summary: (s: {\n name: string;\n count: number;\n min: number;\n max: number;\n lastX: string | number | undefined;\n lastY: number | undefined;\n }) => string;\n /** Label of one data point (tooltip, live region). */\n point: (name: string | undefined, x: string | number, y: number) => string;\n /** Accessible name of a series' tab stop. */\n series: (name: string, count: number) => string;\n}\n\nexport const defaultChartLabels: ChartLabels = {\n summary: ({ name, count, min, max, lastX, lastY }) =>\n `${name}: ${count} points, min ${min}, max ${max}, last ${lastX}: ${lastY}`,\n point: (name, x, y) => `${name ? `${name} — ` : ''}${x}: ${y}`,\n series: (name, count) => `${name}, ${count} points. Use arrow keys to move between points.`,\n};\n\nfunction chartLabelsFromStrings(t: UiStrings['chart']): ChartLabels {\n return {\n summary: ({ name, count, min, max, lastX, lastY }) =>\n formatString(t.summary, { name, count, min, max, x: lastX, y: lastY }),\n point: (name, x, y) => (name ? `${name} — ` : '') + formatString(t.point, { x, y }),\n series: (name, count) => formatString(t.seriesNav, { name, count }),\n };\n}\n\nexport interface ChartProps {\n /** Primary series. Ignored when `series` is provided. */\n data?: ChartPoint[];\n /** Multiple series drawn on the same scale. */\n series?: ChartSeries[];\n /** Per-series colours. Defaults to `--chart-1..6` (categorical; never the accent). */\n colors?: string[];\n /** Drawing height in px. */\n height?: number;\n /** Defaults to fluid 100%. */\n width?: number | string;\n /** Visible caption rendered above the chart. Doubles as the accessible name. */\n caption?: ReactNode;\n /** Accessible name when there is no `caption`. */\n 'aria-label'?: string;\n /** Alias of `aria-label` (SVG `<title>`). */\n title?: string;\n /** Faint horizontal gridlines. Default true. */\n grid?: boolean;\n /** Y-axis tick labels + first/last x labels. Default true. */\n showAxis?: boolean;\n /**\n * Render a visually-hidden `<table>` of the data after the SVG so screen\n * readers and copy/paste get the numbers. Default true.\n */\n tableFallback?: boolean;\n /** Show a small \"View as table\" toggle that reveals the fallback table. */\n showTableToggle?: boolean;\n /** Replace the drawing with a loading skeleton / empty / error message. */\n state?: ChartState;\n /** Override the generated accessible text (English defaults). */\n labels?: Partial<ChartLabels>;\n className?: string;\n}\n\nexport const DEFAULT_CHART_COLORS = [\n 'var(--chart-1)',\n 'var(--chart-2)',\n 'var(--chart-3)',\n 'var(--chart-4)',\n 'var(--chart-5)',\n 'var(--chart-6)',\n];\n\n// Width used before the container has been measured (SSR / first paint).\nconst FALLBACK_W = 600;\nconst PAD = 6;\n\n/** Measure the container's content width; re-renders on resize. */\nfunction useMeasuredWidth<T extends HTMLElement>() {\n const ref = useRef<T>(null);\n const [width, setWidth] = useState(0);\n const useIso = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n useIso(() => {\n const el = ref.current;\n if (!el) return;\n const update = () => setWidth(el.clientWidth);\n update();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(update);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n return { ref, width: width || FALLBACK_W };\n}\nconst MAX_TICKS = 5;\n\n/** 1234 → \"1.2K\", 3_400_000 → \"3.4M\". */\nexport function abbreviateNumber(n: number): string {\n const abs = Math.abs(n);\n const fmt = (v: number, s: string) => `${(Math.round(v * 10) / 10).toString()}${s}`;\n if (abs >= 1e9) return fmt(n / 1e9, 'B');\n if (abs >= 1e6) return fmt(n / 1e6, 'M');\n if (abs >= 1e3) return fmt(n / 1e3, 'K');\n return Number.isInteger(n) ? String(n) : (Math.round(n * 100) / 100).toString();\n}\n\n/** Round a raw step up to 1 / 2 / 2.5 / 5 × 10^n. */\nfunction niceStep(raw: number): number {\n if (raw <= 0) return 1;\n const exp = Math.floor(Math.log10(raw));\n const base = 10 ** exp;\n const f = raw / base;\n const nice = f <= 1 ? 1 : f <= 2 ? 2 : f <= 2.5 ? 2.5 : f <= 5 ? 5 : 10;\n return nice * base;\n}\n\n/**\n * \"Nice\" axis: expands [min, max] to multiples of a 1/2/2.5/5 step so ticks\n * read as round numbers (never `754.5`).\n */\nexport function niceTicks(min: number, max: number, maxTicks = MAX_TICKS) {\n if (max === min) max = min + 1;\n const step = niceStep((max - min) / Math.max(1, maxTicks - 1));\n const lo = Math.floor(min / step) * step;\n const hi = Math.ceil(max / step) * step;\n const ticks: number[] = [];\n // +step/2 guards float drift; toFixed strips 0.30000000000000004-style noise.\n for (let v = hi; v >= lo - step / 2; v -= step) ticks.push(Number(v.toFixed(10)));\n return { min: lo, max: hi, ticks };\n}\n\nfunction resolveSeries(data?: ChartPoint[], series?: ChartSeries[]): ChartSeries[] {\n if (series && series.length) return series;\n return [{ data: data ?? [] }];\n}\n\nconst isNum = (v: number | null | undefined): v is number => typeof v === 'number';\n\nfunction domain(all: ChartSeries[], includeZero = true) {\n const ys = all.flatMap((s) => s.data.map((d) => d.y).filter(isNum));\n const rawMin = includeZero ? Math.min(0, ...ys) : Math.min(...ys);\n const rawMax = Math.max(...ys, includeZero ? 1 : -Infinity);\n const { min, max, ticks } = niceTicks(\n Number.isFinite(rawMin) ? rawMin : 0,\n rawMax === -Infinity ? 1 : rawMax,\n );\n return { min, max, range: max - min || 1, ticks };\n}\n\nfunction scales(length: number, w: number, h: number, min: number, range: number) {\n const innerW = w - PAD * 2;\n const innerH = h - PAD * 2;\n const sx = (i: number) => (length <= 1 ? PAD + innerW / 2 : PAD + (i / (length - 1)) * innerW);\n const sy = (v: number) => PAD + innerH - ((v - min) / range) * innerH;\n return { sx, sy };\n}\n\n/** Catmull-Rom → cubic bézier: a smooth curve through every point. */\nfunction smoothPath(pts: [number, number][]): string {\n if (pts.length === 0) return '';\n if (pts.length < 3) return pts.map((p, i) => `${i ? 'L' : 'M'}${p[0]},${p[1]}`).join(' ');\n let d = `M${pts[0][0]},${pts[0][1]}`;\n for (let i = 0; i < pts.length - 1; i++) {\n const p0 = pts[i - 1] ?? pts[i];\n const p1 = pts[i];\n const p2 = pts[i + 1];\n const p3 = pts[i + 2] ?? p2;\n const c1x = p1[0] + (p2[0] - p0[0]) / 6;\n const c1y = p1[1] + (p2[1] - p0[1]) / 6;\n const c2x = p2[0] - (p3[0] - p1[0]) / 6;\n const c2y = p2[1] - (p3[1] - p1[1]) / 6;\n d += ` C${c1x.toFixed(1)},${c1y.toFixed(1)} ${c2x.toFixed(1)},${c2y.toFixed(1)} ${p2[0].toFixed(1)},${p2[1].toFixed(1)}`;\n }\n return d;\n}\n\n/** Split at `null` gaps → one smooth sub-path per run of real values. */\nfunction segments(\n data: ChartPoint[],\n sx: (i: number) => number,\n sy: (v: number) => number,\n): [number, number][][] {\n const out: [number, number][][] = [];\n let run: [number, number][] = [];\n data.forEach((d, i) => {\n if (isNum(d.y)) run.push([sx(i), sy(d.y)]);\n else if (run.length) {\n out.push(run);\n run = [];\n }\n });\n if (run.length) out.push(run);\n return out;\n}\n\nconst seriesName = (s: ChartSeries, i: number, t: UiStrings['chart']) =>\n s.name ?? formatString(t.series, { n: i + 1 });\n\n/** Plain-language summary for the `<desc>` element. */\nfunction describe(all: ChartSeries[], t: UiStrings['chart'], labels: ChartLabels): string {\n return all\n .map((s, i) => {\n const ys = s.data.map((d) => d.y).filter(isNum);\n const name = seriesName(s, i, t);\n if (!ys.length) return `${name}: ${t.noData}`;\n const last = [...s.data].reverse().find((d) => isNum(d.y));\n return labels.summary({\n name,\n count: ys.length,\n min: Math.min(...ys),\n max: Math.max(...ys),\n lastX: last?.x,\n lastY: last?.y ?? undefined,\n });\n })\n .join('. ');\n}\n\nfunction Grid({ width, height, lines }: { width: number; height: number; lines: number }) {\n const innerH = height - PAD * 2;\n const n = Math.max(1, lines);\n return (\n <g aria-hidden>\n {Array.from({ length: n + 1 }, (_, i) => {\n const y = PAD + (i / n) * innerH;\n return (\n <line\n key={i}\n x1={0}\n x2={width}\n y1={y}\n y2={y}\n stroke=\"var(--color-border)\"\n strokeWidth={1}\n opacity={0.6}\n />\n );\n })}\n </g>\n );\n}\n\n/** Axis labels are HTML so they follow the document font and wrap normally. */\nfunction YAxis({ ticks }: { ticks: number[] }) {\n return (\n <div\n aria-hidden\n className=\"tabular text-foreground-subtle pointer-events-none flex shrink-0 flex-col justify-between py-1.5 pr-1.5 text-right text-xs\"\n >\n {ticks.map((t, i) => (\n <span key={i} className=\"leading-none\">\n {abbreviateNumber(t)}\n </span>\n ))}\n </div>\n );\n}\n\nfunction XAxis({ first, last }: { first?: ChartPoint; last?: ChartPoint }) {\n if (!first) return null;\n return (\n <div aria-hidden className=\"text-foreground-subtle flex justify-between text-xs\">\n <span>{String(first.x)}</span>\n {last && last !== first && <span>{String(last.x)}</span>}\n </div>\n );\n}\n\nfunction DataTable({\n id,\n all,\n name,\n visible,\n t,\n}: {\n id: string;\n all: ChartSeries[];\n name?: string;\n visible: boolean;\n t: UiStrings['chart'];\n}) {\n const longest = Math.max(...all.map((s) => s.data.length));\n const xs = all.find((s) => s.data.length === longest)?.data ?? [];\n // A <table> ignores `sr-only`'s 1px width (min-content wins) and can widen\n // the document on narrow viewports — hide it inside a wrapper instead.\n const table = (\n <table\n id={id}\n data-chart-table\n className={cn(visible && 'tabular text-foreground-muted mt-2 w-full text-left text-xs')}\n >\n <caption className={cn(visible && 'text-foreground-subtle pb-1 text-left')}>\n {formatString(t.tableCaption, { name: name ?? '' }).trim()}\n </caption>\n <thead>\n <tr>\n <th scope=\"col\" className={cn(visible && 'border-border border-b py-1 pr-3 font-medium')}>\n x\n </th>\n {all.map((s, i) => (\n <th\n key={i}\n scope=\"col\"\n className={cn(visible && 'border-border border-b py-1 pr-3 font-medium')}\n >\n {seriesName(s, i, t)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {xs.map((p, i) => (\n <tr key={i}>\n <th scope=\"row\" className={cn(visible && 'py-0.5 pr-3 font-normal')}>\n {String(p.x)}\n </th>\n {all.map((s, si) => (\n <td key={si} className={cn(visible && 'py-0.5 pr-3')}>\n {isNum(s.data[i]?.y) ? String(s.data[i]?.y) : '—'}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return visible ? table : <div className=\"sr-only\">{table}</div>;\n}\n\nfunction Frame({\n caption,\n ariaLabel,\n title,\n all,\n height,\n width,\n className,\n showAxis,\n ticks,\n xFirst,\n xLast,\n tableFallback,\n showTableToggle,\n state,\n labels,\n children,\n}: {\n caption?: ReactNode;\n ariaLabel?: string;\n title?: string;\n all: ChartSeries[];\n height: number;\n width: number | string;\n className?: string;\n showAxis: boolean;\n ticks: number[];\n xFirst?: ChartPoint;\n xLast?: ChartPoint;\n tableFallback: boolean;\n showTableToggle?: boolean;\n state?: ChartState;\n labels: ChartLabels;\n children: (ctx: FrameContext) => ReactNode;\n}) {\n const t = useStrings().chart;\n const id = useId().replace(/:/g, '');\n const captionId = `chart-cap-${id}`;\n const titleId = `chart-title-${id}`;\n const descId = `chart-desc-${id}`;\n const tableId = `chart-table-${id}`;\n const name = ariaLabel ?? title;\n const [tableOpen, setTableOpen] = useState(false);\n const { ref: plotRef, width: plotW } = useMeasuredWidth<HTMLDivElement>();\n const roving = useRovingPoints(all, t, labels);\n\n if (process.env.NODE_ENV !== 'production' && !name && !caption) {\n console.warn(\n '[craftzbay/ui] Chart: provide `caption`, `aria-label`, or `title` so the chart has an accessible name.',\n );\n }\n\n const tableRendered = (tableFallback || tableOpen) && !state;\n\n const stateNode =\n state === 'loading' ? (\n <div role=\"status\" aria-label={t.loading} style={{ height }} className=\"w-full\">\n <Skeleton style={{ height }} className=\"w-full\" />\n <span className=\"sr-only\">{t.loading}</span>\n </div>\n ) : state ? (\n <div\n role={state === 'error' ? 'alert' : 'status'}\n style={{ height }}\n className=\"text-foreground-subtle flex w-full items-center justify-center text-sm\"\n >\n {state === 'error' ? t.error : t.empty}\n </div>\n ) : null;\n\n return (\n <figure className={cn('flex flex-col gap-1.5', className)} style={{ width }}>\n {caption && (\n <figcaption id={captionId} className=\"text-foreground-muted text-xs\">\n {caption}\n </figcaption>\n )}\n {stateNode ?? (\n <>\n <div className=\"flex\">\n {showAxis && <YAxis ticks={ticks} />}\n {/* The plot area is measured; the SVG is drawn 1:1 in px inside it. */}\n <div ref={plotRef} className=\"min-w-0 flex-1\">\n {/* role=group (not img): series inside are focusable and carry their own labels. */}\n <svg\n viewBox={`0 0 ${plotW} ${height}`}\n width={plotW}\n height={height}\n role=\"group\"\n aria-labelledby={caption ? captionId : name ? titleId : undefined}\n aria-describedby={descId}\n className=\"block max-w-full overflow-visible\"\n >\n {name && <title id={titleId}>{name}</title>}\n <desc id={descId}>{describe(all, t, labels)}</desc>\n {children({ width: plotW, ...roving })}\n </svg>\n </div>\n </div>\n {showAxis && <XAxis first={xFirst} last={xLast} />}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {roving.announcement}\n </span>\n </>\n )}\n {showTableToggle && !state && (\n <button\n type=\"button\"\n onClick={() => setTableOpen((v) => !v)}\n aria-expanded={tableOpen}\n aria-controls={tableRendered ? tableId : undefined}\n className={cn(\n 'text-foreground-subtle hover:text-foreground self-start rounded-sm text-xs underline-offset-2 outline-none hover:underline',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n {tableOpen ? t.hideTable : t.viewAsTable}\n </button>\n )}\n {tableRendered && (\n <DataTable\n id={tableId}\n all={all}\n name={name ?? (typeof caption === 'string' ? caption : undefined)}\n visible={tableOpen}\n t={t}\n />\n )}\n </figure>\n );\n}\n\ninterface FrameContext {\n width: number;\n active: { series: number; index: number } | null;\n seriesProps: (si: number) => {\n tabIndex: number;\n role: 'group';\n 'aria-label': string;\n 'data-chart-series': true;\n onKeyDown: (e: KeyboardEvent<SVGGElement>) => void;\n onFocus: () => void;\n onBlur: () => void;\n className: string;\n };\n}\n\n/**\n * Roving focus: each series is a single tab stop; ←/→/Home/End move the\n * active point and the live region announces it. Per-point tab stops would\n * make a 200-point chart a 200-tab ordeal.\n */\nfunction useRovingPoints(all: ChartSeries[], t: UiStrings['chart'], labels: ChartLabels) {\n const [active, setActive] = useState<{ series: number; index: number } | null>(null);\n const [announcement, setAnnouncement] = useState('');\n\n const announce = useCallback(\n (si: number, idx: number) => {\n const s = all[si];\n const d = s?.data[idx];\n if (!d || !isNum(d.y)) return;\n setActive({ series: si, index: idx });\n setAnnouncement(labels.point(s.name, d.x, d.y));\n },\n [all, labels],\n );\n\n const validIndices = (si: number) =>\n all[si].data.map((d, i) => (isNum(d.y) ? i : -1)).filter((i) => i >= 0);\n\n const seriesProps = (si: number) => ({\n tabIndex: 0,\n role: 'group' as const,\n 'aria-label': labels.series(seriesName(all[si], si, t), validIndices(si).length),\n // Focus ring comes from theme.css `[data-chart-series]:focus-visible`\n // (CSS outline — Tailwind's box-shadow ring does not paint on SVG <g>).\n 'data-chart-series': true as const,\n className: cn(\n '[&:focus-visible_[data-active]]:stroke-[var(--ring)] [&:focus-visible_[data-active]]:stroke-[3px]',\n ),\n onFocus: () => {\n const idxs = validIndices(si);\n if (idxs.length) announce(si, active?.series === si ? active.index : idxs[idxs.length - 1]);\n },\n onBlur: () => {\n setActive(null);\n setAnnouncement('');\n },\n onKeyDown: (e: KeyboardEvent<SVGGElement>) => {\n const idxs = validIndices(si);\n if (!idxs.length) return;\n const pos = active?.series === si ? idxs.indexOf(active.index) : idxs.length - 1;\n let next = pos;\n if (e.key === 'ArrowRight' || e.key === 'ArrowUp') next = Math.min(idxs.length - 1, pos + 1);\n else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') next = Math.max(0, pos - 1);\n else if (e.key === 'Home') next = 0;\n else if (e.key === 'End') next = idxs.length - 1;\n else return;\n e.preventDefault();\n announce(si, idxs[next]);\n },\n });\n\n return { active, announcement, seriesProps };\n}\n\n/** Labelled data point. Invisible until hovered / active unless `always`. */\nfunction Point({\n x,\n y,\n color,\n label,\n always,\n active,\n}: {\n x: number;\n y: number;\n color: string;\n label: string;\n always?: boolean;\n active?: boolean;\n}) {\n return (\n <circle\n cx={x}\n cy={y}\n r={3.5}\n fill={color}\n data-active={active || undefined}\n className={cn(!always && !active && 'opacity-0 hover:opacity-100')}\n >\n <title>{label}</title>\n </circle>\n );\n}\n\nexport function LineChart({\n data,\n series,\n colors = DEFAULT_CHART_COLORS,\n height = 160,\n width = '100%',\n caption,\n 'aria-label': ariaLabel,\n title,\n grid = true,\n showAxis = true,\n tableFallback = true,\n showTableToggle,\n state,\n labels: labelsProp,\n className,\n}: ChartProps) {\n const t = useStrings().chart;\n const labels = { ...chartLabelsFromStrings(t), ...labelsProp };\n const all = resolveSeries(data, series);\n const { min, range, ticks } = domain(all);\n const longest = Math.max(...all.map((s) => s.data.length));\n const primary = all[0].data;\n\n return (\n <Frame\n caption={caption}\n ariaLabel={ariaLabel}\n title={title}\n all={all}\n height={height}\n width={width}\n className={className}\n showAxis={showAxis}\n ticks={ticks}\n xFirst={primary[0]}\n xLast={primary[primary.length - 1]}\n tableFallback={tableFallback}\n showTableToggle={showTableToggle}\n state={state}\n labels={labels}\n >\n {({ width: w, active, seriesProps }) => (\n <>\n {grid && <Grid width={w} height={height} lines={ticks.length - 1} />}\n {all.map((s, si) => {\n const color = colors[si % colors.length];\n const { sx, sy } = scales(longest, w, height, min, range);\n const segs = segments(s.data, sx, sy);\n const line = segs.map(smoothPath).join(' ');\n const baseline = sy(Math.max(min, 0));\n const area = segs\n .map(\n (pts) =>\n `${smoothPath(pts)} L${pts[pts.length - 1][0].toFixed(1)},${baseline.toFixed(1)} L${pts[0][0].toFixed(1)},${baseline.toFixed(1)} Z`,\n )\n .join(' ');\n const lastIdx = s.data.map((d) => isNum(d.y)).lastIndexOf(true);\n return (\n <g key={si} {...seriesProps(si)}>\n {area && <path d={area} fill={color} fillOpacity={0.08} />}\n <path\n d={line}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n {s.data.map((d, i) =>\n isNum(d.y) ? (\n <Point\n key={i}\n x={sx(i)}\n y={sy(d.y)}\n color={color}\n always={i === lastIdx}\n active={active?.series === si && active.index === i}\n label={labels.point(s.name, d.x, d.y)}\n />\n ) : null,\n )}\n </g>\n );\n })}\n </>\n )}\n </Frame>\n );\n}\n\nexport function AreaChart(props: ChartProps) {\n // The line chart already renders a flat low-opacity area; alias for intent / naming.\n return <LineChart {...props} />;\n}\n\nexport function BarChart({\n data,\n series,\n colors = DEFAULT_CHART_COLORS,\n height = 160,\n width = '100%',\n caption,\n 'aria-label': ariaLabel,\n title,\n grid = true,\n showAxis = true,\n tableFallback = true,\n showTableToggle,\n state,\n labels: labelsProp,\n className,\n}: ChartProps) {\n const t = useStrings().chart;\n const labels = { ...chartLabelsFromStrings(t), ...labelsProp };\n const all = resolveSeries(data, series);\n const longest = Math.max(...all.map((s) => s.data.length));\n const { min, range, ticks } = domain(all);\n const primary = all[0].data;\n\n return (\n <Frame\n caption={caption}\n ariaLabel={ariaLabel}\n title={title}\n all={all}\n height={height}\n width={width}\n className={className}\n showAxis={showAxis}\n ticks={ticks}\n xFirst={primary[0]}\n xLast={primary[primary.length - 1]}\n tableFallback={tableFallback}\n showTableToggle={showTableToggle}\n state={state}\n labels={labels}\n >\n {({ width: w, active, seriesProps }) => {\n const innerW = w - PAD * 2;\n const slot = innerW / Math.max(1, longest);\n const groupW = slot * 0.62;\n const barW = Math.max(2, groupW / all.length);\n const { sy } = scales(longest, w, height, min, range);\n // Bars grow from the zero line, so negatives hang below it.\n const zeroY = sy(Math.min(Math.max(0, min), min + range));\n return (\n <>\n {grid && <Grid width={w} height={height} lines={ticks.length - 1} />}\n {min < 0 && (\n <line\n aria-hidden\n x1={0}\n x2={w}\n y1={zeroY}\n y2={zeroY}\n stroke=\"var(--color-border-strong)\"\n strokeWidth={1}\n />\n )}\n {all.map((s, si) => (\n <g key={si} {...seriesProps(si)}>\n {s.data.map((d, i) => {\n if (!isNum(d.y)) return null;\n const yv = sy(d.y);\n const x = PAD + i * slot + (slot - groupW) / 2 + si * barW;\n const label = labels.point(s.name, d.x, d.y);\n const isActive = active?.series === si && active.index === i;\n return (\n <rect\n key={i}\n x={x}\n y={Math.min(zeroY, yv)}\n width={barW}\n height={Math.abs(zeroY - yv)}\n fill={colors[si % colors.length]}\n rx={2}\n data-active={isActive || undefined}\n className=\"transition-opacity hover:opacity-80\"\n >\n <title>{label}</title>\n </rect>\n );\n })}\n </g>\n ))}\n </>\n );\n }}\n </Frame>\n );\n}\n"],"mappings":";;;;;;;;AA0DA,IAAa,IAAkC;CAC7C,UAAU,EAAE,SAAM,UAAO,QAAK,QAAK,UAAO,eACxC,GAAG,EAAK,IAAI,EAAM,eAAe,EAAI,QAAQ,EAAI,SAAS,EAAM,IAAI;CACtE,QAAQ,GAAM,GAAG,MAAM,GAAG,IAAO,GAAG,EAAK,OAAO,KAAK,EAAE,IAAI;CAC3D,SAAS,GAAM,MAAU,GAAG,EAAK,IAAI,EAAM;AAC7C;AAEA,SAAS,EAAuB,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AAI,CAAA;IAClE,IAAM,KACL,kBAAC,QAAD;KACE,eAAA;KACA,IAAI;KACJ,IAAI;KACJ,IAAI;KACJ,IAAI;KACJ,QAAO;KACP,aAAa;IACd,CAAA;IAEF,EAAI,KAAK,GAAG,MACX,kBAAC,KAAD;KAAY,GAAI,EAAY,CAAE;KAC3B,UAAA,EAAE,KAAK,KAAK,GAAG,MAAM;MACpB,IAAI,CAAC,EAAM,EAAE,CAAC,GAAG,OAAO;MACxB,IAAM,IAAK,EAAG,EAAE,CAAC,GACX,IAAI,IAAM,IAAI,KAAQ,IAAO,KAAU,IAAI,IAAK,GAChD,IAAQ,EAAO,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GACrC,IAAW,GAAQ,WAAW,KAAM,EAAO,UAAU;MAC3D,OACE,kBAAC,QAAD;OAEK;OACH,GAAG,KAAK,IAAI,GAAO,CAAE;OACrB,OAAO;OACP,QAAQ,KAAK,IAAI,IAAQ,CAAE;OAC3B,MAAM,EAAO,IAAK,EAAO;OACzB,IAAI;OACJ,eAAa,KAAY,KAAA;OACzB,WAAU;OAEV,UAAA,kBAAC,SAAD,EAAA,UAAQ,EAAa,CAAA;MACjB,GAXC,CAWD;KAEV,CAAC;IACA,GAvBK,CAuBL,CACJ;GACD,EAAA,CAAA;EAEN;CACK,CAAA;AAEX"}
1
+ {"version":3,"file":"Chart.js","names":[],"sources":["../../../src/components/ui/Chart.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\nimport { Skeleton } from './Skeleton';\n\n/**\n * Tiny, dependency-free chart primitives for inline dashboards — sparklines,\n * KPI cards, at-a-glance trends. For heavy interactive visualisations reach for\n * a charting library. The SVG is drawn in real pixels: a ResizeObserver\n * measures the container width, so points and bars are never distorted.\n *\n * Keyboard: one tab stop per series; ←/→ (Home/End) move between points and\n * the active point is announced via a polite live region.\n */\n\nexport interface ChartPoint {\n x: string | number;\n /** `null` breaks the line (a gap) and is skipped in bars/tables. */\n y: number | null;\n}\n\nexport interface ChartSeries {\n /** Name used in the accessible summary, table header and tooltips. */\n name?: string;\n data: ChartPoint[];\n}\n\nexport type ChartState = 'loading' | 'empty' | 'error';\n\n/** Text builders for the accessible summary + point labels (i18n). */\nexport interface ChartLabels {\n /** `<desc>` sentence per series. */\n summary: (s: {\n name: string;\n count: number;\n min: number;\n max: number;\n lastX: string | number | undefined;\n lastY: number | undefined;\n }) => string;\n /** Label of one data point (tooltip, live region). */\n point: (name: string | undefined, x: string | number, y: number) => string;\n /** Accessible name of a series' tab stop. */\n series: (name: string, count: number) => string;\n}\n\nexport const defaultChartLabels: ChartLabels = {\n summary: ({ name, count, min, max, lastX, lastY }) =>\n `${name}: ${count} points, min ${min}, max ${max}, last ${lastX}: ${lastY}`,\n point: (name, x, y) => `${name ? `${name} — ` : ''}${x}: ${y}`,\n series: (name, count) => `${name}, ${count} points. Use arrow keys to move between points.`,\n};\n\nfunction chartLabelsFromStrings(t: UiStrings['chart']): ChartLabels {\n return {\n summary: ({ name, count, min, max, lastX, lastY }) =>\n formatString(t.summary, { name, count, min, max, x: lastX, y: lastY }),\n point: (name, x, y) => (name ? `${name} — ` : '') + formatString(t.point, { x, y }),\n series: (name, count) => formatString(t.seriesNav, { name, count }),\n };\n}\n\nexport interface ChartProps {\n /** Primary series. Ignored when `series` is provided. */\n data?: ChartPoint[];\n /** Multiple series drawn on the same scale. */\n series?: ChartSeries[];\n /** Per-series colours. Defaults to `--chart-1..6` (categorical; never the accent). */\n colors?: string[];\n /** Drawing height in px. */\n height?: number;\n /** Defaults to fluid 100%. */\n width?: number | string;\n /** Visible caption rendered above the chart. Doubles as the accessible name. */\n caption?: ReactNode;\n /** Accessible name when there is no `caption`. */\n 'aria-label'?: string;\n /** Alias of `aria-label` (SVG `<title>`). */\n title?: string;\n /** Faint horizontal gridlines. Default true. */\n grid?: boolean;\n /** Y-axis tick labels + first/last x labels. Default true. */\n showAxis?: boolean;\n /**\n * Render a visually-hidden `<table>` of the data after the SVG so screen\n * readers and copy/paste get the numbers. Default true.\n */\n tableFallback?: boolean;\n /** Show a small \"View as table\" toggle that reveals the fallback table. */\n showTableToggle?: boolean;\n /** Replace the drawing with a loading skeleton / empty / error message. */\n state?: ChartState;\n /** Override the generated accessible text (English defaults). */\n labels?: Partial<ChartLabels>;\n className?: string;\n}\n\nexport const DEFAULT_CHART_COLORS = [\n 'var(--chart-1)',\n 'var(--chart-2)',\n 'var(--chart-3)',\n 'var(--chart-4)',\n 'var(--chart-5)',\n 'var(--chart-6)',\n];\n\n// Width used before the container has been measured (SSR / first paint).\nconst FALLBACK_W = 600;\nconst PAD = 6;\n\n/** `useLayoutEffect` warns during SSR; fall back to `useEffect` there. */\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/** Measure the container's content width; re-renders on resize. */\nfunction useMeasuredWidth<T extends HTMLElement>() {\n const ref = useRef<T>(null);\n const [width, setWidth] = useState(0);\n useIsomorphicLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const update = () => setWidth(el.clientWidth);\n update();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(update);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n return { ref, width: width || FALLBACK_W };\n}\nconst MAX_TICKS = 5;\n\n/** 1234 → \"1.2K\", 3_400_000 → \"3.4M\". */\nexport function abbreviateNumber(n: number): string {\n const abs = Math.abs(n);\n const fmt = (v: number, s: string) => `${(Math.round(v * 10) / 10).toString()}${s}`;\n if (abs >= 1e9) return fmt(n / 1e9, 'B');\n if (abs >= 1e6) return fmt(n / 1e6, 'M');\n if (abs >= 1e3) return fmt(n / 1e3, 'K');\n return Number.isInteger(n) ? String(n) : (Math.round(n * 100) / 100).toString();\n}\n\n/** Round a raw step up to 1 / 2 / 2.5 / 5 × 10^n. */\nfunction niceStep(raw: number): number {\n if (raw <= 0) return 1;\n const exp = Math.floor(Math.log10(raw));\n const base = 10 ** exp;\n const f = raw / base;\n const nice = f <= 1 ? 1 : f <= 2 ? 2 : f <= 2.5 ? 2.5 : f <= 5 ? 5 : 10;\n return nice * base;\n}\n\n/**\n * \"Nice\" axis: expands [min, max] to multiples of a 1/2/2.5/5 step so ticks\n * read as round numbers (never `754.5`).\n */\nexport function niceTicks(min: number, max: number, maxTicks = MAX_TICKS) {\n if (max === min) max = min + 1;\n const step = niceStep((max - min) / Math.max(1, maxTicks - 1));\n const lo = Math.floor(min / step) * step;\n const hi = Math.ceil(max / step) * step;\n const ticks: number[] = [];\n // +step/2 guards float drift; toFixed strips 0.30000000000000004-style noise.\n for (let v = hi; v >= lo - step / 2; v -= step) ticks.push(Number(v.toFixed(10)));\n return { min: lo, max: hi, ticks };\n}\n\nfunction resolveSeries(data?: ChartPoint[], series?: ChartSeries[]): ChartSeries[] {\n if (series && series.length) return series;\n return [{ data: data ?? [] }];\n}\n\nconst isNum = (v: number | null | undefined): v is number => typeof v === 'number';\n\nfunction domain(all: ChartSeries[], includeZero = true) {\n const ys = all.flatMap((s) => s.data.map((d) => d.y).filter(isNum));\n const rawMin = includeZero ? Math.min(0, ...ys) : Math.min(...ys);\n const rawMax = Math.max(...ys, includeZero ? 1 : -Infinity);\n const { min, max, ticks } = niceTicks(\n Number.isFinite(rawMin) ? rawMin : 0,\n rawMax === -Infinity ? 1 : rawMax,\n );\n return { min, max, range: max - min || 1, ticks };\n}\n\nfunction scales(length: number, w: number, h: number, min: number, range: number) {\n const innerW = w - PAD * 2;\n const innerH = h - PAD * 2;\n const sx = (i: number) => (length <= 1 ? PAD + innerW / 2 : PAD + (i / (length - 1)) * innerW);\n const sy = (v: number) => PAD + innerH - ((v - min) / range) * innerH;\n return { sx, sy };\n}\n\n/** Catmull-Rom → cubic bézier: a smooth curve through every point. */\nfunction smoothPath(pts: [number, number][]): string {\n if (pts.length === 0) return '';\n if (pts.length < 3) return pts.map((p, i) => `${i ? 'L' : 'M'}${p[0]},${p[1]}`).join(' ');\n let d = `M${pts[0][0]},${pts[0][1]}`;\n for (let i = 0; i < pts.length - 1; i++) {\n const p0 = pts[i - 1] ?? pts[i];\n const p1 = pts[i];\n const p2 = pts[i + 1];\n const p3 = pts[i + 2] ?? p2;\n const c1x = p1[0] + (p2[0] - p0[0]) / 6;\n const c1y = p1[1] + (p2[1] - p0[1]) / 6;\n const c2x = p2[0] - (p3[0] - p1[0]) / 6;\n const c2y = p2[1] - (p3[1] - p1[1]) / 6;\n d += ` C${c1x.toFixed(1)},${c1y.toFixed(1)} ${c2x.toFixed(1)},${c2y.toFixed(1)} ${p2[0].toFixed(1)},${p2[1].toFixed(1)}`;\n }\n return d;\n}\n\n/** Split at `null` gaps → one smooth sub-path per run of real values. */\nfunction segments(\n data: ChartPoint[],\n sx: (i: number) => number,\n sy: (v: number) => number,\n): [number, number][][] {\n const out: [number, number][][] = [];\n let run: [number, number][] = [];\n data.forEach((d, i) => {\n if (isNum(d.y)) run.push([sx(i), sy(d.y)]);\n else if (run.length) {\n out.push(run);\n run = [];\n }\n });\n if (run.length) out.push(run);\n return out;\n}\n\nconst seriesName = (s: ChartSeries, i: number, t: UiStrings['chart']) =>\n s.name ?? formatString(t.series, { n: i + 1 });\n\n/** Plain-language summary for the `<desc>` element. */\nfunction describe(all: ChartSeries[], t: UiStrings['chart'], labels: ChartLabels): string {\n return all\n .map((s, i) => {\n const ys = s.data.map((d) => d.y).filter(isNum);\n const name = seriesName(s, i, t);\n if (!ys.length) return `${name}: ${t.noData}`;\n const last = [...s.data].reverse().find((d) => isNum(d.y));\n return labels.summary({\n name,\n count: ys.length,\n min: Math.min(...ys),\n max: Math.max(...ys),\n lastX: last?.x,\n lastY: last?.y ?? undefined,\n });\n })\n .join('. ');\n}\n\nfunction Grid({ width, height, lines }: { width: number; height: number; lines: number }) {\n const innerH = height - PAD * 2;\n const n = Math.max(1, lines);\n return (\n <g aria-hidden>\n {Array.from({ length: n + 1 }, (_, i) => {\n const y = PAD + (i / n) * innerH;\n return (\n <line\n key={i}\n x1={0}\n x2={width}\n y1={y}\n y2={y}\n stroke=\"var(--color-border)\"\n strokeWidth={1}\n opacity={0.6}\n />\n );\n })}\n </g>\n );\n}\n\n/** Axis labels are HTML so they follow the document font and wrap normally. */\nfunction YAxis({ ticks }: { ticks: number[] }) {\n return (\n <div\n aria-hidden\n className=\"tabular text-foreground-subtle pointer-events-none flex shrink-0 flex-col justify-between py-1.5 pr-1.5 text-right text-xs\"\n >\n {ticks.map((t, i) => (\n <span key={i} className=\"leading-none\">\n {abbreviateNumber(t)}\n </span>\n ))}\n </div>\n );\n}\n\nfunction XAxis({ first, last }: { first?: ChartPoint; last?: ChartPoint }) {\n if (!first) return null;\n return (\n <div aria-hidden className=\"text-foreground-subtle flex justify-between text-xs\">\n <span>{String(first.x)}</span>\n {last && last !== first && <span>{String(last.x)}</span>}\n </div>\n );\n}\n\nfunction DataTable({\n id,\n all,\n name,\n visible,\n t,\n}: {\n id: string;\n all: ChartSeries[];\n name?: string;\n visible: boolean;\n t: UiStrings['chart'];\n}) {\n const longest = Math.max(...all.map((s) => s.data.length));\n const xs = all.find((s) => s.data.length === longest)?.data ?? [];\n // A <table> ignores `sr-only`'s 1px width (min-content wins) and can widen\n // the document on narrow viewports — hide it inside a wrapper instead.\n const table = (\n <table\n id={id}\n data-chart-table\n className={cn(visible && 'tabular text-foreground-muted mt-2 w-full text-left text-xs')}\n >\n <caption className={cn(visible && 'text-foreground-subtle pb-1 text-left')}>\n {formatString(t.tableCaption, { name: name ?? '' }).trim()}\n </caption>\n <thead>\n <tr>\n <th scope=\"col\" className={cn(visible && 'border-border border-b py-1 pr-3 font-medium')}>\n x\n </th>\n {all.map((s, i) => (\n <th\n key={i}\n scope=\"col\"\n className={cn(visible && 'border-border border-b py-1 pr-3 font-medium')}\n >\n {seriesName(s, i, t)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {xs.map((p, i) => (\n <tr key={i}>\n <th scope=\"row\" className={cn(visible && 'py-0.5 pr-3 font-normal')}>\n {String(p.x)}\n </th>\n {all.map((s, si) => (\n <td key={si} className={cn(visible && 'py-0.5 pr-3')}>\n {isNum(s.data[i]?.y) ? String(s.data[i]?.y) : '—'}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return visible ? table : <div className=\"sr-only\">{table}</div>;\n}\n\nfunction Frame({\n caption,\n ariaLabel,\n title,\n all,\n height,\n width,\n className,\n showAxis,\n ticks,\n xFirst,\n xLast,\n tableFallback,\n showTableToggle,\n state,\n labels,\n children,\n}: {\n caption?: ReactNode;\n ariaLabel?: string;\n title?: string;\n all: ChartSeries[];\n height: number;\n width: number | string;\n className?: string;\n showAxis: boolean;\n ticks: number[];\n xFirst?: ChartPoint;\n xLast?: ChartPoint;\n tableFallback: boolean;\n showTableToggle?: boolean;\n state?: ChartState;\n labels: ChartLabels;\n children: (ctx: FrameContext) => ReactNode;\n}) {\n const t = useStrings().chart;\n const id = useId().replace(/:/g, '');\n const captionId = `chart-cap-${id}`;\n const titleId = `chart-title-${id}`;\n const descId = `chart-desc-${id}`;\n const tableId = `chart-table-${id}`;\n const name = ariaLabel ?? title;\n const [tableOpen, setTableOpen] = useState(false);\n const { ref: plotRef, width: plotW } = useMeasuredWidth<HTMLDivElement>();\n const roving = useRovingPoints(all, t, labels);\n\n if (process.env.NODE_ENV !== 'production' && !name && !caption) {\n console.warn(\n '[craftzbay/ui] Chart: provide `caption`, `aria-label`, or `title` so the chart has an accessible name.',\n );\n }\n\n const tableRendered = (tableFallback || tableOpen) && !state;\n\n const stateNode =\n state === 'loading' ? (\n <div role=\"status\" aria-label={t.loading} style={{ height }} className=\"w-full\">\n <Skeleton style={{ height }} className=\"w-full\" />\n <span className=\"sr-only\">{t.loading}</span>\n </div>\n ) : state ? (\n <div\n role={state === 'error' ? 'alert' : 'status'}\n style={{ height }}\n className=\"text-foreground-subtle flex w-full items-center justify-center text-sm\"\n >\n {state === 'error' ? t.error : t.empty}\n </div>\n ) : null;\n\n return (\n <figure className={cn('flex flex-col gap-1.5', className)} style={{ width }}>\n {caption && (\n <figcaption id={captionId} className=\"text-foreground-muted text-xs\">\n {caption}\n </figcaption>\n )}\n {stateNode ?? (\n <>\n <div className=\"flex\">\n {showAxis && <YAxis ticks={ticks} />}\n {/* The plot area is measured; the SVG is drawn 1:1 in px inside it. */}\n <div ref={plotRef} className=\"min-w-0 flex-1\">\n {/* role=group (not img): series inside are focusable and carry their own labels. */}\n <svg\n viewBox={`0 0 ${plotW} ${height}`}\n width={plotW}\n height={height}\n role=\"group\"\n aria-labelledby={caption ? captionId : name ? titleId : undefined}\n aria-describedby={descId}\n className=\"block max-w-full overflow-visible\"\n >\n {name && <title id={titleId}>{name}</title>}\n <desc id={descId}>{describe(all, t, labels)}</desc>\n {children({ width: plotW, ...roving })}\n </svg>\n </div>\n </div>\n {showAxis && <XAxis first={xFirst} last={xLast} />}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {roving.announcement}\n </span>\n </>\n )}\n {showTableToggle && !state && (\n <button\n type=\"button\"\n onClick={() => setTableOpen((v) => !v)}\n aria-expanded={tableOpen}\n aria-controls={tableRendered ? tableId : undefined}\n className={cn(\n 'text-foreground-subtle hover:text-foreground self-start rounded-sm text-xs underline-offset-2 outline-none hover:underline',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n {tableOpen ? t.hideTable : t.viewAsTable}\n </button>\n )}\n {tableRendered && (\n <DataTable\n id={tableId}\n all={all}\n name={name ?? (typeof caption === 'string' ? caption : undefined)}\n visible={tableOpen}\n t={t}\n />\n )}\n </figure>\n );\n}\n\ninterface FrameContext {\n width: number;\n active: { series: number; index: number } | null;\n seriesProps: (si: number) => {\n tabIndex: number;\n role: 'group';\n 'aria-label': string;\n 'data-chart-series': true;\n onKeyDown: (e: KeyboardEvent<SVGGElement>) => void;\n onFocus: () => void;\n onBlur: () => void;\n className: string;\n };\n}\n\n/**\n * Roving focus: each series is a single tab stop; ←/→/Home/End move the\n * active point and the live region announces it. Per-point tab stops would\n * make a 200-point chart a 200-tab ordeal.\n */\nfunction useRovingPoints(all: ChartSeries[], t: UiStrings['chart'], labels: ChartLabels) {\n const [active, setActive] = useState<{ series: number; index: number } | null>(null);\n const [announcement, setAnnouncement] = useState('');\n\n const announce = useCallback(\n (si: number, idx: number) => {\n const s = all[si];\n const d = s?.data[idx];\n if (!d || !isNum(d.y)) return;\n setActive({ series: si, index: idx });\n setAnnouncement(labels.point(s.name, d.x, d.y));\n },\n [all, labels],\n );\n\n const validIndices = (si: number) =>\n all[si].data.map((d, i) => (isNum(d.y) ? i : -1)).filter((i) => i >= 0);\n\n const seriesProps = (si: number) => ({\n tabIndex: 0,\n role: 'group' as const,\n 'aria-label': labels.series(seriesName(all[si], si, t), validIndices(si).length),\n // Focus ring comes from theme.css `[data-chart-series]:focus-visible`\n // (CSS outline — Tailwind's box-shadow ring does not paint on SVG <g>).\n 'data-chart-series': true as const,\n className: cn(\n '[&:focus-visible_[data-active]]:stroke-[var(--ring)] [&:focus-visible_[data-active]]:stroke-[3px]',\n ),\n onFocus: () => {\n const idxs = validIndices(si);\n if (idxs.length) announce(si, active?.series === si ? active.index : idxs[idxs.length - 1]);\n },\n onBlur: () => {\n setActive(null);\n setAnnouncement('');\n },\n onKeyDown: (e: KeyboardEvent<SVGGElement>) => {\n const idxs = validIndices(si);\n if (!idxs.length) return;\n const pos = active?.series === si ? idxs.indexOf(active.index) : idxs.length - 1;\n let next = pos;\n if (e.key === 'ArrowRight' || e.key === 'ArrowUp') next = Math.min(idxs.length - 1, pos + 1);\n else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') next = Math.max(0, pos - 1);\n else if (e.key === 'Home') next = 0;\n else if (e.key === 'End') next = idxs.length - 1;\n else return;\n e.preventDefault();\n announce(si, idxs[next]);\n },\n });\n\n return { active, announcement, seriesProps };\n}\n\n/** Labelled data point. Invisible until hovered / active unless `always`. */\nfunction Point({\n x,\n y,\n color,\n label,\n always,\n active,\n}: {\n x: number;\n y: number;\n color: string;\n label: string;\n always?: boolean;\n active?: boolean;\n}) {\n return (\n <circle\n cx={x}\n cy={y}\n r={3.5}\n fill={color}\n data-active={active || undefined}\n className={cn(!always && !active && 'opacity-0 hover:opacity-100')}\n >\n <title>{label}</title>\n </circle>\n );\n}\n\nexport function LineChart({\n data,\n series,\n colors = DEFAULT_CHART_COLORS,\n height = 160,\n width = '100%',\n caption,\n 'aria-label': ariaLabel,\n title,\n grid = true,\n showAxis = true,\n tableFallback = true,\n showTableToggle,\n state,\n labels: labelsProp,\n className,\n}: ChartProps) {\n const t = useStrings().chart;\n const labels = { ...chartLabelsFromStrings(t), ...labelsProp };\n const all = resolveSeries(data, series);\n const { min, range, ticks } = domain(all);\n const longest = Math.max(...all.map((s) => s.data.length));\n const primary = all[0].data;\n\n return (\n <Frame\n caption={caption}\n ariaLabel={ariaLabel}\n title={title}\n all={all}\n height={height}\n width={width}\n className={className}\n showAxis={showAxis}\n ticks={ticks}\n xFirst={primary[0]}\n xLast={primary[primary.length - 1]}\n tableFallback={tableFallback}\n showTableToggle={showTableToggle}\n state={state}\n labels={labels}\n >\n {({ width: w, active, seriesProps }) => (\n <>\n {grid && <Grid width={w} height={height} lines={ticks.length - 1} />}\n {all.map((s, si) => {\n const color = colors[si % colors.length];\n const { sx, sy } = scales(longest, w, height, min, range);\n const segs = segments(s.data, sx, sy);\n const line = segs.map(smoothPath).join(' ');\n const baseline = sy(Math.max(min, 0));\n const area = segs\n .map(\n (pts) =>\n `${smoothPath(pts)} L${pts[pts.length - 1][0].toFixed(1)},${baseline.toFixed(1)} L${pts[0][0].toFixed(1)},${baseline.toFixed(1)} Z`,\n )\n .join(' ');\n const lastIdx = s.data.map((d) => isNum(d.y)).lastIndexOf(true);\n return (\n <g key={si} {...seriesProps(si)}>\n {area && <path d={area} fill={color} fillOpacity={0.08} />}\n <path\n d={line}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n {s.data.map((d, i) =>\n isNum(d.y) ? (\n <Point\n key={i}\n x={sx(i)}\n y={sy(d.y)}\n color={color}\n always={i === lastIdx}\n active={active?.series === si && active.index === i}\n label={labels.point(s.name, d.x, d.y)}\n />\n ) : null,\n )}\n </g>\n );\n })}\n </>\n )}\n </Frame>\n );\n}\n\nexport function AreaChart(props: ChartProps) {\n // The line chart already renders a flat low-opacity area; alias for intent / naming.\n return <LineChart {...props} />;\n}\n\nexport function BarChart({\n data,\n series,\n colors = DEFAULT_CHART_COLORS,\n height = 160,\n width = '100%',\n caption,\n 'aria-label': ariaLabel,\n title,\n grid = true,\n showAxis = true,\n tableFallback = true,\n showTableToggle,\n state,\n labels: labelsProp,\n className,\n}: ChartProps) {\n const t = useStrings().chart;\n const labels = { ...chartLabelsFromStrings(t), ...labelsProp };\n const all = resolveSeries(data, series);\n const longest = Math.max(...all.map((s) => s.data.length));\n const { min, range, ticks } = domain(all);\n const primary = all[0].data;\n\n return (\n <Frame\n caption={caption}\n ariaLabel={ariaLabel}\n title={title}\n all={all}\n height={height}\n width={width}\n className={className}\n showAxis={showAxis}\n ticks={ticks}\n xFirst={primary[0]}\n xLast={primary[primary.length - 1]}\n tableFallback={tableFallback}\n showTableToggle={showTableToggle}\n state={state}\n labels={labels}\n >\n {({ width: w, active, seriesProps }) => {\n const innerW = w - PAD * 2;\n const slot = innerW / Math.max(1, longest);\n const groupW = slot * 0.62;\n const barW = Math.max(2, groupW / all.length);\n const { sy } = scales(longest, w, height, min, range);\n // Bars grow from the zero line, so negatives hang below it.\n const zeroY = sy(Math.min(Math.max(0, min), min + range));\n return (\n <>\n {grid && <Grid width={w} height={height} lines={ticks.length - 1} />}\n {min < 0 && (\n <line\n aria-hidden\n x1={0}\n x2={w}\n y1={zeroY}\n y2={zeroY}\n stroke=\"var(--color-border-strong)\"\n strokeWidth={1}\n />\n )}\n {all.map((s, si) => (\n <g key={si} {...seriesProps(si)}>\n {s.data.map((d, i) => {\n if (!isNum(d.y)) return null;\n const yv = sy(d.y);\n const x = PAD + i * slot + (slot - groupW) / 2 + si * barW;\n const label = labels.point(s.name, d.x, d.y);\n const isActive = active?.series === si && active.index === i;\n return (\n <rect\n key={i}\n x={x}\n y={Math.min(zeroY, yv)}\n width={barW}\n height={Math.abs(zeroY - yv)}\n fill={colors[si % colors.length]}\n rx={2}\n data-active={isActive || undefined}\n className=\"transition-opacity hover:opacity-80\"\n >\n <title>{label}</title>\n </rect>\n );\n })}\n </g>\n ))}\n </>\n );\n }}\n </Frame>\n );\n}\n"],"mappings":";;;;;;;;AA0DA,IAAa,IAAkC;CAC7C,UAAU,EAAE,SAAM,UAAO,QAAK,QAAK,UAAO,eACxC,GAAG,EAAK,IAAI,EAAM,eAAe,EAAI,QAAQ,EAAI,SAAS,EAAM,IAAI;CACtE,QAAQ,GAAM,GAAG,MAAM,GAAG,IAAO,GAAG,EAAK,OAAO,KAAK,EAAE,IAAI;CAC3D,SAAS,GAAM,MAAU,GAAG,EAAK,IAAI,EAAM;AAC7C;AAEA,SAAS,EAAuB,GAAoC;CAClE,OAAO;EACL,UAAU,EAAE,SAAM,UAAO,QAAK,QAAK,UAAO,eACxC,EAAa,EAAE,SAAS;GAAE;GAAM;GAAO;GAAK;GAAK,GAAG;GAAO,GAAG;EAAM,CAAC;EACvE,QAAQ,GAAM,GAAG,OAAO,IAAO,GAAG,EAAK,OAAO,MAAM,EAAa,EAAE,OAAO;GAAE;GAAG;EAAE,CAAC;EAClF,SAAS,GAAM,MAAU,EAAa,EAAE,WAAW;GAAE;GAAM;EAAM,CAAC;CACpE;AACF;AAqCA,IAAa,IAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF,GAGM,IAAa,KACb,IAAM,GAGN,IAA4B,OAAO,SAAW,MAAc,IAAY;AAG9E,SAAS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AAW,GAAQ,WAAW,KAAM,EAAO,UAAU;MAC3D,OACE,kBAAC,QAAD;OAEK;OACH,GAAG,KAAK,IAAI,GAAO,CAAE;OACrB,OAAO;OACP,QAAQ,KAAK,IAAI,IAAQ,CAAE;OAC3B,MAAM,EAAO,IAAK,EAAO;OACzB,IAAI;OACJ,eAAa,KAAY,KAAA;OACzB,WAAU;OAEV,UAAA,kBAAC,SAAD,EAAA,UAAQ,EAAa,CAAA;MACjB,GAXC,CAWD;KAEV,CAAC;IACA,GAvBK,CAuBL,CACJ;GACD,EAAA,CAAA;EAEN;CACK,CAAA;AAEX"}
@@ -5,7 +5,7 @@ import { forwardRef as i } from "react";
5
5
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
6
  import * as s from "@radix-ui/react-context-menu";
7
7
  //#region src/components/ui/ContextMenu.tsx
8
- var c = s.Root, l = s.Trigger, u = s.Group, d = s.Portal, f = s.Sub, p = s.RadioGroup, m = e("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none", "data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "transition-colors duration-[var(--duration-fast)]"), h = i(function({ className: t, inset: r, children: i, ...c }, l) {
8
+ var c = s.Root, l = s.Trigger, u = s.Group, d = s.Portal, f = s.Sub, p = s.RadioGroup, m = e("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none", "data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "transition-colors duration-[var(--duration-fast)]", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"), h = i(function({ className: t, inset: r, children: i, ...c }, l) {
9
9
  return /* @__PURE__ */ o(s.SubTrigger, {
10
10
  ref: l,
11
11
  className: e(m, "data-[state=open]:bg-background-muted", r && "pl-8", t),
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ui/ContextMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n} from 'react';\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Right-click (or two-finger tap) menu. Visual surface mirrors DropdownMenu\n * for consistency.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild>\n * <div className=\"grid h-32 place-items-center rounded-lg border border-border\">\n * Right-click me\n * </div>\n * </ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem>Open</ContextMenuItem>\n * <ContextMenuSeparator />\n * <ContextMenuItem destructive>Delete</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n *\n * @do Mirror DropdownMenu items for the same surface — users expect the same\n * operations from both.\n * @dont Hide critical actions behind right-click — they must also exist in\n * a visible button or menu.\n */\nexport const ContextMenu = ContextMenuPrimitive.Root;\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\nexport const ContextMenuGroup = ContextMenuPrimitive.Group;\nexport const ContextMenuPortal = ContextMenuPrimitive.Portal;\nexport const ContextMenuSub = ContextMenuPrimitive.Sub;\nexport const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n);\n\nexport const ContextMenuSubTrigger = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }\n>(function ContextMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </ContextMenuPrimitive.SubTrigger>\n );\n});\nContextMenuSubTrigger.displayName = 'ContextMenuSubTrigger';\n\nexport const ContextMenuSubContent = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(function ContextMenuSubContent({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuSubContent.displayName = 'ContextMenuSubContent';\n\nexport const ContextMenuContent = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(function ContextMenuContent({ className, ...props }, ref) {\n return (\n <ContextMenuPortal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n </ContextMenuPortal>\n );\n});\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport const ContextMenuItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function ContextMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuItem.displayName = 'ContextMenuItem';\n\nexport const ContextMenuCheckboxItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(function ContextMenuCheckboxItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n});\nContextMenuCheckboxItem.displayName = 'ContextMenuCheckboxItem';\n\nexport const ContextMenuRadioItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(function ContextMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n});\nContextMenuRadioItem.displayName = 'ContextMenuRadioItem';\n\nexport const ContextMenuLabel = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & { inset?: boolean }\n>(function ContextMenuLabel({ className, inset, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuLabel.displayName = 'ContextMenuLabel';\n\nexport const ContextMenuSeparator = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nContextMenuSeparator.displayName = 'ContextMenuSeparator';\n\nexport function ContextMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nContextMenuShortcut.displayName = 'ContextMenuShortcut';\n"],"mappings":";;;;;;;AAmCA,IAAa,IAAc,EAAqB,MACnC,IAAqB,EAAqB,SAC1C,IAAmB,EAAqB,OACxC,IAAoB,EAAqB,QACzC,IAAiB,EAAqB,KACtC,IAAwB,EAAqB,YAEpD,IAAc,EAClB,2HACA,6EACA,kEACA,mDACF,GAEa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,UAAO,aAAU,GAAG,KAAS,GAAK;CAC9E,OACE,kBAAC,EAAqB,YAAtB;EACO;EACL,WAAW,EACT,GACA,yCACA,KAAS,QACT,CACF;EACA,GAAI;EARN,UAAA,CAUG,GACD,kBAAC,GAAD;GAAc,WAAU;GAAwC,eAAA;EAAa,CAAA,CAC9C;;AAErC,CAAC;AACD,EAAsB,cAAc;AAEpC,IAAa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC7D,OACE,kBAAC,EAAqB,YAAtB;EACO;EACL,W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AC6B;;AAEpC,CAAC;AACD,EAAqB,cAAc;AAEnC,IAAa,IAAmB,EAG9B,SAA0B,EAAE,cAAW,UAAO,GAAG,KAAS,GAAK;CAC/D,OACE,kBAAC,EAAqB,OAAtB;EACO;EACL,WAAW,EACT,0DACA,KAAS,QACT,CACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAiB,cAAc;AAE/B,IAAa,IAAuB,EAGlC,SAA8B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC5D,OACE,kBAAC,EAAqB,WAAtB;EACO;EACL,WAAW,EAAG,6BAA6B,CAAS;EACpD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAqB,cAAc;AAEnC,SAAgB,EAAoB,EAAE,cAAW,GAAG,KAA0C;CAC5F,OACE,kBAAC,QAAD;EACE,WAAW,EAAG,oEAAoE,CAAS;EAC3F,GAAI;CACL,CAAA;AAEL;AACA,EAAoB,cAAc"}
1
+ {"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ui/ContextMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n} from 'react';\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Right-click (or two-finger tap) menu. Visual surface mirrors DropdownMenu\n * for consistency.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild>\n * <div className=\"grid h-32 place-items-center rounded-lg border border-border\">\n * Right-click me\n * </div>\n * </ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem>Open</ContextMenuItem>\n * <ContextMenuSeparator />\n * <ContextMenuItem destructive>Delete</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n *\n * @do Mirror DropdownMenu items for the same surface — users expect the same\n * operations from both.\n * @dont Hide critical actions behind right-click — they must also exist in\n * a visible button or menu.\n */\nexport const ContextMenu = ContextMenuPrimitive.Root;\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\nexport const ContextMenuGroup = ContextMenuPrimitive.Group;\nexport const ContextMenuPortal = ContextMenuPrimitive.Portal;\nexport const ContextMenuSub = ContextMenuPrimitive.Sub;\nexport const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons passed as children default to 16px like Button/Sidebar do;\n // an explicit `size-*` on the svg (e.g. the size-2 radio dot) still wins.\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n);\n\nexport const ContextMenuSubTrigger = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }\n>(function ContextMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </ContextMenuPrimitive.SubTrigger>\n );\n});\nContextMenuSubTrigger.displayName = 'ContextMenuSubTrigger';\n\nexport const ContextMenuSubContent = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(function ContextMenuSubContent({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuSubContent.displayName = 'ContextMenuSubContent';\n\nexport const ContextMenuContent = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(function ContextMenuContent({ className, ...props }, ref) {\n return (\n <ContextMenuPortal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n </ContextMenuPortal>\n );\n});\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport const ContextMenuItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function ContextMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuItem.displayName = 'ContextMenuItem';\n\nexport const ContextMenuCheckboxItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(function ContextMenuCheckboxItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n});\nContextMenuCheckboxItem.displayName = 'ContextMenuCheckboxItem';\n\nexport const ContextMenuRadioItem = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(function ContextMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n});\nContextMenuRadioItem.displayName = 'ContextMenuRadioItem';\n\nexport const ContextMenuLabel = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & { inset?: boolean }\n>(function ContextMenuLabel({ className, inset, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuLabel.displayName = 'ContextMenuLabel';\n\nexport const ContextMenuSeparator = forwardRef<\n ElementRef<typeof ContextMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nContextMenuSeparator.displayName = 'ContextMenuSeparator';\n\nexport function ContextMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nContextMenuShortcut.displayName = 'ContextMenuShortcut';\n"],"mappings":";;;;;;;AAmCA,IAAa,IAAc,EAAqB,MACnC,IAAqB,EAAqB,SAC1C,IAAmB,EAAqB,OACxC,IAAoB,EAAqB,QACzC,IAAiB,EAAqB,KACtC,IAAwB,EAAqB,YAEpD,IAAc,EAClB,2HACA,6EACA,kEACA,qDAGA,mFACF,GAEa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,UAAO,aAAU,GAAG,KAAS,GAAK;CAC9E,OACE,kBAAC,EAAqB,YAAtB;EACO;EACL,WAAW,EACT,GACA,yCACA,KAAS,QACT,CACF;EACA,GAAI;EARN,UAAA,CAUG,GACD,kBAAC,GAAD;GAAc,WAAU;GAAwC,eAAA;EAAa,CAAA,CAC9C;;AAErC,CAAC;AACD,EAAsB,cAAc;AAEpC,IAAa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC7D,OACE,kBAAC,EAAqB,YAAtB;EACO;EACL,WAAW,EACT,sIACA,gEACA,8DACA,gEACA,CACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAsB,cAAc;AAEpC,IAAa,IAAqB,EAGhC,SAA4B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC1D,OACE,kBAAC,GAAD,EAAA,UACE,kBAAC,EAAqB,SAAtB;EACO;EACL,WAAW,EACT,uIACA,gEACA,8DACA,gEACA,CACF;EACA,GAAI;CACL,CAAA,EACgB,CAAA;AAEvB,CAAC;AACD,EAAmB,cAAc;AAEjC,IAAa,IAAkB,EAM7B,SAAyB,EAAE,cAAW,UAAO,gBAAa,GAAG,KAAS,GAAK;CAC3E,OACE,kBAAC,EAAqB,MAAtB;EACO;EACL,WAAW,EACT,GACA,KAAS,QACT,KACE,0FACF,CACF;EACA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D;EACE,WAAW,EAAG,oEAAoE,CAAS;EAC3F,GAAI;CACL,CAAA;AAEL;AACA,EAAoB,cAAc"}
@@ -5,7 +5,7 @@ import { forwardRef as i } from "react";
5
5
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
6
  import * as s from "@radix-ui/react-dropdown-menu";
7
7
  //#region src/components/ui/DropdownMenu.tsx
8
- var c = s.Root, l = s.Trigger, u = s.Group, d = s.Portal, f = s.Sub, p = s.RadioGroup, m = e("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none", "data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "transition-colors duration-[var(--duration-fast)]"), h = i(function({ className: t, inset: r, children: i, ...c }, l) {
8
+ var c = s.Root, l = s.Trigger, u = s.Group, d = s.Portal, f = s.Sub, p = s.RadioGroup, m = e("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none", "data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "transition-colors duration-[var(--duration-fast)]", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"), h = i(function({ className: t, inset: r, children: i, ...c }, l) {
9
9
  return /* @__PURE__ */ o(s.SubTrigger, {
10
10
  ref: l,
11
11
  className: e(m, "data-[state=open]:bg-background-muted", r && "pl-8", t),
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"mappings":";;;;;;;AAiBA,IAAa,IAAe,EAAsB,MACrC,IAAsB,EAAsB,SAC5C,IAAoB,EAAsB,OAC1C,IAAqB,EAAsB,QAC3C,IAAkB,EAAsB,KACxC,IAAyB,EAAsB,YAEtD,IAAc,EAClB,2HACA,6EACA,kEACA,mDACF,GAEa,IAAyB,EAKpC,SAAgC,EAAE,cAAW,UAAO,aAAU,GAAG,KAAS,GAAK;CAC/E,OACE,kBAAC,EAAsB,YAAvB;EACO;EACL,WAAW,EACT,GACA,yCACA,KAAS,QACT,CACF;EACA,GAAI;EAR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S,GAAK;CACvE,OACE,kBAAC,EAAsB,WAAvB;EACO;EACL,WAAW,EAAG,GAAa,QAAQ,CAAS;EAC5C,GAAI;EAHN,UAAA,CAKE,kBAAC,QAAD;GAAM,WAAU;GACd,UAAA,kBAAC,EAAsB,eAAvB,EAAA,UACE,kBAAC,GAAD;IAAQ,WAAU;IAAiC,eAAA;GAAa,CAAA,EAC7B,CAAA;EACjC,CAAA,GACL,CAC8B;;AAErC,CAAC;AACD,EAAsB,cAAc;AAEpC,IAAa,IAAoB,EAK/B,SAA2B,EAAE,cAAW,UAAO,GAAG,KAAS,GAAK;CAChE,OACE,kBAAC,EAAsB,OAAvB;EACO;EACL,WAAW,EACT,0DACA,KAAS,QACT,CACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAkB,cAAc;AAEhC,IAAa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC7D,OACE,kBAAC,EAAsB,WAAvB;EACO;EACL,WAAW,EAAG,6BAA6B,CAAS;EACpD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAsB,cAAc;AAMpC,SAAgB,EAAqB,EAAE,cAAW,GAAG,KAA0C;CAC7F,OACE,kBAAC,QAAD;EACE,WAAW,EAAG,oEAAoE,CAAS;EAC3F,GAAI;CACL,CAAA;AAEL;AACA,EAAqB,cAAc"}
1
+ {"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons passed as children default to 16px like Button/Sidebar do;\n // an explicit `size-*` on the svg (e.g. the size-2 radio dot) still wins.\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"mappings":";;;;;;;AAiBA,IAAa,IAAe,EAAsB,MACrC,IAAsB,EAAsB,SAC5C,IAAoB,EAAsB,OAC1C,IAAqB,EAAsB,QAC3C,IAAkB,EAAsB,KACxC,IAAyB,EAAsB,YAEtD,IAAc,EAClB,2HACA,6EACA,kEACA,qDAGA,mFACF,GAEa,IAAyB,EAKpC,SAAgC,EAAE,cAAW,UAAO,aAAU,GAAG,KAAS,GAAK;CAC/E,OACE,kBAAC,EAAsB,YAAvB;EAC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C,IAAa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,aAAU,GAAG,KAAS,GAAK;CACvE,OACE,kBAAC,EAAsB,WAAvB;EACO;EACL,WAAW,EAAG,GAAa,QAAQ,CAAS;EAC5C,GAAI;EAHN,UAAA,CAKE,kBAAC,QAAD;GAAM,WAAU;GACd,UAAA,kBAAC,EAAsB,eAAvB,EAAA,UACE,kBAAC,GAAD;IAAQ,WAAU;IAAiC,eAAA;GAAa,CAAA,EAC7B,CAAA;EACjC,CAAA,GACL,CAC8B;;AAErC,CAAC;AACD,EAAsB,cAAc;AAEpC,IAAa,IAAoB,EAK/B,SAA2B,EAAE,cAAW,UAAO,GAAG,KAAS,GAAK;CAChE,OACE,kBAAC,EAAsB,OAAvB;EACO;EACL,WAAW,EACT,0DACA,KAAS,QACT,CACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAkB,cAAc;AAEhC,IAAa,IAAwB,EAGnC,SAA+B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC7D,OACE,kBAAC,EAAsB,WAAvB;EACO;EACL,WAAW,EAAG,6BAA6B,CAAS;EACpD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAsB,cAAc;AAMpC,SAAgB,EAAqB,EAAE,cAAW,GAAG,KAA0C;CAC7F,OACE,kBAAC,QAAD;EACE,WAAW,EAAG,oEAAoE,CAAS;EAC3F,GAAI;CACL,CAAA;AAEL;AACA,EAAqB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","names":[],"sources":["../../../src/components/ui/Icon.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense, useMemo, type LazyExoticComponent, type ReactNode } from 'react';\nimport dynamicIconImports from 'lucide-react/dynamicIconImports';\nimport type { LucideIcon, LucideProps } from 'lucide-react';\n\n/** Every lucide icon name, kebab-case — e.g. `calendar`, `chevrons-up-down`. */\nexport type IconName = keyof typeof dynamicIconImports;\n\n/** All available icon names (useful for pickers and docs). */\nexport const iconNames = Object.keys(dynamicIconImports) as IconName[];\n\n// lazy() must return a stable component per name or React remounts (and\n// re-suspends) on every render.\nconst cache = new Map<IconName, LazyExoticComponent<LucideIcon>>();\nconst warned = new Set<string>();\n\nfunction getIcon(name: IconName): LazyExoticComponent<LucideIcon> | null {\n const cached = cache.get(name);\n if (cached) return cached;\n const loader = dynamicIconImports[name];\n if (typeof loader !== 'function') {\n // Unknown name (data-driven input) → render nothing, warn once in dev.\n if (process.env.NODE_ENV !== 'production' && !warned.has(name)) {\n warned.add(name);\n console.warn(\n `[@craftzbay/ui] <Icon name=\"${name}\"> is not a lucide icon; rendering nothing.`,\n );\n }\n return null;\n }\n const created = lazy(loader);\n cache.set(name, created);\n return created;\n}\n\nexport interface IconProps extends Omit<LucideProps, 'ref'> {\n /** Lucide icon name in kebab-case, e.g. `name=\"calendar\"`. Autocompletes. */\n name: IconName;\n /**\n * Shown while the icon chunk loads (first use only — icons are cached).\n * Defaults to an invisible square so layout doesn't shift.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Name-addressed lucide icon. Use when the icon is dynamic (data-driven\n * nav items, user-configurable dashboards) or when importing components for\n * every icon is friction.\n *\n * Each icon is code-split and loaded on first use, so referencing the full\n * lucide set costs nothing up front — `<Icon name=\"rocket\" />` ships only\n * the rocket.\n *\n * @example\n * <Icon name=\"calendar\" className=\"size-4\" />\n * <Icon name=\"chevrons-up-down\" size={16} strokeWidth={1.5} />\n *\n * @do Use `size-4` (16px) inline with text, `size-5` (20px) inside buttons.\n * @dont Reach for this in hot lists with hundreds of distinct icons on first\n * paint — statically imported icons from `Icons` skip the lazy hop.\n */\nexport function Icon({ name, fallback, ...props }: IconProps) {\n const LucideIcon = useMemo(() => getIcon(name), [name]);\n\n const placeholder = fallback ?? (\n <span\n aria-hidden\n className={props.className}\n style={{ display: 'inline-block', width: props.size ?? '1em', height: props.size ?? '1em' }}\n />\n );\n\n if (!LucideIcon) return null;\n\n return (\n <Suspense fallback={placeholder}>\n <LucideIcon {...props} />\n </Suspense>\n );\n}\n"],"mappings":";;;;;AAUA,IAAa,IAAY,OAAO,KAAK,CAAkB,GAIjD,oBAAQ,IAAI,IAA+C,GAC3D,oBAAS,IAAI,IAAY;AAE/B,SAAS,EAAQ,GAAwD;CACvE,IAAM,IAAS,EAAM,IAAI,CAAI;CAC7B,IAAI,GAAQ,OAAO;CACnB,IAAM,IAAS,EAAmB;CAClC,IAAI,OAAO,KAAW,YAQpB,OANA,QAAA,IAAA,aAA6B,gBAAgB,CAAC,EAAO,IAAI,CAAI,MAC3D,EAAO,IAAI,CAAI,GACf,QAAQ,KACN,+BAA+B,EAAK,4CACtC,IAEK;CAET,IAAM,IAAU,EAAK,CAAM;CAE3B,OADA,EAAM,IAAI,GAAM,CAAO,GAChB;AACT;AA6BA,SAAgB,EAAK,EAAE,SAAM,aAAU,GAAG,KAAoB;CAC5D,IAAM,IAAa,QAAc,EAAQ,CAAI,GAAG,CAAC,CAAI,CAAC,GAEhD,IAAc,KAClB,kBAAC,QAAD;EACE,eAAA;EACA,WAAW,EAAM;EACjB,OAAO;GAAE,SAAS;GAAgB,OAAO,EAAM,QAAQ;GAAO,QAAQ,EAAM,QAAQ;EAAM;CAC3F,CAAA;CAKH,OAFK,IAGH,kBAAC,GAAD;EAAU,UAAU;EAClB,UAAA,kBAAC,GAAD,EAAY,GAAI,EAAQ,CAAA;CAChB,CAAA,IALY;AAO1B"}
1
+ {"version":3,"file":"Icon.js","names":[],"sources":["../../../src/components/ui/Icon.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense, useMemo, type LazyExoticComponent, type ReactNode } from 'react';\nimport dynamicIconImports from 'lucide-react/dynamicIconImports';\nimport type { LucideIcon, LucideProps } from 'lucide-react';\n\n/** Every lucide icon name, kebab-case — e.g. `calendar`, `chevrons-up-down`. */\nexport type IconName = keyof typeof dynamicIconImports;\n\n/** All available icon names (useful for pickers and docs). */\nexport const iconNames = Object.keys(dynamicIconImports) as IconName[];\n\n// lazy() must return a stable component per name or React remounts (and\n// re-suspends) on every render.\nconst cache = new Map<IconName, LazyExoticComponent<LucideIcon>>();\nconst warned = new Set<string>();\n\nfunction getIcon(name: IconName): LazyExoticComponent<LucideIcon> | null {\n const cached = cache.get(name);\n if (cached) return cached;\n const loader = dynamicIconImports[name];\n if (typeof loader !== 'function') {\n // Unknown name (data-driven input) → render nothing, warn once in dev.\n if (process.env.NODE_ENV !== 'production' && !warned.has(name)) {\n warned.add(name);\n console.warn(\n `[@craftzbay/ui] <Icon name=\"${name}\"> is not a lucide icon; rendering nothing.`,\n );\n }\n return null;\n }\n const created = lazy(loader);\n cache.set(name, created);\n return created;\n}\n\nexport interface IconProps extends Omit<LucideProps, 'ref'> {\n /** Lucide icon name in kebab-case, e.g. `name=\"calendar\"`. Autocompletes. */\n name: IconName;\n /**\n * Shown while the icon chunk loads (first use only — icons are cached).\n * Defaults to an invisible square so layout doesn't shift.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Name-addressed lucide icon. Use when the icon is dynamic (data-driven\n * nav items, user-configurable dashboards) or when importing components for\n * every icon is friction.\n *\n * Each icon is code-split and loaded on first use, so referencing the full\n * lucide set costs nothing up front — `<Icon name=\"rocket\" />` ships only\n * the rocket.\n *\n * @example\n * <Icon name=\"calendar\" className=\"size-4\" />\n * <Icon name=\"chevrons-up-down\" size={16} strokeWidth={1.5} />\n *\n * @do Use `size-4` (16px) inline with text, `size-5` (20px) inside buttons.\n * @dont Reach for this in hot lists with hundreds of distinct icons on first\n * paint — statically imported icons from `Icons` skip the lazy hop.\n */\nexport function Icon({ name, fallback, ...props }: IconProps) {\n const LucideIcon = useMemo(() => getIcon(name), [name]);\n\n const placeholder = fallback ?? (\n <span\n aria-hidden\n className={props.className}\n style={{ display: 'inline-block', width: props.size ?? '1em', height: props.size ?? '1em' }}\n />\n );\n\n if (!LucideIcon) return null;\n\n return (\n <Suspense fallback={placeholder}>\n {/* `getIcon` returns the same lazy component for a name (module cache),\n so its identity is stable across renders. */}\n {/* eslint-disable-next-line react-hooks/static-components */}\n <LucideIcon {...props} />\n </Suspense>\n );\n}\n"],"mappings":";;;;;AAUA,IAAa,IAAY,OAAO,KAAK,CAAkB,GAIjD,oBAAQ,IAAI,IAA+C,GAC3D,oBAAS,IAAI,IAAY;AAE/B,SAAS,EAAQ,GAAwD;CACvE,IAAM,IAAS,EAAM,IAAI,CAAI;CAC7B,IAAI,GAAQ,OAAO;CACnB,IAAM,IAAS,EAAmB;CAClC,IAAI,OAAO,KAAW,YAQpB,OANA,QAAA,IAAA,aAA6B,gBAAgB,CAAC,EAAO,IAAI,CAAI,MAC3D,EAAO,IAAI,CAAI,GACf,QAAQ,KACN,+BAA+B,EAAK,4CACtC,IAEK;CAET,IAAM,IAAU,EAAK,CAAM;CAE3B,OADA,EAAM,IAAI,GAAM,CAAO,GAChB;AACT;AA6BA,SAAgB,EAAK,EAAE,SAAM,aAAU,GAAG,KAAoB;CAC5D,IAAM,IAAa,QAAc,EAAQ,CAAI,GAAG,CAAC,CAAI,CAAC,GAEhD,IAAc,KAClB,kBAAC,QAAD;EACE,eAAA;EACA,WAAW,EAAM;EACjB,OAAO;GAAE,SAAS;GAAgB,OAAO,EAAM,QAAQ;GAAO,QAAQ,EAAM,QAAQ;EAAM;CAC3F,CAAA;CAKH,OAFK,IAGH,kBAAC,GAAD;EAAU,UAAU;EAIlB,UAAA,kBAAC,GAAD,EAAY,GAAI,EAAQ,CAAA;CAChB,CAAA,IARY;AAU1B"}
@@ -4,13 +4,10 @@ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "re
4
4
  function i(e, n = 300) {
5
5
  let [i, a] = r(e);
6
6
  return t(() => {
7
- if (n <= 0) {
8
- a(e);
9
- return;
10
- }
7
+ if (n <= 0) return;
11
8
  let t = window.setTimeout(() => a(e), n);
12
9
  return () => window.clearTimeout(t);
13
- }, [e, n]), i;
10
+ }, [e, n]), n <= 0 ? e : i;
14
11
  }
15
12
  function a(r, i = 300) {
16
13
  let a = n(r), o = n(null);
@@ -1 +1 @@
1
- {"version":3,"file":"use-debounce.js","names":[],"sources":["../../src/hooks/use-debounce.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Returns `value` after it has stopped changing for `delay` ms. Use for\n * search inputs that drive a query (URL or fetch) without firing per keystroke.\n *\n * @example\n * const [q, setQ] = useState('');\n * const debouncedQ = useDebounce(q); // 300ms\n * useEffect(() => { fetchRows(debouncedQ); }, [debouncedQ]);\n */\nexport function useDebounce<T>(value: T, delay = 300): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n if (delay <= 0) {\n setDebounced(value);\n return;\n }\n const t = window.setTimeout(() => setDebounced(value), delay);\n return () => window.clearTimeout(t);\n }, [value, delay]);\n return debounced;\n}\n\n/**\n * Stable callback that runs `fn` once `delay` ms have passed since the last\n * call. Always invokes the latest `fn`; pending calls are dropped on unmount.\n *\n * @example\n * const save = useDebouncedCallback((draft: string) => api.save(draft), 500);\n * <Textarea onChange={(e) => save(e.target.value)} />\n */\nexport function useDebouncedCallback<A extends unknown[]>(\n fn: (...args: A) => void,\n delay = 300,\n): (...args: A) => void {\n const fnRef = useRef(fn);\n const timer = useRef<number | null>(null);\n useEffect(() => {\n fnRef.current = fn;\n }, [fn]);\n useEffect(\n () => () => {\n if (timer.current !== null) window.clearTimeout(timer.current);\n },\n [],\n );\n return useCallback(\n (...args: A) => {\n if (timer.current !== null) window.clearTimeout(timer.current);\n timer.current = window.setTimeout(() => {\n timer.current = null;\n fnRef.current(...args);\n }, delay);\n },\n [delay],\n );\n}\n"],"mappings":";;;AAaA,SAAgB,EAAe,GAAU,IAAQ,KAAQ;CACvD,IAAM,CAAC,GAAW,KAAgB,EAAS,CAAK;CAShD,OARA,QAAgB;EACd,IAAI,KAAS,GAAG;GACd,EAAa,CAAK;GAClB;EACF;EACA,IAAM,IAAI,OAAO,iBAAiB,EAAa,CAAK,GAAG,CAAK;EAC5D,aAAa,OAAO,aAAa,CAAC;CACpC,GAAG,CAAC,GAAO,CAAK,CAAC,GACV;AACT;AAUA,SAAgB,EACd,GACA,IAAQ,KACc;CACtB,IAAM,IAAQ,EAAO,CAAE,GACjB,IAAQ,EAAsB,IAAI;CAUxC,OATA,QAAgB;EACd,EAAM,UAAU;CAClB,GAAG,CAAC,CAAE,CAAC,GACP,cACc;EACV,AAAI,EAAM,YAAY,QAAM,OAAO,aAAa,EAAM,OAAO;CAC/D,GACA,CAAC,CACH,GACO,GACJ,GAAG,MAAY;EAEd,AADI,EAAM,YAAY,QAAM,OAAO,aAAa,EAAM,OAAO,GAC7D,EAAM,UAAU,OAAO,iBAAiB;GAEtC,AADA,EAAM,UAAU,MAChB,EAAM,QAAQ,GAAG,CAAI;EACvB,GAAG,CAAK;CACV,GACA,CAAC,CAAK,CACR;AACF"}
1
+ {"version":3,"file":"use-debounce.js","names":[],"sources":["../../src/hooks/use-debounce.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Returns `value` after it has stopped changing for `delay` ms. Use for\n * search inputs that drive a query (URL or fetch) without firing per keystroke.\n *\n * @example\n * const [q, setQ] = useState('');\n * const debouncedQ = useDebounce(q); // 300ms\n * useEffect(() => { fetchRows(debouncedQ); }, [debouncedQ]);\n */\nexport function useDebounce<T>(value: T, delay = 300): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n if (delay <= 0) return;\n const t = window.setTimeout(() => setDebounced(value), delay);\n return () => window.clearTimeout(t);\n }, [value, delay]);\n // With no delay the value is the debounced value — derive it instead of\n // writing state from the effect.\n return delay <= 0 ? value : debounced;\n}\n\n/**\n * Stable callback that runs `fn` once `delay` ms have passed since the last\n * call. Always invokes the latest `fn`; pending calls are dropped on unmount.\n *\n * @example\n * const save = useDebouncedCallback((draft: string) => api.save(draft), 500);\n * <Textarea onChange={(e) => save(e.target.value)} />\n */\nexport function useDebouncedCallback<A extends unknown[]>(\n fn: (...args: A) => void,\n delay = 300,\n): (...args: A) => void {\n const fnRef = useRef(fn);\n const timer = useRef<number | null>(null);\n useEffect(() => {\n fnRef.current = fn;\n }, [fn]);\n useEffect(\n () => () => {\n if (timer.current !== null) window.clearTimeout(timer.current);\n },\n [],\n );\n return useCallback(\n (...args: A) => {\n if (timer.current !== null) window.clearTimeout(timer.current);\n timer.current = window.setTimeout(() => {\n timer.current = null;\n fnRef.current(...args);\n }, delay);\n },\n [delay],\n );\n}\n"],"mappings":";;;AAaA,SAAgB,EAAe,GAAU,IAAQ,KAAQ;CACvD,IAAM,CAAC,GAAW,KAAgB,EAAS,CAAK;CAQhD,OAPA,QAAgB;EACd,IAAI,KAAS,GAAG;EAChB,IAAM,IAAI,OAAO,iBAAiB,EAAa,CAAK,GAAG,CAAK;EAC5D,aAAa,OAAO,aAAa,CAAC;CACpC,GAAG,CAAC,GAAO,CAAK,CAAC,GAGV,KAAS,IAAI,IAAQ;AAC9B;AAUA,SAAgB,EACd,GACA,IAAQ,KACc;CACtB,IAAM,IAAQ,EAAO,CAAE,GACjB,IAAQ,EAAsB,IAAI;CAUxC,OATA,QAAgB;EACd,EAAM,UAAU;CAClB,GAAG,CAAC,CAAE,CAAC,GACP,cACc;EACV,AAAI,EAAM,YAAY,QAAM,OAAO,aAAa,EAAM,OAAO;CAC/D,GACA,CAAC,CACH,GACO,GACJ,GAAG,MAAY;EAEd,AADI,EAAM,YAAY,QAAM,OAAO,aAAa,EAAM,OAAO,GAC7D,EAAM,UAAU,OAAO,iBAAiB;GAEtC,AADA,EAAM,UAAU,MAChB,EAAM,QAAQ,GAAG,CAAI;EACvB,GAAG,CAAK;CACV,GACA,CAAC,CAAK,CACR;AACF"}
@@ -2,17 +2,18 @@
2
2
  import { useEffect as e, useRef as t, useState as n } from "react";
3
3
  //#region src/hooks/use-delayed-loading.ts
4
4
  function r(r, { minVisible: i = 500 } = {}) {
5
- let [a, o] = n(r <= 0), s = t(r <= 0 ? Date.now() : null);
5
+ let [a, o] = n(r <= 0), s = t(null);
6
6
  return e(() => {
7
7
  let e = () => {
8
8
  s.current = Date.now(), o(!0);
9
9
  };
10
10
  if (r <= 0) {
11
- s.current ??= Date.now(), o(!0);
12
- return;
11
+ s.current ??= Date.now();
12
+ let t = window.setTimeout(e, 0);
13
+ return () => window.clearTimeout(t);
13
14
  }
14
- let t = s.current === null ? 0 : Math.max(0, i - (Date.now() - s.current)), n = [];
15
- return t > 0 ? n.push(window.setTimeout(() => o(!1), t)) : o(!1), n.push(window.setTimeout(e, t + r)), () => n.forEach((e) => window.clearTimeout(e));
15
+ let t = s.current === null ? 0 : Math.max(0, i - (Date.now() - s.current)), n = [window.setTimeout(() => o(!1), t), window.setTimeout(e, t + r)];
16
+ return () => n.forEach((e) => window.clearTimeout(e));
16
17
  }, [r, i]), a;
17
18
  }
18
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"use-delayed-loading.js","names":[],"sources":["../../src/hooks/use-delayed-loading.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface DelayedLoadingOptions {\n /**\n * Once `true`, the value holds for at least this many ms even if `ms`\n * changes, so a placeholder that did appear never flickers away. Default 500.\n */\n minVisible?: number;\n}\n\n/**\n * Returns `false` until `ms` has elapsed, then `true`. Gate skeletons and\n * spinners behind it so sub-300ms loads never flash a placeholder.\n * `ms <= 0` returns `true` immediately (and synchronously on first render).\n *\n * Once shown, the value stays `true` for `minVisible` ms (default 500). Keep\n * the gated component mounted for that window on the consumer side too —\n * unmounting it early defeats the hold.\n *\n * @example\n * const showSkeleton = useDelayedLoading(300);\n * if (isLoading) return showSkeleton ? <Skeleton /> : null;\n */\nexport function useDelayedLoading(\n ms: number,\n { minVisible = 500 }: DelayedLoadingOptions = {},\n): boolean {\n const [ready, setReady] = useState(ms <= 0);\n const shownAt = useRef<number | null>(ms <= 0 ? Date.now() : null);\n\n useEffect(() => {\n const show = () => {\n shownAt.current = Date.now();\n setReady(true);\n };\n if (ms <= 0) {\n shownAt.current ??= Date.now();\n setReady(true);\n return;\n }\n // Respect the minimum-visible window before hiding again.\n const hold =\n shownAt.current === null ? 0 : Math.max(0, minVisible - (Date.now() - shownAt.current));\n const timers: number[] = [];\n if (hold > 0) {\n timers.push(window.setTimeout(() => setReady(false), hold));\n } else {\n setReady(false);\n }\n timers.push(window.setTimeout(show, hold + ms));\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [ms, minVisible]);\n\n return ready;\n}\n"],"mappings":";;;AAyBA,SAAgB,EACd,GACA,EAAE,gBAAa,QAA+B,CAAC,GACtC;CACT,IAAM,CAAC,GAAO,KAAY,EAAS,KAAM,CAAC,GACpC,IAAU,EAAsB,KAAM,IAAI,KAAK,IAAI,IAAI,IAAI;CAyBjE,OAvBA,QAAgB;EACd,IAAM,UAAa;GAEjB,AADA,EAAQ,UAAU,KAAK,IAAI,GAC3B,EAAS,EAAI;EACf;EACA,IAAI,KAAM,GAAG;GAEX,AADA,EAAQ,YAAY,KAAK,IAAI,GAC7B,EAAS,EAAI;GACb;EACF;EAEA,IAAM,IACJ,EAAQ,YAAY,OAAO,IAAI,KAAK,IAAI,GAAG,KAAc,KAAK,IAAI,IAAI,EAAQ,QAAQ,GAClF,IAAmB,CAAC;EAO1B,OANI,IAAO,IACT,EAAO,KAAK,OAAO,iBAAiB,EAAS,EAAK,GAAG,CAAI,CAAC,IAE1D,EAAS,EAAK,GAEhB,EAAO,KAAK,OAAO,WAAW,GAAM,IAAO,CAAE,CAAC,SACjC,EAAO,SAAS,MAAM,OAAO,aAAa,CAAC,CAAC;CAC3D,GAAG,CAAC,GAAI,CAAU,CAAC,GAEZ;AACT"}
1
+ {"version":3,"file":"use-delayed-loading.js","names":[],"sources":["../../src/hooks/use-delayed-loading.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface DelayedLoadingOptions {\n /**\n * Once `true`, the value holds for at least this many ms even if `ms`\n * changes, so a placeholder that did appear never flickers away. Default 500.\n */\n minVisible?: number;\n}\n\n/**\n * Returns `false` until `ms` has elapsed, then `true`. Gate skeletons and\n * spinners behind it so sub-300ms loads never flash a placeholder.\n * `ms <= 0` returns `true` immediately (and synchronously on first render).\n *\n * Once shown, the value stays `true` for `minVisible` ms (default 500). Keep\n * the gated component mounted for that window on the consumer side too —\n * unmounting it early defeats the hold.\n *\n * @example\n * const showSkeleton = useDelayedLoading(300);\n * if (isLoading) return showSkeleton ? <Skeleton /> : null;\n */\nexport function useDelayedLoading(\n ms: number,\n { minVisible = 500 }: DelayedLoadingOptions = {},\n): boolean {\n const [ready, setReady] = useState(ms <= 0);\n const shownAt = useRef<number | null>(null);\n\n // Every transition runs from a timer (a 0 ms one when it is due now), so the\n // effect itself never writes state synchronously.\n useEffect(() => {\n const show = () => {\n shownAt.current = Date.now();\n setReady(true);\n };\n if (ms <= 0) {\n shownAt.current ??= Date.now();\n const t = window.setTimeout(show, 0);\n return () => window.clearTimeout(t);\n }\n // Respect the minimum-visible window before hiding again.\n const hold =\n shownAt.current === null ? 0 : Math.max(0, minVisible - (Date.now() - shownAt.current));\n const timers = [\n window.setTimeout(() => setReady(false), hold),\n window.setTimeout(show, hold + ms),\n ];\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [ms, minVisible]);\n\n return ready;\n}\n"],"mappings":";;;AAyBA,SAAgB,EACd,GACA,EAAE,gBAAa,QAA+B,CAAC,GACtC;CACT,IAAM,CAAC,GAAO,KAAY,EAAS,KAAM,CAAC,GACpC,IAAU,EAAsB,IAAI;CAwB1C,OApBA,QAAgB;EACd,IAAM,UAAa;GAEjB,AADA,EAAQ,UAAU,KAAK,IAAI,GAC3B,EAAS,EAAI;EACf;EACA,IAAI,KAAM,GAAG;GACX,EAAQ,YAAY,KAAK,IAAI;GAC7B,IAAM,IAAI,OAAO,WAAW,GAAM,CAAC;GACnC,aAAa,OAAO,aAAa,CAAC;EACpC;EAEA,IAAM,IACJ,EAAQ,YAAY,OAAO,IAAI,KAAK,IAAI,GAAG,KAAc,KAAK,IAAI,IAAI,EAAQ,QAAQ,GAClF,IAAS,CACb,OAAO,iBAAiB,EAAS,EAAK,GAAG,CAAI,GAC7C,OAAO,WAAW,GAAM,IAAO,CAAE,CACnC;EACA,aAAa,EAAO,SAAS,MAAM,OAAO,aAAa,CAAC,CAAC;CAC3D,GAAG,CAAC,GAAI,CAAU,CAAC,GAEZ;AACT"}
@@ -6,8 +6,4 @@ export interface ModifierKey {
6
6
  /** Spoken/long form for aria-labels and tooltips: `Cmd` / `Ctrl`. */
7
7
  label: 'Cmd' | 'Ctrl';
8
8
  }
9
- /**
10
- * Platform-correct command modifier for shortcut hints (⌘K vs Ctrl K).
11
- * Defaults to Ctrl until mounted so server output is deterministic.
12
- */
13
9
  export declare function useModifierKey(): ModifierKey;
@@ -1,16 +1,14 @@
1
1
  "use client";
2
- import { useEffect as e, useState as t } from "react";
2
+ import { useSyncExternalStore as e } from "react";
3
3
  //#region src/hooks/use-modifier-key.ts
4
- function n() {
4
+ function t() {
5
5
  if (typeof navigator > "u") return !1;
6
6
  let e = navigator, t = e.userAgentData?.platform ?? e.platform ?? "";
7
7
  return /mac|iphone|ipad|ipod/i.test(t) || /Mac OS X/i.test(e.userAgent ?? "");
8
8
  }
9
+ var n = () => () => {};
9
10
  function r() {
10
- let [r, i] = t(!1);
11
- return e(() => {
12
- i(n());
13
- }, []), r ? {
11
+ return e(n, t, () => !1) ? {
14
12
  symbol: "⌘",
15
13
  label: "Cmd"
16
14
  } : {
@@ -19,6 +17,6 @@ function r() {
19
17
  };
20
18
  }
21
19
  //#endregion
22
- export { n as isApplePlatform, r as useModifierKey };
20
+ export { t as isApplePlatform, r as useModifierKey };
23
21
 
24
22
  //# sourceMappingURL=use-modifier-key.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-modifier-key.js","names":[],"sources":["../../src/hooks/use-modifier-key.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\n/** True on macOS / iOS / iPadOS, where the command modifier is ⌘. */\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') return false;\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const platform = nav.userAgentData?.platform ?? nav.platform ?? '';\n return /mac|iphone|ipad|ipod/i.test(platform) || /Mac OS X/i.test(nav.userAgent ?? '');\n}\n\nexport interface ModifierKey {\n /** Glyph for `<Kbd>`: `⌘` on Apple platforms, `Ctrl` elsewhere. */\n symbol: '⌘' | 'Ctrl';\n /** Spoken/long form for aria-labels and tooltips: `Cmd` / `Ctrl`. */\n label: 'Cmd' | 'Ctrl';\n}\n\n/**\n * Platform-correct command modifier for shortcut hints (⌘K vs Ctrl K).\n * Defaults to Ctrl until mounted so server output is deterministic.\n */\nexport function useModifierKey(): ModifierKey {\n const [apple, setApple] = useState(false);\n useEffect(() => {\n setApple(isApplePlatform());\n }, []);\n return apple ? { symbol: '⌘', label: 'Cmd' } : { symbol: 'Ctrl', label: 'Ctrl' };\n}\n"],"mappings":";;;AAKA,SAAgB,IAA2B;CACzC,IAAI,OAAO,YAAc,KAAa,OAAO;CAC7C,IAAM,IAAM,WACN,IAAW,EAAI,eAAe,YAAY,EAAI,YAAY;CAChE,OAAO,wBAAwB,KAAK,CAAQ,KAAK,YAAY,KAAK,EAAI,aAAa,EAAE;AACvF;AAaA,SAAgB,IAA8B;CAC5C,IAAM,CAAC,GAAO,KAAY,EAAS,EAAK;CAIxC,OAHA,QAAgB;EACd,EAAS,EAAgB,CAAC;CAC5B,GAAG,CAAC,CAAC,GACE,IAAQ;EAAE,QAAQ;EAAK,OAAO;CAAM,IAAI;EAAE,QAAQ;EAAQ,OAAO;CAAO;AACjF"}
1
+ {"version":3,"file":"use-modifier-key.js","names":[],"sources":["../../src/hooks/use-modifier-key.ts"],"sourcesContent":["'use client';\n\nimport { useSyncExternalStore } from 'react';\n\n/** True on macOS / iOS / iPadOS, where the command modifier is ⌘. */\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') return false;\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const platform = nav.userAgentData?.platform ?? nav.platform ?? '';\n return /mac|iphone|ipad|ipod/i.test(platform) || /Mac OS X/i.test(nav.userAgent ?? '');\n}\n\nexport interface ModifierKey {\n /** Glyph for `<Kbd>`: `⌘` on Apple platforms, `Ctrl` elsewhere. */\n symbol: '⌘' | 'Ctrl';\n /** Spoken/long form for aria-labels and tooltips: `Cmd` / `Ctrl`. */\n label: 'Cmd' | 'Ctrl';\n}\n\n/**\n * Platform-correct command modifier for shortcut hints (⌘K vs Ctrl K).\n * Defaults to Ctrl until mounted so server output is deterministic.\n */\nconst subscribe = () => () => {};\n\nexport function useModifierKey(): ModifierKey {\n // Platform never changes, so there is nothing to subscribe to; the store\n // shape just gives a `false` server snapshot and the real value after\n // hydration without a state write in an effect.\n const apple = useSyncExternalStore(subscribe, isApplePlatform, () => false);\n return apple ? { symbol: '⌘', label: 'Cmd' } : { symbol: 'Ctrl', label: 'Ctrl' };\n}\n"],"mappings":";;;AAKA,SAAgB,IAA2B;CACzC,IAAI,OAAO,YAAc,KAAa,OAAO;CAC7C,IAAM,IAAM,WACN,IAAW,EAAI,eAAe,YAAY,EAAI,YAAY;CAChE,OAAO,wBAAwB,KAAK,CAAQ,KAAK,YAAY,KAAK,EAAI,aAAa,EAAE;AACvF;AAaA,IAAM,gBAAwB,CAAC;AAE/B,SAAgB,IAA8B;CAK5C,OADc,EAAqB,GAAW,SAAuB,EAC9D,IAAQ;EAAE,QAAQ;EAAK,OAAO;CAAM,IAAI;EAAE,QAAQ;EAAQ,OAAO;CAAO;AACjF"}
@@ -38,7 +38,7 @@ export declare const FileText: LucideIcon;
38
38
  export declare const Filter: LucideIcon;
39
39
  export declare const Folder: LucideIcon;
40
40
  export declare const FolderOpen: LucideIcon;
41
- export declare const Github: LucideIcon;
41
+ export declare const Code: LucideIcon;
42
42
  export declare const GripVertical: LucideIcon;
43
43
  export declare const Heart: LucideIcon;
44
44
  export declare const HelpCircle: LucideIcon;