@pixerate/editor-react 0.107.0 → 0.109.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.
@@ -1,16 +1,34 @@
1
- import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot } from '@pixerate/editor/canvas';
1
+ import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot, type Rect } from '@pixerate/editor/canvas';
2
2
  export interface CanvasGraphTarget<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
3
3
  nodes: TNode[];
4
4
  edges: TEdge[];
5
5
  setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
6
6
  setEdges: (updater: TEdge[] | ((prev: TEdge[]) => TEdge[])) => void;
7
+ /** Builds a parent-to-child edge. Default `{ id: 'explode:<parent>:<child>', source, target }`. */
8
+ createEdge?: (sourceId: string, targetId: string) => TEdge;
9
+ }
10
+ export interface UseCanvasExplosionOptions<TNode extends CanvasNode = CanvasNode> {
11
+ /** Bounds of a set of nodes (e.g. React Flow's `getNodesBounds`). Default: measured sizes. */
12
+ getNodesBounds?: (nodes: TNode[]) => Rect;
13
+ /** Called after an explosion or collapse finishes (e.g. to persist). */
14
+ onSave?: () => void;
7
15
  }
8
16
  /**
9
- * React hook managing node explosion and collapse transitions with exact reversibility.
17
+ * Imperative explosion coordinator for a React Flow graph held in state (whiteboards, diagrams):
18
+ * adds child nodes and edges, animates them out along a trajectory while surrounding nodes slide
19
+ * aside, and collapses back exactly. The layout math is `computeCanvasExplosionLayout`; several
20
+ * nodes can be exploded at once. The same API as the Svelte `createCanvasExplosion`. For a canvas
21
+ * derived from state (`useMemo`), use `useCanvasExplosionState` and the layout functions instead.
22
+ *
23
+ * `explodeNode` throws when a child id is already on the canvas or repeated.
10
24
  */
11
- export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>): {
12
- explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => void;
13
- collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => void;
25
+ export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>, hookOptions?: UseCanvasExplosionOptions<TNode>): {
26
+ /** Ids of nodes whose explosion animation has finished (and not yet collapsed). */
27
+ explodedNodeIds: string[];
28
+ explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => boolean;
29
+ collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => boolean;
30
+ toggleExplode: (parentNodeId: string, explodeOptions: ExplodeNodeOptions<TNode, TEdge>, collapseOptions?: CollapseNodeOptions) => boolean;
31
+ /** True once the node's explosion has finished, until a collapse finishes. */
14
32
  isExploded: (parentNodeId: string) => boolean;
15
33
  getSnapshot: (parentNodeId: string) => ExplosionSnapshot<TNode, TEdge> | undefined;
16
34
  };
@@ -1,16 +1,34 @@
1
- import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot } from '@pixerate/editor/canvas';
1
+ import { type CanvasEdge, type CanvasNode, type CollapseNodeOptions, type ExplodeNodeOptions, type ExplosionSnapshot, type Rect } from '@pixerate/editor/canvas';
2
2
  export interface CanvasGraphTarget<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
3
3
  nodes: TNode[];
4
4
  edges: TEdge[];
5
5
  setNodes: (updater: TNode[] | ((prev: TNode[]) => TNode[])) => void;
6
6
  setEdges: (updater: TEdge[] | ((prev: TEdge[]) => TEdge[])) => void;
7
+ /** Builds a parent-to-child edge. Default `{ id: 'explode:<parent>:<child>', source, target }`. */
8
+ createEdge?: (sourceId: string, targetId: string) => TEdge;
9
+ }
10
+ export interface UseCanvasExplosionOptions<TNode extends CanvasNode = CanvasNode> {
11
+ /** Bounds of a set of nodes (e.g. React Flow's `getNodesBounds`). Default: measured sizes. */
12
+ getNodesBounds?: (nodes: TNode[]) => Rect;
13
+ /** Called after an explosion or collapse finishes (e.g. to persist). */
14
+ onSave?: () => void;
7
15
  }
8
16
  /**
9
- * React hook managing node explosion and collapse transitions with exact reversibility.
17
+ * Imperative explosion coordinator for a React Flow graph held in state (whiteboards, diagrams):
18
+ * adds child nodes and edges, animates them out along a trajectory while surrounding nodes slide
19
+ * aside, and collapses back exactly. The layout math is `computeCanvasExplosionLayout`; several
20
+ * nodes can be exploded at once. The same API as the Svelte `createCanvasExplosion`. For a canvas
21
+ * derived from state (`useMemo`), use `useCanvasExplosionState` and the layout functions instead.
22
+ *
23
+ * `explodeNode` throws when a child id is already on the canvas or repeated.
10
24
  */
11
- export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>): {
12
- explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => void;
13
- collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => void;
25
+ export declare function useCanvasExplosion<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(target: CanvasGraphTarget<TNode, TEdge>, hookOptions?: UseCanvasExplosionOptions<TNode>): {
26
+ /** Ids of nodes whose explosion animation has finished (and not yet collapsed). */
27
+ explodedNodeIds: string[];
28
+ explodeNode: (parentNodeId: string, options: ExplodeNodeOptions<TNode, TEdge>) => boolean;
29
+ collapseNode: (parentNodeId: string, options?: CollapseNodeOptions) => boolean;
30
+ toggleExplode: (parentNodeId: string, explodeOptions: ExplodeNodeOptions<TNode, TEdge>, collapseOptions?: CollapseNodeOptions) => boolean;
31
+ /** True once the node's explosion has finished, until a collapse finishes. */
14
32
  isExploded: (parentNodeId: string) => boolean;
15
33
  getSnapshot: (parentNodeId: string) => ExplosionSnapshot<TNode, TEdge> | undefined;
16
34
  };
@@ -0,0 +1,17 @@
1
+ import { type CanvasExplosionState, type CanvasExplosionStateController, type CanvasExplosionStateOptions } from '@pixerate/editor/canvas';
2
+ export type { CanvasExplosionState, CanvasExplosionStateOptions };
3
+ export interface CanvasExplosionStateHandle extends CanvasExplosionState {
4
+ /** The framework-free controller underneath (for `canvasExplosionToolTarget` and agent tools). */
5
+ readonly controller: CanvasExplosionStateController;
6
+ }
7
+ /**
8
+ * Headless, declarative explosion state as a React hook: which node is exploded (`activeId`),
9
+ * which is still collapsing (`collapsingId`, so its children can play a collapse animation
10
+ * before unmounting), and the collapse timer. It never touches a graph: derive the canvas from
11
+ * it with `useMemo` and `computeCanvasExplosionLayout` / `calculateDirectionalDisplacement`.
12
+ * The same API and lifecycle as the Svelte `createCanvasExplosionState`.
13
+ *
14
+ * `collapseDurationMs` and `initialActiveId` are read once; the callbacks always call the latest
15
+ * props. A running collapse ends (and its timer is cleared) on unmount.
16
+ */
17
+ export declare function useCanvasExplosionState(options?: CanvasExplosionStateOptions): CanvasExplosionStateHandle;
@@ -0,0 +1,17 @@
1
+ import { type CanvasExplosionState, type CanvasExplosionStateController, type CanvasExplosionStateOptions } from '@pixerate/editor/canvas';
2
+ export type { CanvasExplosionState, CanvasExplosionStateOptions };
3
+ export interface CanvasExplosionStateHandle extends CanvasExplosionState {
4
+ /** The framework-free controller underneath (for `canvasExplosionToolTarget` and agent tools). */
5
+ readonly controller: CanvasExplosionStateController;
6
+ }
7
+ /**
8
+ * Headless, declarative explosion state as a React hook: which node is exploded (`activeId`),
9
+ * which is still collapsing (`collapsingId`, so its children can play a collapse animation
10
+ * before unmounting), and the collapse timer. It never touches a graph: derive the canvas from
11
+ * it with `useMemo` and `computeCanvasExplosionLayout` / `calculateDirectionalDisplacement`.
12
+ * The same API and lifecycle as the Svelte `createCanvasExplosionState`.
13
+ *
14
+ * `collapseDurationMs` and `initialActiveId` are read once; the callbacks always call the latest
15
+ * props. A running collapse ends (and its timer is cleared) on unmount.
16
+ */
17
+ export declare function useCanvasExplosionState(options?: CanvasExplosionStateOptions): CanvasExplosionStateHandle;
@@ -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,