@pixerate/editor-react 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/chart/index.ts","../../src/chart/useChartEditor.ts","../../src/chart/styles.ts","../../src/chart/ChartCanvas.tsx","../../src/chart/ChartDataGrid.tsx","../../src/chart/ChartInspector.tsx","../../src/chart/ChartEditor.tsx"],"sourcesContent":["export * from './useChartEditor';\nexport * from './styles';\nexport * from './ChartCanvas';\nexport * from './ChartDataGrid';\nexport * from './ChartInspector';\nexport * from './ChartEditor';\n","import { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n ChartController,\n createChartCommands,\n type ChartActionResult,\n type ChartCommandOptions,\n type ChartControllerOptions,\n type ChartSelection,\n type ChartSpecPatch,\n type ChartState,\n type ChartType,\n} from '@pixerate/editor/chart';\n\n/** A `ChartController` created once for the component's lifetime. */\nexport function useChartController(options: ChartControllerOptions = {}): ChartController {\n const ref = useRef<ChartController | null>(null);\n if (!ref.current) ref.current = new ChartController(options);\n return ref.current;\n}\n\n/** The controller's state (re-renders on every change). */\nexport function useChartState(controller: ChartController): ChartState {\n return useSyncExternalStore(controller.subscribe, controller.getState, controller.getState);\n}\n\nexport interface UseChartEditorResult {\n controller: ChartController;\n state: ChartState;\n spec: ChartState['spec'];\n selection: ChartSelection | null;\n update: (patch: ChartSpecPatch) => ChartActionResult;\n setType: (type: ChartType) => ChartActionResult;\n setValue: (seriesId: string, index: number, value: unknown) => ChartActionResult;\n select: (selection: ChartSelection | null) => void;\n undo: () => void;\n redo: () => void;\n}\n\n/**\n * Subscribes to a chart controller and exposes its state with bound actions. Pass options\n * instead of a controller to create one for the component's lifetime.\n */\nexport function useChartEditor(controllerOrOptions: ChartController | ChartControllerOptions = {}): UseChartEditorResult {\n const own = useRef<ChartController | null>(null);\n let controller: ChartController;\n if (controllerOrOptions instanceof ChartController) controller = controllerOrOptions;\n else {\n if (!own.current) own.current = new ChartController(controllerOrOptions);\n controller = own.current;\n }\n const state = useChartState(controller);\n const actions = useMemo(\n () => ({\n update: (patch: ChartSpecPatch) => controller.update(patch),\n setType: (type: ChartType) => controller.setType(type),\n setValue: (seriesId: string, index: number, value: unknown) => controller.setValue(seriesId, index, value),\n select: (selection: ChartSelection | null) => controller.select(selection),\n undo: () => void controller.undo(),\n redo: () => void controller.redo(),\n }),\n [controller],\n );\n return { controller, state, spec: state.spec, selection: state.selection, ...actions };\n}\n\n/** Anything with `register(specs) → unregister` (a `CommandRegistry`). */\nexport interface ChartCommandTarget {\n register(specs: any): () => void;\n}\n\n/**\n * Registers the controller's palette / agent commands (`chart.describe`, `chart.update`,\n * `chart.setValues`, …) in `registry` while mounted.\n */\nexport function useChartCommands(registry: ChartCommandTarget | null | undefined, controller: ChartController, options: ChartCommandOptions = {}): void {\n const { prefix, group, scope } = options;\n useEffect(() => {\n if (!registry) return;\n return registry.register(createChartCommands(controller, { prefix, group, scope }));\n }, [registry, controller, prefix, group, scope]);\n}\n","// Class names shared by the chart components (the same as the Svelte package's).\nexport const chartInputClass =\n 'h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50';\nexport const chartButtonClass =\n 'inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50';\nexport const chartIconButtonClass =\n 'inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-40';\nexport const chartSegmentClass = (active: boolean) =>\n `inline-flex h-7 flex-1 items-center justify-center rounded px-2 text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary ${\n active ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'\n }`;\nexport const chartLabelClass = 'text-[11px] font-medium text-muted-foreground';\nexport const chartSectionClass = 'space-y-2 border-b border-border pb-3 last:border-b-0';\nexport const chartCellClass =\n 'h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right text-xs tabular-nums text-foreground focus-visible:bg-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary';\n","import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CSS_VARIABLE_CHART_THEME,\n chartClientToScene,\n chartTextBaseline,\n chartTextTransform,\n describeChartSelection,\n handleChartKey,\n layoutChart,\n startChartPointDrag,\n type ChartController,\n type ChartMark,\n type ChartPointDrag,\n type ChartTextMeasure,\n type ChartTheme,\n} from '@pixerate/editor/chart';\nimport { useChartState } from './useChartEditor';\n\nexport interface ChartCanvasProps {\n controller: ChartController;\n /** Scene width; with `responsive` this is only the fallback before the container is measured (default 640). */\n width?: number;\n /** Scene height in pixels (default 400). */\n height?: number;\n /** Follow the container's width (default `true`). */\n responsive?: boolean;\n /** Colours and type (default: shadcn-style CSS variables). */\n theme?: Partial<ChartTheme>;\n /** Click to select, drag bars and points, keyboard editing (default `true`). */\n editable?: boolean;\n /** Text width for layout (default: an estimate). */\n measureText?: ChartTextMeasure;\n emptyMessage?: string;\n className?: string;\n}\n\n/** SVG attributes for one mark (colours go in `style` so CSS variables work). */\nfunction renderMark(mark: ChartMark, fontFamily: string, interactive: boolean): React.ReactNode {\n const common = {\n 'data-role': mark.role,\n 'data-chart-key': mark.target ? mark.key : undefined,\n 'data-selected': mark.selected ? '' : undefined,\n opacity: mark.opacity,\n pointerEvents: mark.role === 'selection' || (!mark.target && mark.role !== 'background') ? ('none' as const) : undefined,\n cursor: interactive && mark.target && mark.role !== 'background' ? 'pointer' : undefined,\n };\n switch (mark.kind) {\n case 'rect':\n return <rect key={mark.key} {...common} x={mark.x} y={mark.y} width={mark.width} height={mark.height} rx={mark.radius} style={{ fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth }} />;\n case 'path':\n return (\n <path\n key={mark.key}\n {...common}\n d={mark.d}\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n strokeDasharray={mark.dash}\n style={{ fill: mark.fill ?? 'none', stroke: mark.stroke, strokeWidth: mark.strokeWidth }}\n />\n );\n case 'circle':\n return <circle key={mark.key} {...common} cx={mark.cx} cy={mark.cy} r={mark.r} style={{ fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth }} />;\n case 'line':\n return <line key={mark.key} {...common} x1={mark.x1} y1={mark.y1} x2={mark.x2} y2={mark.y2} strokeDasharray={mark.dash} style={{ stroke: mark.stroke, strokeWidth: mark.strokeWidth }} />;\n case 'text':\n return (\n <text\n key={mark.key}\n {...common}\n x={mark.x}\n y={mark.y}\n textAnchor={mark.anchor}\n dominantBaseline={chartTextBaseline(mark.baseline)}\n transform={chartTextTransform(mark)}\n style={{ fill: mark.fill, fontSize: mark.size, fontWeight: mark.weight, fontFamily, userSelect: 'none' }}\n >\n {mark.text}\n </text>\n );\n }\n}\n\n/**\n * Draws a chart controller's spec as SVG. Click a mark to select it, drag a bar or point to\n * change its value (one undo step), and with the chart focused use ← → ↑ ↓, Delete and\n * Escape (see `handleChartKey`).\n */\nexport function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className }: ChartCanvasProps) {\n const state = useChartState(controller);\n const wrapper = useRef<HTMLDivElement>(null);\n const svg = useRef<SVGSVGElement>(null);\n const drag = useRef<ChartPointDrag | null>(null);\n const [measured, setMeasured] = useState<number | null>(null);\n\n useEffect(() => {\n const el = wrapper.current;\n if (!responsive || !el || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(([entry]) => {\n const w = Math.round(entry.contentRect.width);\n if (w > 0) setMeasured(w);\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, [responsive]);\n\n const sceneWidth = (responsive && measured) || width;\n const fullTheme = useMemo(() => ({ ...CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);\n const scene = useMemo(\n () => layoutChart(state.spec, { width: sceneWidth, height, theme: fullTheme, selection: editable ? state.selection : null, measureText, emptyMessage }),\n [state.spec, state.selection, sceneWidth, height, fullTheme, editable, measureText, emptyMessage],\n );\n const byKey = useMemo(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);\n\n useEffect(() => () => drag.current?.end(), []);\n\n const scenePoint = (e: React.PointerEvent) => chartClientToScene(scene, svg.current!.getBoundingClientRect(), e.clientX, e.clientY);\n\n const onPointerDown = (e: React.PointerEvent<SVGSVGElement>) => {\n if (!editable || e.button !== 0) return;\n const key = (e.target as Element).closest?.('[data-chart-key]')?.getAttribute('data-chart-key');\n const target = key ? byKey.get(key)?.target : undefined;\n controller.select(target ?? null);\n drag.current = startChartPointDrag(controller, scene, target, scenePoint(e));\n if (drag.current) svg.current?.setPointerCapture?.(e.pointerId);\n };\n const onPointerMove = (e: React.PointerEvent<SVGSVGElement>) => {\n if (drag.current) drag.current.move(scenePoint(e));\n };\n const endDrag = () => {\n drag.current?.end();\n drag.current = null;\n };\n const onKeyDown = (e: React.KeyboardEvent<SVGSVGElement>) => {\n if (editable && handleChartKey(controller, scene, e)) e.preventDefault();\n };\n\n const label = state.spec.title || 'Chart';\n return (\n <div ref={wrapper} className={`w-full ${className ?? ''}`} data-chart-canvas=\"\">\n <svg\n ref={svg}\n width={sceneWidth}\n height={height}\n viewBox={`0 0 ${scene.width} ${scene.height}`}\n role=\"img\"\n aria-label={editable ? `${label}. ${describeChartSelection(controller, state.selection)}` : label}\n tabIndex={editable ? 0 : undefined}\n className=\"block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={onKeyDown}\n >\n {scene.marks.map((m) => renderMark(m, scene.theme.fontFamily, editable))}\n </svg>\n </div>\n );\n}\n","import React, { useEffect, useRef, useState } from 'react';\nimport { chartColorInputValue, chartSeriesColor, formatChartNumber, type ChartController } from '@pixerate/editor/chart';\nimport { useChartState } from './useChartEditor';\nimport { chartButtonClass, chartCellClass, chartIconButtonClass, chartInputClass } from './styles';\n\ntype CommitInputProps = {\n value: string;\n /** Called with the typed text. Return `false` to show the stored value again (a refused edit). */\n onCommit: (value: string) => boolean | void;\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'>;\n\n/** A text box that commits on blur or Enter and resets on Escape. Follows `value` unless the user is typing. */\nexport function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }: CommitInputProps) {\n const [draft, setDraft] = useState(value);\n const typing = useRef(false);\n useEffect(() => {\n if (!typing.current) setDraft(value);\n }, [value]);\n const commit = () => {\n if (!typing.current) return;\n typing.current = false;\n if (draft === value) return;\n if (onCommit(draft) === false) setDraft(value);\n };\n return (\n <input\n {...rest}\n value={draft}\n onChange={(e) => {\n typing.current = true;\n setDraft(e.currentTarget.value);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n commit();\n }}\n onKeyDown={(e) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (e.key === 'Enter') {\n e.preventDefault();\n commit();\n } else if (e.key === 'Escape') {\n typing.current = false;\n setDraft(value);\n }\n }}\n />\n );\n}\n\nexport interface ChartDataGridProps {\n controller: ChartController;\n /** Header of the category column (default \"Category\"). */\n categoryHeader?: string;\n /** Hide the add / delete buttons. */\n readOnly?: boolean;\n className?: string;\n}\n\n/**\n * The chart's data as an editable grid: categories down the side, one column per series\n * (name, colour, show / hide, delete). Cells take numbers as people type them (`1,200`,\n * `12%`, blank for a gap); pasting TSV or CSV fills and grows the grid from the cell.\n */\nexport function ChartDataGrid({ controller, categoryHeader = 'Category', readOnly = false, className }: ChartDataGridProps) {\n const { spec, selection } = useChartState(controller);\n const paste = (row: number, column: number) => (e: React.ClipboardEvent<HTMLInputElement>) => {\n const text = e.clipboardData?.getData('text/plain') ?? '';\n if (!/[\\t\\n]/.test(text.replace(/\\n$/, ''))) return;\n e.preventDefault();\n controller.pasteCells(row, column, text);\n };\n return (\n <div className={`overflow-auto rounded-md border border-border ${className ?? ''}`} data-chart-grid=\"\">\n <table className=\"w-full border-collapse text-xs\">\n <thead className=\"bg-muted/50\">\n <tr>\n <th className=\"border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground\">{categoryHeader}</th>\n {spec.series.map((s, si) => {\n const color = chartSeriesColor(spec, si);\n const selected = selection?.kind === 'series' && selection.seriesId === s.id;\n return (\n <th key={s.id} data-series-id={s.id} className={`border-b border-r border-border px-1 py-1 font-medium ${selected ? 'bg-primary/10' : ''}`}>\n <div className=\"flex items-center gap-1\">\n <input\n type=\"color\"\n aria-label={`${s.name} colour`}\n value={chartColorInputValue(color)}\n disabled={readOnly}\n onPointerDown={() => controller.beginGesture(`color:${s.id}`)}\n onChange={(e) => controller.updateSeries(s.id, { color: e.currentTarget.value })}\n onBlur={() => controller.endGesture()}\n className=\"h-5 w-5 shrink-0 cursor-pointer rounded border-0 bg-transparent p-0\"\n />\n <ChartCommitInput\n value={s.name}\n aria-label=\"Series name\"\n onFocus={() => controller.select({ kind: 'series', seriesId: s.id })}\n onCommit={(name) => void controller.updateSeries(s.id, { name })}\n className={`${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? 'text-muted-foreground line-through' : ''}`}\n />\n {!readOnly && (\n <>\n <button\n type=\"button\"\n className={chartIconButtonClass}\n title={s.hidden ? 'Show series' : 'Hide series'}\n aria-label={s.hidden ? `Show ${s.name}` : `Hide ${s.name}`}\n aria-pressed={!s.hidden}\n data-action=\"toggle-series\"\n onClick={() => controller.toggleSeries(s.id)}\n >\n {s.hidden ? '○' : '●'}\n </button>\n <button type=\"button\" className={chartIconButtonClass} title=\"Delete series\" aria-label={`Delete ${s.name}`} data-action=\"remove-series\" onClick={() => controller.removeSeries(s.id)}>\n ×\n </button>\n </>\n )}\n </div>\n </th>\n );\n })}\n {!readOnly && (\n <th className=\"w-8 border-b border-border px-1\">\n <button type=\"button\" className={chartIconButtonClass} title=\"Add series\" aria-label=\"Add series\" data-action=\"add-series\" onClick={() => controller.addSeries()}>\n +\n </button>\n </th>\n )}\n </tr>\n </thead>\n <tbody>\n {spec.categories.map((category, i) => {\n const rowSelected = selection?.kind === 'category' && selection.index === i;\n return (\n <tr key={i} data-category-index={i} className={rowSelected ? 'bg-primary/10' : undefined}>\n <th className=\"border-b border-r border-border p-0 text-left font-normal\">\n <ChartCommitInput\n value={category}\n aria-label={`Category ${i + 1}`}\n onFocus={() => controller.select({ kind: 'category', index: i })}\n onPaste={paste(i, -1)}\n onCommit={(label) => void controller.renameCategory(i, label)}\n className={`${chartCellClass} text-left`}\n />\n </th>\n {spec.series.map((s) => {\n const value = s.values[i];\n const selected = selection?.kind === 'point' && selection.seriesId === s.id && selection.index === i;\n return (\n <td key={s.id} className={`border-b border-r border-border p-0 ${selected ? 'bg-primary/10' : ''}`}>\n <ChartCommitInput\n value={value === null || value === undefined ? '' : String(value)}\n inputMode=\"decimal\"\n aria-label={`${s.name}, ${category}`}\n title={value === null ? undefined : formatChartNumber(value, spec.yAxis.format)}\n data-cell={`${s.id}:${i}`}\n onFocus={() => controller.select({ kind: 'point', seriesId: s.id, index: i })}\n onPaste={paste(i, spec.series.indexOf(s))}\n onCommit={(text) => controller.setValue(s.id, i, text).ok}\n className={chartCellClass}\n />\n </td>\n );\n })}\n {!readOnly && (\n <td className=\"border-b border-border px-1\">\n <button type=\"button\" className={chartIconButtonClass} title=\"Delete category\" aria-label={`Delete ${category}`} data-action=\"remove-category\" onClick={() => controller.removeCategory(i)}>\n ×\n </button>\n </td>\n )}\n </tr>\n );\n })}\n </tbody>\n </table>\n {!readOnly && (\n <div className=\"p-1\">\n <button type=\"button\" className={`${chartButtonClass} h-6 border-dashed`} data-action=\"add-category\" onClick={() => controller.addCategory()}>\n + Add category\n </button>\n </div>\n )}\n </div>\n );\n}\n","import React, { useId } from 'react';\nimport {\n CHART_CURVES,\n CHART_LEGEND_POSITIONS,\n CHART_NUMBER_STYLES,\n CHART_SERIES_TYPES,\n CHART_STACKINGS,\n CHART_TYPE_LABELS,\n CHART_TYPES,\n chartColorInputValue,\n chartSeriesColor,\n chartSeriesType,\n isCartesianChart,\n type ChartAxis,\n type ChartController,\n type ChartNumberFormat,\n} from '@pixerate/editor/chart';\nimport { useChartState } from './useChartEditor';\nimport { ChartCommitInput } from './ChartDataGrid';\nimport { chartButtonClass, chartInputClass, chartLabelClass, chartSectionClass, chartSegmentClass } from './styles';\n\nexport interface ChartInspectorProps {\n controller: ChartController;\n /** Which sections to show (default: all that apply to the chart). */\n sections?: readonly ChartInspectorSection[];\n className?: string;\n}\n\nexport type ChartInspectorSection = 'type' | 'titles' | 'options' | 'legend' | 'axes' | 'series';\n\nconst cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);\n\nfunction Field({ label, htmlFor, children }: { label: string; htmlFor?: string; children: React.ReactNode }) {\n return (\n <div className=\"flex items-center gap-2\">\n <label htmlFor={htmlFor} className={`${chartLabelClass} w-20 shrink-0`}>\n {label}\n </label>\n <div className=\"min-w-0 flex-1\">{children}</div>\n </div>\n );\n}\n\nfunction Toggle({ label, checked, onChange, name }: { label: string; checked: boolean; onChange: (checked: boolean) => void; name: string }) {\n return (\n <label className=\"flex cursor-pointer items-center gap-2 text-xs text-foreground\">\n <input type=\"checkbox\" className=\"h-3.5 w-3.5 accent-primary\" checked={checked} data-option={name} onChange={(e) => onChange(e.currentTarget.checked)} />\n {label}\n </label>\n );\n}\n\nfunction Select<T extends string>({ id, value, options, onChange, name, labels }: { id?: string; value: T; options: readonly T[]; onChange: (value: T) => void; name: string; labels?: Partial<Record<T, string>> }) {\n return (\n <select id={id} className={chartInputClass} value={value} data-option={name} onChange={(e) => onChange(e.currentTarget.value as T)}>\n {options.map((o) => (\n <option key={o} value={o}>\n {labels?.[o] ?? cap(o)}\n </option>\n ))}\n </select>\n );\n}\n\nfunction AxisSection({ controller, axis, value, idBase, horizontal }: { controller: ChartController; axis: 'x' | 'y'; value: ChartAxis; idBase: string; horizontal: boolean }) {\n const set = (patch: Partial<ChartAxis>) => controller.setAxis(axis, patch);\n const setFormat = (patch: Partial<ChartNumberFormat>) => set({ format: { ...value.format, ...patch } });\n const bound = (key: 'min' | 'max') => (\n <ChartCommitInput\n id={`${idBase}-${axis}-${key}`}\n value={value[key] === null ? '' : String(value[key])}\n placeholder=\"Auto\"\n inputMode=\"decimal\"\n data-option={`${axis}Axis.${key}`}\n className={chartInputClass}\n onCommit={(text) => set({ [key]: text.trim() === '' ? null : Number(text) }).ok}\n />\n );\n const name = axis === 'x' ? 'Category axis' : 'Value axis';\n return (\n <div className={chartSectionClass} data-section={`axis-${axis}`}>\n <div className=\"flex items-center justify-between\">\n <h4 className=\"text-xs font-semibold text-foreground\">\n {name}\n <span className=\"ml-1 font-normal text-muted-foreground\">({axis === 'x' ? (horizontal ? 'left' : 'bottom') : horizontal ? 'bottom' : 'left'})</span>\n </h4>\n <Toggle label=\"Show\" name={`${axis}Axis.show`} checked={value.show} onChange={(show) => set({ show })} />\n </div>\n <Field label=\"Title\" htmlFor={`${idBase}-${axis}-title`}>\n <ChartCommitInput id={`${idBase}-${axis}-title`} value={value.title} data-option={`${axis}Axis.title`} className={chartInputClass} onCommit={(title) => void set({ title })} />\n </Field>\n <Toggle label=\"Grid lines\" name={`${axis}Axis.gridlines`} checked={value.gridlines} onChange={(gridlines) => set({ gridlines })} />\n {axis === 'y' && (\n <>\n <Field label=\"Min / max\">\n <div className=\"flex gap-1\">\n {bound('min')}\n {bound('max')}\n </div>\n </Field>\n <Field label=\"Format\" htmlFor={`${idBase}-y-format`}>\n <div className=\"flex gap-1\">\n <Select id={`${idBase}-y-format`} name=\"yAxis.format.style\" value={value.format.style ?? 'number'} options={CHART_NUMBER_STYLES} onChange={(style) => setFormat({ style })} />\n <ChartCommitInput\n value={value.format.decimals === undefined ? '' : String(value.format.decimals)}\n placeholder=\"Auto\"\n aria-label=\"Decimals\"\n title=\"Decimals\"\n inputMode=\"numeric\"\n data-option=\"yAxis.format.decimals\"\n className={`${chartInputClass} w-14 shrink-0`}\n onCommit={(text) => {\n const format = { ...value.format };\n if (text.trim() === '') delete format.decimals;\n else format.decimals = Number(text);\n return set({ format }).ok;\n }}\n />\n </div>\n </Field>\n {value.format.style === 'currency' && (\n <Field label=\"Currency\" htmlFor={`${idBase}-y-currency`}>\n <ChartCommitInput id={`${idBase}-y-currency`} value={value.format.currency ?? 'USD'} data-option=\"yAxis.format.currency\" className={chartInputClass} onCommit={(currency) => void setFormat({ currency: currency.toUpperCase() })} />\n </Field>\n )}\n </>\n )}\n </div>\n );\n}\n\n/**\n * Settings for a chart controller: type, titles, stacking and line options, legend, both\n * axes and the selected series. Every change is one undo step.\n */\nexport function ChartInspector({ controller, sections, className }: ChartInspectorProps) {\n const { spec, selectedSeries } = useChartState(controller);\n const idBase = useId();\n const show = (section: ChartInspectorSection) => !sections || sections.includes(section);\n const cartesian = isCartesianChart(spec.type);\n const types = spec.series.map((s) => chartSeriesType(spec, s));\n const hasBars = cartesian && types.includes('bar');\n const hasLines = cartesian && types.some((t) => t === 'line' || t === 'area');\n const seriesIndex = selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1;\n\n return (\n <div className={`space-y-3 text-xs ${className ?? ''}`} data-chart-inspector=\"\">\n {show('type') && (\n <div className={chartSectionClass} data-section=\"type\">\n <div className=\"grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5\" role=\"radiogroup\" aria-label=\"Chart type\">\n {CHART_TYPES.map((type) => (\n <button key={type} type=\"button\" role=\"radio\" aria-checked={spec.type === type} data-chart-type={type} className={chartSegmentClass(spec.type === type)} onClick={() => controller.setType(type)}>\n {CHART_TYPE_LABELS[type]}\n </button>\n ))}\n </div>\n </div>\n )}\n\n {show('titles') && (\n <div className={chartSectionClass} data-section=\"titles\">\n <Field label=\"Title\" htmlFor={`${idBase}-title`}>\n <ChartCommitInput id={`${idBase}-title`} value={spec.title} data-option=\"title\" className={chartInputClass} onCommit={(title) => void controller.setTitle(title)} />\n </Field>\n <Field label=\"Subtitle\" htmlFor={`${idBase}-subtitle`}>\n <ChartCommitInput id={`${idBase}-subtitle`} value={spec.subtitle} data-option=\"subtitle\" className={chartInputClass} onCommit={(subtitle) => void controller.setSubtitle(subtitle)} />\n </Field>\n </div>\n )}\n\n {show('options') && (\n <div className={chartSectionClass} data-section=\"options\">\n {cartesian && (\n <Field label=\"Stacking\" htmlFor={`${idBase}-stacking`}>\n <Select id={`${idBase}-stacking`} name=\"stacking\" value={spec.stacking} options={CHART_STACKINGS} labels={{ none: 'None', stacked: 'Stacked', percent: '100%' }} onChange={(stacking) => controller.update({ stacking })} />\n </Field>\n )}\n {hasBars && (\n <Field label=\"Bars\">\n <div className=\"flex gap-0.5 rounded-md bg-muted p-0.5\">\n {(['vertical', 'horizontal'] as const).map((o) => (\n <button key={o} type=\"button\" aria-pressed={spec.orientation === o} data-option={`orientation.${o}`} className={chartSegmentClass(spec.orientation === o)} onClick={() => controller.update({ orientation: o })}>\n {cap(o)}\n </button>\n ))}\n </div>\n </Field>\n )}\n {hasLines && (\n <Field label=\"Lines\" htmlFor={`${idBase}-curve`}>\n <Select id={`${idBase}-curve`} name=\"curve\" value={spec.curve} options={CHART_CURVES} onChange={(curve) => controller.update({ curve })} />\n </Field>\n )}\n {spec.type === 'donut' && (\n <Field label=\"Hole\" htmlFor={`${idBase}-hole`}>\n <input\n id={`${idBase}-hole`}\n type=\"range\"\n min={0}\n max={0.9}\n step={0.05}\n value={spec.innerRadius}\n data-option=\"innerRadius\"\n className=\"w-full accent-primary\"\n onPointerDown={() => controller.beginGesture('innerRadius')}\n onPointerUp={() => controller.endGesture()}\n onChange={(e) => controller.update({ innerRadius: Number(e.currentTarget.value) })}\n />\n </Field>\n )}\n <div className=\"flex flex-wrap gap-x-4 gap-y-1\">\n {hasLines && <Toggle label=\"Points\" name=\"points\" checked={spec.points} onChange={(points) => controller.update({ points })} />}\n <Toggle label=\"Data labels\" name=\"dataLabels\" checked={spec.dataLabels} onChange={(dataLabels) => controller.update({ dataLabels })} />\n </div>\n </div>\n )}\n\n {show('legend') && (\n <div className={chartSectionClass} data-section=\"legend\">\n <div className=\"flex items-center justify-between\">\n <h4 className=\"text-xs font-semibold text-foreground\">Legend</h4>\n <Toggle label=\"Show\" name=\"legend.show\" checked={spec.legend.show} onChange={(v) => controller.setLegend({ show: v })} />\n </div>\n {spec.legend.show && (\n <div className=\"flex gap-0.5 rounded-md bg-muted p-0.5\">\n {CHART_LEGEND_POSITIONS.map((p) => (\n <button key={p} type=\"button\" aria-pressed={spec.legend.position === p} data-option={`legend.${p}`} className={chartSegmentClass(spec.legend.position === p)} onClick={() => controller.setLegend({ position: p })}>\n {cap(p)}\n </button>\n ))}\n </div>\n )}\n </div>\n )}\n\n {show('axes') && cartesian && (\n <>\n <AxisSection controller={controller} axis=\"x\" value={spec.xAxis} idBase={idBase} horizontal={spec.orientation === 'horizontal'} />\n <AxisSection controller={controller} axis=\"y\" value={spec.yAxis} idBase={idBase} horizontal={spec.orientation === 'horizontal'} />\n </>\n )}\n\n {show('series') && selectedSeries && (\n <div className={chartSectionClass} data-section=\"series\" data-series-id={selectedSeries.id}>\n <h4 className=\"text-xs font-semibold text-foreground\">Series</h4>\n <Field label=\"Name\" htmlFor={`${idBase}-series-name`}>\n <ChartCommitInput id={`${idBase}-series-name`} value={selectedSeries.name} data-option=\"series.name\" className={chartInputClass} onCommit={(name) => void controller.updateSeries(selectedSeries.id, { name })} />\n </Field>\n <Field label=\"Colour\" htmlFor={`${idBase}-series-color`}>\n <div className=\"flex items-center gap-1\">\n <input\n id={`${idBase}-series-color`}\n type=\"color\"\n value={chartColorInputValue(chartSeriesColor(spec, seriesIndex))}\n data-option=\"series.color\"\n className=\"h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5\"\n onPointerDown={() => controller.beginGesture(`color:${selectedSeries.id}`)}\n onBlur={() => controller.endGesture()}\n onChange={(e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })}\n />\n {selectedSeries.color && (\n <button type=\"button\" className={chartButtonClass} data-action=\"reset-color\" onClick={() => controller.updateSeries(selectedSeries.id, { color: null })}>\n Palette\n </button>\n )}\n </div>\n </Field>\n {cartesian && (\n <Field label=\"Draw as\" htmlFor={`${idBase}-series-type`}>\n <select\n id={`${idBase}-series-type`}\n className={chartInputClass}\n value={selectedSeries.type ?? ''}\n data-option=\"series.type\"\n onChange={(e) => controller.updateSeries(selectedSeries.id, { type: (e.currentTarget.value || null) as any })}\n >\n <option value=\"\">Chart type</option>\n {CHART_SERIES_TYPES.map((t) => (\n <option key={t} value={t}>\n {CHART_TYPE_LABELS[t]}\n </option>\n ))}\n </select>\n </Field>\n )}\n <div className=\"flex flex-wrap items-center gap-1\">\n <Toggle label=\"Hidden\" name=\"series.hidden\" checked={!!selectedSeries.hidden} onChange={(hidden) => controller.updateSeries(selectedSeries.id, { hidden })} />\n <span className=\"flex-1\" />\n <button type=\"button\" className={chartButtonClass} disabled={seriesIndex <= 0} aria-label=\"Move series earlier\" data-action=\"series-up\" onClick={() => controller.moveSeries(selectedSeries.id, seriesIndex - 1)}>\n ↑\n </button>\n <button type=\"button\" className={chartButtonClass} disabled={seriesIndex >= spec.series.length - 1} aria-label=\"Move series later\" data-action=\"series-down\" onClick={() => controller.moveSeries(selectedSeries.id, seriesIndex + 1)}>\n ↓\n </button>\n <button type=\"button\" className={`${chartButtonClass} text-destructive`} data-action=\"series-delete\" onClick={() => controller.removeSeries(selectedSeries.id)}>\n Delete\n </button>\n </div>\n </div>\n )}\n </div>\n );\n}\n","import React from 'react';\nimport { describeChartSelection, type ChartController } from '@pixerate/editor/chart';\nimport { ChartCanvas, type ChartCanvasProps } from './ChartCanvas';\nimport { ChartDataGrid } from './ChartDataGrid';\nimport { ChartInspector } from './ChartInspector';\nimport { useChartState } from './useChartEditor';\nimport { chartButtonClass } from './styles';\n\nexport interface ChartEditorProps {\n controller: ChartController;\n /** The settings sidebar (default `true`). */\n showInspector?: boolean;\n /** The data grid under the chart (default `true`). */\n showDataGrid?: boolean;\n /** Undo / redo and the selection readout (default `true`). */\n showToolbar?: boolean;\n /** Chart height in pixels (default 380). */\n height?: number;\n canvasProps?: Omit<ChartCanvasProps, 'controller' | 'height'>;\n className?: string;\n}\n\n/** Toolbar, chart, settings sidebar and data grid for a `ChartController`. */\nexport function ChartEditor({ controller, showInspector = true, showDataGrid = true, showToolbar = true, height = 380, canvasProps, className }: ChartEditorProps) {\n const state = useChartState(controller);\n return (\n <div className={`flex flex-col gap-2 ${className ?? ''}`} data-chart-editor=\"\">\n {showToolbar && (\n <div className=\"flex items-center gap-1\" data-chart-toolbar=\"\">\n <button type=\"button\" className={chartButtonClass} disabled={!state.canUndo} title={state.undoLabel ? `Undo ${state.undoLabel}` : 'Undo'} data-action=\"undo\" onClick={() => controller.undo()}>\n Undo\n </button>\n <button type=\"button\" className={chartButtonClass} disabled={!state.canRedo} title={state.redoLabel ? `Redo ${state.redoLabel}` : 'Redo'} data-action=\"redo\" onClick={() => controller.redo()}>\n Redo\n </button>\n <span className=\"ml-2 truncate text-xs text-muted-foreground\" data-chart-selection=\"\" aria-live=\"polite\">\n {describeChartSelection(controller, state.selection)}\n </span>\n </div>\n )}\n {state.issues.length > 0 && (\n <p role=\"alert\" className=\"rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive\" data-chart-issues=\"\">\n {state.issues.map((i) => i.message).join(' ')}\n </p>\n )}\n <div className=\"flex min-h-0 flex-col gap-2 md:flex-row\">\n <div className=\"min-w-0 flex-1 rounded-md border border-border bg-background p-1\">\n <ChartCanvas controller={controller} height={height} {...canvasProps} />\n </div>\n {showInspector && <ChartInspector controller={controller} className=\"w-full shrink-0 overflow-y-auto rounded-md border border-border p-3 md:w-64\" />}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,QAAO,SAAS,MAAM,WAAW,KAAK,GAAG,kBAE/L;AAAA,MACA,6CAAC,UAAK,WAAU,+CAA8C,wBAAqB,IAAG,aAAU,UAC7F,oDAAuB,YAAY,MAAM,SAAS,GACrD;AAAA,OACF;AAAA,IAED,MAAM,OAAO,SAAS,KACrB,6CAAC,OAAE,MAAK,SAAQ,WAAU,gGAA+F,qBAAkB,IACxI,gBAAM,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,GAC9C;AAAA,IAEF,8CAAC,SAAI,WAAU,2CACb;AAAA,mDAAC,SAAI,WAAU,oEACb,uDAAC,eAAY,YAAwB,QAAiB,GAAG,aAAa,GACxE;AAAA,MACC,iBAAiB,6CAAC,kBAAe,YAAwB,WAAU,+EAA8E;AAAA,OACpJ;AAAA,IACC,gBAAgB,6CAAC,iBAAc,YAAwB;AAAA,KAC1D;AAEJ;","names":["import_react","import_chart","import_react","import_chart","import_jsx_runtime","import_react","import_chart","import_jsx_runtime","import_chart","import_jsx_runtime"]}
@@ -0,0 +1,118 @@
1
+ import { ChartController, ChartState, ChartSelection, ChartSpecPatch, ChartActionResult, ChartType, ChartCommandOptions, ChartControllerOptions, ChartTheme, ChartTextMeasure } from '@pixerate/editor/chart';
2
+ import React__default from 'react';
3
+
4
+ /** A `ChartController` created once for the component's lifetime. */
5
+ declare function useChartController(options?: ChartControllerOptions): ChartController;
6
+ /** The controller's state (re-renders on every change). */
7
+ declare function useChartState(controller: ChartController): ChartState;
8
+ interface UseChartEditorResult {
9
+ controller: ChartController;
10
+ state: ChartState;
11
+ spec: ChartState['spec'];
12
+ selection: ChartSelection | null;
13
+ update: (patch: ChartSpecPatch) => ChartActionResult;
14
+ setType: (type: ChartType) => ChartActionResult;
15
+ setValue: (seriesId: string, index: number, value: unknown) => ChartActionResult;
16
+ select: (selection: ChartSelection | null) => void;
17
+ undo: () => void;
18
+ redo: () => void;
19
+ }
20
+ /**
21
+ * Subscribes to a chart controller and exposes its state with bound actions. Pass options
22
+ * instead of a controller to create one for the component's lifetime.
23
+ */
24
+ declare function useChartEditor(controllerOrOptions?: ChartController | ChartControllerOptions): UseChartEditorResult;
25
+ /** Anything with `register(specs) → unregister` (a `CommandRegistry`). */
26
+ interface ChartCommandTarget {
27
+ register(specs: any): () => void;
28
+ }
29
+ /**
30
+ * Registers the controller's palette / agent commands (`chart.describe`, `chart.update`,
31
+ * `chart.setValues`, …) in `registry` while mounted.
32
+ */
33
+ declare function useChartCommands(registry: ChartCommandTarget | null | undefined, controller: ChartController, options?: ChartCommandOptions): void;
34
+
35
+ declare const chartInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
36
+ declare const chartButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
37
+ declare const chartIconButtonClass = "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-40";
38
+ declare const chartSegmentClass: (active: boolean) => string;
39
+ declare const chartLabelClass = "text-[11px] font-medium text-muted-foreground";
40
+ declare const chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
41
+ declare const chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right text-xs tabular-nums text-foreground focus-visible:bg-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary";
42
+
43
+ interface ChartCanvasProps {
44
+ controller: ChartController;
45
+ /** Scene width; with `responsive` this is only the fallback before the container is measured (default 640). */
46
+ width?: number;
47
+ /** Scene height in pixels (default 400). */
48
+ height?: number;
49
+ /** Follow the container's width (default `true`). */
50
+ responsive?: boolean;
51
+ /** Colours and type (default: shadcn-style CSS variables). */
52
+ theme?: Partial<ChartTheme>;
53
+ /** Click to select, drag bars and points, keyboard editing (default `true`). */
54
+ editable?: boolean;
55
+ /** Text width for layout (default: an estimate). */
56
+ measureText?: ChartTextMeasure;
57
+ emptyMessage?: string;
58
+ className?: string;
59
+ }
60
+ /**
61
+ * Draws a chart controller's spec as SVG. Click a mark to select it, drag a bar or point to
62
+ * change its value (one undo step), and with the chart focused use ← → ↑ ↓, Delete and
63
+ * Escape (see `handleChartKey`).
64
+ */
65
+ declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className }: ChartCanvasProps): React__default.JSX.Element;
66
+
67
+ type CommitInputProps = {
68
+ value: string;
69
+ /** Called with the typed text. Return `false` to show the stored value again (a refused edit). */
70
+ onCommit: (value: string) => boolean | void;
71
+ } & Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'>;
72
+ /** A text box that commits on blur or Enter and resets on Escape. Follows `value` unless the user is typing. */
73
+ declare function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }: CommitInputProps): React__default.JSX.Element;
74
+ interface ChartDataGridProps {
75
+ controller: ChartController;
76
+ /** Header of the category column (default "Category"). */
77
+ categoryHeader?: string;
78
+ /** Hide the add / delete buttons. */
79
+ readOnly?: boolean;
80
+ className?: string;
81
+ }
82
+ /**
83
+ * The chart's data as an editable grid: categories down the side, one column per series
84
+ * (name, colour, show / hide, delete). Cells take numbers as people type them (`1,200`,
85
+ * `12%`, blank for a gap); pasting TSV or CSV fills and grows the grid from the cell.
86
+ */
87
+ declare function ChartDataGrid({ controller, categoryHeader, readOnly, className }: ChartDataGridProps): React__default.JSX.Element;
88
+
89
+ interface ChartInspectorProps {
90
+ controller: ChartController;
91
+ /** Which sections to show (default: all that apply to the chart). */
92
+ sections?: readonly ChartInspectorSection[];
93
+ className?: string;
94
+ }
95
+ type ChartInspectorSection = 'type' | 'titles' | 'options' | 'legend' | 'axes' | 'series';
96
+ /**
97
+ * Settings for a chart controller: type, titles, stacking and line options, legend, both
98
+ * axes and the selected series. Every change is one undo step.
99
+ */
100
+ declare function ChartInspector({ controller, sections, className }: ChartInspectorProps): React__default.JSX.Element;
101
+
102
+ interface ChartEditorProps {
103
+ controller: ChartController;
104
+ /** The settings sidebar (default `true`). */
105
+ showInspector?: boolean;
106
+ /** The data grid under the chart (default `true`). */
107
+ showDataGrid?: boolean;
108
+ /** Undo / redo and the selection readout (default `true`). */
109
+ showToolbar?: boolean;
110
+ /** Chart height in pixels (default 380). */
111
+ height?: number;
112
+ canvasProps?: Omit<ChartCanvasProps, 'controller' | 'height'>;
113
+ className?: string;
114
+ }
115
+ /** Toolbar, chart, settings sidebar and data grid for a `ChartController`. */
116
+ declare function ChartEditor({ controller, showInspector, showDataGrid, showToolbar, height, canvasProps, className }: ChartEditorProps): React__default.JSX.Element;
117
+
118
+ export { ChartCanvas, type ChartCanvasProps, type ChartCommandTarget, ChartCommitInput, ChartDataGrid, type ChartDataGridProps, ChartEditor, type ChartEditorProps, ChartInspector, type ChartInspectorProps, type ChartInspectorSection, type UseChartEditorResult, chartButtonClass, chartCellClass, chartIconButtonClass, chartInputClass, chartLabelClass, chartSectionClass, chartSegmentClass, useChartCommands, useChartController, useChartEditor, useChartState };
@@ -0,0 +1,118 @@
1
+ import { ChartController, ChartState, ChartSelection, ChartSpecPatch, ChartActionResult, ChartType, ChartCommandOptions, ChartControllerOptions, ChartTheme, ChartTextMeasure } from '@pixerate/editor/chart';
2
+ import React__default from 'react';
3
+
4
+ /** A `ChartController` created once for the component's lifetime. */
5
+ declare function useChartController(options?: ChartControllerOptions): ChartController;
6
+ /** The controller's state (re-renders on every change). */
7
+ declare function useChartState(controller: ChartController): ChartState;
8
+ interface UseChartEditorResult {
9
+ controller: ChartController;
10
+ state: ChartState;
11
+ spec: ChartState['spec'];
12
+ selection: ChartSelection | null;
13
+ update: (patch: ChartSpecPatch) => ChartActionResult;
14
+ setType: (type: ChartType) => ChartActionResult;
15
+ setValue: (seriesId: string, index: number, value: unknown) => ChartActionResult;
16
+ select: (selection: ChartSelection | null) => void;
17
+ undo: () => void;
18
+ redo: () => void;
19
+ }
20
+ /**
21
+ * Subscribes to a chart controller and exposes its state with bound actions. Pass options
22
+ * instead of a controller to create one for the component's lifetime.
23
+ */
24
+ declare function useChartEditor(controllerOrOptions?: ChartController | ChartControllerOptions): UseChartEditorResult;
25
+ /** Anything with `register(specs) → unregister` (a `CommandRegistry`). */
26
+ interface ChartCommandTarget {
27
+ register(specs: any): () => void;
28
+ }
29
+ /**
30
+ * Registers the controller's palette / agent commands (`chart.describe`, `chart.update`,
31
+ * `chart.setValues`, …) in `registry` while mounted.
32
+ */
33
+ declare function useChartCommands(registry: ChartCommandTarget | null | undefined, controller: ChartController, options?: ChartCommandOptions): void;
34
+
35
+ declare const chartInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
36
+ declare const chartButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
37
+ declare const chartIconButtonClass = "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-40";
38
+ declare const chartSegmentClass: (active: boolean) => string;
39
+ declare const chartLabelClass = "text-[11px] font-medium text-muted-foreground";
40
+ declare const chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
41
+ declare const chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right text-xs tabular-nums text-foreground focus-visible:bg-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary";
42
+
43
+ interface ChartCanvasProps {
44
+ controller: ChartController;
45
+ /** Scene width; with `responsive` this is only the fallback before the container is measured (default 640). */
46
+ width?: number;
47
+ /** Scene height in pixels (default 400). */
48
+ height?: number;
49
+ /** Follow the container's width (default `true`). */
50
+ responsive?: boolean;
51
+ /** Colours and type (default: shadcn-style CSS variables). */
52
+ theme?: Partial<ChartTheme>;
53
+ /** Click to select, drag bars and points, keyboard editing (default `true`). */
54
+ editable?: boolean;
55
+ /** Text width for layout (default: an estimate). */
56
+ measureText?: ChartTextMeasure;
57
+ emptyMessage?: string;
58
+ className?: string;
59
+ }
60
+ /**
61
+ * Draws a chart controller's spec as SVG. Click a mark to select it, drag a bar or point to
62
+ * change its value (one undo step), and with the chart focused use ← → ↑ ↓, Delete and
63
+ * Escape (see `handleChartKey`).
64
+ */
65
+ declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className }: ChartCanvasProps): React__default.JSX.Element;
66
+
67
+ type CommitInputProps = {
68
+ value: string;
69
+ /** Called with the typed text. Return `false` to show the stored value again (a refused edit). */
70
+ onCommit: (value: string) => boolean | void;
71
+ } & Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'>;
72
+ /** A text box that commits on blur or Enter and resets on Escape. Follows `value` unless the user is typing. */
73
+ declare function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }: CommitInputProps): React__default.JSX.Element;
74
+ interface ChartDataGridProps {
75
+ controller: ChartController;
76
+ /** Header of the category column (default "Category"). */
77
+ categoryHeader?: string;
78
+ /** Hide the add / delete buttons. */
79
+ readOnly?: boolean;
80
+ className?: string;
81
+ }
82
+ /**
83
+ * The chart's data as an editable grid: categories down the side, one column per series
84
+ * (name, colour, show / hide, delete). Cells take numbers as people type them (`1,200`,
85
+ * `12%`, blank for a gap); pasting TSV or CSV fills and grows the grid from the cell.
86
+ */
87
+ declare function ChartDataGrid({ controller, categoryHeader, readOnly, className }: ChartDataGridProps): React__default.JSX.Element;
88
+
89
+ interface ChartInspectorProps {
90
+ controller: ChartController;
91
+ /** Which sections to show (default: all that apply to the chart). */
92
+ sections?: readonly ChartInspectorSection[];
93
+ className?: string;
94
+ }
95
+ type ChartInspectorSection = 'type' | 'titles' | 'options' | 'legend' | 'axes' | 'series';
96
+ /**
97
+ * Settings for a chart controller: type, titles, stacking and line options, legend, both
98
+ * axes and the selected series. Every change is one undo step.
99
+ */
100
+ declare function ChartInspector({ controller, sections, className }: ChartInspectorProps): React__default.JSX.Element;
101
+
102
+ interface ChartEditorProps {
103
+ controller: ChartController;
104
+ /** The settings sidebar (default `true`). */
105
+ showInspector?: boolean;
106
+ /** The data grid under the chart (default `true`). */
107
+ showDataGrid?: boolean;
108
+ /** Undo / redo and the selection readout (default `true`). */
109
+ showToolbar?: boolean;
110
+ /** Chart height in pixels (default 380). */
111
+ height?: number;
112
+ canvasProps?: Omit<ChartCanvasProps, 'controller' | 'height'>;
113
+ className?: string;
114
+ }
115
+ /** Toolbar, chart, settings sidebar and data grid for a `ChartController`. */
116
+ declare function ChartEditor({ controller, showInspector, showDataGrid, showToolbar, height, canvasProps, className }: ChartEditorProps): React__default.JSX.Element;
117
+
118
+ export { ChartCanvas, type ChartCanvasProps, type ChartCommandTarget, ChartCommitInput, ChartDataGrid, type ChartDataGridProps, ChartEditor, type ChartEditorProps, ChartInspector, type ChartInspectorProps, type ChartInspectorSection, type UseChartEditorResult, chartButtonClass, chartCellClass, chartIconButtonClass, chartInputClass, chartLabelClass, chartSectionClass, chartSegmentClass, useChartCommands, useChartController, useChartEditor, useChartState };