@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.
@@ -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.109.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.164.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.164.0"
289
289
  },
290
290
  "scripts": {
291
291
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",