@pixerate/editor-react 0.202.0 → 0.203.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart/ChartEditor.d.cts +3 -1
- package/dist/chart/ChartEditor.d.ts +3 -1
- package/dist/chart/ChartInspector.d.cts +3 -1
- package/dist/chart/ChartInspector.d.ts +3 -1
- package/dist/chart/index.cjs +33 -18
- package/dist/chart/index.js +3 -3
- package/dist/{chunk-VUSYAHIU.js → chunk-HOTNCOPK.js} +31 -16
- package/dist/index.cjs +47 -16
- package/dist/index.js +17 -2
- package/dist/style/useStyle.d.cts +16 -1
- package/dist/style/useStyle.d.ts +16 -1
- package/package.json +3 -3
|
@@ -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;
|
package/dist/chart/index.cjs
CHANGED
|
@@ -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.
|
|
942
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
943
|
-
|
|
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
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
"
|
|
949
|
-
className: "h-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
)
|
|
955
|
-
|
|
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
|
] });
|
package/dist/chart/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
useChartState,
|
|
23
23
|
useChartToolProvider,
|
|
24
24
|
useOfficeChartToolProvider
|
|
25
|
-
} from "../chunk-
|
|
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__ */
|
|
950
|
-
/* @__PURE__ */
|
|
951
|
-
|
|
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
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
"
|
|
957
|
-
className: "h-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
)
|
|
963
|
-
|
|
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
|
@@ -150,6 +150,7 @@ __export(src_exports, {
|
|
|
150
150
|
useStyle: () => useStyle,
|
|
151
151
|
useStyleChoices: () => useStyleChoices,
|
|
152
152
|
useStyleFindings: () => useStyleFindings,
|
|
153
|
+
useStyleSwatches: () => useStyleSwatches,
|
|
153
154
|
useTableMenu: () => useTableMenu,
|
|
154
155
|
useToolBridge: () => useToolBridge,
|
|
155
156
|
useToolRegistryView: () => useToolRegistryView,
|
|
@@ -14184,7 +14185,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
14184
14185
|
] })
|
|
14185
14186
|
] });
|
|
14186
14187
|
}
|
|
14187
|
-
function ChartInspector({ controller, sections, className }) {
|
|
14188
|
+
function ChartInspector({ controller, sections, className, swatches }) {
|
|
14188
14189
|
const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
|
|
14189
14190
|
const idBase = (0, import_react103.useId)();
|
|
14190
14191
|
const show = (section) => !sections || sections.includes(section);
|
|
@@ -14366,22 +14367,37 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
14366
14367
|
show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
|
|
14367
14368
|
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
|
|
14368
14369
|
/* @__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.
|
|
14370
|
-
/* @__PURE__ */ (0, import_jsx_runtime78.
|
|
14371
|
-
|
|
14370
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: [
|
|
14371
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
14372
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
14373
|
+
"input",
|
|
14374
|
+
{
|
|
14375
|
+
id: `${idBase}-series-color`,
|
|
14376
|
+
type: "color",
|
|
14377
|
+
value: (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)),
|
|
14378
|
+
"data-option": "series.color",
|
|
14379
|
+
className: "h-7 w-9 shrink-0 cursor-pointer rounded border border-input bg-background p-0.5",
|
|
14380
|
+
onPointerDown: () => controller.beginGesture(`color:${selectedSeries.id}`),
|
|
14381
|
+
onBlur: () => controller.endGesture(),
|
|
14382
|
+
onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
|
|
14383
|
+
}
|
|
14384
|
+
),
|
|
14385
|
+
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" })
|
|
14386
|
+
] }),
|
|
14387
|
+
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)(
|
|
14388
|
+
"button",
|
|
14372
14389
|
{
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
"
|
|
14377
|
-
className: "h-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
14382
|
-
)
|
|
14383
|
-
|
|
14384
|
-
] }) }),
|
|
14390
|
+
type: "button",
|
|
14391
|
+
title: color,
|
|
14392
|
+
"aria-label": `Use ${color}`,
|
|
14393
|
+
"aria-pressed": (0, import_chart4.chartColorInputValue)((0, import_chart4.chartSeriesColor)(spec, seriesIndex)) === (0, import_chart4.chartColorInputValue)(color),
|
|
14394
|
+
className: "h-5 w-5 rounded border border-border",
|
|
14395
|
+
style: { background: color },
|
|
14396
|
+
onClick: () => controller.updateSeries(selectedSeries.id, { color })
|
|
14397
|
+
},
|
|
14398
|
+
color
|
|
14399
|
+
)) })
|
|
14400
|
+
] }),
|
|
14385
14401
|
cartesian && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
14386
14402
|
"select",
|
|
14387
14403
|
{
|
|
@@ -14530,6 +14546,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
14530
14546
|
|
|
14531
14547
|
// src/style/useStyle.ts
|
|
14532
14548
|
var import_react104 = require("react");
|
|
14549
|
+
var import_tools5 = require("@pixerate/editor/tools");
|
|
14533
14550
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
14534
14551
|
function useResolverTask(styles, run, deliver, deps) {
|
|
14535
14552
|
(0, import_react104.useEffect)(() => {
|
|
@@ -14606,6 +14623,19 @@ function useStyleChoices(styles, scope) {
|
|
|
14606
14623
|
);
|
|
14607
14624
|
return { ...state, choose };
|
|
14608
14625
|
}
|
|
14626
|
+
function useStyleSwatches(styles, domain, scope) {
|
|
14627
|
+
const [state, setState] = (0, import_react104.useState)({ style: null, error: null });
|
|
14628
|
+
useResolverTask(
|
|
14629
|
+
styles,
|
|
14630
|
+
(s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
|
|
14631
|
+
({ value, error }) => setState({ style: value, error }),
|
|
14632
|
+
[domain, scope]
|
|
14633
|
+
);
|
|
14634
|
+
return (0, import_react104.useMemo)(() => {
|
|
14635
|
+
const { colors, fonts } = state.style ? (0, import_tools5.styleSwatches)(state.style) : { colors: [], fonts: [] };
|
|
14636
|
+
return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
|
|
14637
|
+
}, [state]);
|
|
14638
|
+
}
|
|
14609
14639
|
|
|
14610
14640
|
// src/style/StyleFindings.tsx
|
|
14611
14641
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
@@ -14781,6 +14811,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
14781
14811
|
useStyle,
|
|
14782
14812
|
useStyleChoices,
|
|
14783
14813
|
useStyleFindings,
|
|
14814
|
+
useStyleSwatches,
|
|
14784
14815
|
useTableMenu,
|
|
14785
14816
|
useToolBridge,
|
|
14786
14817
|
useToolRegistryView,
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
ChartDataGrid,
|
|
16
16
|
ChartInspector,
|
|
17
17
|
chartButtonClass
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HOTNCOPK.js";
|
|
19
19
|
import {
|
|
20
20
|
FormulaHints,
|
|
21
21
|
NameManager,
|
|
@@ -2264,7 +2264,8 @@ 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";
|
|
2268
2269
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
2269
2270
|
function useResolverTask(styles, run, deliver, deps) {
|
|
2270
2271
|
useEffect13(() => {
|
|
@@ -2341,6 +2342,19 @@ function useStyleChoices(styles, scope) {
|
|
|
2341
2342
|
);
|
|
2342
2343
|
return { ...state, choose };
|
|
2343
2344
|
}
|
|
2345
|
+
function useStyleSwatches(styles, domain, scope) {
|
|
2346
|
+
const [state, setState] = useState14({ style: null, error: null });
|
|
2347
|
+
useResolverTask(
|
|
2348
|
+
styles,
|
|
2349
|
+
(s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
|
|
2350
|
+
({ value, error }) => setState({ style: value, error }),
|
|
2351
|
+
[domain, scope]
|
|
2352
|
+
);
|
|
2353
|
+
return useMemo17(() => {
|
|
2354
|
+
const { colors, fonts } = state.style ? styleSwatches(state.style) : { colors: [], fonts: [] };
|
|
2355
|
+
return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
|
|
2356
|
+
}, [state]);
|
|
2357
|
+
}
|
|
2344
2358
|
|
|
2345
2359
|
// src/style/StyleFindings.tsx
|
|
2346
2360
|
import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
@@ -2515,6 +2529,7 @@ export {
|
|
|
2515
2529
|
useStyle,
|
|
2516
2530
|
useStyleChoices,
|
|
2517
2531
|
useStyleFindings,
|
|
2532
|
+
useStyleSwatches,
|
|
2518
2533
|
useTableMenu,
|
|
2519
2534
|
useToolBridge,
|
|
2520
2535
|
useToolRegistryView,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver } from '@pixerate/editor/tools';
|
|
1
|
+
import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
|
|
2
2
|
export interface UseStyleResult {
|
|
3
3
|
/** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
|
|
4
4
|
style: ResolvedStyle | null;
|
|
@@ -36,3 +36,18 @@ export interface UseStyleChoicesResult {
|
|
|
36
36
|
* agent makes with `choose_style` shows at once. Parity with Svelte's `useStyleChoices`.
|
|
37
37
|
*/
|
|
38
38
|
export declare function useStyleChoices(styles: StyleResolver | null | undefined, scope?: string): UseStyleChoicesResult;
|
|
39
|
+
export interface UseStyleSwatchesResult {
|
|
40
|
+
/** The house colours, in picker order (feed `ColorPicker`'s `swatches` or `ChartEditor`'s). */
|
|
41
|
+
colors: string[];
|
|
42
|
+
/** The same colours with what each is for (`primary`, `palette 2`, ...). */
|
|
43
|
+
swatches: StyleSwatch[];
|
|
44
|
+
/** The house fonts (for a font picker's suggestions). */
|
|
45
|
+
fonts: string[];
|
|
46
|
+
/** Why the last resolve failed, or `null`. */
|
|
47
|
+
error: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The colours and fonts the house style offers for one domain, for pickers. The agent's
|
|
51
|
+
* `get_style` returns the same list, so people and agents choose from one set.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
|
package/dist/style/useStyle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver } from '@pixerate/editor/tools';
|
|
1
|
+
import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
|
|
2
2
|
export interface UseStyleResult {
|
|
3
3
|
/** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
|
|
4
4
|
style: ResolvedStyle | null;
|
|
@@ -36,3 +36,18 @@ export interface UseStyleChoicesResult {
|
|
|
36
36
|
* agent makes with `choose_style` shows at once. Parity with Svelte's `useStyleChoices`.
|
|
37
37
|
*/
|
|
38
38
|
export declare function useStyleChoices(styles: StyleResolver | null | undefined, scope?: string): UseStyleChoicesResult;
|
|
39
|
+
export interface UseStyleSwatchesResult {
|
|
40
|
+
/** The house colours, in picker order (feed `ColorPicker`'s `swatches` or `ChartEditor`'s). */
|
|
41
|
+
colors: string[];
|
|
42
|
+
/** The same colours with what each is for (`primary`, `palette 2`, ...). */
|
|
43
|
+
swatches: StyleSwatch[];
|
|
44
|
+
/** The house fonts (for a font picker's suggestions). */
|
|
45
|
+
fonts: string[];
|
|
46
|
+
/** Why the last resolve failed, or `null`. */
|
|
47
|
+
error: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The colours and fonts the house style offers for one domain, for pickers. The agent's
|
|
51
|
+
* `get_style` returns the same list, so people and agents choose from one set.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.203.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.
|
|
286
|
+
"@pixerate/editor": ">=0.301.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.
|
|
337
|
+
"@pixerate/editor": "0.301.0"
|
|
338
338
|
},
|
|
339
339
|
"scripts": {
|
|
340
340
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|