@pixerate/editor-react 0.113.2 → 0.114.1

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/README.md CHANGED
@@ -4,6 +4,9 @@ React bindings for [`@pixerate/editor`](https://www.npmjs.com/package/@pixerate/
4
4
 
5
5
  ```bash
6
6
  npm install @pixerate/editor-react @pixerate/editor react react-dom
7
+ # only if you use the rich-text or prompt editors (the root entry): TipTap, and the rich-text peers
8
+ # listed in the @pixerate/editor README
9
+ npm install @tiptap/react @tiptap/extension-bubble-menu @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/extension-placeholder
7
10
  # only if you use @pixerate/editor-react/canvas:
8
11
  npm install @xyflow/react @dagrejs/dagre
9
12
  ```
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type ChartController, type ChartMark, type ChartPresence, type ChartScene, type ChartTextMeasure, type ChartTheme } from '@pixerate/editor/chart';
2
+ import { type ChartController, type ChartMark, type ChartPresence, type ChartScene, type ChartTextMeasure, type ChartTheme, type ChartTooltip, type ChartTooltipMode } from '@pixerate/editor/chart';
3
3
  export interface ChartCanvasProps {
4
4
  controller: ChartController;
5
5
  /** Scene width; with `responsive` this is only the fallback before the container is measured (default 640). */
@@ -22,6 +22,10 @@ export interface ChartCanvasProps {
22
22
  sceneRef?: {
23
23
  current: ChartScene | null;
24
24
  };
25
+ /** Show a tooltip on hover: `point` (or `true`) for the bar, point or slice under the pointer, `category` for every series in the category under it (default off). */
26
+ tooltip?: boolean | ChartTooltipMode;
27
+ /** Draws the tooltip's content instead of the category label and one row per series. */
28
+ renderTooltip?: (tooltip: ChartTooltip) => React.ReactNode;
25
29
  }
26
30
  /** SVG attributes for one mark (colours go in `style` so CSS variables work). */
27
31
  export declare function renderChartMark(mark: ChartMark, fontFamily: string, interactive: boolean): React.ReactNode;
@@ -41,4 +45,4 @@ export declare function ChartSceneSvg({ scene, label, className }: {
41
45
  * charts, Ctrl / ⌘ to skip snapping, Escape to cancel), and with the chart focused use
42
46
  * ← → ↑ ↓, Delete and Escape (see `handleChartKey`).
43
47
  */
44
- export declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className, presence, sceneRef }: ChartCanvasProps): React.JSX.Element;
48
+ export declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className, presence, sceneRef, tooltip, renderTooltip }: ChartCanvasProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type ChartController, type ChartMark, type ChartPresence, type ChartScene, type ChartTextMeasure, type ChartTheme } from '@pixerate/editor/chart';
2
+ import { type ChartController, type ChartMark, type ChartPresence, type ChartScene, type ChartTextMeasure, type ChartTheme, type ChartTooltip, type ChartTooltipMode } from '@pixerate/editor/chart';
3
3
  export interface ChartCanvasProps {
4
4
  controller: ChartController;
5
5
  /** Scene width; with `responsive` this is only the fallback before the container is measured (default 640). */
@@ -22,6 +22,10 @@ export interface ChartCanvasProps {
22
22
  sceneRef?: {
23
23
  current: ChartScene | null;
24
24
  };
25
+ /** Show a tooltip on hover: `point` (or `true`) for the bar, point or slice under the pointer, `category` for every series in the category under it (default off). */
26
+ tooltip?: boolean | ChartTooltipMode;
27
+ /** Draws the tooltip's content instead of the category label and one row per series. */
28
+ renderTooltip?: (tooltip: ChartTooltip) => React.ReactNode;
25
29
  }
26
30
  /** SVG attributes for one mark (colours go in `style` so CSS variables work). */
27
31
  export declare function renderChartMark(mark: ChartMark, fontFamily: string, interactive: boolean): React.ReactNode;
@@ -41,4 +45,4 @@ export declare function ChartSceneSvg({ scene, label, className }: {
41
45
  * charts, Ctrl / ⌘ to skip snapping, Escape to cancel), and with the chart focused use
42
46
  * ← → ↑ ↓, Delete and Escape (see `handleChartKey`).
43
47
  */
44
- export declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className, presence, sceneRef }: ChartCanvasProps): React.JSX.Element;
48
+ export declare function ChartCanvas({ controller, width, height, responsive, theme, editable, measureText, emptyMessage, className, presence, sceneRef, tooltip, renderTooltip }: ChartCanvasProps): React.JSX.Element;
@@ -215,16 +215,29 @@ function ChartPresenceLayer({ presence }) {
215
215
  ] })
216
216
  ] }, a.id)) });
217
217
  }
218
+ function ChartTooltipContent({ tooltip }) {
219
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
220
+ tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
221
+ tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
223
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
224
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
225
+ ] }, item.seriesId))
226
+ ] });
227
+ }
218
228
  function ChartSceneSvg({ scene, label, className }) {
219
229
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: scene.width, height: scene.height, viewBox: `0 0 ${scene.width} ${scene.height}`, role: "img", "aria-label": label, className: `block max-w-full ${className ?? ""}`, children: scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, false)) });
220
230
  }
221
- function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef }) {
231
+ function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
222
232
  const state = useChartState(controller);
223
233
  const wrapper = (0, import_react2.useRef)(null);
224
234
  const svg = (0, import_react2.useRef)(null);
225
235
  const drag = (0, import_react2.useRef)(null);
226
236
  const [measured, setMeasured] = (0, import_react2.useState)(null);
227
237
  const [frozen, setFrozen] = (0, import_react2.useState)(null);
238
+ const tooltipMode = tooltip === true ? "point" : tooltip || null;
239
+ const [tip, setTip] = (0, import_react2.useState)(null);
240
+ const [tipAt, setTipAt] = (0, import_react2.useState)({ left: 0, top: 0, flip: false });
228
241
  (0, import_react2.useEffect)(() => {
229
242
  const el = wrapper.current;
230
243
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
@@ -265,12 +278,26 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
265
278
  drag.current = (0, import_chart2.startChartPointDrag)(controller, scene, target, scenePoint(e));
266
279
  if (drag.current) {
267
280
  const d = drag.current;
281
+ setTip(null);
268
282
  setFrozen({ valueDomain: d.valueDomain, valueDomain2: d.valueDomain2 ?? null, xDomain: d.xDomain ?? null, readout: d.target });
269
283
  svg.current?.setPointerCapture?.(e.pointerId);
270
284
  }
271
285
  };
272
286
  const onPointerMove = (e) => {
273
287
  if (drag.current) drag.current.move(scenePoint(e), { fine: e.altKey, lockAxis: e.shiftKey, noSnap: e.ctrlKey || e.metaKey });
288
+ hover(e);
289
+ };
290
+ const hover = (e) => {
291
+ if (!tooltipMode || drag.current || !wrapper.current) {
292
+ setTip(null);
293
+ return;
294
+ }
295
+ const next = (0, import_chart2.chartTooltipAt)(state.spec, scene, scenePoint(e), { mode: tooltipMode, measureText });
296
+ setTip((prev) => (0, import_chart2.sameChartTooltip)(prev, next) ? prev : next);
297
+ if (!next) return;
298
+ const box = wrapper.current.getBoundingClientRect();
299
+ const left = e.clientX - box.left;
300
+ setTipAt({ left, top: e.clientY - box.top, flip: left > box.width * 0.6 });
274
301
  };
275
302
  const endDrag = () => {
276
303
  drag.current?.end();
@@ -288,28 +315,49 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
288
315
  if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
289
316
  };
290
317
  const label = state.spec.title || "Chart";
291
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: wrapper, className: `w-full ${className ?? ""}`, "data-chart-canvas": "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
292
- "svg",
293
- {
294
- ref: svg,
295
- width: sceneWidth,
296
- height,
297
- viewBox: `0 0 ${scene.width} ${scene.height}`,
298
- role: "img",
299
- "aria-label": editable ? `${label}. ${(0, import_chart2.describeChartSelection)(controller, state.selection)}` : label,
300
- tabIndex: editable ? 0 : void 0,
301
- className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
302
- onPointerDown,
303
- onPointerMove,
304
- onPointerUp: endDrag,
305
- onPointerCancel: endDrag,
306
- onKeyDown,
307
- children: [
308
- scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
309
- presence && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartPresenceLayer, { presence })
310
- ]
311
- }
312
- ) });
318
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
320
+ "svg",
321
+ {
322
+ ref: svg,
323
+ width: sceneWidth,
324
+ height,
325
+ viewBox: `0 0 ${scene.width} ${scene.height}`,
326
+ role: "img",
327
+ "aria-label": editable ? `${label}. ${(0, import_chart2.describeChartSelection)(controller, state.selection)}` : label,
328
+ tabIndex: editable ? 0 : void 0,
329
+ className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
330
+ onPointerDown,
331
+ onPointerMove,
332
+ onPointerUp: endDrag,
333
+ onPointerCancel: endDrag,
334
+ onPointerLeave: () => setTip(null),
335
+ onKeyDown,
336
+ children: [
337
+ scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
338
+ presence && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartPresenceLayer, { presence })
339
+ ]
340
+ }
341
+ ),
342
+ tip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
343
+ "div",
344
+ {
345
+ role: "tooltip",
346
+ "data-chart-tooltip": "",
347
+ className: "pointer-events-none absolute z-10 min-w-32 rounded-md border px-2.5 py-1.5 text-xs shadow-md",
348
+ style: {
349
+ left: tipAt.left,
350
+ top: tipAt.top,
351
+ transform: `translate(${tipAt.flip ? "calc(-100% - 12px)" : "12px"}, calc(-100% - 8px))`,
352
+ background: "var(--popover, #ffffff)",
353
+ color: "var(--popover-foreground, #0f172a)",
354
+ borderColor: "var(--border, #e2e8f0)",
355
+ fontFamily: scene.theme.fontFamily
356
+ },
357
+ children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartTooltipContent, { tooltip: tip })
358
+ }
359
+ )
360
+ ] });
313
361
  }
314
362
 
315
363
  // src/chart/ChartDataGrid.tsx
@@ -22,7 +22,7 @@ import {
22
22
  useChartState,
23
23
  useChartToolProvider,
24
24
  useOfficeChartToolProvider
25
- } from "../chunk-3MUK5ASL.js";
25
+ } from "../chunk-N2F53ESC.js";
26
26
  import {
27
27
  PresenceLayer,
28
28
  useAgentPlayback,
@@ -101,13 +101,15 @@ import {
101
101
  CSS_VARIABLE_CHART_THEME,
102
102
  chartClientToScene,
103
103
  chartTextBaseline,
104
+ chartTooltipAt,
104
105
  chartTextTransform,
105
106
  describeChartSelection,
106
107
  handleChartKey,
107
108
  layoutChart as layoutChart2,
109
+ sameChartTooltip,
108
110
  startChartPointDrag
109
111
  } from "@pixerate/editor/chart";
110
- import { jsx, jsxs } from "react/jsx-runtime";
112
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
111
113
  function renderChartMark(mark, fontFamily, interactive) {
112
114
  const common = {
113
115
  "data-role": mark.role,
@@ -164,16 +166,29 @@ function ChartPresenceLayer({ presence }) {
164
166
  ] })
165
167
  ] }, a.id)) });
166
168
  }
169
+ function ChartTooltipContent({ tooltip }) {
170
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
171
+ tooltip.title && /* @__PURE__ */ jsx("div", { className: "mb-1 font-medium", children: tooltip.title }),
172
+ tooltip.items.map((item) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
173
+ /* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
174
+ /* @__PURE__ */ jsx("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
175
+ /* @__PURE__ */ jsx("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
176
+ ] }, item.seriesId))
177
+ ] });
178
+ }
167
179
  function ChartSceneSvg({ scene, label, className }) {
168
180
  return /* @__PURE__ */ jsx("svg", { width: scene.width, height: scene.height, viewBox: `0 0 ${scene.width} ${scene.height}`, role: "img", "aria-label": label, className: `block max-w-full ${className ?? ""}`, children: scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, false)) });
169
181
  }
170
- function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef }) {
182
+ function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
171
183
  const state = useChartState(controller);
172
184
  const wrapper = useRef2(null);
173
185
  const svg = useRef2(null);
174
186
  const drag = useRef2(null);
175
187
  const [measured, setMeasured] = useState(null);
176
188
  const [frozen, setFrozen] = useState(null);
189
+ const tooltipMode = tooltip === true ? "point" : tooltip || null;
190
+ const [tip, setTip] = useState(null);
191
+ const [tipAt, setTipAt] = useState({ left: 0, top: 0, flip: false });
177
192
  useEffect2(() => {
178
193
  const el = wrapper.current;
179
194
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
@@ -214,12 +229,26 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
214
229
  drag.current = startChartPointDrag(controller, scene, target, scenePoint(e));
215
230
  if (drag.current) {
216
231
  const d = drag.current;
232
+ setTip(null);
217
233
  setFrozen({ valueDomain: d.valueDomain, valueDomain2: d.valueDomain2 ?? null, xDomain: d.xDomain ?? null, readout: d.target });
218
234
  svg.current?.setPointerCapture?.(e.pointerId);
219
235
  }
220
236
  };
221
237
  const onPointerMove = (e) => {
222
238
  if (drag.current) drag.current.move(scenePoint(e), { fine: e.altKey, lockAxis: e.shiftKey, noSnap: e.ctrlKey || e.metaKey });
239
+ hover(e);
240
+ };
241
+ const hover = (e) => {
242
+ if (!tooltipMode || drag.current || !wrapper.current) {
243
+ setTip(null);
244
+ return;
245
+ }
246
+ const next = chartTooltipAt(state.spec, scene, scenePoint(e), { mode: tooltipMode, measureText });
247
+ setTip((prev) => sameChartTooltip(prev, next) ? prev : next);
248
+ if (!next) return;
249
+ const box = wrapper.current.getBoundingClientRect();
250
+ const left = e.clientX - box.left;
251
+ setTipAt({ left, top: e.clientY - box.top, flip: left > box.width * 0.6 });
223
252
  };
224
253
  const endDrag = () => {
225
254
  drag.current?.end();
@@ -237,28 +266,49 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
237
266
  if (editable && handleChartKey(controller, scene, e)) e.preventDefault();
238
267
  };
239
268
  const label = state.spec.title || "Chart";
240
- return /* @__PURE__ */ jsx("div", { ref: wrapper, className: `w-full ${className ?? ""}`, "data-chart-canvas": "", children: /* @__PURE__ */ jsxs(
241
- "svg",
242
- {
243
- ref: svg,
244
- width: sceneWidth,
245
- height,
246
- viewBox: `0 0 ${scene.width} ${scene.height}`,
247
- role: "img",
248
- "aria-label": editable ? `${label}. ${describeChartSelection(controller, state.selection)}` : label,
249
- tabIndex: editable ? 0 : void 0,
250
- className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
251
- onPointerDown,
252
- onPointerMove,
253
- onPointerUp: endDrag,
254
- onPointerCancel: endDrag,
255
- onKeyDown,
256
- children: [
257
- scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
258
- presence && /* @__PURE__ */ jsx(ChartPresenceLayer, { presence })
259
- ]
260
- }
261
- ) });
269
+ return /* @__PURE__ */ jsxs("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
270
+ /* @__PURE__ */ jsxs(
271
+ "svg",
272
+ {
273
+ ref: svg,
274
+ width: sceneWidth,
275
+ height,
276
+ viewBox: `0 0 ${scene.width} ${scene.height}`,
277
+ role: "img",
278
+ "aria-label": editable ? `${label}. ${describeChartSelection(controller, state.selection)}` : label,
279
+ tabIndex: editable ? 0 : void 0,
280
+ className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
281
+ onPointerDown,
282
+ onPointerMove,
283
+ onPointerUp: endDrag,
284
+ onPointerCancel: endDrag,
285
+ onPointerLeave: () => setTip(null),
286
+ onKeyDown,
287
+ children: [
288
+ scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
289
+ presence && /* @__PURE__ */ jsx(ChartPresenceLayer, { presence })
290
+ ]
291
+ }
292
+ ),
293
+ tip && /* @__PURE__ */ jsx(
294
+ "div",
295
+ {
296
+ role: "tooltip",
297
+ "data-chart-tooltip": "",
298
+ className: "pointer-events-none absolute z-10 min-w-32 rounded-md border px-2.5 py-1.5 text-xs shadow-md",
299
+ style: {
300
+ left: tipAt.left,
301
+ top: tipAt.top,
302
+ transform: `translate(${tipAt.flip ? "calc(-100% - 12px)" : "12px"}, calc(-100% - 8px))`,
303
+ background: "var(--popover, #ffffff)",
304
+ color: "var(--popover-foreground, #0f172a)",
305
+ borderColor: "var(--border, #e2e8f0)",
306
+ fontFamily: scene.theme.fontFamily
307
+ },
308
+ children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ jsx(ChartTooltipContent, { tooltip: tip })
309
+ }
310
+ )
311
+ ] });
262
312
  }
263
313
 
264
314
  // src/chart/styles.ts
@@ -287,7 +337,7 @@ import {
287
337
  setChartTreeRowName,
288
338
  setChartTreeRowValue
289
339
  } from "@pixerate/editor/chart";
290
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
340
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
291
341
  function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
292
342
  const [draft, setDraft] = useState2(value);
293
343
  const typing = useRef3(false);
@@ -443,7 +493,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
443
493
  className: `${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? "text-muted-foreground line-through" : ""}`
444
494
  }
445
495
  ),
446
- !readOnly && /* @__PURE__ */ jsxs2(Fragment, { children: [
496
+ !readOnly && /* @__PURE__ */ jsxs2(Fragment2, { children: [
447
497
  /* @__PURE__ */ jsx2(
448
498
  "button",
449
499
  {
@@ -553,7 +603,7 @@ import {
553
603
  listChartMaps,
554
604
  suggestChartReferences
555
605
  } from "@pixerate/editor/chart";
556
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
606
+ import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
557
607
  var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
558
608
  function Field({ label, htmlFor, children }) {
559
609
  return /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
@@ -630,7 +680,7 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
630
680
  onCommit: (text) => set({ step: text.trim() === "" ? null : Number(text) }).ok
631
681
  }
632
682
  ) }),
633
- valueAxis && /* @__PURE__ */ jsxs3(Fragment2, { children: [
683
+ valueAxis && /* @__PURE__ */ jsxs3(Fragment3, { children: [
634
684
  /* @__PURE__ */ jsx3(Field, { label: "Min / max", children: /* @__PURE__ */ jsxs3("div", { className: "flex gap-1", children: [
635
685
  bound("min"),
636
686
  bound("max")
@@ -689,7 +739,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
689
739
  CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ jsx3("option", { value: t, children: CHART_ERROR_BAR_LABELS[t] }, t))
690
740
  ] }) }),
691
741
  bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ jsx3(Field, { label: bars.type === "percent" ? "Percent" : bars.type === "stddev" ? "Deviations" : "Amount", htmlFor: `${id}-value`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${id}-value`, value: String(bars.value ?? defaultChartErrorBarValue(bars.type)), inputMode: "decimal", "data-option": `${key}.value`, className: chartInputClass, onCommit: (text) => !!patch({ value: text.trim() === "" ? void 0 : Number(text) })?.ok }) }),
692
- bars?.type === "custom" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
742
+ bars?.type === "custom" && /* @__PURE__ */ jsxs3(Fragment3, { children: [
693
743
  /* @__PURE__ */ jsx3(Field, { label: "Plus", htmlFor: `${id}-plus`, children: /* @__PURE__ */ jsx3(ChartCommitInput, { id: `${id}-plus`, value: formatChartAmountList(bars.plus), placeholder: "1, 2, -, 0.5", "data-option": `${key}.plus`, className: chartInputClass, onCommit: (text) => !!patch({ plus: parseChartAmountList(text) })?.ok }) }),
694
744
  /* @__PURE__ */ jsx3(Field, { label: "Minus", htmlFor: `${id}-minus`, children: /* @__PURE__ */ jsx3(
695
745
  ChartCommitInput,
@@ -859,7 +909,7 @@ function ChartInspector({ controller, sections, className }) {
859
909
  ] }),
860
910
  spec.legend.show && /* @__PURE__ */ jsx3("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: CHART_LEGEND_POSITIONS.map((p) => /* @__PURE__ */ jsx3("button", { type: "button", "aria-pressed": spec.legend.position === p, "data-option": `legend.${p}`, className: chartSegmentClass(spec.legend.position === p), onClick: () => controller.setLegend({ position: p }), children: cap(p) }, p)) })
861
911
  ] }),
862
- show("axes") && hasAxes && /* @__PURE__ */ jsxs3(Fragment2, { children: [
912
+ show("axes") && hasAxes && /* @__PURE__ */ jsxs3(Fragment3, { children: [
863
913
  family !== "box" && family !== "histogram" && /* @__PURE__ */ jsx3(AxisSection, { controller, axis: "x", value: spec.xAxis, idBase, horizontal: spec.orientation === "horizontal", numeric: family === "xy", scales }),
864
914
  /* @__PURE__ */ jsx3(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
865
915
  usesSecondary && /* @__PURE__ */ jsx3(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ __export(src_exports, {
43
43
  CommentsPanel: () => CommentsPanel,
44
44
  ControlSlider: () => ControlSlider,
45
45
  CurvesEditor: () => CurvesEditor,
46
- DirtyTracker: () => import_editor22.DirtyTracker,
46
+ DirtyTracker: () => import_editor23.DirtyTracker,
47
47
  EditorContent: () => EditorContent,
48
48
  EditorSlotsProvider: () => EditorSlotsProvider,
49
49
  ExportDocxButton: () => ExportDocxButton,
@@ -53,7 +53,7 @@ __export(src_exports, {
53
53
  GenerationHistory: () => GenerationHistory,
54
54
  GenerationSettings: () => GenerationSettings,
55
55
  Histogram: () => Histogram,
56
- HistoryManager: () => import_editor22.HistoryManager,
56
+ HistoryManager: () => import_editor23.HistoryManager,
57
57
  ImageCheckbox: () => ImageCheckbox,
58
58
  ImageEditor: () => ImageEditor,
59
59
  ImageEditorCanvas: () => ImageEditorCanvas,
@@ -91,11 +91,12 @@ __export(src_exports, {
91
91
  TrackedChangesList: () => TrackedChangesList,
92
92
  TypeOptionsBar: () => TypeOptionsBar,
93
93
  VariableForm: () => VariableForm,
94
- bindDirtyToHistory: () => import_editor22.bindDirtyToHistory,
95
- createDirtyTracker: () => import_editor22.createDirtyTracker,
96
- createHistoryManager: () => import_editor22.createHistoryManager,
94
+ bindDirtyToHistory: () => import_editor23.bindDirtyToHistory,
95
+ createDirtyTracker: () => import_editor23.createDirtyTracker,
96
+ createHistoryManager: () => import_editor23.createHistoryManager,
97
97
  createReactChartNodeView: () => createReactChartNodeView,
98
- defaultIsEqual: () => import_editor22.defaultIsEqual,
98
+ defaultIsEqual: () => import_editor23.defaultIsEqual,
99
+ formatCommandsFor: () => import_editor22.formatCommandsFor,
99
100
  useAgentPlayback: () => useAgentPlayback,
100
101
  useAgentToolProvider: () => useAgentToolProvider,
101
102
  useAutosave: () => useAutosave,
@@ -139,7 +140,7 @@ __export(src_exports, {
139
140
  useToolBridge: () => useToolBridge,
140
141
  useToolRegistryView: () => useToolRegistryView,
141
142
  useTrackChanges: () => useTrackChanges,
142
- withoutDirty: () => import_editor22.withoutDirty
143
+ withoutDirty: () => import_editor23.withoutDirty
143
144
  });
144
145
  module.exports = __toCommonJS(src_exports);
145
146
 
@@ -404,6 +405,9 @@ function useEditor2(options = {}) {
404
405
  });
405
406
  }
406
407
 
408
+ // src/index.ts
409
+ var import_editor22 = require("@pixerate/editor");
410
+
407
411
  // src/hooks/useNavigationGuard.ts
408
412
  var import_react4 = require("react");
409
413
  function useNavigationGuard({
@@ -1693,7 +1697,7 @@ var StylesGallery = ({
1693
1697
  };
1694
1698
 
1695
1699
  // src/index.ts
1696
- var import_editor22 = require("@pixerate/editor");
1700
+ var import_editor23 = require("@pixerate/editor");
1697
1701
 
1698
1702
  // src/spreadsheet/useSpreadsheetEditor.ts
1699
1703
  var import_react28 = require("react");
@@ -11250,13 +11254,26 @@ function ChartPresenceLayer({ presence }) {
11250
11254
  ] })
11251
11255
  ] }, a.id)) });
11252
11256
  }
11253
- function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef }) {
11257
+ function ChartTooltipContent({ tooltip }) {
11258
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
11259
+ tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
11260
+ tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex items-center gap-2", children: [
11261
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
11262
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
11263
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
11264
+ ] }, item.seriesId))
11265
+ ] });
11266
+ }
11267
+ function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
11254
11268
  const state = useChartState(controller);
11255
11269
  const wrapper = (0, import_react84.useRef)(null);
11256
11270
  const svg = (0, import_react84.useRef)(null);
11257
11271
  const drag = (0, import_react84.useRef)(null);
11258
11272
  const [measured, setMeasured] = (0, import_react84.useState)(null);
11259
11273
  const [frozen, setFrozen] = (0, import_react84.useState)(null);
11274
+ const tooltipMode = tooltip === true ? "point" : tooltip || null;
11275
+ const [tip, setTip] = (0, import_react84.useState)(null);
11276
+ const [tipAt, setTipAt] = (0, import_react84.useState)({ left: 0, top: 0, flip: false });
11260
11277
  (0, import_react84.useEffect)(() => {
11261
11278
  const el = wrapper.current;
11262
11279
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
@@ -11297,12 +11314,26 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
11297
11314
  drag.current = (0, import_chart2.startChartPointDrag)(controller, scene, target, scenePoint(e));
11298
11315
  if (drag.current) {
11299
11316
  const d = drag.current;
11317
+ setTip(null);
11300
11318
  setFrozen({ valueDomain: d.valueDomain, valueDomain2: d.valueDomain2 ?? null, xDomain: d.xDomain ?? null, readout: d.target });
11301
11319
  svg.current?.setPointerCapture?.(e.pointerId);
11302
11320
  }
11303
11321
  };
11304
11322
  const onPointerMove = (e) => {
11305
11323
  if (drag.current) drag.current.move(scenePoint(e), { fine: e.altKey, lockAxis: e.shiftKey, noSnap: e.ctrlKey || e.metaKey });
11324
+ hover(e);
11325
+ };
11326
+ const hover = (e) => {
11327
+ if (!tooltipMode || drag.current || !wrapper.current) {
11328
+ setTip(null);
11329
+ return;
11330
+ }
11331
+ const next = (0, import_chart2.chartTooltipAt)(state.spec, scene, scenePoint(e), { mode: tooltipMode, measureText });
11332
+ setTip((prev) => (0, import_chart2.sameChartTooltip)(prev, next) ? prev : next);
11333
+ if (!next) return;
11334
+ const box = wrapper.current.getBoundingClientRect();
11335
+ const left = e.clientX - box.left;
11336
+ setTipAt({ left, top: e.clientY - box.top, flip: left > box.width * 0.6 });
11306
11337
  };
11307
11338
  const endDrag = () => {
11308
11339
  drag.current?.end();
@@ -11320,28 +11351,49 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
11320
11351
  if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
11321
11352
  };
11322
11353
  const label = state.spec.title || "Chart";
11323
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { ref: wrapper, className: `w-full ${className ?? ""}`, "data-chart-canvas": "", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
11324
- "svg",
11325
- {
11326
- ref: svg,
11327
- width: sceneWidth,
11328
- height,
11329
- viewBox: `0 0 ${scene.width} ${scene.height}`,
11330
- role: "img",
11331
- "aria-label": editable ? `${label}. ${(0, import_chart2.describeChartSelection)(controller, state.selection)}` : label,
11332
- tabIndex: editable ? 0 : void 0,
11333
- className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
11334
- onPointerDown,
11335
- onPointerMove,
11336
- onPointerUp: endDrag,
11337
- onPointerCancel: endDrag,
11338
- onKeyDown,
11339
- children: [
11340
- scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
11341
- presence && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ChartPresenceLayer, { presence })
11342
- ]
11343
- }
11344
- ) });
11354
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
11355
+ /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
11356
+ "svg",
11357
+ {
11358
+ ref: svg,
11359
+ width: sceneWidth,
11360
+ height,
11361
+ viewBox: `0 0 ${scene.width} ${scene.height}`,
11362
+ role: "img",
11363
+ "aria-label": editable ? `${label}. ${(0, import_chart2.describeChartSelection)(controller, state.selection)}` : label,
11364
+ tabIndex: editable ? 0 : void 0,
11365
+ className: "block max-w-full touch-none select-none rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
11366
+ onPointerDown,
11367
+ onPointerMove,
11368
+ onPointerUp: endDrag,
11369
+ onPointerCancel: endDrag,
11370
+ onPointerLeave: () => setTip(null),
11371
+ onKeyDown,
11372
+ children: [
11373
+ scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
11374
+ presence && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ChartPresenceLayer, { presence })
11375
+ ]
11376
+ }
11377
+ ),
11378
+ tip && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
11379
+ "div",
11380
+ {
11381
+ role: "tooltip",
11382
+ "data-chart-tooltip": "",
11383
+ className: "pointer-events-none absolute z-10 min-w-32 rounded-md border px-2.5 py-1.5 text-xs shadow-md",
11384
+ style: {
11385
+ left: tipAt.left,
11386
+ top: tipAt.top,
11387
+ transform: `translate(${tipAt.flip ? "calc(-100% - 12px)" : "12px"}, calc(-100% - 8px))`,
11388
+ background: "var(--popover, #ffffff)",
11389
+ color: "var(--popover-foreground, #0f172a)",
11390
+ borderColor: "var(--border, #e2e8f0)",
11391
+ fontFamily: scene.theme.fontFamily
11392
+ },
11393
+ children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ChartTooltipContent, { tooltip: tip })
11394
+ }
11395
+ )
11396
+ ] });
11345
11397
  }
11346
11398
 
11347
11399
  // src/chart/ChartDataGrid.tsx
@@ -12272,6 +12324,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
12272
12324
  createHistoryManager,
12273
12325
  createReactChartNodeView,
12274
12326
  defaultIsEqual,
12327
+ formatCommandsFor,
12275
12328
  useAgentPlayback,
12276
12329
  useAgentToolProvider,
12277
12330
  useAutosave,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./hooks/usePromptEditor.cjs";
2
2
  export * from "./hooks/useEditor.cjs";
3
+ export { formatCommandsFor, type FormatManifest, type FormatManifestCommand, type CodeLanguageOption, type FormatCommandOptions } from "@pixerate/editor";
3
4
  export * from "./hooks/useNavigationGuard.cjs";
4
5
  export * from "./hooks/useDismissGuard.cjs";
5
6
  export * from "./hooks/useHistory.cjs";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./hooks/usePromptEditor.js";
2
2
  export * from "./hooks/useEditor.js";
3
+ export { formatCommandsFor, type FormatManifest, type FormatManifestCommand, type CodeLanguageOption, type FormatCommandOptions } from "@pixerate/editor";
3
4
  export * from "./hooks/useNavigationGuard.js";
4
5
  export * from "./hooks/useDismissGuard.js";
5
6
  export * from "./hooks/useHistory.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  ChartDataGrid,
7
7
  ChartInspector,
8
8
  chartButtonClass
9
- } from "./chunk-3MUK5ASL.js";
9
+ } from "./chunk-N2F53ESC.js";
10
10
  import {
11
11
  FormulaHints,
12
12
  NameManager,
@@ -354,6 +354,9 @@ function useEditor2(options = {}) {
354
354
  });
355
355
  }
356
356
 
357
+ // src/index.ts
358
+ import { formatCommandsFor } from "@pixerate/editor";
359
+
357
360
  // src/hooks/useNavigationGuard.ts
358
361
  import { useState, useEffect as useEffect2, useCallback, useRef as useRef2 } from "react";
359
362
  function useNavigationGuard({
@@ -2585,6 +2588,7 @@ export {
2585
2588
  createHistoryManager2 as createHistoryManager,
2586
2589
  createReactChartNodeView,
2587
2590
  defaultIsEqual,
2591
+ formatCommandsFor,
2588
2592
  useAgentPlayback,
2589
2593
  useAgentToolProvider,
2590
2594
  useAutosave,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.113.2",
3
+ "version": "0.114.1",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -251,17 +251,16 @@
251
251
  "dist"
252
252
  ],
253
253
  "sideEffects": false,
254
- "dependencies": {
255
- "@tiptap/extension-bubble-menu": "^2.27.3",
256
- "@tiptap/extension-placeholder": "^2.27.3",
257
- "@tiptap/starter-kit": "^2.27.3"
258
- },
254
+ "dependencies": {},
259
255
  "peerDependencies": {
260
256
  "@dagrejs/dagre": "^1.1.8",
261
- "@pixerate/editor": ">=0.171.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.174.0 <1.0.0-0",
262
258
  "@tiptap/core": "^2.27.3",
259
+ "@tiptap/extension-bubble-menu": "^2.27.3",
260
+ "@tiptap/extension-placeholder": "^2.27.3",
263
261
  "@tiptap/pm": "^2.27.3",
264
262
  "@tiptap/react": "^2.27.3",
263
+ "@tiptap/starter-kit": "^2.27.3",
265
264
  "@xyflow/react": "^12.0.0",
266
265
  "react": ">=18.0.0",
267
266
  "react-dom": ">=18.0.0"
@@ -270,14 +269,35 @@
270
269
  "@dagrejs/dagre": {
271
270
  "optional": true
272
271
  },
272
+ "@tiptap/core": {
273
+ "optional": true
274
+ },
275
+ "@tiptap/extension-bubble-menu": {
276
+ "optional": true
277
+ },
278
+ "@tiptap/extension-placeholder": {
279
+ "optional": true
280
+ },
281
+ "@tiptap/pm": {
282
+ "optional": true
283
+ },
284
+ "@tiptap/react": {
285
+ "optional": true
286
+ },
287
+ "@tiptap/starter-kit": {
288
+ "optional": true
289
+ },
273
290
  "@xyflow/react": {
274
291
  "optional": true
275
292
  }
276
293
  },
277
294
  "devDependencies": {
278
295
  "@tiptap/core": "^2.27.3",
296
+ "@tiptap/extension-bubble-menu": "^2.27.3",
297
+ "@tiptap/extension-placeholder": "^2.27.3",
279
298
  "@tiptap/pm": "^2.27.3",
280
299
  "@tiptap/react": "^2.27.3",
300
+ "@tiptap/starter-kit": "^2.27.3",
281
301
  "@types/react": "^19.3.0",
282
302
  "@types/react-dom": "^19.3.0",
283
303
  "react": "^19.3.1",
@@ -285,7 +305,7 @@
285
305
  "tsup": "^9.0.0",
286
306
  "typescript": "^5.7.3",
287
307
  "vitest": "^5.0.5",
288
- "@pixerate/editor": "0.171.0"
308
+ "@pixerate/editor": "0.174.0"
289
309
  },
290
310
  "scripts": {
291
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",