@pixerate/editor-react 0.107.0 → 0.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,7 +106,7 @@ useAgentToolProvider(registry, provider);
106
106
  | `@pixerate/editor-react/parameters` | `ParametersPanel` (a whole schema with groups, presets, undo / reset / randomize and keyframe diamonds), `useParameters`, `useParametersController`, `useParametersState`, `useParameterCommands`, and the field controls `ParameterFieldControl`, `ParameterSlider`, `ParameterToggle`, `ParameterSelect`, `ParameterColor`, `ParameterVector`, `ParameterImage`, `ParameterText`, `KeyframeDiamond` over `@pixerate/editor/parameters` (see [the parameters guide](../../docs/parameters.md)) |
107
107
  | `@pixerate/editor-react/color` | `ColorPicker` (interactive hex/rgb/hsl/oklch picker with alpha, swatches, eyedropper, recent history), `DualColorPicker` (dual light/dark mode color picker with theme preview and switch), `useColorScheme` / `useResolvedColor` (the active scheme from the system, a root attribute or an override) |
108
108
  | `@pixerate/editor-react/gradient` | `GradientEditor` (interactive stops bar, midpoints, presets, angle dial, type selector, OKLab/OKLCH/sRGB/linear-sRGB interpolation, CSS output), `FillPicker` (controlled solid-or-gradient fill picker), `useGradientController` |
109
- | `@pixerate/editor-react/canvas` | `useCanvasGraph`, `useCanvasLayout`, `useCanvasClipboard`, `useCanvasDocking`, `useCanvasShortcuts`, `useCanvasExplosion`, `useStreamingCanvas`, `AgentPresenceLayer`, plus the pure layout helpers from `@pixerate/editor/canvas` |
109
+ | `@pixerate/editor-react/canvas` | `useCanvasGraph`, `useCanvasLayout`, `useCanvasClipboard`, `useCanvasDocking`, `useCanvasShortcuts`, `useCanvasExplosion`, `useCanvasExplosionState`, `useStreamingCanvas`, `AgentPresenceLayer`, plus the pure layout helpers from `@pixerate/editor/canvas` |
110
110
 
111
111
  Spreadsheet persistence: `useSpreadsheetEditor` exposes `document` (and passes it to `onDocumentChange`) with the defined names its formulas use in `document.names`, so saving that document and passing it back as `document` restores workbook, sheet-scoped and LAMBDA names. For several sheets, save `controller.getWorkbook()` instead.
112
112
 
@@ -20,5 +20,10 @@ export interface ChartDataGridProps {
20
20
  * (name, colour, show / hide, delete). Cells take numbers as people type them (`1,200`,
21
21
  * `12%`, blank for a gap); pasting TSV or CSV fills and grows the grid from the cell.
22
22
  */
23
+ /**
24
+ * Grouped data as a table: the names from the group down to each item, then its value. Editing
25
+ * a name moves the item (a new name starts a new group); `+ Level` adds a column for deeper groups.
26
+ */
27
+ export declare function ChartTreeGrid({ controller, readOnly, className }: Omit<ChartDataGridProps, 'categoryHeader'>): React.JSX.Element;
23
28
  export declare function ChartDataGrid({ controller, categoryHeader, readOnly, className }: ChartDataGridProps): React.JSX.Element;
24
29
  export {};
@@ -20,5 +20,10 @@ export interface ChartDataGridProps {
20
20
  * (name, colour, show / hide, delete). Cells take numbers as people type them (`1,200`,
21
21
  * `12%`, blank for a gap); pasting TSV or CSV fills and grows the grid from the cell.
22
22
  */
23
+ /**
24
+ * Grouped data as a table: the names from the group down to each item, then its value. Editing
25
+ * a name moves the item (a new name starts a new group); `+ Level` adds a column for deeper groups.
26
+ */
27
+ export declare function ChartTreeGrid({ controller, readOnly, className }: Omit<ChartDataGridProps, 'categoryHeader'>): React.JSX.Element;
23
28
  export declare function ChartDataGrid({ controller, categoryHeader, readOnly, className }: ChartDataGridProps): React.JSX.Element;
24
29
  export {};
@@ -6,7 +6,7 @@ export interface ChartInspectorProps {
6
6
  sections?: readonly ChartInspectorSection[];
7
7
  className?: string;
8
8
  }
9
- export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'series';
9
+ export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'annotations' | 'series';
10
10
  /**
11
11
  * Settings for a chart controller: type, titles, stacking and line options, legend, both
12
12
  * axes and the selected series. Every change is one undo step.
@@ -6,7 +6,7 @@ export interface ChartInspectorProps {
6
6
  sections?: readonly ChartInspectorSection[];
7
7
  className?: string;
8
8
  }
9
- export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'series';
9
+ export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'annotations' | 'series';
10
10
  /**
11
11
  * Settings for a chart controller: type, titles, stacking and line options, legend, both
12
12
  * axes and the selected series. Every change is one undo step.
@@ -39,6 +39,7 @@ __export(chart_exports, {
39
39
  ChartSceneSvg: () => ChartSceneSvg,
40
40
  ChartSparkline: () => ChartSparkline,
41
41
  ChartStreamingView: () => ChartStreamingView,
42
+ ChartTreeGrid: () => ChartTreeGrid,
42
43
  chartButtonClass: () => chartButtonClass,
43
44
  chartCellClass: () => chartCellClass,
44
45
  chartIconButtonClass: () => chartIconButtonClass,
@@ -352,8 +353,60 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
352
353
  }
353
354
  );
354
355
  }
356
+ function ChartTreeGrid({ controller, readOnly = false, className }) {
357
+ const { spec } = useChartState(controller);
358
+ const [columns, setColumns] = (0, import_react3.useState)(1);
359
+ const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
360
+ const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
361
+ const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
362
+ const commit = (next) => controller.setTreeRows(next).ok;
363
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
365
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
366
+ labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
367
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
368
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "w-8 border-b border-border" })
369
+ ] }) }),
370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { "data-tree-row": r, children: [
371
+ labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
372
+ ChartCommitInput,
373
+ {
374
+ value: row.path[k] ?? "",
375
+ "aria-label": `${labels[k]}, row ${r + 1}`,
376
+ "data-tree-cell": `${r}:${k}`,
377
+ readOnly,
378
+ onCommit: (name) => commit((0, import_chart3.setChartTreeRowName)(rows, r, k, name)),
379
+ className: `${chartCellClass} text-left`
380
+ }
381
+ ) }, k)),
382
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
383
+ ChartCommitInput,
384
+ {
385
+ value: String(row.value),
386
+ inputMode: "decimal",
387
+ "aria-label": `Value of ${row.path.join(" / ")}`,
388
+ title: (0, import_chart3.formatChartNumber)(row.value, spec.yAxis.format),
389
+ "data-tree-value": r,
390
+ readOnly,
391
+ onCommit: (text) => commit((0, import_chart3.setChartTreeRowValue)(rows, r, text)),
392
+ className: chartCellClass
393
+ }
394
+ ) }),
395
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete item", "aria-label": `Delete ${row.path.join(" / ")}`, "data-action": "tree-remove-row", onClick: () => commit((0, import_chart3.removeChartTreeRow)(rows, r)), children: "\xD7" }) })
396
+ ] }, r)) })
397
+ ] }),
398
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
399
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-row", onClick: () => commit((0, import_chart3.addChartTreeRow)(rows)), children: "+ Add item" }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
401
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "flex-1" }),
402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "tree-ungroup", title: "Keep the group totals as plain data", onClick: () => controller.setTree([]), children: "Ungroup" })
403
+ ] })
404
+ ] });
405
+ }
355
406
  function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
356
407
  const { spec, selection } = useChartState(controller);
408
+ if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChartTreeGrid, { controller, readOnly, className });
409
+ const canGroup = spec.type === "treemap" || spec.type === "sunburst";
357
410
  const paste = (row, column) => (e) => {
358
411
  const text = e.clipboardData?.getData("text/plain") ?? "";
359
412
  if (!/[\t\n]/.test(text.replace(/\n$/, ""))) return;
@@ -447,7 +500,20 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
447
500
  ] }, i);
448
501
  }) })
449
502
  ] }),
450
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "p-1", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }) })
503
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-1", children: [
504
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
505
+ canGroup && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
506
+ "button",
507
+ {
508
+ type: "button",
509
+ className: `${chartButtonClass} ml-1 h-6`,
510
+ "data-action": "tree-from-table",
511
+ title: "Edit the categories as groups of items",
512
+ onClick: () => controller.setTree((0, import_chart3.chartTreeFromSeries)(spec.categories, spec.series.find((s) => !s.hidden)?.values ?? [])),
513
+ children: "Group items"
514
+ }
515
+ )
516
+ ] })
451
517
  ] });
452
518
  }
453
519
 
@@ -616,7 +682,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
616
682
  ] });
617
683
  }
618
684
  function ChartInspector({ controller, sections, className }) {
619
- const { spec, selectedSeries } = useChartState(controller);
685
+ const { spec, selectedSeries, selection } = useChartState(controller);
620
686
  const idBase = (0, import_react4.useId)();
621
687
  const show = (section) => !sections || sections.includes(section);
622
688
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
@@ -629,6 +695,9 @@ function ChartInspector({ controller, sections, className }) {
629
695
  const hasLines = cartesian && types.some((t) => t === "line" || t === "area");
630
696
  const seriesIndex = selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1;
631
697
  const scales = family === "cartesian" || family === "xy";
698
+ const annotated = scales;
699
+ const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
700
+ const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
632
701
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
633
702
  show("type") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5", role: "radiogroup", "aria-label": "Chart type", children: import_chart4.CHART_TYPES.map((type) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", role: "radio", "aria-checked": spec.type === type, "data-chart-type": type, className: chartSegmentClass(spec.type === type), onClick: () => controller.setType(type), children: import_chart4.CHART_TYPE_LABELS[type] }, type)) }) }),
634
703
  show("style") && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
@@ -645,7 +714,8 @@ function ChartInspector({ controller, sections, className }) {
645
714
  ] }),
646
715
  show("titles") && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
647
716
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
648
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) })
717
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
718
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
649
719
  ] }),
650
720
  show("options") && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
651
721
  cartesian && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { id: `${idBase}-stacking`, name: "stacking", value: spec.stacking, options: import_chart4.CHART_STACKINGS, labels: { none: "None", stacked: "Stacked", percent: "100%" }, onChange: (stacking) => controller.update({ stacking }) }) }),
@@ -683,6 +753,27 @@ function ChartInspector({ controller, sections, className }) {
683
753
  onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
684
754
  }
685
755
  ) }),
756
+ spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
757
+ spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { id: `${idBase}-likert-neutral`, name: "likertNeutral", value: spec.likertNeutral, options: import_chart4.CHART_LIKERT_NEUTRALS, labels: { split: "Across the centre", separate: "In its own column" }, onChange: (likertNeutral) => controller.update({ likertNeutral }) }) }),
758
+ spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { id: `${idBase}-likert-sort`, name: "likertSort", value: spec.likertSort, options: import_chart4.CHART_LIKERT_SORTS, labels: { none: "As entered", positive: "Most agreement first", negative: "Most disagreement first" }, onChange: (likertSort) => controller.update({ likertSort }) }) }),
759
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
760
+ "input",
761
+ {
762
+ id: `${idBase}-parliament-arc`,
763
+ type: "range",
764
+ min: 90,
765
+ max: 360,
766
+ step: 10,
767
+ value: spec.parliamentArc,
768
+ "data-option": "parliamentArc",
769
+ className: "w-full accent-primary",
770
+ onPointerDown: () => controller.beginGesture("parliamentArc"),
771
+ onPointerUp: () => controller.endGesture(),
772
+ onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
773
+ }
774
+ ) }),
775
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-parliament-majority`, value: spec.parliamentMajority === null ? "" : String(spec.parliamentMajority), placeholder: "Half plus one", inputMode: "numeric", "data-option": "parliamentMajority", className: chartInputClass, onCommit: (text) => controller.update({ parliamentMajority: text.trim() === "" ? null : Number(text) }).ok }) }),
776
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
686
777
  spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-radar-ticks`, value: spec.radarTicks === null ? "" : String(spec.radarTicks), placeholder: "Auto", inputMode: "numeric", "data-option": "radarTicks", className: chartInputClass, onCommit: (text) => controller.update({ radarTicks: text.trim() === "" ? null : Number(text) }).ok }) }),
687
778
  spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { id: `${idBase}-radar-graticule`, name: "radarGraticule", value: spec.radarGraticule, options: import_chart4.CHART_RADAR_GRATICULES, labels: { polygon: "Polygons", circle: "Circles" }, onChange: (radarGraticule) => controller.update({ radarGraticule }) }) }),
688
779
  spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
@@ -690,6 +781,7 @@ function ChartInspector({ controller, sections, className }) {
690
781
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
691
782
  spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
692
783
  hasLines && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
784
+ oneSeries && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
693
785
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
694
786
  ] })
695
787
  ] }),
@@ -705,6 +797,35 @@ function ChartInspector({ controller, sections, className }) {
705
797
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
706
798
  usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
707
799
  ] }),
800
+ show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
801
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
802
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
803
+ ChartCommitInput,
804
+ {
805
+ id: `${idBase}-highlight`,
806
+ value: spec.highlight.join(", "),
807
+ placeholder: "Categories or series",
808
+ "data-option": "highlight",
809
+ className: chartInputClass,
810
+ onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
811
+ }
812
+ ) }),
813
+ spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
814
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { value: String(line.value), "aria-label": "Line value", inputMode: "decimal", "data-option": `referenceLine.${i}.value`, className: `${chartInputClass} w-16 shrink-0`, onCommit: (text) => controller.updateReferenceLine(i, { value: Number(text) }).ok }),
815
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { value: line.label ?? "", "aria-label": "Line label", placeholder: "Label", "data-option": `referenceLine.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceLine(i, { label: text || null }).ok }),
816
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
817
+ ] }, `line-${i}`)),
818
+ spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
819
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { value: String(band.from), "aria-label": "Band from", inputMode: "decimal", "data-option": `referenceBand.${i}.from`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { from: Number(text) }).ok }),
820
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { value: String(band.to), "aria-label": "Band to", inputMode: "decimal", "data-option": `referenceBand.${i}.to`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { to: Number(text) }).ok }),
821
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { value: band.label ?? "", "aria-label": "Band label", placeholder: "Label", "data-option": `referenceBand.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceBand(i, { label: text || null }).ok }),
822
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
823
+ ] }, `band-${i}`)),
824
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-1", children: [
825
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
826
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
827
+ ] })
828
+ ] }),
708
829
  show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
709
830
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
710
831
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
@@ -752,6 +873,17 @@ function ChartInspector({ controller, sections, className }) {
752
873
  ]
753
874
  }
754
875
  ) }),
876
+ annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
877
+ ChartCommitInput,
878
+ {
879
+ id: `${idBase}-series-callout`,
880
+ value: selectedSeries.callouts?.[calloutIndex] ?? "",
881
+ placeholder: `Label for ${spec.categories[calloutIndex] ?? "this point"}`,
882
+ "data-option": "series.callout",
883
+ className: chartInputClass,
884
+ onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
885
+ }
886
+ ) }),
755
887
  scales && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
756
888
  family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
757
889
  (0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
@@ -1033,6 +1165,7 @@ function ChartSparkline({ values, width = 80, height = 20, label, className, ...
1033
1165
  ChartSceneSvg,
1034
1166
  ChartSparkline,
1035
1167
  ChartStreamingView,
1168
+ ChartTreeGrid,
1036
1169
  chartButtonClass,
1037
1170
  chartCellClass,
1038
1171
  chartIconButtonClass,
@@ -5,6 +5,7 @@ import {
5
5
  ChartInspector,
6
6
  ChartPresenceLayer,
7
7
  ChartSceneSvg,
8
+ ChartTreeGrid,
8
9
  chartButtonClass,
9
10
  chartCellClass,
10
11
  chartIconButtonClass,
@@ -20,7 +21,7 @@ import {
20
21
  useChartState,
21
22
  useChartToolProvider,
22
23
  useOfficeChartToolProvider
23
- } from "../chunk-FUR7LCDM.js";
24
+ } from "../chunk-GJ3IMZQW.js";
24
25
  import {
25
26
  PresenceLayer,
26
27
  useAgentPlayback,
@@ -186,6 +187,7 @@ export {
186
187
  ChartSceneSvg,
187
188
  ChartSparkline,
188
189
  ChartStreamingView,
190
+ ChartTreeGrid,
189
191
  chartButtonClass,
190
192
  chartCellClass,
191
193
  chartIconButtonClass,
@@ -271,7 +271,19 @@ var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right t
271
271
 
272
272
  // src/chart/ChartDataGrid.tsx
273
273
  import { useEffect as useEffect3, useRef as useRef3, useState as useState2 } from "react";
274
- import { chartColorInputValue, chartSeriesColor, formatChartNumber } from "@pixerate/editor/chart";
274
+ import {
275
+ addChartTreeRow,
276
+ chartColorInputValue,
277
+ chartSeriesColor,
278
+ chartTreeColumnLabels,
279
+ chartTreeDepth,
280
+ chartTreeFromSeries,
281
+ chartTreeToRows,
282
+ formatChartNumber,
283
+ removeChartTreeRow,
284
+ setChartTreeRowName,
285
+ setChartTreeRowValue
286
+ } from "@pixerate/editor/chart";
275
287
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
276
288
  function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
277
289
  const [draft, setDraft] = useState2(value);
@@ -312,8 +324,60 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
312
324
  }
313
325
  );
314
326
  }
327
+ function ChartTreeGrid({ controller, readOnly = false, className }) {
328
+ const { spec } = useChartState(controller);
329
+ const [columns, setColumns] = useState2(1);
330
+ const rows = chartTreeToRows(spec.tree);
331
+ const depth = Math.max(columns, chartTreeDepth(spec.tree));
332
+ const labels = chartTreeColumnLabels(depth);
333
+ const commit = (next) => controller.setTreeRows(next).ok;
334
+ return /* @__PURE__ */ jsxs2("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
335
+ /* @__PURE__ */ jsxs2("table", { className: "w-full border-collapse text-xs", children: [
336
+ /* @__PURE__ */ jsx2("thead", { className: "bg-muted/50", children: /* @__PURE__ */ jsxs2("tr", { children: [
337
+ labels.map((label) => /* @__PURE__ */ jsx2("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
338
+ /* @__PURE__ */ jsx2("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
339
+ !readOnly && /* @__PURE__ */ jsx2("th", { className: "w-8 border-b border-border" })
340
+ ] }) }),
341
+ /* @__PURE__ */ jsx2("tbody", { children: rows.map((row, r) => /* @__PURE__ */ jsxs2("tr", { "data-tree-row": r, children: [
342
+ labels.map((_, k) => /* @__PURE__ */ jsx2("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ jsx2(
343
+ ChartCommitInput,
344
+ {
345
+ value: row.path[k] ?? "",
346
+ "aria-label": `${labels[k]}, row ${r + 1}`,
347
+ "data-tree-cell": `${r}:${k}`,
348
+ readOnly,
349
+ onCommit: (name) => commit(setChartTreeRowName(rows, r, k, name)),
350
+ className: `${chartCellClass} text-left`
351
+ }
352
+ ) }, k)),
353
+ /* @__PURE__ */ jsx2("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ jsx2(
354
+ ChartCommitInput,
355
+ {
356
+ value: String(row.value),
357
+ inputMode: "decimal",
358
+ "aria-label": `Value of ${row.path.join(" / ")}`,
359
+ title: formatChartNumber(row.value, spec.yAxis.format),
360
+ "data-tree-value": r,
361
+ readOnly,
362
+ onCommit: (text) => commit(setChartTreeRowValue(rows, r, text)),
363
+ className: chartCellClass
364
+ }
365
+ ) }),
366
+ !readOnly && /* @__PURE__ */ jsx2("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ jsx2("button", { type: "button", className: chartIconButtonClass, title: "Delete item", "aria-label": `Delete ${row.path.join(" / ")}`, "data-action": "tree-remove-row", onClick: () => commit(removeChartTreeRow(rows, r)), children: "\xD7" }) })
367
+ ] }, r)) })
368
+ ] }),
369
+ !readOnly && /* @__PURE__ */ jsxs2("div", { className: "flex flex-wrap gap-1 p-1", children: [
370
+ /* @__PURE__ */ jsx2("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-row", onClick: () => commit(addChartTreeRow(rows)), children: "+ Add item" }),
371
+ /* @__PURE__ */ jsx2("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
372
+ /* @__PURE__ */ jsx2("span", { className: "flex-1" }),
373
+ /* @__PURE__ */ jsx2("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "tree-ungroup", title: "Keep the group totals as plain data", onClick: () => controller.setTree([]), children: "Ungroup" })
374
+ ] })
375
+ ] });
376
+ }
315
377
  function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
316
378
  const { spec, selection } = useChartState(controller);
379
+ if (spec.tree.length) return /* @__PURE__ */ jsx2(ChartTreeGrid, { controller, readOnly, className });
380
+ const canGroup = spec.type === "treemap" || spec.type === "sunburst";
317
381
  const paste = (row, column) => (e) => {
318
382
  const text = e.clipboardData?.getData("text/plain") ?? "";
319
383
  if (!/[\t\n]/.test(text.replace(/\n$/, ""))) return;
@@ -407,7 +471,20 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
407
471
  ] }, i);
408
472
  }) })
409
473
  ] }),
410
- !readOnly && /* @__PURE__ */ jsx2("div", { className: "p-1", children: /* @__PURE__ */ jsx2("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }) })
474
+ !readOnly && /* @__PURE__ */ jsxs2("div", { className: "p-1", children: [
475
+ /* @__PURE__ */ jsx2("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
476
+ canGroup && /* @__PURE__ */ jsx2(
477
+ "button",
478
+ {
479
+ type: "button",
480
+ className: `${chartButtonClass} ml-1 h-6`,
481
+ "data-action": "tree-from-table",
482
+ title: "Edit the categories as groups of items",
483
+ onClick: () => controller.setTree(chartTreeFromSeries(spec.categories, spec.series.find((s) => !s.hidden)?.values ?? [])),
484
+ children: "Group items"
485
+ }
486
+ )
487
+ ] })
411
488
  ] });
412
489
  }
413
490
 
@@ -429,6 +506,8 @@ import {
429
506
  CHART_CURVES,
430
507
  CHART_RADAR_GRATICULES,
431
508
  CHART_LEGEND_POSITIONS,
509
+ CHART_LIKERT_NEUTRALS,
510
+ CHART_LIKERT_SORTS,
432
511
  CHART_NUMBER_STYLES,
433
512
  CHART_SERIES_TYPES,
434
513
  CHART_STACKINGS,
@@ -441,7 +520,8 @@ import {
441
520
  formatChartAmountList,
442
521
  parseChartAmountList,
443
522
  chartSeriesType,
444
- isCartesianChart
523
+ isCartesianChart,
524
+ suggestChartReferences
445
525
  } from "@pixerate/editor/chart";
446
526
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
447
527
  var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -605,7 +685,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
605
685
  ] });
606
686
  }
607
687
  function ChartInspector({ controller, sections, className }) {
608
- const { spec, selectedSeries } = useChartState(controller);
688
+ const { spec, selectedSeries, selection } = useChartState(controller);
609
689
  const idBase = useId();
610
690
  const show = (section) => !sections || sections.includes(section);
611
691
  const cartesian = isCartesianChart(spec.type);
@@ -618,6 +698,9 @@ function ChartInspector({ controller, sections, className }) {
618
698
  const hasLines = cartesian && types.some((t) => t === "line" || t === "area");
619
699
  const seriesIndex = selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1;
620
700
  const scales = family === "cartesian" || family === "xy";
701
+ const annotated = scales;
702
+ const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
703
+ const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
621
704
  return /* @__PURE__ */ jsxs3("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
622
705
  show("type") && /* @__PURE__ */ jsx3("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ jsx3("div", { className: "grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5", role: "radiogroup", "aria-label": "Chart type", children: CHART_TYPES.map((type) => /* @__PURE__ */ jsx3("button", { type: "button", role: "radio", "aria-checked": spec.type === type, "data-chart-type": type, className: chartSegmentClass(spec.type === type), onClick: () => controller.setType(type), children: CHART_TYPE_LABELS[type] }, type)) }) }),
623
706
  show("style") && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "style", children: [
@@ -634,7 +717,8 @@ function ChartInspector({ controller, sections, className }) {
634
717
  ] }),
635
718
  show("titles") && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "titles", children: [
636
719
  /* @__PURE__ */ jsx3(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
637
- /* @__PURE__ */ jsx3(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) })
720
+ /* @__PURE__ */ jsx3(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
721
+ /* @__PURE__ */ jsx3(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
638
722
  ] }),
639
723
  show("options") && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "options", children: [
640
724
  cartesian && /* @__PURE__ */ jsx3(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ jsx3(Select, { id: `${idBase}-stacking`, name: "stacking", value: spec.stacking, options: CHART_STACKINGS, labels: { none: "None", stacked: "Stacked", percent: "100%" }, onChange: (stacking) => controller.update({ stacking }) }) }),
@@ -672,6 +756,27 @@ function ChartInspector({ controller, sections, className }) {
672
756
  onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
673
757
  }
674
758
  ) }),
759
+ spec.type === "sunburst" && /* @__PURE__ */ jsx3(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
760
+ spec.type === "likert" && /* @__PURE__ */ jsx3(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ jsx3(Select, { id: `${idBase}-likert-neutral`, name: "likertNeutral", value: spec.likertNeutral, options: CHART_LIKERT_NEUTRALS, labels: { split: "Across the centre", separate: "In its own column" }, onChange: (likertNeutral) => controller.update({ likertNeutral }) }) }),
761
+ spec.type === "likert" && /* @__PURE__ */ jsx3(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ jsx3(Select, { id: `${idBase}-likert-sort`, name: "likertSort", value: spec.likertSort, options: CHART_LIKERT_SORTS, labels: { none: "As entered", positive: "Most agreement first", negative: "Most disagreement first" }, onChange: (likertSort) => controller.update({ likertSort }) }) }),
762
+ spec.type === "parliament" && /* @__PURE__ */ jsx3(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ jsx3(
763
+ "input",
764
+ {
765
+ id: `${idBase}-parliament-arc`,
766
+ type: "range",
767
+ min: 90,
768
+ max: 360,
769
+ step: 10,
770
+ value: spec.parliamentArc,
771
+ "data-option": "parliamentArc",
772
+ className: "w-full accent-primary",
773
+ onPointerDown: () => controller.beginGesture("parliamentArc"),
774
+ onPointerUp: () => controller.endGesture(),
775
+ onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
776
+ }
777
+ ) }),
778
+ spec.type === "parliament" && /* @__PURE__ */ jsx3(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-parliament-majority`, value: spec.parliamentMajority === null ? "" : String(spec.parliamentMajority), placeholder: "Half plus one", inputMode: "numeric", "data-option": "parliamentMajority", className: chartInputClass, onCommit: (text) => controller.update({ parliamentMajority: text.trim() === "" ? null : Number(text) }).ok }) }),
779
+ spec.type === "parliament" && /* @__PURE__ */ jsx3(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
675
780
  spec.type === "radar" && /* @__PURE__ */ jsx3(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-radar-ticks`, value: spec.radarTicks === null ? "" : String(spec.radarTicks), placeholder: "Auto", inputMode: "numeric", "data-option": "radarTicks", className: chartInputClass, onCommit: (text) => controller.update({ radarTicks: text.trim() === "" ? null : Number(text) }).ok }) }),
676
781
  spec.type === "radar" && /* @__PURE__ */ jsx3(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ jsx3(Select, { id: `${idBase}-radar-graticule`, name: "radarGraticule", value: spec.radarGraticule, options: CHART_RADAR_GRATICULES, labels: { polygon: "Polygons", circle: "Circles" }, onChange: (radarGraticule) => controller.update({ radarGraticule }) }) }),
677
782
  spec.dataLabels && hasBars && /* @__PURE__ */ jsx3(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ jsx3(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
@@ -679,6 +784,7 @@ function ChartInspector({ controller, sections, className }) {
679
784
  /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
680
785
  spec.type === "waterfall" && /* @__PURE__ */ jsx3(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
681
786
  hasLines && /* @__PURE__ */ jsx3(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
787
+ oneSeries && /* @__PURE__ */ jsx3(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
682
788
  /* @__PURE__ */ jsx3(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
683
789
  ] })
684
790
  ] }),
@@ -694,6 +800,35 @@ function ChartInspector({ controller, sections, className }) {
694
800
  /* @__PURE__ */ jsx3(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
695
801
  usesSecondary && /* @__PURE__ */ jsx3(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
696
802
  ] }),
803
+ show("annotations") && annotated && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "annotations", children: [
804
+ /* @__PURE__ */ jsx3("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
805
+ /* @__PURE__ */ jsx3(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ jsx3(
806
+ ChartCommitInput,
807
+ {
808
+ id: `${idBase}-highlight`,
809
+ value: spec.highlight.join(", "),
810
+ placeholder: "Categories or series",
811
+ "data-option": "highlight",
812
+ className: chartInputClass,
813
+ onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
814
+ }
815
+ ) }),
816
+ spec.referenceLines.map((line, i) => /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
817
+ /* @__PURE__ */ jsx3(ChartCommitInput, { value: String(line.value), "aria-label": "Line value", inputMode: "decimal", "data-option": `referenceLine.${i}.value`, className: `${chartInputClass} w-16 shrink-0`, onCommit: (text) => controller.updateReferenceLine(i, { value: Number(text) }).ok }),
818
+ /* @__PURE__ */ jsx3(ChartCommitInput, { value: line.label ?? "", "aria-label": "Line label", placeholder: "Label", "data-option": `referenceLine.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceLine(i, { label: text || null }).ok }),
819
+ /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
820
+ ] }, `line-${i}`)),
821
+ spec.referenceBands.map((band, i) => /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
822
+ /* @__PURE__ */ jsx3(ChartCommitInput, { value: String(band.from), "aria-label": "Band from", inputMode: "decimal", "data-option": `referenceBand.${i}.from`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { from: Number(text) }).ok }),
823
+ /* @__PURE__ */ jsx3(ChartCommitInput, { value: String(band.to), "aria-label": "Band to", inputMode: "decimal", "data-option": `referenceBand.${i}.to`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { to: Number(text) }).ok }),
824
+ /* @__PURE__ */ jsx3(ChartCommitInput, { value: band.label ?? "", "aria-label": "Band label", placeholder: "Label", "data-option": `referenceBand.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceBand(i, { label: text || null }).ok }),
825
+ /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
826
+ ] }, `band-${i}`)),
827
+ /* @__PURE__ */ jsxs3("div", { className: "flex gap-1", children: [
828
+ /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine(suggestChartReferences(spec).line), children: "Add line" }),
829
+ /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand(suggestChartReferences(spec).band), children: "Add band" })
830
+ ] })
831
+ ] }),
697
832
  show("series") && selectedSeries && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
698
833
  /* @__PURE__ */ jsx3("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
699
834
  /* @__PURE__ */ jsx3(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
@@ -741,6 +876,17 @@ function ChartInspector({ controller, sections, className }) {
741
876
  ]
742
877
  }
743
878
  ) }),
879
+ annotated && calloutIndex !== null && /* @__PURE__ */ jsx3(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ jsx3(
880
+ ChartCommitInput,
881
+ {
882
+ id: `${idBase}-series-callout`,
883
+ value: selectedSeries.callouts?.[calloutIndex] ?? "",
884
+ placeholder: `Label for ${spec.categories[calloutIndex] ?? "this point"}`,
885
+ "data-option": "series.callout",
886
+ className: chartInputClass,
887
+ onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
888
+ }
889
+ ) }),
744
890
  scales && /* @__PURE__ */ jsx3(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
745
891
  family === "xy" && /* @__PURE__ */ jsx3(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
746
892
  chartSupportsTrendlines(spec.type, spec.stacking) && /* @__PURE__ */ jsxs3("div", { className: "space-y-1", "data-section": "trendlines", children: [
@@ -796,6 +942,7 @@ export {
796
942
  chartSectionClass,
797
943
  chartCellClass,
798
944
  ChartCommitInput,
945
+ ChartTreeGrid,
799
946
  ChartDataGrid,
800
947
  ChartInspector
801
948
  };
package/dist/index.cjs CHANGED
@@ -11451,8 +11451,60 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
11451
11451
  }
11452
11452
  );
11453
11453
  }
11454
+ function ChartTreeGrid({ controller, readOnly = false, className }) {
11455
+ const { spec } = useChartState(controller);
11456
+ const [columns, setColumns] = (0, import_react84.useState)(1);
11457
+ const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
11458
+ const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
11459
+ const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
11460
+ const commit = (next) => controller.setTreeRows(next).ok;
11461
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
11462
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
11463
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("tr", { children: [
11464
+ labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
11465
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
11466
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "w-8 border-b border-border" })
11467
+ ] }) }),
11468
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("tr", { "data-tree-row": r, children: [
11469
+ labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
11470
+ ChartCommitInput,
11471
+ {
11472
+ value: row.path[k] ?? "",
11473
+ "aria-label": `${labels[k]}, row ${r + 1}`,
11474
+ "data-tree-cell": `${r}:${k}`,
11475
+ readOnly,
11476
+ onCommit: (name) => commit((0, import_chart3.setChartTreeRowName)(rows, r, k, name)),
11477
+ className: `${chartCellClass} text-left`
11478
+ }
11479
+ ) }, k)),
11480
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
11481
+ ChartCommitInput,
11482
+ {
11483
+ value: String(row.value),
11484
+ inputMode: "decimal",
11485
+ "aria-label": `Value of ${row.path.join(" / ")}`,
11486
+ title: (0, import_chart3.formatChartNumber)(row.value, spec.yAxis.format),
11487
+ "data-tree-value": r,
11488
+ readOnly,
11489
+ onCommit: (text) => commit((0, import_chart3.setChartTreeRowValue)(rows, r, text)),
11490
+ className: chartCellClass
11491
+ }
11492
+ ) }),
11493
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete item", "aria-label": `Delete ${row.path.join(" / ")}`, "data-action": "tree-remove-row", onClick: () => commit((0, import_chart3.removeChartTreeRow)(rows, r)), children: "\xD7" }) })
11494
+ ] }, r)) })
11495
+ ] }),
11496
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
11497
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-row", onClick: () => commit((0, import_chart3.addChartTreeRow)(rows)), children: "+ Add item" }),
11498
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
11499
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "flex-1" }),
11500
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "tree-ungroup", title: "Keep the group totals as plain data", onClick: () => controller.setTree([]), children: "Ungroup" })
11501
+ ] })
11502
+ ] });
11503
+ }
11454
11504
  function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
11455
11505
  const { spec, selection } = useChartState(controller);
11506
+ if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ChartTreeGrid, { controller, readOnly, className });
11507
+ const canGroup = spec.type === "treemap" || spec.type === "sunburst";
11456
11508
  const paste = (row, column) => (e) => {
11457
11509
  const text = e.clipboardData?.getData("text/plain") ?? "";
11458
11510
  if (!/[\t\n]/.test(text.replace(/\n$/, ""))) return;
@@ -11546,7 +11598,20 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
11546
11598
  ] }, i);
11547
11599
  }) })
11548
11600
  ] }),
11549
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "p-1", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }) })
11601
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "p-1", children: [
11602
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
11603
+ canGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
11604
+ "button",
11605
+ {
11606
+ type: "button",
11607
+ className: `${chartButtonClass} ml-1 h-6`,
11608
+ "data-action": "tree-from-table",
11609
+ title: "Edit the categories as groups of items",
11610
+ onClick: () => controller.setTree((0, import_chart3.chartTreeFromSeries)(spec.categories, spec.series.find((s) => !s.hidden)?.values ?? [])),
11611
+ children: "Group items"
11612
+ }
11613
+ )
11614
+ ] })
11550
11615
  ] });
11551
11616
  }
11552
11617
 
@@ -11715,7 +11780,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
11715
11780
  ] });
11716
11781
  }
11717
11782
  function ChartInspector({ controller, sections, className }) {
11718
- const { spec, selectedSeries } = useChartState(controller);
11783
+ const { spec, selectedSeries, selection } = useChartState(controller);
11719
11784
  const idBase = (0, import_react85.useId)();
11720
11785
  const show = (section) => !sections || sections.includes(section);
11721
11786
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
@@ -11728,6 +11793,9 @@ function ChartInspector({ controller, sections, className }) {
11728
11793
  const hasLines = cartesian && types.some((t) => t === "line" || t === "area");
11729
11794
  const seriesIndex = selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1;
11730
11795
  const scales = family === "cartesian" || family === "xy";
11796
+ const annotated = scales;
11797
+ const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
11798
+ const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
11731
11799
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
11732
11800
  show("type") && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5", role: "radiogroup", "aria-label": "Chart type", children: import_chart4.CHART_TYPES.map((type) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("button", { type: "button", role: "radio", "aria-checked": spec.type === type, "data-chart-type": type, className: chartSegmentClass(spec.type === type), onClick: () => controller.setType(type), children: import_chart4.CHART_TYPE_LABELS[type] }, type)) }) }),
11733
11801
  show("style") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
@@ -11744,7 +11812,8 @@ function ChartInspector({ controller, sections, className }) {
11744
11812
  ] }),
11745
11813
  show("titles") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
11746
11814
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
11747
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) })
11815
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
11816
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
11748
11817
  ] }),
11749
11818
  show("options") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
11750
11819
  cartesian && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Select, { id: `${idBase}-stacking`, name: "stacking", value: spec.stacking, options: import_chart4.CHART_STACKINGS, labels: { none: "None", stacked: "Stacked", percent: "100%" }, onChange: (stacking) => controller.update({ stacking }) }) }),
@@ -11782,6 +11851,27 @@ function ChartInspector({ controller, sections, className }) {
11782
11851
  onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
11783
11852
  }
11784
11853
  ) }),
11854
+ spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
11855
+ spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Select, { id: `${idBase}-likert-neutral`, name: "likertNeutral", value: spec.likertNeutral, options: import_chart4.CHART_LIKERT_NEUTRALS, labels: { split: "Across the centre", separate: "In its own column" }, onChange: (likertNeutral) => controller.update({ likertNeutral }) }) }),
11856
+ spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Select, { id: `${idBase}-likert-sort`, name: "likertSort", value: spec.likertSort, options: import_chart4.CHART_LIKERT_SORTS, labels: { none: "As entered", positive: "Most agreement first", negative: "Most disagreement first" }, onChange: (likertSort) => controller.update({ likertSort }) }) }),
11857
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11858
+ "input",
11859
+ {
11860
+ id: `${idBase}-parliament-arc`,
11861
+ type: "range",
11862
+ min: 90,
11863
+ max: 360,
11864
+ step: 10,
11865
+ value: spec.parliamentArc,
11866
+ "data-option": "parliamentArc",
11867
+ className: "w-full accent-primary",
11868
+ onPointerDown: () => controller.beginGesture("parliamentArc"),
11869
+ onPointerUp: () => controller.endGesture(),
11870
+ onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
11871
+ }
11872
+ ) }),
11873
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-parliament-majority`, value: spec.parliamentMajority === null ? "" : String(spec.parliamentMajority), placeholder: "Half plus one", inputMode: "numeric", "data-option": "parliamentMajority", className: chartInputClass, onCommit: (text) => controller.update({ parliamentMajority: text.trim() === "" ? null : Number(text) }).ok }) }),
11874
+ spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
11785
11875
  spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-radar-ticks`, value: spec.radarTicks === null ? "" : String(spec.radarTicks), placeholder: "Auto", inputMode: "numeric", "data-option": "radarTicks", className: chartInputClass, onCommit: (text) => controller.update({ radarTicks: text.trim() === "" ? null : Number(text) }).ok }) }),
11786
11876
  spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Select, { id: `${idBase}-radar-graticule`, name: "radarGraticule", value: spec.radarGraticule, options: import_chart4.CHART_RADAR_GRATICULES, labels: { polygon: "Polygons", circle: "Circles" }, onChange: (radarGraticule) => controller.update({ radarGraticule }) }) }),
11787
11877
  spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
@@ -11789,6 +11879,7 @@ function ChartInspector({ controller, sections, className }) {
11789
11879
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
11790
11880
  spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
11791
11881
  hasLines && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
11882
+ oneSeries && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
11792
11883
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
11793
11884
  ] })
11794
11885
  ] }),
@@ -11804,6 +11895,35 @@ function ChartInspector({ controller, sections, className }) {
11804
11895
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
11805
11896
  usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
11806
11897
  ] }),
11898
+ show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
11899
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
11900
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11901
+ ChartCommitInput,
11902
+ {
11903
+ id: `${idBase}-highlight`,
11904
+ value: spec.highlight.join(", "),
11905
+ placeholder: "Categories or series",
11906
+ "data-option": "highlight",
11907
+ className: chartInputClass,
11908
+ onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
11909
+ }
11910
+ ) }),
11911
+ spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
11912
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { value: String(line.value), "aria-label": "Line value", inputMode: "decimal", "data-option": `referenceLine.${i}.value`, className: `${chartInputClass} w-16 shrink-0`, onCommit: (text) => controller.updateReferenceLine(i, { value: Number(text) }).ok }),
11913
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { value: line.label ?? "", "aria-label": "Line label", placeholder: "Label", "data-option": `referenceLine.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceLine(i, { label: text || null }).ok }),
11914
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
11915
+ ] }, `line-${i}`)),
11916
+ spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
11917
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { value: String(band.from), "aria-label": "Band from", inputMode: "decimal", "data-option": `referenceBand.${i}.from`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { from: Number(text) }).ok }),
11918
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { value: String(band.to), "aria-label": "Band to", inputMode: "decimal", "data-option": `referenceBand.${i}.to`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { to: Number(text) }).ok }),
11919
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { value: band.label ?? "", "aria-label": "Band label", placeholder: "Label", "data-option": `referenceBand.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceBand(i, { label: text || null }).ok }),
11920
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
11921
+ ] }, `band-${i}`)),
11922
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex gap-1", children: [
11923
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
11924
+ /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
11925
+ ] })
11926
+ ] }),
11807
11927
  show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
11808
11928
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
11809
11929
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
@@ -11851,6 +11971,17 @@ function ChartInspector({ controller, sections, className }) {
11851
11971
  ]
11852
11972
  }
11853
11973
  ) }),
11974
+ annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11975
+ ChartCommitInput,
11976
+ {
11977
+ id: `${idBase}-series-callout`,
11978
+ value: selectedSeries.callouts?.[calloutIndex] ?? "",
11979
+ placeholder: `Label for ${spec.categories[calloutIndex] ?? "this point"}`,
11980
+ "data-option": "series.callout",
11981
+ className: chartInputClass,
11982
+ onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
11983
+ }
11984
+ ) }),
11854
11985
  scales && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
11855
11986
  family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
11856
11987
  (0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  ChartDataGrid,
7
7
  ChartInspector,
8
8
  chartButtonClass
9
- } from "./chunk-FUR7LCDM.js";
9
+ } from "./chunk-GJ3IMZQW.js";
10
10
  import {
11
11
  FormulaHints,
12
12
  NameManager,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.107.0",
3
+ "version": "0.108.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -258,7 +258,7 @@
258
258
  },
259
259
  "peerDependencies": {
260
260
  "@dagrejs/dagre": "^1.1.8",
261
- "@pixerate/editor": ">=0.162.0 <1.0.0-0",
261
+ "@pixerate/editor": ">=0.163.0 <1.0.0-0",
262
262
  "@tiptap/core": "^2.27.3",
263
263
  "@tiptap/pm": "^2.27.3",
264
264
  "@tiptap/react": "^2.27.3",
@@ -285,7 +285,7 @@
285
285
  "tsup": "^9.0.0",
286
286
  "typescript": "^5.7.3",
287
287
  "vitest": "^5.0.5",
288
- "@pixerate/editor": "0.162.0"
288
+ "@pixerate/editor": "0.163.0"
289
289
  },
290
290
  "scripts": {
291
291
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",