@pixerate/editor-react 0.106.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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/animation-editor/index.cjs +2 -1
  3. package/dist/animation-editor/index.js +1 -1
  4. package/dist/canvas/index.cjs +2 -1
  5. package/dist/canvas/index.js +1 -1
  6. package/dist/chart/ChartDataGrid.d.cts +5 -0
  7. package/dist/chart/ChartDataGrid.d.ts +5 -0
  8. package/dist/chart/ChartInspector.d.cts +1 -1
  9. package/dist/chart/ChartInspector.d.ts +1 -1
  10. package/dist/chart/index.cjs +136 -3
  11. package/dist/chart/index.js +3 -1
  12. package/dist/{chunk-CEV4OEOY.js → chunk-6XI62THS.js} +1 -1
  13. package/dist/{chunk-FUR7LCDM.js → chunk-GJ3IMZQW.js} +152 -5
  14. package/dist/{chunk-Q7LAFHGP.js → chunk-ZQ6H2C7N.js} +2 -1
  15. package/dist/effects/EffectParameters.d.cts +4 -2
  16. package/dist/effects/EffectParameters.d.ts +4 -2
  17. package/dist/effects/index.cjs +2 -1
  18. package/dist/effects/index.js +1 -1
  19. package/dist/image-editor/index.cjs +2 -1
  20. package/dist/image-editor/index.js +2 -2
  21. package/dist/index.cjs +136 -4
  22. package/dist/index.js +3 -3
  23. package/dist/paint-editor/index.cjs +2 -1
  24. package/dist/paint-editor/index.js +1 -1
  25. package/dist/typography/FontPicker.d.cts +48 -0
  26. package/dist/typography/FontPicker.d.ts +48 -0
  27. package/dist/typography/TypographyControl.d.cts +11 -0
  28. package/dist/typography/TypographyControl.d.ts +11 -0
  29. package/dist/typography/index.cjs +328 -0
  30. package/dist/typography/index.d.cts +7 -0
  31. package/dist/typography/index.d.ts +7 -0
  32. package/dist/typography/index.js +299 -0
  33. package/dist/typography/useFontPicker.d.cts +17 -0
  34. package/dist/typography/useFontPicker.d.ts +17 -0
  35. package/dist/vector/index.cjs +2 -1
  36. package/dist/vector/index.js +1 -1
  37. package/dist/video-editor/index.cjs +2 -1
  38. package/dist/video-editor/index.js +1 -1
  39. package/package.json +16 -3
@@ -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
  };
@@ -152,10 +152,11 @@ function EffectParameters({
152
152
  onPreset,
153
153
  onPresetName,
154
154
  renderControlAddon,
155
+ fonts,
155
156
  disabled = false,
156
157
  className = ""
157
158
  }) {
158
- const fields = useMemo2(() => effectParameterFields(description), [description]);
159
+ const fields = useMemo2(() => effectParameterFields(description, { fonts }), [description, fonts]);
159
160
  const idBase = useId();
160
161
  const gesture = React3.useRef(null);
161
162
  const count = React3.useRef(0);
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type EffectDescription } from '@pixerate/editor/effects';
2
+ import { type EffectDescription, type EffectFieldOptions } from '@pixerate/editor/effects';
3
3
  import { type ParameterValue } from '@pixerate/editor/parameters';
4
4
  export interface EffectParametersProps {
5
5
  /** The effect's description (`describe`). */
@@ -21,6 +21,8 @@ export interface EffectParametersProps {
21
21
  onPresetName?: (name: string) => void;
22
22
  /** Optional addon rendered next to the control label (e.g. keyframe toggle button). */
23
23
  renderControlAddon?: (control: string) => React.ReactNode;
24
+ /** Families offered by font controls (`format: "font"`); default the system font catalog. */
25
+ fonts?: EffectFieldOptions['fonts'];
24
26
  disabled?: boolean;
25
27
  className?: string;
26
28
  }
@@ -29,4 +31,4 @@ export interface EffectParametersProps {
29
31
  * numbers, switches, choices, colour pickers, vectors and text, with each control's description,
30
32
  * per-control reset and the effect's presets.
31
33
  */
32
- export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, disabled, className }: EffectParametersProps): React.JSX.Element;
34
+ export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, fonts, disabled, className }: EffectParametersProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type EffectDescription } from '@pixerate/editor/effects';
2
+ import { type EffectDescription, type EffectFieldOptions } from '@pixerate/editor/effects';
3
3
  import { type ParameterValue } from '@pixerate/editor/parameters';
4
4
  export interface EffectParametersProps {
5
5
  /** The effect's description (`describe`). */
@@ -21,6 +21,8 @@ export interface EffectParametersProps {
21
21
  onPresetName?: (name: string) => void;
22
22
  /** Optional addon rendered next to the control label (e.g. keyframe toggle button). */
23
23
  renderControlAddon?: (control: string) => React.ReactNode;
24
+ /** Families offered by font controls (`format: "font"`); default the system font catalog. */
25
+ fonts?: EffectFieldOptions['fonts'];
24
26
  disabled?: boolean;
25
27
  className?: string;
26
28
  }
@@ -29,4 +31,4 @@ export interface EffectParametersProps {
29
31
  * numbers, switches, choices, colour pickers, vectors and text, with each control's description,
30
32
  * per-control reset and the effect's presets.
31
33
  */
32
- export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, disabled, className }: EffectParametersProps): React.JSX.Element;
34
+ export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, fonts, disabled, className }: EffectParametersProps): React.JSX.Element;
@@ -1599,10 +1599,11 @@ function EffectParameters({
1599
1599
  onPreset,
1600
1600
  onPresetName,
1601
1601
  renderControlAddon,
1602
+ fonts,
1602
1603
  disabled = false,
1603
1604
  className = ""
1604
1605
  }) {
1605
- const fields = (0, import_react8.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1606
+ const fields = (0, import_react8.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
1606
1607
  const idBase = (0, import_react8.useId)();
1607
1608
  const gesture = import_react8.default.useRef(null);
1608
1609
  const count = import_react8.default.useRef(0);
@@ -6,7 +6,7 @@ import {
6
6
  useEffectAuthoring,
7
7
  useEffectDescription,
8
8
  useEffects
9
- } from "../chunk-Q7LAFHGP.js";
9
+ } from "../chunk-ZQ6H2C7N.js";
10
10
  import "../chunk-5LFQ2UQZ.js";
11
11
  import "../chunk-KIRIU53A.js";
12
12
  import "../chunk-3I7FOSLF.js";
@@ -3677,10 +3677,11 @@ function EffectParameters({
3677
3677
  onPreset,
3678
3678
  onPresetName,
3679
3679
  renderControlAddon,
3680
+ fonts,
3680
3681
  disabled = false,
3681
3682
  className = ""
3682
3683
  }) {
3683
- const fields = (0, import_react18.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
3684
+ const fields = (0, import_react18.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3684
3685
  const idBase = (0, import_react18.useId)();
3685
3686
  const gesture = import_react18.default.useRef(null);
3686
3687
  const count = import_react18.default.useRef(0);
@@ -20,9 +20,9 @@ import {
20
20
  useImageEditor,
21
21
  useImageEffectsTools,
22
22
  useImageHistogram
23
- } from "../chunk-CEV4OEOY.js";
23
+ } from "../chunk-6XI62THS.js";
24
24
  import "../chunk-AJCWF6SN.js";
25
- import "../chunk-Q7LAFHGP.js";
25
+ import "../chunk-ZQ6H2C7N.js";
26
26
  import "../chunk-5LFQ2UQZ.js";
27
27
  import "../chunk-KIRIU53A.js";
28
28
  import "../chunk-3I7FOSLF.js";
package/dist/index.cjs CHANGED
@@ -7384,10 +7384,11 @@ function EffectParameters({
7384
7384
  onPreset,
7385
7385
  onPresetName,
7386
7386
  renderControlAddon,
7387
+ fonts,
7387
7388
  disabled = false,
7388
7389
  className = ""
7389
7390
  }) {
7390
- const fields = (0, import_react54.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
7391
+ const fields = (0, import_react54.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
7391
7392
  const idBase = (0, import_react54.useId)();
7392
7393
  const gesture = import_react54.default.useRef(null);
7393
7394
  const count = import_react54.default.useRef(0);
@@ -11450,8 +11451,60 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
11450
11451
  }
11451
11452
  );
11452
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
+ }
11453
11504
  function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
11454
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";
11455
11508
  const paste = (row, column) => (e) => {
11456
11509
  const text = e.clipboardData?.getData("text/plain") ?? "";
11457
11510
  if (!/[\t\n]/.test(text.replace(/\n$/, ""))) return;
@@ -11545,7 +11598,20 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
11545
11598
  ] }, i);
11546
11599
  }) })
11547
11600
  ] }),
11548
- !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
+ ] })
11549
11615
  ] });
11550
11616
  }
11551
11617
 
@@ -11714,7 +11780,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
11714
11780
  ] });
11715
11781
  }
11716
11782
  function ChartInspector({ controller, sections, className }) {
11717
- const { spec, selectedSeries } = useChartState(controller);
11783
+ const { spec, selectedSeries, selection } = useChartState(controller);
11718
11784
  const idBase = (0, import_react85.useId)();
11719
11785
  const show = (section) => !sections || sections.includes(section);
11720
11786
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
@@ -11727,6 +11793,9 @@ function ChartInspector({ controller, sections, className }) {
11727
11793
  const hasLines = cartesian && types.some((t) => t === "line" || t === "area");
11728
11794
  const seriesIndex = selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1;
11729
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;
11730
11799
  return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
11731
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)) }) }),
11732
11801
  show("style") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
@@ -11743,7 +11812,8 @@ function ChartInspector({ controller, sections, className }) {
11743
11812
  ] }),
11744
11813
  show("titles") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
11745
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) }) }),
11746
- /* @__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) }) })
11747
11817
  ] }),
11748
11818
  show("options") && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
11749
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 }) }) }),
@@ -11781,6 +11851,27 @@ function ChartInspector({ controller, sections, className }) {
11781
11851
  onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
11782
11852
  }
11783
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 }) }),
11784
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 }) }),
11785
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 }) }) }),
11786
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 }) }) }),
@@ -11788,6 +11879,7 @@ function ChartInspector({ controller, sections, className }) {
11788
11879
  /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
11789
11880
  spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
11790
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 }) }),
11791
11883
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
11792
11884
  ] })
11793
11885
  ] }),
@@ -11803,6 +11895,35 @@ function ChartInspector({ controller, sections, className }) {
11803
11895
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
11804
11896
  usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
11805
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
+ ] }),
11806
11927
  show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
11807
11928
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
11808
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 }) }) }),
@@ -11850,6 +11971,17 @@ function ChartInspector({ controller, sections, className }) {
11850
11971
  ]
11851
11972
  }
11852
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
+ ) }),
11853
11985
  scales && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
11854
11986
  family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
11855
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,
@@ -44,9 +44,9 @@ import {
44
44
  useImageEditor,
45
45
  useImageEffectsTools,
46
46
  useImageHistogram
47
- } from "./chunk-CEV4OEOY.js";
47
+ } from "./chunk-6XI62THS.js";
48
48
  import "./chunk-AJCWF6SN.js";
49
- import "./chunk-Q7LAFHGP.js";
49
+ import "./chunk-ZQ6H2C7N.js";
50
50
  import "./chunk-5LFQ2UQZ.js";
51
51
  import "./chunk-KIRIU53A.js";
52
52
  import "./chunk-3I7FOSLF.js";