@pixerate/editor-react 0.202.0 → 0.204.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.
@@ -5,6 +5,8 @@ import { type ChartCanvasProps } from './ChartCanvas.cjs';
5
5
  export interface ChartEditorProps {
6
6
  controller: ChartController;
7
7
  /** The settings sidebar (default `true`). */
8
+ /** House colours the inspector offers beside each series colour (e.g. from `useStyleSwatches`). */
9
+ swatches?: readonly string[];
8
10
  showInspector?: boolean;
9
11
  /** The data grid under the chart (default `true`). */
10
12
  showDataGrid?: boolean;
@@ -28,4 +30,4 @@ export interface ChartEditorProps {
28
30
  onPlaybackReveal?: () => void | Promise<void>;
29
31
  }
30
32
  /** Toolbar, chart, settings sidebar and data grid for a `ChartController`. */
31
- export declare function ChartEditor({ controller, showInspector, showDataGrid, showToolbar, pngOptions, height, canvasProps, className, playback, playbackId, onPlaybackReveal }: ChartEditorProps): React.JSX.Element;
33
+ export declare function ChartEditor({ controller, swatches, showInspector, showDataGrid, showToolbar, pngOptions, height, canvasProps, className, playback, playbackId, onPlaybackReveal }: ChartEditorProps): React.JSX.Element;
@@ -5,6 +5,8 @@ import { type ChartCanvasProps } from './ChartCanvas.js';
5
5
  export interface ChartEditorProps {
6
6
  controller: ChartController;
7
7
  /** The settings sidebar (default `true`). */
8
+ /** House colours the inspector offers beside each series colour (e.g. from `useStyleSwatches`). */
9
+ swatches?: readonly string[];
8
10
  showInspector?: boolean;
9
11
  /** The data grid under the chart (default `true`). */
10
12
  showDataGrid?: boolean;
@@ -28,4 +30,4 @@ export interface ChartEditorProps {
28
30
  onPlaybackReveal?: () => void | Promise<void>;
29
31
  }
30
32
  /** Toolbar, chart, settings sidebar and data grid for a `ChartController`. */
31
- export declare function ChartEditor({ controller, showInspector, showDataGrid, showToolbar, pngOptions, height, canvasProps, className, playback, playbackId, onPlaybackReveal }: ChartEditorProps): React.JSX.Element;
33
+ export declare function ChartEditor({ controller, swatches, showInspector, showDataGrid, showToolbar, pngOptions, height, canvasProps, className, playback, playbackId, onPlaybackReveal }: ChartEditorProps): React.JSX.Element;
@@ -5,10 +5,12 @@ export interface ChartInspectorProps {
5
5
  /** Which sections to show (default: all that apply to the chart). */
6
6
  sections?: readonly ChartInspectorSection[];
7
7
  className?: string;
8
+ /** House colours offered beside the series colour (e.g. from `useStyleSwatches`). */
9
+ swatches?: readonly string[];
8
10
  }
9
11
  export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'annotations' | 'series';
10
12
  /**
11
13
  * Settings for a chart controller: type, titles, stacking and line options, legend, both
12
14
  * axes and the selected series. Every change is one undo step.
13
15
  */
14
- export declare function ChartInspector({ controller, sections, className }: ChartInspectorProps): React.JSX.Element;
16
+ export declare function ChartInspector({ controller, sections, className, swatches }: ChartInspectorProps): React.JSX.Element;
@@ -5,10 +5,12 @@ export interface ChartInspectorProps {
5
5
  /** Which sections to show (default: all that apply to the chart). */
6
6
  sections?: readonly ChartInspectorSection[];
7
7
  className?: string;
8
+ /** House colours offered beside the series colour (e.g. from `useStyleSwatches`). */
9
+ swatches?: readonly string[];
8
10
  }
9
11
  export type ChartInspectorSection = 'type' | 'style' | 'titles' | 'options' | 'legend' | 'axes' | 'annotations' | 'series';
10
12
  /**
11
13
  * Settings for a chart controller: type, titles, stacking and line options, legend, both
12
14
  * axes and the selected series. Every change is one undo step.
13
15
  */
14
- export declare function ChartInspector({ controller, sections, className }: ChartInspectorProps): React.JSX.Element;
16
+ export declare function ChartInspector({ controller, sections, className, swatches }: ChartInspectorProps): React.JSX.Element;
@@ -756,7 +756,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
756
756
  ] })
757
757
  ] });
758
758
  }
759
- function ChartInspector({ controller, sections, className }) {
759
+ function ChartInspector({ controller, sections, className, swatches }) {
760
760
  const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
761
761
  const idBase = (0, import_react4.useId)();
762
762
  const show = (section) => !sections || sections.includes(section);
@@ -938,22 +938,37 @@ function ChartInspector({ controller, sections, className }) {
938
938
  show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
939
939
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
940
940
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
941
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1", children: [
942
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
943
- "input",
941
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: [
942
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1", children: [
943
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
944
+ "input",
945
+ {
946
+ id: `${idBase}-series-color`,
947
+ type: "color",
948
+ value: (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)),
949
+ "data-option": "series.color",
950
+ className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
951
+ onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
952
+ onBlur: () => controller.endGesture(),
953
+ onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
954
+ }
955
+ ),
956
+ selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
957
+ ] }),
958
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", role: "group", "aria-label": "House colours", "data-option": "series.swatches", children: swatches.map((color) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
959
+ "button",
944
960
  {
945
- id: `${idBase}-series-color`,
946
- type: "color",
947
- value: (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)),
948
- "data-option": "series.color",
949
- className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
950
- onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
951
- onBlur: () => controller.endGesture(),
952
- onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
953
- }
954
- ),
955
- selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
956
- ] }) }),
961
+ type: "button",
962
+ title: color,
963
+ "aria-label": `Use ${color}`,
964
+ "aria-pressed": (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)) === (0, import_chart4.chartColorInputValue)(color),
965
+ className: "h-5 w-5 rounded border border-border",
966
+ style: { background: color },
967
+ onClick: () => controller.updateSeries(selectedSeries.id, { color })
968
+ },
969
+ color
970
+ )) })
971
+ ] }),
957
972
  cartesian && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
958
973
  "select",
959
974
  {
@@ -1125,7 +1140,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
1125
1140
 
1126
1141
  // src/chart/ChartEditor.tsx
1127
1142
  var import_jsx_runtime6 = require("react/jsx-runtime");
1128
- function ChartEditor({ controller, showInspector = true, showDataGrid = true, showToolbar = true, pngOptions, height = 380, canvasProps, className, playback, playbackId = "chart", onPlaybackReveal }) {
1143
+ function ChartEditor({ controller, swatches, showInspector = true, showDataGrid = true, showToolbar = true, pngOptions, height = 380, canvasProps, className, playback, playbackId = "chart", onPlaybackReveal }) {
1129
1144
  const state = useChartState(controller);
1130
1145
  const rootRef = (0, import_react8.useRef)(null);
1131
1146
  const ownScene = (0, import_react8.useRef)(null);
@@ -1203,7 +1218,7 @@ function ChartEditor({ controller, showInspector = true, showDataGrid = true, sh
1203
1218
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
1204
1219
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-w-0 flex-1 rounded-md border border-border bg-background p-1", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartCanvas, { controller, height, ...canvasProps, sceneRef, presence: playing ? void 0 : canvasProps?.presence }) }),
1205
1220
  showInspector && // Side by side, the canvas sets the row's height and the inspector scrolls within it.
1206
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative w-full shrink-0 md:w-64", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartInspector, { controller, className: "overflow-y-auto rounded-md border border-border p-3 md:absolute md:inset-0" }) })
1221
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "relative w-full shrink-0 md:w-64", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartInspector, { controller, swatches, className: "overflow-y-auto rounded-md border border-border p-3 md:absolute md:inset-0" }) })
1207
1222
  ] }),
1208
1223
  showDataGrid && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartDataGrid, { controller })
1209
1224
  ] });
@@ -22,7 +22,7 @@ import {
22
22
  useChartState,
23
23
  useChartToolProvider,
24
24
  useOfficeChartToolProvider
25
- } from "../chunk-VUSYAHIU.js";
25
+ } from "../chunk-HOTNCOPK.js";
26
26
  import {
27
27
  PresenceLayer,
28
28
  useAgentPlayback,
@@ -33,7 +33,7 @@ import {
33
33
  import { useRef, useState } from "react";
34
34
  import { describeChartSelection, downloadChartPng, locateChartPoint, ChartPresence } from "@pixerate/editor/chart";
35
35
  import { jsx, jsxs } from "react/jsx-runtime";
36
- function ChartEditor({ controller, showInspector = true, showDataGrid = true, showToolbar = true, pngOptions, height = 380, canvasProps, className, playback, playbackId = "chart", onPlaybackReveal }) {
36
+ function ChartEditor({ controller, swatches, showInspector = true, showDataGrid = true, showToolbar = true, pngOptions, height = 380, canvasProps, className, playback, playbackId = "chart", onPlaybackReveal }) {
37
37
  const state = useChartState(controller);
38
38
  const rootRef = useRef(null);
39
39
  const ownScene = useRef(null);
@@ -111,7 +111,7 @@ function ChartEditor({ controller, showInspector = true, showDataGrid = true, sh
111
111
  /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
112
112
  /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 rounded-md border border-border bg-background p-1", children: /* @__PURE__ */ jsx(ChartCanvas, { controller, height, ...canvasProps, sceneRef, presence: playing ? void 0 : canvasProps?.presence }) }),
113
113
  showInspector && // Side by side, the canvas sets the row's height and the inspector scrolls within it.
114
- /* @__PURE__ */ jsx("div", { className: "relative w-full shrink-0 md:w-64", children: /* @__PURE__ */ jsx(ChartInspector, { controller, className: "overflow-y-auto rounded-md border border-border p-3 md:absolute md:inset-0" }) })
114
+ /* @__PURE__ */ jsx("div", { className: "relative w-full shrink-0 md:w-64", children: /* @__PURE__ */ jsx(ChartInspector, { controller, swatches, className: "overflow-y-auto rounded-md border border-border p-3 md:absolute md:inset-0" }) })
115
115
  ] }),
116
116
  showDataGrid && /* @__PURE__ */ jsx(ChartDataGrid, { controller })
117
117
  ] });
@@ -764,7 +764,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
764
764
  ] })
765
765
  ] });
766
766
  }
767
- function ChartInspector({ controller, sections, className }) {
767
+ function ChartInspector({ controller, sections, className, swatches }) {
768
768
  const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
769
769
  const idBase = useId();
770
770
  const show = (section) => !sections || sections.includes(section);
@@ -946,22 +946,37 @@ function ChartInspector({ controller, sections, className }) {
946
946
  show("series") && selectedSeries && /* @__PURE__ */ jsxs3("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
947
947
  /* @__PURE__ */ jsx3("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
948
948
  /* @__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 }) }) }),
949
- /* @__PURE__ */ jsx3(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
950
- /* @__PURE__ */ jsx3(
951
- "input",
949
+ /* @__PURE__ */ jsxs3(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: [
950
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
951
+ /* @__PURE__ */ jsx3(
952
+ "input",
953
+ {
954
+ id: `${idBase}-series-color`,
955
+ type: "color",
956
+ value: chartColorInputValue2(chartSeriesColor2(spec, seriesIndex)),
957
+ "data-option": "series.color",
958
+ className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
959
+ onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
960
+ onBlur: () => controller.endGesture(),
961
+ onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
962
+ }
963
+ ),
964
+ selectedSeries.color && /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
965
+ ] }),
966
+ swatches && swatches.length > 0 && /* @__PURE__ */ jsx3("div", { className: "mt-1 flex flex-wrap gap-1", role: "group", "aria-label": "House colours", "data-option": "series.swatches", children: swatches.map((color) => /* @__PURE__ */ jsx3(
967
+ "button",
952
968
  {
953
- id: `${idBase}-series-color`,
954
- type: "color",
955
- value: chartColorInputValue2(chartSeriesColor2(spec, seriesIndex)),
956
- "data-option": "series.color",
957
- className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
958
- onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
959
- onBlur: () => controller.endGesture(),
960
- onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
961
- }
962
- ),
963
- selectedSeries.color && /* @__PURE__ */ jsx3("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
964
- ] }) }),
969
+ type: "button",
970
+ title: color,
971
+ "aria-label": `Use ${color}`,
972
+ "aria-pressed": chartColorInputValue2(chartSeriesColor2(spec, seriesIndex)) === chartColorInputValue2(color),
973
+ className: "h-5 w-5 rounded border border-border",
974
+ style: { background: color },
975
+ onClick: () => controller.updateSeries(selectedSeries.id, { color })
976
+ },
977
+ color
978
+ )) })
979
+ ] }),
965
980
  cartesian && /* @__PURE__ */ jsx3(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ jsxs3(
966
981
  "select",
967
982
  {
package/dist/index.cjs CHANGED
@@ -45,7 +45,7 @@ __export(src_exports, {
45
45
  ContentAwareFillWorkspace: () => ContentAwareFillWorkspace,
46
46
  ControlSlider: () => ControlSlider,
47
47
  CurvesEditor: () => CurvesEditor,
48
- DirtyTracker: () => import_editor23.DirtyTracker,
48
+ DirtyTracker: () => import_editor24.DirtyTracker,
49
49
  EdgeColorPanel: () => EdgeColorPanel,
50
50
  EditorContent: () => EditorContent,
51
51
  EditorSlotsProvider: () => EditorSlotsProvider,
@@ -56,7 +56,7 @@ __export(src_exports, {
56
56
  GenerationHistory: () => GenerationHistory,
57
57
  GenerationSettings: () => GenerationSettings,
58
58
  Histogram: () => Histogram,
59
- HistoryManager: () => import_editor23.HistoryManager,
59
+ HistoryManager: () => import_editor24.HistoryManager,
60
60
  ImageCheckbox: () => ImageCheckbox,
61
61
  ImageColor: () => ImageColor,
62
62
  ImageEditor: () => ImageEditor,
@@ -102,13 +102,13 @@ __export(src_exports, {
102
102
  TypeOptionsBar: () => TypeOptionsBar,
103
103
  VariableForm: () => VariableForm,
104
104
  VectorMaskEdgesPanel: () => VectorMaskEdgesPanel,
105
- bindDirtyToHistory: () => import_editor23.bindDirtyToHistory,
106
- createDirtyTracker: () => import_editor23.createDirtyTracker,
107
- createHistoryManager: () => import_editor23.createHistoryManager,
105
+ bindDirtyToHistory: () => import_editor24.bindDirtyToHistory,
106
+ createDirtyTracker: () => import_editor24.createDirtyTracker,
107
+ createHistoryManager: () => import_editor24.createHistoryManager,
108
108
  createReactChartNodeView: () => createReactChartNodeView,
109
109
  createReactLoadingNodeView: () => createReactLoadingNodeView,
110
- defaultIsEqual: () => import_editor23.defaultIsEqual,
111
- formatCommandsFor: () => import_editor22.formatCommandsFor,
110
+ defaultIsEqual: () => import_editor24.defaultIsEqual,
111
+ formatCommandsFor: () => import_editor23.formatCommandsFor,
112
112
  useAgentPlayback: () => useAgentPlayback,
113
113
  useAgentToolProvider: () => useAgentToolProvider,
114
114
  useAutosave: () => useAutosave,
@@ -144,17 +144,19 @@ __export(src_exports, {
144
144
  usePromptEditor: () => usePromptEditor,
145
145
  useRegisterCommands: () => useRegisterCommands,
146
146
  useRichTextEditorDocument: () => useRichTextEditorDocument,
147
+ useRichTextStyleFindings: () => useRichTextStyleFindings,
147
148
  useSpreadsheetClipboard: () => useSpreadsheetClipboard,
148
149
  useSpreadsheetEditor: () => useSpreadsheetEditor,
149
150
  useSpreadsheetViewport: () => useSpreadsheetViewport,
150
151
  useStyle: () => useStyle,
151
152
  useStyleChoices: () => useStyleChoices,
152
153
  useStyleFindings: () => useStyleFindings,
154
+ useStyleSwatches: () => useStyleSwatches,
153
155
  useTableMenu: () => useTableMenu,
154
156
  useToolBridge: () => useToolBridge,
155
157
  useToolRegistryView: () => useToolRegistryView,
156
158
  useTrackChanges: () => useTrackChanges,
157
- withoutDirty: () => import_editor23.withoutDirty
159
+ withoutDirty: () => import_editor24.withoutDirty
158
160
  });
159
161
  module.exports = __toCommonJS(src_exports);
160
162
 
@@ -256,7 +258,7 @@ function useEditor2(options = {}) {
256
258
  }
257
259
 
258
260
  // src/index.ts
259
- var import_editor22 = require("@pixerate/editor");
261
+ var import_editor23 = require("@pixerate/editor");
260
262
 
261
263
  // src/hooks/useNavigationGuard.ts
262
264
  var import_react4 = require("react");
@@ -1552,7 +1554,7 @@ var StylesGallery = ({
1552
1554
  };
1553
1555
 
1554
1556
  // src/index.ts
1555
- var import_editor23 = require("@pixerate/editor");
1557
+ var import_editor24 = require("@pixerate/editor");
1556
1558
 
1557
1559
  // src/spreadsheet/useSpreadsheetEditor.ts
1558
1560
  var import_react28 = require("react");
@@ -14184,7 +14186,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
14184
14186
  ] })
14185
14187
  ] });
14186
14188
  }
14187
- function ChartInspector({ controller, sections, className }) {
14189
+ function ChartInspector({ controller, sections, className, swatches }) {
14188
14190
  const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
14189
14191
  const idBase = (0, import_react103.useId)();
14190
14192
  const show = (section) => !sections || sections.includes(section);
@@ -14366,22 +14368,37 @@ function ChartInspector({ controller, sections, className }) {
14366
14368
  show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
14367
14369
  /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
14368
14370
  /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
14369
- /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex items-center gap-1", children: [
14370
- /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14371
- "input",
14371
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: [
14372
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex items-center gap-1", children: [
14373
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14374
+ "input",
14375
+ {
14376
+ id: `${idBase}-series-color`,
14377
+ type: "color",
14378
+ value: (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)),
14379
+ "data-option": "series.color",
14380
+ className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
14381
+ onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
14382
+ onBlur: () => controller.endGesture(),
14383
+ onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
14384
+ }
14385
+ ),
14386
+ selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
14387
+ ] }),
14388
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", role: "group", "aria-label": "House colours", "data-option": "series.swatches", children: swatches.map((color) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14389
+ "button",
14372
14390
  {
14373
- id: `${idBase}-series-color`,
14374
- type: "color",
14375
- value: (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)),
14376
- "data-option": "series.color",
14377
- className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
14378
- onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
14379
- onBlur: () => controller.endGesture(),
14380
- onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
14381
- }
14382
- ),
14383
- selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
14384
- ] }) }),
14391
+ type: "button",
14392
+ title: color,
14393
+ "aria-label": `Use ${color}`,
14394
+ "aria-pressed": (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)) === (0, import_chart4.chartColorInputValue)(color),
14395
+ className: "h-5 w-5 rounded border border-border",
14396
+ style: { background: color },
14397
+ onClick: () => controller.updateSeries(selectedSeries.id, { color })
14398
+ },
14399
+ color
14400
+ )) })
14401
+ ] }),
14385
14402
  cartesian && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
14386
14403
  "select",
14387
14404
  {
@@ -14530,6 +14547,8 @@ function createReactChartNodeView(options = {}) {
14530
14547
 
14531
14548
  // src/style/useStyle.ts
14532
14549
  var import_react104 = require("react");
14550
+ var import_tools5 = require("@pixerate/editor/tools");
14551
+ var import_editor22 = require("@pixerate/editor");
14533
14552
  var message = (error) => error instanceof Error ? error.message : String(error);
14534
14553
  function useResolverTask(styles, run, deliver, deps) {
14535
14554
  (0, import_react104.useEffect)(() => {
@@ -14568,11 +14587,11 @@ function useStyle(styles, domain) {
14568
14587
  );
14569
14588
  return result;
14570
14589
  }
14571
- function useStyleFindings(styles, domain, state) {
14590
+ function useStyleFindings(styles, domain, state, scope) {
14572
14591
  const [result, setResult] = (0, import_react104.useState)({ report: null, style: null, error: null });
14573
14592
  useResolverTask(
14574
14593
  styles,
14575
- (s) => s.check(domain, state),
14594
+ (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
14576
14595
  ({ value, error }) => {
14577
14596
  if (!value) setResult({ report: null, style: null, error });
14578
14597
  else {
@@ -14580,7 +14599,7 @@ function useStyleFindings(styles, domain, state) {
14580
14599
  setResult({ report, style, error: null });
14581
14600
  }
14582
14601
  },
14583
- [domain, state]
14602
+ [domain, state, scope]
14584
14603
  );
14585
14604
  return result;
14586
14605
  }
@@ -14606,6 +14625,36 @@ function useStyleChoices(styles, scope) {
14606
14625
  );
14607
14626
  return { ...state, choose };
14608
14627
  }
14628
+ function useStyleSwatches(styles, domain, scope) {
14629
+ const [state, setState] = (0, import_react104.useState)({ style: null, error: null });
14630
+ useResolverTask(
14631
+ styles,
14632
+ (s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
14633
+ ({ value, error }) => setState({ style: value, error }),
14634
+ [domain, scope]
14635
+ );
14636
+ return (0, import_react104.useMemo)(() => {
14637
+ const { colors, fonts } = state.style ? (0, import_tools5.styleSwatches)(state.style) : { colors: [], fonts: [] };
14638
+ return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
14639
+ }, [state]);
14640
+ }
14641
+ function useRichTextStyleFindings(styles, editor, scope) {
14642
+ const [doc, setDoc] = (0, import_react104.useState)(() => editor?.state.doc ?? null);
14643
+ (0, import_react104.useEffect)(() => {
14644
+ if (!editor) {
14645
+ setDoc(null);
14646
+ return;
14647
+ }
14648
+ setDoc(editor.state.doc);
14649
+ const onUpdate = () => setDoc(editor.state.doc);
14650
+ editor.on("update", onUpdate);
14651
+ return () => {
14652
+ editor.off("update", onUpdate);
14653
+ };
14654
+ }, [editor]);
14655
+ const state = (0, import_react104.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
14656
+ return useStyleFindings(state ? styles : null, "rich-text", state, scope);
14657
+ }
14609
14658
 
14610
14659
  // src/style/StyleFindings.tsx
14611
14660
  var import_jsx_runtime80 = require("react/jsx-runtime");
@@ -14775,12 +14824,14 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
14775
14824
  usePromptEditor,
14776
14825
  useRegisterCommands,
14777
14826
  useRichTextEditorDocument,
14827
+ useRichTextStyleFindings,
14778
14828
  useSpreadsheetClipboard,
14779
14829
  useSpreadsheetEditor,
14780
14830
  useSpreadsheetViewport,
14781
14831
  useStyle,
14782
14832
  useStyleChoices,
14783
14833
  useStyleFindings,
14834
+ useStyleSwatches,
14784
14835
  useTableMenu,
14785
14836
  useToolBridge,
14786
14837
  useToolRegistryView,
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  ChartDataGrid,
16
16
  ChartInspector,
17
17
  chartButtonClass
18
- } from "./chunk-VUSYAHIU.js";
18
+ } from "./chunk-HOTNCOPK.js";
19
19
  import {
20
20
  FormulaHints,
21
21
  NameManager,
@@ -2264,7 +2264,9 @@ function createReactChartNodeView(options = {}) {
2264
2264
  }
2265
2265
 
2266
2266
  // src/style/useStyle.ts
2267
- import { useCallback as useCallback9, useEffect as useEffect13, useState as useState14 } from "react";
2267
+ import { useCallback as useCallback9, useEffect as useEffect13, useMemo as useMemo17, useState as useState14 } from "react";
2268
+ import { styleSwatches } from "@pixerate/editor/tools";
2269
+ import { richTextStyleState } from "@pixerate/editor";
2268
2270
  var message = (error) => error instanceof Error ? error.message : String(error);
2269
2271
  function useResolverTask(styles, run, deliver, deps) {
2270
2272
  useEffect13(() => {
@@ -2303,11 +2305,11 @@ function useStyle(styles, domain) {
2303
2305
  );
2304
2306
  return result;
2305
2307
  }
2306
- function useStyleFindings(styles, domain, state) {
2308
+ function useStyleFindings(styles, domain, state, scope) {
2307
2309
  const [result, setResult] = useState14({ report: null, style: null, error: null });
2308
2310
  useResolverTask(
2309
2311
  styles,
2310
- (s) => s.check(domain, state),
2312
+ (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
2311
2313
  ({ value, error }) => {
2312
2314
  if (!value) setResult({ report: null, style: null, error });
2313
2315
  else {
@@ -2315,7 +2317,7 @@ function useStyleFindings(styles, domain, state) {
2315
2317
  setResult({ report, style, error: null });
2316
2318
  }
2317
2319
  },
2318
- [domain, state]
2320
+ [domain, state, scope]
2319
2321
  );
2320
2322
  return result;
2321
2323
  }
@@ -2341,6 +2343,36 @@ function useStyleChoices(styles, scope) {
2341
2343
  );
2342
2344
  return { ...state, choose };
2343
2345
  }
2346
+ function useStyleSwatches(styles, domain, scope) {
2347
+ const [state, setState] = useState14({ style: null, error: null });
2348
+ useResolverTask(
2349
+ styles,
2350
+ (s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
2351
+ ({ value, error }) => setState({ style: value, error }),
2352
+ [domain, scope]
2353
+ );
2354
+ return useMemo17(() => {
2355
+ const { colors, fonts } = state.style ? styleSwatches(state.style) : { colors: [], fonts: [] };
2356
+ return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
2357
+ }, [state]);
2358
+ }
2359
+ function useRichTextStyleFindings(styles, editor, scope) {
2360
+ const [doc, setDoc] = useState14(() => editor?.state.doc ?? null);
2361
+ useEffect13(() => {
2362
+ if (!editor) {
2363
+ setDoc(null);
2364
+ return;
2365
+ }
2366
+ setDoc(editor.state.doc);
2367
+ const onUpdate = () => setDoc(editor.state.doc);
2368
+ editor.on("update", onUpdate);
2369
+ return () => {
2370
+ editor.off("update", onUpdate);
2371
+ };
2372
+ }, [editor]);
2373
+ const state = useMemo17(() => doc ? richTextStyleState(doc) : null, [doc]);
2374
+ return useStyleFindings(state ? styles : null, "rich-text", state, scope);
2375
+ }
2344
2376
 
2345
2377
  // src/style/StyleFindings.tsx
2346
2378
  import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
@@ -2509,12 +2541,14 @@ export {
2509
2541
  usePromptEditor,
2510
2542
  useRegisterCommands,
2511
2543
  useRichTextEditorDocument,
2544
+ useRichTextStyleFindings,
2512
2545
  useSpreadsheetClipboard,
2513
2546
  useSpreadsheetEditor,
2514
2547
  useSpreadsheetViewport,
2515
2548
  useStyle,
2516
2549
  useStyleChoices,
2517
2550
  useStyleFindings,
2551
+ useStyleSwatches,
2518
2552
  useTableMenu,
2519
2553
  useToolBridge,
2520
2554
  useToolRegistryView,
@@ -1,4 +1,5 @@
1
- import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver } from '@pixerate/editor/tools';
1
+ import type { Editor } from '@tiptap/core';
2
+ import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
2
3
  export interface UseStyleResult {
3
4
  /** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
4
5
  style: ResolvedStyle | null;
@@ -19,7 +20,7 @@ export declare function useStyle(styles: StyleResolver | null | undefined, domai
19
20
  * changes by reference, the domain or resolver changes, or the resolver notifies. Results of
20
21
  * older runs that settle late are ignored. Feed `report` to `<StyleFindings>`.
21
22
  */
22
- export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown): UseStyleFindingsResult;
23
+ export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown, scope?: string): UseStyleFindingsResult;
23
24
  export interface UseStyleChoicesResult {
24
25
  /** The one-of-a-kind groups (a look, a theme) with the chosen skill and every option, or `null` before the first read. */
25
26
  groups: StyleChoiceGroup[] | null;
@@ -36,3 +37,25 @@ export interface UseStyleChoicesResult {
36
37
  * agent makes with `choose_style` shows at once. Parity with Svelte's `useStyleChoices`.
37
38
  */
38
39
  export declare function useStyleChoices(styles: StyleResolver | null | undefined, scope?: string): UseStyleChoicesResult;
40
+ export interface UseStyleSwatchesResult {
41
+ /** The house colours, in picker order (feed `ColorPicker`'s `swatches` or `ChartEditor`'s). */
42
+ colors: string[];
43
+ /** The same colours with what each is for (`primary`, `palette 2`, ...). */
44
+ swatches: StyleSwatch[];
45
+ /** The house fonts (for a font picker's suggestions). */
46
+ fonts: string[];
47
+ /** Why the last resolve failed, or `null`. */
48
+ error: string | null;
49
+ }
50
+ /**
51
+ * The colours and fonts the house style offers for one domain, for pickers. The agent's
52
+ * `get_style` returns the same list, so people and agents choose from one set.
53
+ */
54
+ export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
55
+ /**
56
+ * The document house-style findings for a TipTap editor (`rich-text` domain), re-checked after
57
+ * every edit. Feed `report` to `<StyleFindings>`; each finding's `target` is a `{ from, to }`
58
+ * range (with `replacement` when the fix is certain). Parity with Svelte's
59
+ * `useRichTextStyleFindings`.
60
+ */
61
+ export declare function useRichTextStyleFindings(styles: StyleResolver | null | undefined, editor: Editor | null | undefined, scope?: string): UseStyleFindingsResult;
@@ -1,4 +1,5 @@
1
- import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver } from '@pixerate/editor/tools';
1
+ import type { Editor } from '@tiptap/core';
2
+ import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
2
3
  export interface UseStyleResult {
3
4
  /** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
4
5
  style: ResolvedStyle | null;
@@ -19,7 +20,7 @@ export declare function useStyle(styles: StyleResolver | null | undefined, domai
19
20
  * changes by reference, the domain or resolver changes, or the resolver notifies. Results of
20
21
  * older runs that settle late are ignored. Feed `report` to `<StyleFindings>`.
21
22
  */
22
- export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown): UseStyleFindingsResult;
23
+ export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown, scope?: string): UseStyleFindingsResult;
23
24
  export interface UseStyleChoicesResult {
24
25
  /** The one-of-a-kind groups (a look, a theme) with the chosen skill and every option, or `null` before the first read. */
25
26
  groups: StyleChoiceGroup[] | null;
@@ -36,3 +37,25 @@ export interface UseStyleChoicesResult {
36
37
  * agent makes with `choose_style` shows at once. Parity with Svelte's `useStyleChoices`.
37
38
  */
38
39
  export declare function useStyleChoices(styles: StyleResolver | null | undefined, scope?: string): UseStyleChoicesResult;
40
+ export interface UseStyleSwatchesResult {
41
+ /** The house colours, in picker order (feed `ColorPicker`'s `swatches` or `ChartEditor`'s). */
42
+ colors: string[];
43
+ /** The same colours with what each is for (`primary`, `palette 2`, ...). */
44
+ swatches: StyleSwatch[];
45
+ /** The house fonts (for a font picker's suggestions). */
46
+ fonts: string[];
47
+ /** Why the last resolve failed, or `null`. */
48
+ error: string | null;
49
+ }
50
+ /**
51
+ * The colours and fonts the house style offers for one domain, for pickers. The agent's
52
+ * `get_style` returns the same list, so people and agents choose from one set.
53
+ */
54
+ export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
55
+ /**
56
+ * The document house-style findings for a TipTap editor (`rich-text` domain), re-checked after
57
+ * every edit. Feed `report` to `<StyleFindings>`; each finding's `target` is a `{ from, to }`
58
+ * range (with `replacement` when the fix is certain). Parity with Svelte's
59
+ * `useRichTextStyleFindings`.
60
+ */
61
+ export declare function useRichTextStyleFindings(styles: StyleResolver | null | undefined, editor: Editor | null | undefined, scope?: string): UseStyleFindingsResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.202.0",
3
+ "version": "0.204.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -283,7 +283,7 @@
283
283
  "dependencies": {},
284
284
  "peerDependencies": {
285
285
  "@dagrejs/dagre": "^1.1.8",
286
- "@pixerate/editor": ">=0.299.0 <1.0.0-0",
286
+ "@pixerate/editor": ">=0.302.0 <1.0.0-0",
287
287
  "@tiptap/core": "^2.27.3",
288
288
  "@tiptap/extension-bubble-menu": "^2.27.3",
289
289
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -334,7 +334,7 @@
334
334
  "tsup": "^9.0.0",
335
335
  "typescript": "^5.7.3",
336
336
  "vitest": "^5.1.0",
337
- "@pixerate/editor": "0.299.0"
337
+ "@pixerate/editor": "0.302.0"
338
338
  },
339
339
  "scripts": {
340
340
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",