@pixerate/editor-react 0.140.0 → 0.142.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/{chunk-75P7WMCR.js → chunk-ULBLX67B.js} +407 -296
- package/dist/image-editor/ContentAwareFillWorkspace.d.cts +1 -1
- package/dist/image-editor/ContentAwareFillWorkspace.d.ts +1 -1
- package/dist/image-editor/PathsPanel.d.cts +16 -0
- package/dist/image-editor/PathsPanel.d.ts +16 -0
- package/dist/image-editor/index.cjs +420 -308
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +3 -1
- package/dist/index.cjs +940 -828
- package/dist/index.js +3 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ __export(src_exports, {
|
|
|
73
73
|
NameManager: () => NameManager,
|
|
74
74
|
OutlinePanel: () => OutlinePanel,
|
|
75
75
|
PaintGradientEditor: () => PaintGradientEditor,
|
|
76
|
+
PathsPanel: () => PathsPanel,
|
|
76
77
|
PresenceLayer: () => PresenceLayer,
|
|
77
78
|
RecoveryPrompt: () => RecoveryPrompt,
|
|
78
79
|
RefineEdgePanel: () => RefineEdgePanel,
|
|
@@ -4042,8 +4043,8 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
4042
4043
|
}
|
|
4043
4044
|
|
|
4044
4045
|
// src/image-editor/ImageEditor.tsx
|
|
4045
|
-
var
|
|
4046
|
-
var
|
|
4046
|
+
var import_react70 = __toESM(require("react"), 1);
|
|
4047
|
+
var import_image_editor23 = require("@pixerate/editor/image-editor");
|
|
4047
4048
|
|
|
4048
4049
|
// src/image-editor/ImageEditorCanvas.tsx
|
|
4049
4050
|
var import_react41 = require("react");
|
|
@@ -8701,6 +8702,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8701
8702
|
Math.round(zoom * 100),
|
|
8702
8703
|
"%"
|
|
8703
8704
|
] }),
|
|
8705
|
+
!session.showsWholeImage && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: button3, title: "Show (and sample from) more of the image around the selection", onClick: () => session.expandView(), children: "Expand View" }),
|
|
8704
8706
|
session.computing && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
|
|
8705
8707
|
] }),
|
|
8706
8708
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex-1 grid grid-cols-2 gap-2 p-2 min-h-0", children: [
|
|
@@ -8772,7 +8774,8 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8772
8774
|
value: settings.output,
|
|
8773
8775
|
options: [
|
|
8774
8776
|
{ value: "new-layer", label: "New Layer" },
|
|
8775
|
-
{ value: "current", label: "Current Layer" }
|
|
8777
|
+
{ value: "current", label: "Current Layer" },
|
|
8778
|
+
{ value: "duplicate-layer", label: "Duplicate Layer" }
|
|
8776
8779
|
],
|
|
8777
8780
|
onChange: (v) => set({ output: v })
|
|
8778
8781
|
}
|
|
@@ -9678,14 +9681,121 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9678
9681
|
] });
|
|
9679
9682
|
};
|
|
9680
9683
|
|
|
9681
|
-
// src/image-editor/
|
|
9684
|
+
// src/image-editor/PathsPanel.tsx
|
|
9682
9685
|
var import_react66 = require("react");
|
|
9683
9686
|
var import_image_editor19 = require("@pixerate/editor/image-editor");
|
|
9684
9687
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9688
|
+
var btn3 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
9689
|
+
var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
9690
|
+
const [, setTick] = (0, import_react66.useState)(0);
|
|
9691
|
+
(0, import_react66.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9692
|
+
const [renaming, setRenaming] = (0, import_react66.useState)(null);
|
|
9693
|
+
const [color, setColor] = (0, import_react66.useState)("#000000");
|
|
9694
|
+
const [width, setWidth] = (0, import_react66.useState)(2);
|
|
9695
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
9696
|
+
const paths = controller.getPaths();
|
|
9697
|
+
const activeId = controller.getState().activePathId ?? null;
|
|
9698
|
+
const active = paths.find((p) => p.id === activeId) ?? null;
|
|
9699
|
+
const hasSelection = Boolean(controller.getSelection());
|
|
9700
|
+
const { width: w, height: h } = controller.getState().imageDimensions;
|
|
9701
|
+
const attempt = (fn) => {
|
|
9702
|
+
setError(null);
|
|
9703
|
+
try {
|
|
9704
|
+
fn();
|
|
9705
|
+
} catch (err) {
|
|
9706
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
9707
|
+
}
|
|
9708
|
+
};
|
|
9709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
9710
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
|
|
9711
|
+
paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
|
|
9712
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
9713
|
+
"li",
|
|
9714
|
+
{
|
|
9715
|
+
"data-testid": "path-row",
|
|
9716
|
+
"aria-current": p.id === activeId ? "true" : void 0,
|
|
9717
|
+
className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${p.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
|
|
9718
|
+
onClick: () => attempt(() => controller.setActivePath(p.id)),
|
|
9719
|
+
onDoubleClick: () => setRenaming(p.id),
|
|
9720
|
+
children: [
|
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("path", { d: (0, import_image_editor19.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
|
|
9722
|
+
renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9723
|
+
"input",
|
|
9724
|
+
{
|
|
9725
|
+
autoFocus: true,
|
|
9726
|
+
"aria-label": "Path name",
|
|
9727
|
+
defaultValue: p.work ? "" : p.name,
|
|
9728
|
+
placeholder: "Path name",
|
|
9729
|
+
className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
|
|
9730
|
+
onClick: (e) => e.stopPropagation(),
|
|
9731
|
+
onBlur: (e) => {
|
|
9732
|
+
setRenaming(null);
|
|
9733
|
+
const name = e.currentTarget.value.trim();
|
|
9734
|
+
if (name && name !== p.name) attempt(() => controller.renamePath(p.id, name));
|
|
9735
|
+
},
|
|
9736
|
+
onKeyDown: (e) => {
|
|
9737
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
9738
|
+
if (e.key === "Escape") setRenaming(null);
|
|
9739
|
+
}
|
|
9740
|
+
}
|
|
9741
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
|
|
9742
|
+
]
|
|
9743
|
+
},
|
|
9744
|
+
p.id
|
|
9745
|
+
)) }),
|
|
9746
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
9747
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9748
|
+
"button",
|
|
9749
|
+
{
|
|
9750
|
+
type: "button",
|
|
9751
|
+
className: btn3(),
|
|
9752
|
+
disabled: !active,
|
|
9753
|
+
title: "Load the path as the selection (Shift adds, Alt subtracts)",
|
|
9754
|
+
onClick: (e) => attempt(() => controller.loadPathAsSelection(active.id, { mode: (0, import_image_editor19.selectionModeFromModifiers)(e, "replace") })),
|
|
9755
|
+
children: "Load as Selection"
|
|
9756
|
+
}
|
|
9757
|
+
),
|
|
9758
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
|
|
9759
|
+
active?.work && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
|
|
9760
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
|
|
9761
|
+
] }),
|
|
9762
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
9763
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
|
|
9764
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
|
|
9765
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
9766
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9767
|
+
"input",
|
|
9768
|
+
{
|
|
9769
|
+
type: "number",
|
|
9770
|
+
min: 0.5,
|
|
9771
|
+
max: 250,
|
|
9772
|
+
step: 0.5,
|
|
9773
|
+
"aria-label": "Stroke width",
|
|
9774
|
+
value: width,
|
|
9775
|
+
onChange: (e) => setWidth(Math.min(250, Math.max(0.5, Number(e.target.value) || 1))),
|
|
9776
|
+
className: "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground"
|
|
9777
|
+
}
|
|
9778
|
+
),
|
|
9779
|
+
"px"
|
|
9780
|
+
] }),
|
|
9781
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
|
|
9782
|
+
] }),
|
|
9783
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
9784
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
|
|
9785
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
|
|
9786
|
+
] }),
|
|
9787
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9788
|
+
] });
|
|
9789
|
+
};
|
|
9790
|
+
|
|
9791
|
+
// src/image-editor/FreeTransformOptionsBar.tsx
|
|
9792
|
+
var import_react67 = require("react");
|
|
9793
|
+
var import_image_editor20 = require("@pixerate/editor/image-editor");
|
|
9794
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9685
9795
|
var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
|
|
9686
9796
|
var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
9687
|
-
const [, setTick] = (0,
|
|
9688
|
-
(0,
|
|
9797
|
+
const [, setTick] = (0, import_react67.useState)(0);
|
|
9798
|
+
(0, import_react67.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
|
|
9689
9799
|
const bar = tool.bar();
|
|
9690
9800
|
if (!tool.active || !bar) return null;
|
|
9691
9801
|
const warp = tool.warpBar();
|
|
@@ -9697,17 +9807,17 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
9697
9807
|
const v = Number(raw);
|
|
9698
9808
|
if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
|
|
9699
9809
|
};
|
|
9700
|
-
return /* @__PURE__ */ (0,
|
|
9701
|
-
/* @__PURE__ */ (0,
|
|
9702
|
-
/* @__PURE__ */ (0,
|
|
9703
|
-
tool.mode === "warp" && /* @__PURE__ */ (0,
|
|
9704
|
-
/* @__PURE__ */ (0,
|
|
9705
|
-
/* @__PURE__ */ (0,
|
|
9706
|
-
/* @__PURE__ */ (0,
|
|
9810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: `flex flex-wrap items-center gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "free-transform-options", role: "toolbar", "aria-label": "Free Transform options", children: [
|
|
9811
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor20.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", title: m.title, "aria-pressed": tool.mode === m.id, className: imageChipClass(tool.mode === m.id), onClick: () => tool.setMode(m.id), children: m.label }, m.id)) }),
|
|
9812
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor20.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": `Reference point ${a}`, title: `Reference point: ${a}`, className: "h-2.5 w-2.5 rounded-sm bg-accent hover:bg-primary/90", onClick: () => tool.setReference(a) }, a)) }),
|
|
9813
|
+
tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
|
|
9814
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9815
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: "Warp" }),
|
|
9816
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: imageFieldClass, children: import_image_editor20.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: o.id, children: o.label }, o.id)) })
|
|
9707
9817
|
] }),
|
|
9708
|
-
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0,
|
|
9709
|
-
/* @__PURE__ */ (0,
|
|
9710
|
-
/* @__PURE__ */ (0,
|
|
9818
|
+
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9819
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
|
|
9820
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9711
9821
|
"input",
|
|
9712
9822
|
{
|
|
9713
9823
|
type: "number",
|
|
@@ -9728,9 +9838,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
9728
9838
|
},
|
|
9729
9839
|
`${k}:${warp[k]}`
|
|
9730
9840
|
),
|
|
9731
|
-
/* @__PURE__ */ (0,
|
|
9841
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: "%" })
|
|
9732
9842
|
] }, k)),
|
|
9733
|
-
/* @__PURE__ */ (0,
|
|
9843
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9734
9844
|
"button",
|
|
9735
9845
|
{
|
|
9736
9846
|
type: "button",
|
|
@@ -9742,26 +9852,26 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
9742
9852
|
children: "Vertical"
|
|
9743
9853
|
}
|
|
9744
9854
|
),
|
|
9745
|
-
/* @__PURE__ */ (0,
|
|
9746
|
-
/* @__PURE__ */ (0,
|
|
9747
|
-
/* @__PURE__ */ (0,
|
|
9855
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9856
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: "Grid" }),
|
|
9857
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9748
9858
|
"select",
|
|
9749
9859
|
{
|
|
9750
9860
|
"aria-label": "Warp grid",
|
|
9751
|
-
value:
|
|
9861
|
+
value: import_image_editor20.WARP_GRID_OPTIONS.find((g) => g.columns === warp.columns && g.rows === warp.rows)?.id ?? "1x1",
|
|
9752
9862
|
onChange: (e) => {
|
|
9753
|
-
const g =
|
|
9863
|
+
const g = import_image_editor20.WARP_GRID_OPTIONS.find((o) => o.id === e.target.value);
|
|
9754
9864
|
tool.setWarp({ columns: g.columns, rows: g.rows });
|
|
9755
9865
|
},
|
|
9756
9866
|
className: imageFieldClass,
|
|
9757
|
-
children:
|
|
9867
|
+
children: import_image_editor20.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: g.id, children: g.label }, g.id))
|
|
9758
9868
|
}
|
|
9759
9869
|
)
|
|
9760
9870
|
] })
|
|
9761
9871
|
] }),
|
|
9762
|
-
tool.mode !== "warp" &&
|
|
9763
|
-
/* @__PURE__ */ (0,
|
|
9764
|
-
/* @__PURE__ */ (0,
|
|
9872
|
+
tool.mode !== "warp" && import_image_editor20.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
|
|
9873
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: f.label }),
|
|
9874
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9765
9875
|
"input",
|
|
9766
9876
|
{
|
|
9767
9877
|
type: "number",
|
|
@@ -9781,8 +9891,8 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
9781
9891
|
},
|
|
9782
9892
|
`${f.id}:${round(bar[f.id], f.unit)}`
|
|
9783
9893
|
),
|
|
9784
|
-
/* @__PURE__ */ (0,
|
|
9785
|
-
f.id === "scaleX" && /* @__PURE__ */ (0,
|
|
9894
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: f.unit }),
|
|
9895
|
+
f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9786
9896
|
"button",
|
|
9787
9897
|
{
|
|
9788
9898
|
type: "button",
|
|
@@ -9797,33 +9907,33 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
9797
9907
|
}
|
|
9798
9908
|
)
|
|
9799
9909
|
] }, f.id)),
|
|
9800
|
-
/* @__PURE__ */ (0,
|
|
9801
|
-
/* @__PURE__ */ (0,
|
|
9802
|
-
/* @__PURE__ */ (0,
|
|
9910
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9911
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-muted-foreground", children: "Interpolation" }),
|
|
9912
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9803
9913
|
"select",
|
|
9804
9914
|
{
|
|
9805
9915
|
"aria-label": "Interpolation",
|
|
9806
9916
|
value: tool.interpolation,
|
|
9807
9917
|
onChange: (e) => tool.setInterpolation(e.target.value),
|
|
9808
9918
|
className: imageFieldClass,
|
|
9809
|
-
children:
|
|
9919
|
+
children: import_image_editor20.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
|
|
9810
9920
|
}
|
|
9811
9921
|
)
|
|
9812
9922
|
] }),
|
|
9813
|
-
/* @__PURE__ */ (0,
|
|
9814
|
-
/* @__PURE__ */ (0,
|
|
9815
|
-
tool.error && /* @__PURE__ */ (0,
|
|
9923
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", title: "Commit (Enter)", className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90", onClick: () => tool.commit(), children: "Commit" }),
|
|
9924
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", title: "Cancel (Esc)", className: imageChipClass(false), onClick: () => tool.cancel(), children: "Cancel" }),
|
|
9925
|
+
tool.error && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { role: "alert", className: "text-destructive", children: tool.error })
|
|
9816
9926
|
] });
|
|
9817
9927
|
};
|
|
9818
9928
|
|
|
9819
9929
|
// src/image-editor/ShapeOptionsBar.tsx
|
|
9820
|
-
var
|
|
9821
|
-
var
|
|
9822
|
-
var
|
|
9930
|
+
var import_react68 = require("react");
|
|
9931
|
+
var import_image_editor21 = require("@pixerate/editor/image-editor");
|
|
9932
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9823
9933
|
var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
9824
|
-
const [, setTick] = (0,
|
|
9825
|
-
(0,
|
|
9826
|
-
const [error, setError] = (0,
|
|
9934
|
+
const [, setTick] = (0, import_react68.useState)(0);
|
|
9935
|
+
(0, import_react68.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9936
|
+
const [error, setError] = (0, import_react68.useState)(null);
|
|
9827
9937
|
const active = controller.getActiveLayer();
|
|
9828
9938
|
const shapeId = active?.type === "shape" ? active.id : null;
|
|
9829
9939
|
const set = (change) => {
|
|
@@ -9831,28 +9941,28 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
9831
9941
|
if (!shapeId) return;
|
|
9832
9942
|
try {
|
|
9833
9943
|
setError(null);
|
|
9834
|
-
(0,
|
|
9944
|
+
(0, import_image_editor21.applyShapeOptions)(controller, shapeId, change);
|
|
9835
9945
|
} catch (e) {
|
|
9836
9946
|
setError(e instanceof Error ? e.message : String(e));
|
|
9837
9947
|
}
|
|
9838
9948
|
};
|
|
9839
9949
|
const num = (v, min, max) => Math.max(min, Math.min(max, Number(v) || min));
|
|
9840
|
-
return /* @__PURE__ */ (0,
|
|
9841
|
-
/* @__PURE__ */ (0,
|
|
9842
|
-
/* @__PURE__ */ (0,
|
|
9843
|
-
/* @__PURE__ */ (0,
|
|
9844
|
-
/* @__PURE__ */ (0,
|
|
9950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "shape-options", children: [
|
|
9951
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor21.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: imageChipClass(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor21.SHAPE_KIND_LABELS[k] }, k)) }),
|
|
9952
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9953
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9954
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
|
|
9845
9955
|
"Fill",
|
|
9846
|
-
/* @__PURE__ */ (0,
|
|
9956
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
|
|
9847
9957
|
] }),
|
|
9848
|
-
/* @__PURE__ */ (0,
|
|
9849
|
-
/* @__PURE__ */ (0,
|
|
9958
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9959
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
|
|
9850
9960
|
"Stroke",
|
|
9851
|
-
/* @__PURE__ */ (0,
|
|
9961
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
|
|
9852
9962
|
] }),
|
|
9853
|
-
/* @__PURE__ */ (0,
|
|
9963
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9854
9964
|
"Width",
|
|
9855
|
-
/* @__PURE__ */ (0,
|
|
9965
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9856
9966
|
"input",
|
|
9857
9967
|
{
|
|
9858
9968
|
type: "number",
|
|
@@ -9866,52 +9976,52 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
9866
9976
|
)
|
|
9867
9977
|
] })
|
|
9868
9978
|
] }),
|
|
9869
|
-
/* @__PURE__ */ (0,
|
|
9870
|
-
options.kind === "rect" && /* @__PURE__ */ (0,
|
|
9979
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9980
|
+
options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9871
9981
|
"Radius",
|
|
9872
|
-
/* @__PURE__ */ (0,
|
|
9982
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("input", { type: "number", "aria-label": "Corner radius", min: 0, max: 1e3, value: options.radius, onChange: (e) => set({ radius: num(e.target.value, 0, 1e3) }), className: `w-14 ${imageFieldClass}` })
|
|
9873
9983
|
] }),
|
|
9874
|
-
options.kind === "polygon" && /* @__PURE__ */ (0,
|
|
9984
|
+
options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9875
9985
|
"Sides",
|
|
9876
|
-
/* @__PURE__ */ (0,
|
|
9986
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("input", { type: "number", "aria-label": "Sides", min: 3, max: 100, value: options.sides, onChange: (e) => set({ sides: num(e.target.value, 3, 100) }), className: `w-14 ${imageFieldClass}` })
|
|
9877
9987
|
] }),
|
|
9878
|
-
options.kind === "star" && /* @__PURE__ */ (0,
|
|
9879
|
-
/* @__PURE__ */ (0,
|
|
9988
|
+
options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
|
|
9989
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9880
9990
|
"Points",
|
|
9881
|
-
/* @__PURE__ */ (0,
|
|
9991
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("input", { type: "number", "aria-label": "Points", min: 3, max: 100, value: options.points, onChange: (e) => set({ points: num(e.target.value, 3, 100) }), className: `w-14 ${imageFieldClass}` })
|
|
9882
9992
|
] }),
|
|
9883
|
-
/* @__PURE__ */ (0,
|
|
9993
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9884
9994
|
"Inner",
|
|
9885
|
-
/* @__PURE__ */ (0,
|
|
9995
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageRange, { label: "Inner radius", min: 0.05, max: 1, step: 0.05, value: options.innerRatio, onChange: (v) => set({ innerRatio: v }) })
|
|
9886
9996
|
] })
|
|
9887
9997
|
] }),
|
|
9888
|
-
options.kind === "line" && /* @__PURE__ */ (0,
|
|
9889
|
-
/* @__PURE__ */ (0,
|
|
9998
|
+
options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
|
|
9999
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9890
10000
|
"Weight",
|
|
9891
|
-
/* @__PURE__ */ (0,
|
|
10001
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("input", { type: "number", "aria-label": "Line weight", min: 1, max: 200, value: options.weight, onChange: (e) => set({ weight: num(e.target.value, 1, 200) }), className: `w-14 ${imageFieldClass}` })
|
|
9892
10002
|
] }),
|
|
9893
|
-
/* @__PURE__ */ (0,
|
|
9894
|
-
/* @__PURE__ */ (0,
|
|
10003
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10004
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ImageCheckbox, { label: "Arrowhead", checked: options.arrow, onChange: (on) => set({ arrow: on }) }),
|
|
9895
10005
|
"Arrowhead"
|
|
9896
10006
|
] })
|
|
9897
10007
|
] })
|
|
9898
10008
|
] }),
|
|
9899
|
-
/* @__PURE__ */ (0,
|
|
9900
|
-
error && /* @__PURE__ */ (0,
|
|
10009
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Drag on the image to draw. Shift: square, circle or 45\xB0 line. Alt: from the centre." }),
|
|
10010
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9901
10011
|
] });
|
|
9902
10012
|
};
|
|
9903
10013
|
|
|
9904
10014
|
// src/image-editor/TypeOptionsBar.tsx
|
|
9905
|
-
var
|
|
9906
|
-
var
|
|
9907
|
-
var
|
|
10015
|
+
var import_react69 = require("react");
|
|
10016
|
+
var import_image_editor22 = require("@pixerate/editor/image-editor");
|
|
10017
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
9908
10018
|
var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
|
|
9909
10019
|
var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
|
|
9910
10020
|
var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
|
|
9911
|
-
const [, setTick] = (0,
|
|
9912
|
-
(0,
|
|
9913
|
-
(0,
|
|
9914
|
-
const [error, setError] = (0,
|
|
10021
|
+
const [, setTick] = (0, import_react69.useState)(0);
|
|
10022
|
+
(0, import_react69.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
10023
|
+
(0, import_react69.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
|
|
10024
|
+
const [error, setError] = (0, import_react69.useState)(null);
|
|
9915
10025
|
const active = controller.getActiveLayer();
|
|
9916
10026
|
const typeId = !session && active?.type === "type" ? active.id : null;
|
|
9917
10027
|
const here = session?.alive ? session.styleHere() : {};
|
|
@@ -9964,11 +10074,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9964
10074
|
setError(e instanceof Error ? e.message : String(e));
|
|
9965
10075
|
}
|
|
9966
10076
|
};
|
|
9967
|
-
return /* @__PURE__ */ (0,
|
|
9968
|
-
/* @__PURE__ */ (0,
|
|
9969
|
-
/* @__PURE__ */ (0,
|
|
10077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "type-options", children: [
|
|
10078
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
10079
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9970
10080
|
"Font",
|
|
9971
|
-
/* @__PURE__ */ (0,
|
|
10081
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
9972
10082
|
"input",
|
|
9973
10083
|
{
|
|
9974
10084
|
list: "pixerate-type-fonts",
|
|
@@ -9978,11 +10088,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9978
10088
|
className: "w-32 rounded border border-border bg-background px-1 py-0.5"
|
|
9979
10089
|
}
|
|
9980
10090
|
),
|
|
9981
|
-
/* @__PURE__ */ (0,
|
|
10091
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value: f }, f)) })
|
|
9982
10092
|
] }),
|
|
9983
|
-
/* @__PURE__ */ (0,
|
|
10093
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9984
10094
|
"Size",
|
|
9985
|
-
/* @__PURE__ */ (0,
|
|
10095
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
9986
10096
|
"input",
|
|
9987
10097
|
{
|
|
9988
10098
|
type: "number",
|
|
@@ -9995,14 +10105,14 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9995
10105
|
}
|
|
9996
10106
|
)
|
|
9997
10107
|
] }),
|
|
9998
|
-
/* @__PURE__ */ (0,
|
|
9999
|
-
/* @__PURE__ */ (0,
|
|
10000
|
-
/* @__PURE__ */ (0,
|
|
10108
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${imageChipClass(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
|
|
10109
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
|
|
10110
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
|
|
10001
10111
|
] }),
|
|
10002
|
-
/* @__PURE__ */ (0,
|
|
10003
|
-
/* @__PURE__ */ (0,
|
|
10004
|
-
|
|
10005
|
-
orientation === "vertical" && editedId && /* @__PURE__ */ (0,
|
|
10112
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor22.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
|
|
10113
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Orientation", children: [
|
|
10114
|
+
import_image_editor22.TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", "aria-pressed": orientation === o, className: imageChipClass(orientation === o), onClick: () => orient(o), children: ORIENTATION_LABELS[o] }, o)),
|
|
10115
|
+
orientation === "vertical" && editedId && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10006
10116
|
"button",
|
|
10007
10117
|
{
|
|
10008
10118
|
type: "button",
|
|
@@ -10014,19 +10124,19 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
10014
10124
|
}
|
|
10015
10125
|
)
|
|
10016
10126
|
] }),
|
|
10017
|
-
/* @__PURE__ */ (0,
|
|
10018
|
-
missing.length > 0 && /* @__PURE__ */ (0,
|
|
10127
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text (vertical: a column down from the click), drag for a paragraph box, click text to edit it. Esc finishes." }),
|
|
10128
|
+
missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
|
|
10019
10129
|
"Missing ",
|
|
10020
10130
|
missing.length === 1 ? "font" : "fonts",
|
|
10021
10131
|
": ",
|
|
10022
10132
|
missing.join(", ")
|
|
10023
10133
|
] }),
|
|
10024
|
-
error && /* @__PURE__ */ (0,
|
|
10134
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
10025
10135
|
] });
|
|
10026
10136
|
};
|
|
10027
10137
|
|
|
10028
10138
|
// src/image-editor/ImageEditor.tsx
|
|
10029
|
-
var
|
|
10139
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
10030
10140
|
var ImageEditor = ({
|
|
10031
10141
|
editor: externalEditor,
|
|
10032
10142
|
src,
|
|
@@ -10050,51 +10160,51 @@ var ImageEditor = ({
|
|
|
10050
10160
|
const effectsShown = !!controller.effectsProvider || state.layers.some(function has(l) {
|
|
10051
10161
|
return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
|
|
10052
10162
|
});
|
|
10053
|
-
const legacyProcess = (0,
|
|
10054
|
-
const [activeTab, setActiveTab] = (0,
|
|
10055
|
-
const rootRef = (0,
|
|
10163
|
+
const legacyProcess = (0, import_image_editor23.normalizeProcessVersion)(state.adjustments.process) < import_image_editor23.LATEST_PROCESS_VERSION;
|
|
10164
|
+
const [activeTab, setActiveTab] = (0, import_react70.useState)("crop");
|
|
10165
|
+
const rootRef = (0, import_react70.useRef)(null);
|
|
10056
10166
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
10057
|
-
const activeTabRef = (0,
|
|
10167
|
+
const activeTabRef = (0, import_react70.useRef)(activeTab);
|
|
10058
10168
|
activeTabRef.current = activeTab;
|
|
10059
10169
|
const openPanel = async (ref) => {
|
|
10060
10170
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
10061
10171
|
rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
|
|
10062
10172
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
10063
10173
|
};
|
|
10064
|
-
const [activeCropRatio, setActiveCropRatio] = (0,
|
|
10065
|
-
const [selectionOptions, setSelectionOptions] = (0,
|
|
10066
|
-
const [shapeOptions, setShapeOptions] = (0,
|
|
10067
|
-
const [typeOptions, setTypeOptions] = (0,
|
|
10068
|
-
const [typeSession, setTypeSession] = (0,
|
|
10069
|
-
const [selectionError, setSelectionError] = (0,
|
|
10070
|
-
const [paintError, setPaintError] = (0,
|
|
10071
|
-
const [shapeTypeError, setShapeTypeError] = (0,
|
|
10174
|
+
const [activeCropRatio, setActiveCropRatio] = (0, import_react70.useState)(null);
|
|
10175
|
+
const [selectionOptions, setSelectionOptions] = (0, import_react70.useState)(import_image_editor23.DEFAULT_SELECTION_TOOL_OPTIONS);
|
|
10176
|
+
const [shapeOptions, setShapeOptions] = (0, import_react70.useState)(import_image_editor23.DEFAULT_SHAPE_TOOL_OPTIONS);
|
|
10177
|
+
const [typeOptions, setTypeOptions] = (0, import_react70.useState)(import_image_editor23.DEFAULT_TYPE_TOOL_OPTIONS);
|
|
10178
|
+
const [typeSession, setTypeSession] = (0, import_react70.useState)(null);
|
|
10179
|
+
const [selectionError, setSelectionError] = (0, import_react70.useState)(null);
|
|
10180
|
+
const [paintError, setPaintError] = (0, import_react70.useState)(null);
|
|
10181
|
+
const [shapeTypeError, setShapeTypeError] = (0, import_react70.useState)(null);
|
|
10072
10182
|
const handleCanvasError = (source, message2) => {
|
|
10073
10183
|
if (source === "paint") setPaintError(message2);
|
|
10074
10184
|
else if (source === "select") setSelectionError(message2);
|
|
10075
10185
|
else setShapeTypeError(message2);
|
|
10076
10186
|
};
|
|
10077
10187
|
const finishTyping = () => setTypeSession(null);
|
|
10078
|
-
const transformToolRef = (0,
|
|
10079
|
-
const transformControllerRef = (0,
|
|
10188
|
+
const transformToolRef = (0, import_react70.useRef)(null);
|
|
10189
|
+
const transformControllerRef = (0, import_react70.useRef)(controller);
|
|
10080
10190
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
10081
10191
|
transformToolRef.current?.cancel();
|
|
10082
|
-
transformToolRef.current = new
|
|
10192
|
+
transformToolRef.current = new import_image_editor23.FreeTransformTool(controller, {
|
|
10083
10193
|
schedule: (run) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(run) : run()
|
|
10084
10194
|
});
|
|
10085
10195
|
transformControllerRef.current = controller;
|
|
10086
10196
|
}
|
|
10087
10197
|
const transformTool = transformToolRef.current;
|
|
10088
|
-
const [, setTransformTick] = (0,
|
|
10089
|
-
(0,
|
|
10090
|
-
(0,
|
|
10091
|
-
const [inpaintPrompt, setInpaintPrompt] = (0,
|
|
10092
|
-
const [inpaintMaskMode, setInpaintMaskMode] = (0,
|
|
10093
|
-
const [isRemovingBg, setIsRemovingBg] = (0,
|
|
10094
|
-
const [isInpainting, setIsInpainting] = (0,
|
|
10095
|
-
const [aiError, setAiError] = (0,
|
|
10096
|
-
const [aiSuccess, setAiSuccess] = (0,
|
|
10097
|
-
const [aiTarget, setAiTarget] = (0,
|
|
10198
|
+
const [, setTransformTick] = (0, import_react70.useState)(0);
|
|
10199
|
+
(0, import_react70.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
|
|
10200
|
+
(0, import_react70.useEffect)(() => () => transformToolRef.current?.cancel(), []);
|
|
10201
|
+
const [inpaintPrompt, setInpaintPrompt] = (0, import_react70.useState)("");
|
|
10202
|
+
const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react70.useState)("annotations");
|
|
10203
|
+
const [isRemovingBg, setIsRemovingBg] = (0, import_react70.useState)(false);
|
|
10204
|
+
const [isInpainting, setIsInpainting] = (0, import_react70.useState)(false);
|
|
10205
|
+
const [aiError, setAiError] = (0, import_react70.useState)(null);
|
|
10206
|
+
const [aiSuccess, setAiSuccess] = (0, import_react70.useState)(null);
|
|
10207
|
+
const [aiTarget, setAiTarget] = (0, import_react70.useState)("auto");
|
|
10098
10208
|
const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
|
|
10099
10209
|
const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
|
|
10100
10210
|
const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
|
|
@@ -10157,11 +10267,11 @@ var ImageEditor = ({
|
|
|
10157
10267
|
setIsInpainting(false);
|
|
10158
10268
|
}
|
|
10159
10269
|
};
|
|
10160
|
-
const [activeColor, setActiveColor] = (0,
|
|
10161
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
10162
|
-
const [fontSize, setFontSize] = (0,
|
|
10163
|
-
const [textInput, setTextInput] = (0,
|
|
10164
|
-
(0,
|
|
10270
|
+
const [activeColor, setActiveColor] = (0, import_react70.useState)("#ef4444");
|
|
10271
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react70.useState)(3);
|
|
10272
|
+
const [fontSize, setFontSize] = (0, import_react70.useState)(24);
|
|
10273
|
+
const [textInput, setTextInput] = (0, import_react70.useState)("");
|
|
10274
|
+
(0, import_react70.useEffect)(() => {
|
|
10165
10275
|
if (activeTab === "crop" && editor.state.activeTool !== "crop") {
|
|
10166
10276
|
editor.setTool("crop");
|
|
10167
10277
|
}
|
|
@@ -10189,16 +10299,16 @@ var ImageEditor = ({
|
|
|
10189
10299
|
link.click();
|
|
10190
10300
|
}
|
|
10191
10301
|
};
|
|
10192
|
-
return /* @__PURE__ */ (0,
|
|
10302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
10193
10303
|
"div",
|
|
10194
10304
|
{
|
|
10195
10305
|
ref: rootRef,
|
|
10196
10306
|
className: `${imageEditorFrameClass} ${className}`,
|
|
10197
10307
|
style,
|
|
10198
10308
|
children: [
|
|
10199
|
-
/* @__PURE__ */ (0,
|
|
10200
|
-
/* @__PURE__ */ (0,
|
|
10201
|
-
/* @__PURE__ */ (0,
|
|
10309
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: imageEditorHeaderClass, children: [
|
|
10310
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { role: "tablist", className: imageTabListClass, children: [
|
|
10311
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10202
10312
|
"button",
|
|
10203
10313
|
{
|
|
10204
10314
|
type: "button",
|
|
@@ -10213,7 +10323,7 @@ var ImageEditor = ({
|
|
|
10213
10323
|
children: "Transform & Crop"
|
|
10214
10324
|
}
|
|
10215
10325
|
),
|
|
10216
|
-
/* @__PURE__ */ (0,
|
|
10326
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10217
10327
|
"button",
|
|
10218
10328
|
{
|
|
10219
10329
|
type: "button",
|
|
@@ -10228,7 +10338,7 @@ var ImageEditor = ({
|
|
|
10228
10338
|
children: "Adjustments"
|
|
10229
10339
|
}
|
|
10230
10340
|
),
|
|
10231
|
-
/* @__PURE__ */ (0,
|
|
10341
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10232
10342
|
"button",
|
|
10233
10343
|
{
|
|
10234
10344
|
type: "button",
|
|
@@ -10243,7 +10353,7 @@ var ImageEditor = ({
|
|
|
10243
10353
|
children: "Layers"
|
|
10244
10354
|
}
|
|
10245
10355
|
),
|
|
10246
|
-
/* @__PURE__ */ (0,
|
|
10356
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10247
10357
|
"button",
|
|
10248
10358
|
{
|
|
10249
10359
|
type: "button",
|
|
@@ -10258,7 +10368,7 @@ var ImageEditor = ({
|
|
|
10258
10368
|
children: "Paint"
|
|
10259
10369
|
}
|
|
10260
10370
|
),
|
|
10261
|
-
/* @__PURE__ */ (0,
|
|
10371
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10262
10372
|
"button",
|
|
10263
10373
|
{
|
|
10264
10374
|
type: "button",
|
|
@@ -10273,7 +10383,7 @@ var ImageEditor = ({
|
|
|
10273
10383
|
children: "Select & Mask"
|
|
10274
10384
|
}
|
|
10275
10385
|
),
|
|
10276
|
-
/* @__PURE__ */ (0,
|
|
10386
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10277
10387
|
"button",
|
|
10278
10388
|
{
|
|
10279
10389
|
type: "button",
|
|
@@ -10288,7 +10398,7 @@ var ImageEditor = ({
|
|
|
10288
10398
|
children: "Annotations"
|
|
10289
10399
|
}
|
|
10290
10400
|
),
|
|
10291
|
-
/* @__PURE__ */ (0,
|
|
10401
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10292
10402
|
"button",
|
|
10293
10403
|
{
|
|
10294
10404
|
type: "button",
|
|
@@ -10303,7 +10413,7 @@ var ImageEditor = ({
|
|
|
10303
10413
|
children: "Depth Mask"
|
|
10304
10414
|
}
|
|
10305
10415
|
),
|
|
10306
|
-
/* @__PURE__ */ (0,
|
|
10416
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
10307
10417
|
"button",
|
|
10308
10418
|
{
|
|
10309
10419
|
type: "button",
|
|
@@ -10316,14 +10426,14 @@ var ImageEditor = ({
|
|
|
10316
10426
|
"aria-selected": activeTab === "ai",
|
|
10317
10427
|
className: `${imageTabClass(activeTab === "ai")} flex items-center gap-1.5`,
|
|
10318
10428
|
children: [
|
|
10319
|
-
/* @__PURE__ */ (0,
|
|
10429
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
10320
10430
|
"AI Tools"
|
|
10321
10431
|
]
|
|
10322
10432
|
}
|
|
10323
10433
|
)
|
|
10324
10434
|
] }),
|
|
10325
|
-
/* @__PURE__ */ (0,
|
|
10326
|
-
/* @__PURE__ */ (0,
|
|
10435
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
10436
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10327
10437
|
"button",
|
|
10328
10438
|
{
|
|
10329
10439
|
type: "button",
|
|
@@ -10334,7 +10444,7 @@ var ImageEditor = ({
|
|
|
10334
10444
|
children: "\u21A9"
|
|
10335
10445
|
}
|
|
10336
10446
|
),
|
|
10337
|
-
/* @__PURE__ */ (0,
|
|
10447
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10338
10448
|
"button",
|
|
10339
10449
|
{
|
|
10340
10450
|
type: "button",
|
|
@@ -10345,7 +10455,7 @@ var ImageEditor = ({
|
|
|
10345
10455
|
children: "\u21AA"
|
|
10346
10456
|
}
|
|
10347
10457
|
),
|
|
10348
|
-
/* @__PURE__ */ (0,
|
|
10458
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10349
10459
|
"button",
|
|
10350
10460
|
{
|
|
10351
10461
|
type: "button",
|
|
@@ -10354,8 +10464,8 @@ var ImageEditor = ({
|
|
|
10354
10464
|
children: "Reset"
|
|
10355
10465
|
}
|
|
10356
10466
|
),
|
|
10357
|
-
/* @__PURE__ */ (0,
|
|
10358
|
-
/* @__PURE__ */ (0,
|
|
10467
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
10468
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10359
10469
|
"button",
|
|
10360
10470
|
{
|
|
10361
10471
|
type: "button",
|
|
@@ -10365,11 +10475,11 @@ var ImageEditor = ({
|
|
|
10365
10475
|
children: "-"
|
|
10366
10476
|
}
|
|
10367
10477
|
),
|
|
10368
|
-
/* @__PURE__ */ (0,
|
|
10478
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "font-mono text-muted-foreground w-10 text-center", children: [
|
|
10369
10479
|
Math.round(state.zoom * 100),
|
|
10370
10480
|
"%"
|
|
10371
10481
|
] }),
|
|
10372
|
-
/* @__PURE__ */ (0,
|
|
10482
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10373
10483
|
"button",
|
|
10374
10484
|
{
|
|
10375
10485
|
type: "button",
|
|
@@ -10379,8 +10489,8 @@ var ImageEditor = ({
|
|
|
10379
10489
|
children: "+"
|
|
10380
10490
|
}
|
|
10381
10491
|
),
|
|
10382
|
-
/* @__PURE__ */ (0,
|
|
10383
|
-
/* @__PURE__ */ (0,
|
|
10492
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
10493
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10384
10494
|
"button",
|
|
10385
10495
|
{
|
|
10386
10496
|
type: "button",
|
|
@@ -10391,7 +10501,7 @@ var ImageEditor = ({
|
|
|
10391
10501
|
children: "Hold Compare"
|
|
10392
10502
|
}
|
|
10393
10503
|
),
|
|
10394
|
-
/* @__PURE__ */ (0,
|
|
10504
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10395
10505
|
"button",
|
|
10396
10506
|
{
|
|
10397
10507
|
type: "button",
|
|
@@ -10402,10 +10512,10 @@ var ImageEditor = ({
|
|
|
10402
10512
|
)
|
|
10403
10513
|
] })
|
|
10404
10514
|
] }),
|
|
10405
|
-
transformTool.active && /* @__PURE__ */ (0,
|
|
10406
|
-
!transformTool.active && transformTool.error && /* @__PURE__ */ (0,
|
|
10407
|
-
/* @__PURE__ */ (0,
|
|
10408
|
-
/* @__PURE__ */ (0,
|
|
10515
|
+
transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-border bg-background/95 px-4 py-2" }),
|
|
10516
|
+
!transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { role: "alert", className: imageErrorBannerClass, children: transformTool.error }),
|
|
10517
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
|
|
10518
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10409
10519
|
ImageEditorCanvas,
|
|
10410
10520
|
{
|
|
10411
10521
|
editor,
|
|
@@ -10429,11 +10539,11 @@ var ImageEditor = ({
|
|
|
10429
10539
|
className: "flex-1 h-[360px] md:h-full min-h-[320px] bg-muted"
|
|
10430
10540
|
}
|
|
10431
10541
|
),
|
|
10432
|
-
/* @__PURE__ */ (0,
|
|
10433
|
-
activeTab === "crop" && /* @__PURE__ */ (0,
|
|
10434
|
-
/* @__PURE__ */ (0,
|
|
10435
|
-
/* @__PURE__ */ (0,
|
|
10436
|
-
/* @__PURE__ */ (0,
|
|
10542
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: imageSidebarClass, children: [
|
|
10543
|
+
activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10544
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Aspect Ratio Presets" }),
|
|
10545
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
|
|
10546
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10437
10547
|
"button",
|
|
10438
10548
|
{
|
|
10439
10549
|
type: "button",
|
|
@@ -10445,7 +10555,7 @@ var ImageEditor = ({
|
|
|
10445
10555
|
children: "Freeform"
|
|
10446
10556
|
}
|
|
10447
10557
|
),
|
|
10448
|
-
/* @__PURE__ */ (0,
|
|
10558
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10449
10559
|
"button",
|
|
10450
10560
|
{
|
|
10451
10561
|
type: "button",
|
|
@@ -10457,7 +10567,7 @@ var ImageEditor = ({
|
|
|
10457
10567
|
children: "1:1 Square"
|
|
10458
10568
|
}
|
|
10459
10569
|
),
|
|
10460
|
-
/* @__PURE__ */ (0,
|
|
10570
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10461
10571
|
"button",
|
|
10462
10572
|
{
|
|
10463
10573
|
type: "button",
|
|
@@ -10469,7 +10579,7 @@ var ImageEditor = ({
|
|
|
10469
10579
|
children: "4:3 Standard"
|
|
10470
10580
|
}
|
|
10471
10581
|
),
|
|
10472
|
-
/* @__PURE__ */ (0,
|
|
10582
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10473
10583
|
"button",
|
|
10474
10584
|
{
|
|
10475
10585
|
type: "button",
|
|
@@ -10481,7 +10591,7 @@ var ImageEditor = ({
|
|
|
10481
10591
|
children: "16:9 Wide"
|
|
10482
10592
|
}
|
|
10483
10593
|
),
|
|
10484
|
-
/* @__PURE__ */ (0,
|
|
10594
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10485
10595
|
"button",
|
|
10486
10596
|
{
|
|
10487
10597
|
type: "button",
|
|
@@ -10493,7 +10603,7 @@ var ImageEditor = ({
|
|
|
10493
10603
|
children: "3:2 Photo"
|
|
10494
10604
|
}
|
|
10495
10605
|
),
|
|
10496
|
-
/* @__PURE__ */ (0,
|
|
10606
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10497
10607
|
"button",
|
|
10498
10608
|
{
|
|
10499
10609
|
type: "button",
|
|
@@ -10506,10 +10616,10 @@ var ImageEditor = ({
|
|
|
10506
10616
|
}
|
|
10507
10617
|
)
|
|
10508
10618
|
] }),
|
|
10509
|
-
/* @__PURE__ */ (0,
|
|
10510
|
-
/* @__PURE__ */ (0,
|
|
10511
|
-
/* @__PURE__ */ (0,
|
|
10512
|
-
/* @__PURE__ */ (0,
|
|
10619
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageDividerClass }),
|
|
10620
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Orientation & Flips" }),
|
|
10621
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
10622
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10513
10623
|
"button",
|
|
10514
10624
|
{
|
|
10515
10625
|
type: "button",
|
|
@@ -10518,7 +10628,7 @@ var ImageEditor = ({
|
|
|
10518
10628
|
children: "Rotate -90\xB0"
|
|
10519
10629
|
}
|
|
10520
10630
|
),
|
|
10521
|
-
/* @__PURE__ */ (0,
|
|
10631
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10522
10632
|
"button",
|
|
10523
10633
|
{
|
|
10524
10634
|
type: "button",
|
|
@@ -10527,7 +10637,7 @@ var ImageEditor = ({
|
|
|
10527
10637
|
children: "Rotate +90\xB0"
|
|
10528
10638
|
}
|
|
10529
10639
|
),
|
|
10530
|
-
/* @__PURE__ */ (0,
|
|
10640
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10531
10641
|
"button",
|
|
10532
10642
|
{
|
|
10533
10643
|
type: "button",
|
|
@@ -10536,7 +10646,7 @@ var ImageEditor = ({
|
|
|
10536
10646
|
children: "Flip Horizontal"
|
|
10537
10647
|
}
|
|
10538
10648
|
),
|
|
10539
|
-
/* @__PURE__ */ (0,
|
|
10649
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10540
10650
|
"button",
|
|
10541
10651
|
{
|
|
10542
10652
|
type: "button",
|
|
@@ -10547,10 +10657,10 @@ var ImageEditor = ({
|
|
|
10547
10657
|
)
|
|
10548
10658
|
] })
|
|
10549
10659
|
] }),
|
|
10550
|
-
activeTab === "adjust" && /* @__PURE__ */ (0,
|
|
10551
|
-
/* @__PURE__ */ (0,
|
|
10552
|
-
/* @__PURE__ */ (0,
|
|
10553
|
-
/* @__PURE__ */ (0,
|
|
10660
|
+
activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10661
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10662
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Color Adjustments" }),
|
|
10663
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10554
10664
|
"button",
|
|
10555
10665
|
{
|
|
10556
10666
|
type: "button",
|
|
@@ -10560,25 +10670,25 @@ var ImageEditor = ({
|
|
|
10560
10670
|
}
|
|
10561
10671
|
)
|
|
10562
10672
|
] }),
|
|
10563
|
-
/* @__PURE__ */ (0,
|
|
10564
|
-
|
|
10565
|
-
/* @__PURE__ */ (0,
|
|
10673
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Histogram, { histogram: editor.histogram }),
|
|
10674
|
+
import_image_editor23.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_react70.default.Fragment, { children: [
|
|
10675
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10566
10676
|
ControlSlider,
|
|
10567
10677
|
{
|
|
10568
10678
|
spec,
|
|
10569
|
-
value: (0,
|
|
10679
|
+
value: (0, import_image_editor23.readAdjustmentControls)(state.adjustments)[spec.id],
|
|
10570
10680
|
disabled: spec.requiresProcess !== void 0 && legacyProcess,
|
|
10571
10681
|
onChange: (v) => editor.setAdjustments({ [spec.id]: v })
|
|
10572
10682
|
}
|
|
10573
10683
|
),
|
|
10574
|
-
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0,
|
|
10684
|
+
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
10575
10685
|
"div",
|
|
10576
10686
|
{
|
|
10577
10687
|
className: "flex items-center justify-between gap-2 rounded border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-600",
|
|
10578
10688
|
"data-testid": "image-editor-process-notice",
|
|
10579
10689
|
children: [
|
|
10580
|
-
/* @__PURE__ */ (0,
|
|
10581
|
-
/* @__PURE__ */ (0,
|
|
10690
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
|
|
10691
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10582
10692
|
"button",
|
|
10583
10693
|
{
|
|
10584
10694
|
type: "button",
|
|
@@ -10591,7 +10701,7 @@ var ImageEditor = ({
|
|
|
10591
10701
|
}
|
|
10592
10702
|
)
|
|
10593
10703
|
] }, spec.id)),
|
|
10594
|
-
/* @__PURE__ */ (0,
|
|
10704
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10595
10705
|
AdjustmentLayersPanel,
|
|
10596
10706
|
{
|
|
10597
10707
|
controller,
|
|
@@ -10600,9 +10710,9 @@ var ImageEditor = ({
|
|
|
10600
10710
|
}
|
|
10601
10711
|
) })
|
|
10602
10712
|
] }),
|
|
10603
|
-
activeTab === "layers" && /* @__PURE__ */ (0,
|
|
10604
|
-
/* @__PURE__ */ (0,
|
|
10605
|
-
/* @__PURE__ */ (0,
|
|
10713
|
+
activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10714
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Layers" }),
|
|
10715
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10606
10716
|
"button",
|
|
10607
10717
|
{
|
|
10608
10718
|
type: "button",
|
|
@@ -10613,15 +10723,15 @@ var ImageEditor = ({
|
|
|
10613
10723
|
children: "Free Transform"
|
|
10614
10724
|
}
|
|
10615
10725
|
),
|
|
10616
|
-
/* @__PURE__ */ (0,
|
|
10617
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
10618
|
-
/* @__PURE__ */ (0,
|
|
10619
|
-
/* @__PURE__ */ (0,
|
|
10726
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LayersPanel, { controller }),
|
|
10727
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ImageProviderEffectsPanel, { controller, className: imageSectionClass }),
|
|
10728
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Colour" }),
|
|
10729
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorProfilePanel, { controller })
|
|
10620
10730
|
] }),
|
|
10621
|
-
activeTab === "paint" && /* @__PURE__ */ (0,
|
|
10622
|
-
/* @__PURE__ */ (0,
|
|
10623
|
-
/* @__PURE__ */ (0,
|
|
10624
|
-
/* @__PURE__ */ (0,
|
|
10731
|
+
activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10732
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Paint" }),
|
|
10733
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BrushOptionsBar, { controller }),
|
|
10734
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10625
10735
|
"button",
|
|
10626
10736
|
{
|
|
10627
10737
|
type: "button",
|
|
@@ -10632,12 +10742,12 @@ var ImageEditor = ({
|
|
|
10632
10742
|
children: "Free Transform"
|
|
10633
10743
|
}
|
|
10634
10744
|
),
|
|
10635
|
-
paintError && /* @__PURE__ */ (0,
|
|
10636
|
-
/* @__PURE__ */ (0,
|
|
10745
|
+
paintError && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "paint-error", children: paintError }),
|
|
10746
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LayersPanel, { controller }) })
|
|
10637
10747
|
] }),
|
|
10638
|
-
activeTab === "annotate" && /* @__PURE__ */ (0,
|
|
10639
|
-
/* @__PURE__ */ (0,
|
|
10640
|
-
/* @__PURE__ */ (0,
|
|
10748
|
+
activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10749
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
|
|
10750
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10641
10751
|
"button",
|
|
10642
10752
|
{
|
|
10643
10753
|
type: "button",
|
|
@@ -10648,13 +10758,13 @@ var ImageEditor = ({
|
|
|
10648
10758
|
},
|
|
10649
10759
|
t
|
|
10650
10760
|
)) }),
|
|
10651
|
-
state.activeTool === "shape" && /* @__PURE__ */ (0,
|
|
10652
|
-
state.activeTool === "type" && /* @__PURE__ */ (0,
|
|
10653
|
-
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0,
|
|
10654
|
-
shapeTypeError && /* @__PURE__ */ (0,
|
|
10655
|
-
/* @__PURE__ */ (0,
|
|
10656
|
-
/* @__PURE__ */ (0,
|
|
10657
|
-
/* @__PURE__ */ (0,
|
|
10761
|
+
state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
|
|
10762
|
+
state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
|
|
10763
|
+
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("button", { type: "button", onClick: finishTyping, className: "self-start rounded bg-muted px-2 py-1 text-[11px] text-foreground hover:bg-accent", children: "Done editing text" }),
|
|
10764
|
+
shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "shape-type-error", children: shapeTypeError }),
|
|
10765
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageDividerClass }),
|
|
10766
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Draw & Annotate" }),
|
|
10767
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10658
10768
|
"button",
|
|
10659
10769
|
{
|
|
10660
10770
|
type: "button",
|
|
@@ -10664,18 +10774,18 @@ var ImageEditor = ({
|
|
|
10664
10774
|
},
|
|
10665
10775
|
t
|
|
10666
10776
|
)) }),
|
|
10667
|
-
/* @__PURE__ */ (0,
|
|
10668
|
-
/* @__PURE__ */ (0,
|
|
10669
|
-
/* @__PURE__ */ (0,
|
|
10670
|
-
/* @__PURE__ */ (0,
|
|
10671
|
-
/* @__PURE__ */ (0,
|
|
10672
|
-
/* @__PURE__ */ (0,
|
|
10673
|
-
/* @__PURE__ */ (0,
|
|
10777
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
|
|
10778
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
|
|
10779
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
|
|
10780
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex-1 ml-2", children: [
|
|
10781
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
|
|
10782
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Width:" }),
|
|
10783
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "font-mono", children: [
|
|
10674
10784
|
strokeWidth,
|
|
10675
10785
|
"px"
|
|
10676
10786
|
] })
|
|
10677
10787
|
] }),
|
|
10678
|
-
/* @__PURE__ */ (0,
|
|
10788
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10679
10789
|
"input",
|
|
10680
10790
|
{
|
|
10681
10791
|
type: "range",
|
|
@@ -10688,10 +10798,10 @@ var ImageEditor = ({
|
|
|
10688
10798
|
)
|
|
10689
10799
|
] })
|
|
10690
10800
|
] }),
|
|
10691
|
-
/* @__PURE__ */ (0,
|
|
10692
|
-
/* @__PURE__ */ (0,
|
|
10693
|
-
/* @__PURE__ */ (0,
|
|
10694
|
-
/* @__PURE__ */ (0,
|
|
10801
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageDividerClass }),
|
|
10802
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Add Text" }),
|
|
10803
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex gap-2", children: [
|
|
10804
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10695
10805
|
"input",
|
|
10696
10806
|
{
|
|
10697
10807
|
type: "text",
|
|
@@ -10702,7 +10812,7 @@ var ImageEditor = ({
|
|
|
10702
10812
|
className: "flex-1 bg-background border border-border rounded-lg px-2.5 py-1.5 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary"
|
|
10703
10813
|
}
|
|
10704
10814
|
),
|
|
10705
|
-
/* @__PURE__ */ (0,
|
|
10815
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10706
10816
|
"button",
|
|
10707
10817
|
{
|
|
10708
10818
|
type: "button",
|
|
@@ -10712,14 +10822,14 @@ var ImageEditor = ({
|
|
|
10712
10822
|
}
|
|
10713
10823
|
)
|
|
10714
10824
|
] }),
|
|
10715
|
-
/* @__PURE__ */ (0,
|
|
10716
|
-
/* @__PURE__ */ (0,
|
|
10717
|
-
/* @__PURE__ */ (0,
|
|
10825
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between text-muted-foreground", children: [
|
|
10826
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Font Size:" }),
|
|
10827
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "font-mono", children: [
|
|
10718
10828
|
fontSize,
|
|
10719
10829
|
"px"
|
|
10720
10830
|
] })
|
|
10721
10831
|
] }),
|
|
10722
|
-
/* @__PURE__ */ (0,
|
|
10832
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10723
10833
|
"input",
|
|
10724
10834
|
{
|
|
10725
10835
|
type: "range",
|
|
@@ -10730,14 +10840,14 @@ var ImageEditor = ({
|
|
|
10730
10840
|
className: imageRangeClass
|
|
10731
10841
|
}
|
|
10732
10842
|
),
|
|
10733
|
-
/* @__PURE__ */ (0,
|
|
10734
|
-
/* @__PURE__ */ (0,
|
|
10735
|
-
/* @__PURE__ */ (0,
|
|
10843
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageDividerClass }),
|
|
10844
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10845
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
10736
10846
|
"Layers (",
|
|
10737
10847
|
state.annotations.length,
|
|
10738
10848
|
")"
|
|
10739
10849
|
] }),
|
|
10740
|
-
state.selectedAnnotationId && /* @__PURE__ */ (0,
|
|
10850
|
+
state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10741
10851
|
"button",
|
|
10742
10852
|
{
|
|
10743
10853
|
type: "button",
|
|
@@ -10746,7 +10856,7 @@ var ImageEditor = ({
|
|
|
10746
10856
|
children: "Delete Selected"
|
|
10747
10857
|
}
|
|
10748
10858
|
),
|
|
10749
|
-
state.annotations.length > 0 && /* @__PURE__ */ (0,
|
|
10859
|
+
state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10750
10860
|
"button",
|
|
10751
10861
|
{
|
|
10752
10862
|
type: "button",
|
|
@@ -10757,10 +10867,10 @@ var ImageEditor = ({
|
|
|
10757
10867
|
)
|
|
10758
10868
|
] })
|
|
10759
10869
|
] }),
|
|
10760
|
-
activeTab === "depth" && /* @__PURE__ */ (0,
|
|
10761
|
-
/* @__PURE__ */ (0,
|
|
10762
|
-
/* @__PURE__ */ (0,
|
|
10763
|
-
/* @__PURE__ */ (0,
|
|
10870
|
+
activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10871
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10872
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: imageSectionTitleClass, children: "Depth Masking" }),
|
|
10873
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10764
10874
|
"button",
|
|
10765
10875
|
{
|
|
10766
10876
|
type: "button",
|
|
@@ -10770,8 +10880,8 @@ var ImageEditor = ({
|
|
|
10770
10880
|
}
|
|
10771
10881
|
)
|
|
10772
10882
|
] }),
|
|
10773
|
-
/* @__PURE__ */ (0,
|
|
10774
|
-
/* @__PURE__ */ (0,
|
|
10883
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground", children: [
|
|
10884
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10775
10885
|
"input",
|
|
10776
10886
|
{
|
|
10777
10887
|
type: "checkbox",
|
|
@@ -10780,12 +10890,12 @@ var ImageEditor = ({
|
|
|
10780
10890
|
className: "rounded accent-primary"
|
|
10781
10891
|
}
|
|
10782
10892
|
),
|
|
10783
|
-
/* @__PURE__ */ (0,
|
|
10893
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Enable Depth / Alpha Mask" })
|
|
10784
10894
|
] }),
|
|
10785
|
-
state.depthMask.enabled && /* @__PURE__ */ (0,
|
|
10786
|
-
/* @__PURE__ */ (0,
|
|
10787
|
-
/* @__PURE__ */ (0,
|
|
10788
|
-
/* @__PURE__ */ (0,
|
|
10895
|
+
state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
10896
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
10897
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { className: "text-muted-foreground block mb-1", children: "Mask Image URL:" }),
|
|
10898
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10789
10899
|
"input",
|
|
10790
10900
|
{
|
|
10791
10901
|
type: "text",
|
|
@@ -10796,8 +10906,8 @@ var ImageEditor = ({
|
|
|
10796
10906
|
}
|
|
10797
10907
|
)
|
|
10798
10908
|
] }),
|
|
10799
|
-
/* @__PURE__ */ (0,
|
|
10800
|
-
/* @__PURE__ */ (0,
|
|
10909
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex gap-2", children: [
|
|
10910
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10801
10911
|
"button",
|
|
10802
10912
|
{
|
|
10803
10913
|
type: "button",
|
|
@@ -10806,7 +10916,7 @@ var ImageEditor = ({
|
|
|
10806
10916
|
children: "Threshold Mode"
|
|
10807
10917
|
}
|
|
10808
10918
|
),
|
|
10809
|
-
/* @__PURE__ */ (0,
|
|
10919
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10810
10920
|
"button",
|
|
10811
10921
|
{
|
|
10812
10922
|
type: "button",
|
|
@@ -10816,12 +10926,12 @@ var ImageEditor = ({
|
|
|
10816
10926
|
}
|
|
10817
10927
|
)
|
|
10818
10928
|
] }),
|
|
10819
|
-
/* @__PURE__ */ (0,
|
|
10820
|
-
/* @__PURE__ */ (0,
|
|
10821
|
-
/* @__PURE__ */ (0,
|
|
10822
|
-
/* @__PURE__ */ (0,
|
|
10929
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
10930
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
10931
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Depth Start (Lower):" }),
|
|
10932
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
|
|
10823
10933
|
] }),
|
|
10824
|
-
/* @__PURE__ */ (0,
|
|
10934
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10825
10935
|
"input",
|
|
10826
10936
|
{
|
|
10827
10937
|
type: "range",
|
|
@@ -10835,12 +10945,12 @@ var ImageEditor = ({
|
|
|
10835
10945
|
}
|
|
10836
10946
|
)
|
|
10837
10947
|
] }),
|
|
10838
|
-
/* @__PURE__ */ (0,
|
|
10839
|
-
/* @__PURE__ */ (0,
|
|
10840
|
-
/* @__PURE__ */ (0,
|
|
10841
|
-
/* @__PURE__ */ (0,
|
|
10948
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
10949
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
10950
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Depth Stop (Upper):" }),
|
|
10951
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
|
|
10842
10952
|
] }),
|
|
10843
|
-
/* @__PURE__ */ (0,
|
|
10953
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10844
10954
|
"input",
|
|
10845
10955
|
{
|
|
10846
10956
|
type: "range",
|
|
@@ -10854,12 +10964,12 @@ var ImageEditor = ({
|
|
|
10854
10964
|
}
|
|
10855
10965
|
)
|
|
10856
10966
|
] }),
|
|
10857
|
-
/* @__PURE__ */ (0,
|
|
10858
|
-
/* @__PURE__ */ (0,
|
|
10859
|
-
/* @__PURE__ */ (0,
|
|
10860
|
-
/* @__PURE__ */ (0,
|
|
10967
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
10968
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
10969
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Softness:" }),
|
|
10970
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
|
|
10861
10971
|
] }),
|
|
10862
|
-
/* @__PURE__ */ (0,
|
|
10972
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10863
10973
|
"input",
|
|
10864
10974
|
{
|
|
10865
10975
|
type: "range",
|
|
@@ -10871,8 +10981,8 @@ var ImageEditor = ({
|
|
|
10871
10981
|
}
|
|
10872
10982
|
)
|
|
10873
10983
|
] }),
|
|
10874
|
-
/* @__PURE__ */ (0,
|
|
10875
|
-
/* @__PURE__ */ (0,
|
|
10984
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground mt-1", children: [
|
|
10985
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10876
10986
|
"input",
|
|
10877
10987
|
{
|
|
10878
10988
|
type: "checkbox",
|
|
@@ -10881,12 +10991,12 @@ var ImageEditor = ({
|
|
|
10881
10991
|
className: "rounded accent-primary"
|
|
10882
10992
|
}
|
|
10883
10993
|
),
|
|
10884
|
-
/* @__PURE__ */ (0,
|
|
10994
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Invert Mask" })
|
|
10885
10995
|
] })
|
|
10886
10996
|
] })
|
|
10887
10997
|
] }),
|
|
10888
|
-
activeTab === "select" && /* @__PURE__ */ (0,
|
|
10889
|
-
/* @__PURE__ */ (0,
|
|
10998
|
+
activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10999
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10890
11000
|
SelectionOptionsBar,
|
|
10891
11001
|
{
|
|
10892
11002
|
controller,
|
|
@@ -10897,9 +11007,9 @@ var ImageEditor = ({
|
|
|
10897
11007
|
selectionDisplay: state.selectionDisplay
|
|
10898
11008
|
}
|
|
10899
11009
|
),
|
|
10900
|
-
selectionError && /* @__PURE__ */ (0,
|
|
10901
|
-
/* @__PURE__ */ (0,
|
|
10902
|
-
/* @__PURE__ */ (0,
|
|
11010
|
+
selectionError && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
|
|
11011
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex gap-1", children: [
|
|
11012
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10903
11013
|
"button",
|
|
10904
11014
|
{
|
|
10905
11015
|
type: "button",
|
|
@@ -10910,7 +11020,7 @@ var ImageEditor = ({
|
|
|
10910
11020
|
children: "Transform Selection"
|
|
10911
11021
|
}
|
|
10912
11022
|
),
|
|
10913
|
-
/* @__PURE__ */ (0,
|
|
11023
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10914
11024
|
"button",
|
|
10915
11025
|
{
|
|
10916
11026
|
type: "button",
|
|
@@ -10922,13 +11032,14 @@ var ImageEditor = ({
|
|
|
10922
11032
|
}
|
|
10923
11033
|
)
|
|
10924
11034
|
] }),
|
|
10925
|
-
/* @__PURE__ */ (0,
|
|
10926
|
-
/* @__PURE__ */ (0,
|
|
11035
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers }),
|
|
11036
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ChannelsPanel, { controller }),
|
|
11037
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PathsPanel, { controller })
|
|
10927
11038
|
] }),
|
|
10928
|
-
activeTab === "ai" && /* @__PURE__ */ (0,
|
|
10929
|
-
/* @__PURE__ */ (0,
|
|
10930
|
-
/* @__PURE__ */ (0,
|
|
10931
|
-
/* @__PURE__ */ (0,
|
|
11039
|
+
activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
11040
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center justify-between gap-2 text-foreground", children: [
|
|
11041
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: "Results go to" }),
|
|
11042
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
10932
11043
|
"select",
|
|
10933
11044
|
{
|
|
10934
11045
|
"aria-label": "AI result target",
|
|
@@ -10936,54 +11047,54 @@ var ImageEditor = ({
|
|
|
10936
11047
|
onChange: (e) => setAiTarget(e.target.value),
|
|
10937
11048
|
className: imageSelectClass,
|
|
10938
11049
|
children: [
|
|
10939
|
-
/* @__PURE__ */ (0,
|
|
10940
|
-
/* @__PURE__ */ (0,
|
|
10941
|
-
/* @__PURE__ */ (0,
|
|
11050
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
|
|
11051
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
|
|
11052
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: "replace", children: "Replace image" })
|
|
10942
11053
|
]
|
|
10943
11054
|
}
|
|
10944
11055
|
)
|
|
10945
11056
|
] }),
|
|
10946
|
-
/* @__PURE__ */ (0,
|
|
10947
|
-
/* @__PURE__ */ (0,
|
|
10948
|
-
/* @__PURE__ */ (0,
|
|
10949
|
-
/* @__PURE__ */ (0,
|
|
11057
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
11058
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11059
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
11060
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" }) }),
|
|
10950
11061
|
"Background Removal"
|
|
10951
11062
|
] }),
|
|
10952
|
-
isRemovingBg && /* @__PURE__ */ (0,
|
|
11063
|
+
isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-primary/15 text-primary animate-pulse", children: "Removing..." })
|
|
10953
11064
|
] }),
|
|
10954
|
-
/* @__PURE__ */ (0,
|
|
10955
|
-
/* @__PURE__ */ (0,
|
|
11065
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
|
|
11066
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10956
11067
|
"button",
|
|
10957
11068
|
{
|
|
10958
11069
|
type: "button",
|
|
10959
11070
|
onClick: handleRemoveBackground,
|
|
10960
11071
|
disabled: isRemovingBg || isInpainting,
|
|
10961
11072
|
className: "mt-1 px-3 py-2 rounded-lg bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground font-medium shadow transition-colors flex items-center justify-center gap-2",
|
|
10962
|
-
children: isRemovingBg ? /* @__PURE__ */ (0,
|
|
10963
|
-
/* @__PURE__ */ (0,
|
|
11073
|
+
children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
11074
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSpinnerClass }),
|
|
10964
11075
|
"Removing Background..."
|
|
10965
|
-
] }) : /* @__PURE__ */ (0,
|
|
10966
|
-
/* @__PURE__ */ (0,
|
|
11076
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
11077
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
10967
11078
|
"Remove Background"
|
|
10968
11079
|
] })
|
|
10969
11080
|
}
|
|
10970
11081
|
)
|
|
10971
11082
|
] }),
|
|
10972
|
-
/* @__PURE__ */ (0,
|
|
10973
|
-
/* @__PURE__ */ (0,
|
|
10974
|
-
/* @__PURE__ */ (0,
|
|
10975
|
-
/* @__PURE__ */ (0,
|
|
10976
|
-
/* @__PURE__ */ (0,
|
|
10977
|
-
/* @__PURE__ */ (0,
|
|
11083
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
11084
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11085
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
11086
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
11087
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "m21.64 3.64-1.28-1.28a1.2 1.2 0 0 0-1.7 0l-9.72 9.72-1.94 4.86 4.86-1.94 9.72-9.72a1.2 1.2 0 0 0 .06-1.64z" }),
|
|
11088
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "m14 7 3 3" })
|
|
10978
11089
|
] }),
|
|
10979
11090
|
"Generative Inpainting"
|
|
10980
11091
|
] }),
|
|
10981
|
-
isInpainting && /* @__PURE__ */ (0,
|
|
11092
|
+
isInpainting && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-primary/15 text-primary animate-pulse", children: "Inpainting..." })
|
|
10982
11093
|
] }),
|
|
10983
|
-
/* @__PURE__ */ (0,
|
|
10984
|
-
/* @__PURE__ */ (0,
|
|
10985
|
-
/* @__PURE__ */ (0,
|
|
10986
|
-
/* @__PURE__ */ (0,
|
|
11094
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
|
|
11095
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
11096
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-foreground text-[11px] font-medium", children: "Prompt" }),
|
|
11097
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10987
11098
|
"textarea",
|
|
10988
11099
|
{
|
|
10989
11100
|
id: "ai-inpaint-prompt-react",
|
|
@@ -10995,10 +11106,10 @@ var ImageEditor = ({
|
|
|
10995
11106
|
}
|
|
10996
11107
|
)
|
|
10997
11108
|
] }),
|
|
10998
|
-
/* @__PURE__ */ (0,
|
|
10999
|
-
/* @__PURE__ */ (0,
|
|
11000
|
-
/* @__PURE__ */ (0,
|
|
11001
|
-
/* @__PURE__ */ (0,
|
|
11109
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
11110
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-foreground text-[11px] font-medium", children: "Target Mask Region" }),
|
|
11111
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
|
|
11112
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
11002
11113
|
"button",
|
|
11003
11114
|
{
|
|
11004
11115
|
type: "button",
|
|
@@ -11011,7 +11122,7 @@ var ImageEditor = ({
|
|
|
11011
11122
|
]
|
|
11012
11123
|
}
|
|
11013
11124
|
),
|
|
11014
|
-
/* @__PURE__ */ (0,
|
|
11125
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
11015
11126
|
"button",
|
|
11016
11127
|
{
|
|
11017
11128
|
type: "button",
|
|
@@ -11026,25 +11137,25 @@ var ImageEditor = ({
|
|
|
11026
11137
|
)
|
|
11027
11138
|
] })
|
|
11028
11139
|
] }),
|
|
11029
|
-
/* @__PURE__ */ (0,
|
|
11140
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
11030
11141
|
"button",
|
|
11031
11142
|
{
|
|
11032
11143
|
type: "button",
|
|
11033
11144
|
onClick: handleInpaint,
|
|
11034
11145
|
disabled: isInpainting || isRemovingBg || !inpaintPrompt.trim(),
|
|
11035
11146
|
className: "mt-1 px-3 py-2 rounded-lg bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground font-medium shadow transition-colors flex items-center justify-center gap-2",
|
|
11036
|
-
children: isInpainting ? /* @__PURE__ */ (0,
|
|
11037
|
-
/* @__PURE__ */ (0,
|
|
11147
|
+
children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
11148
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: imageSpinnerClass }),
|
|
11038
11149
|
"Generating Inpaint..."
|
|
11039
|
-
] }) : /* @__PURE__ */ (0,
|
|
11040
|
-
/* @__PURE__ */ (0,
|
|
11150
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
11151
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
11041
11152
|
"Apply Inpainting"
|
|
11042
11153
|
] })
|
|
11043
11154
|
}
|
|
11044
11155
|
)
|
|
11045
11156
|
] }),
|
|
11046
|
-
aiError && /* @__PURE__ */ (0,
|
|
11047
|
-
aiSuccess && /* @__PURE__ */ (0,
|
|
11157
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "p-2.5 rounded-lg bg-destructive/10 border border-destructive/40 text-destructive text-[11px]", children: aiError }),
|
|
11158
|
+
aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-600 text-[11px]", children: aiSuccess })
|
|
11048
11159
|
] })
|
|
11049
11160
|
] })
|
|
11050
11161
|
] })
|
|
@@ -11054,7 +11165,7 @@ var ImageEditor = ({
|
|
|
11054
11165
|
};
|
|
11055
11166
|
|
|
11056
11167
|
// src/review/useReview.ts
|
|
11057
|
-
var
|
|
11168
|
+
var import_react71 = require("react");
|
|
11058
11169
|
var import_editor13 = require("@pixerate/editor");
|
|
11059
11170
|
var EMPTY_COMMENTS = Object.freeze({
|
|
11060
11171
|
threads: [],
|
|
@@ -11073,23 +11184,23 @@ function isCommentStore(value) {
|
|
|
11073
11184
|
}
|
|
11074
11185
|
function useComments(source) {
|
|
11075
11186
|
const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
|
|
11076
|
-
const subscribe = (0,
|
|
11187
|
+
const subscribe = (0, import_react71.useCallback)(
|
|
11077
11188
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
11078
11189
|
[store]
|
|
11079
11190
|
);
|
|
11080
11191
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
11081
|
-
const snapshot = (0,
|
|
11082
|
-
return (0,
|
|
11192
|
+
const snapshot = (0, import_react71.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11193
|
+
return (0, import_react71.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
11083
11194
|
}
|
|
11084
11195
|
function useTrackChanges(editor) {
|
|
11085
11196
|
const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
|
|
11086
|
-
const subscribe = (0,
|
|
11197
|
+
const subscribe = (0, import_react71.useCallback)(
|
|
11087
11198
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
11088
11199
|
[store]
|
|
11089
11200
|
);
|
|
11090
11201
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
11091
|
-
const snapshot = (0,
|
|
11092
|
-
return (0,
|
|
11202
|
+
const snapshot = (0, import_react71.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11203
|
+
return (0, import_react71.useMemo)(() => {
|
|
11093
11204
|
const run = (fn) => () => {
|
|
11094
11205
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
11095
11206
|
};
|
|
@@ -11112,9 +11223,9 @@ function useTrackChanges(editor) {
|
|
|
11112
11223
|
}
|
|
11113
11224
|
|
|
11114
11225
|
// src/review/CommentsPanel.tsx
|
|
11115
|
-
var
|
|
11226
|
+
var import_react72 = require("react");
|
|
11116
11227
|
var import_editor14 = require("@pixerate/editor");
|
|
11117
|
-
var
|
|
11228
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
11118
11229
|
var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
|
|
11119
11230
|
var primaryButtonClass = "rounded px-2 py-1 text-xs bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50";
|
|
11120
11231
|
var textareaClass = "w-full resize-y rounded-md border border-input bg-background p-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-primary";
|
|
@@ -11128,18 +11239,18 @@ var CommentsPanel = ({
|
|
|
11128
11239
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
11129
11240
|
}) => {
|
|
11130
11241
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
11131
|
-
const [showResolved, setShowResolved] = (0,
|
|
11242
|
+
const [showResolved, setShowResolved] = (0, import_react72.useState)(showResolvedInitial);
|
|
11132
11243
|
const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
11133
11244
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
11134
11245
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
11135
|
-
return /* @__PURE__ */ (0,
|
|
11136
|
-
/* @__PURE__ */ (0,
|
|
11137
|
-
/* @__PURE__ */ (0,
|
|
11246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("aside", { className, "aria-label": "Comments", children: [
|
|
11247
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
11248
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
11138
11249
|
threads.length - resolvedCount,
|
|
11139
11250
|
" open",
|
|
11140
11251
|
resolvedCount > 0 ? ` \xB7 ${resolvedCount} resolved` : ""
|
|
11141
11252
|
] }),
|
|
11142
|
-
resolvedCount > 0 && /* @__PURE__ */ (0,
|
|
11253
|
+
resolvedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
11143
11254
|
"button",
|
|
11144
11255
|
{
|
|
11145
11256
|
type: "button",
|
|
@@ -11150,7 +11261,7 @@ var CommentsPanel = ({
|
|
|
11150
11261
|
}
|
|
11151
11262
|
)
|
|
11152
11263
|
] }),
|
|
11153
|
-
visible.length === 0 ? /* @__PURE__ */ (0,
|
|
11264
|
+
visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className: "flex flex-col gap-2", role: "list", children: visible.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
11154
11265
|
CommentThreadCard,
|
|
11155
11266
|
{
|
|
11156
11267
|
thread,
|
|
@@ -11172,7 +11283,7 @@ var CommentThreadCard = ({
|
|
|
11172
11283
|
author,
|
|
11173
11284
|
formatTime
|
|
11174
11285
|
}) => {
|
|
11175
|
-
const [draft, setDraft] = (0,
|
|
11286
|
+
const [draft, setDraft] = (0, import_react72.useState)("");
|
|
11176
11287
|
const isDraft = thread.body === "";
|
|
11177
11288
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
11178
11289
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -11198,7 +11309,7 @@ var CommentThreadCard = ({
|
|
|
11198
11309
|
setDraft("");
|
|
11199
11310
|
};
|
|
11200
11311
|
const stop = (e) => e.stopPropagation();
|
|
11201
|
-
return /* @__PURE__ */ (0,
|
|
11312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
11202
11313
|
"li",
|
|
11203
11314
|
{
|
|
11204
11315
|
className: `flex flex-col gap-2 rounded-md border bg-background p-3 cursor-pointer ${active ? "border-primary ring-1 ring-primary" : "border-border"} ${thread.resolved ? "opacity-70" : ""}`,
|
|
@@ -11214,24 +11325,24 @@ var CommentThreadCard = ({
|
|
|
11214
11325
|
}
|
|
11215
11326
|
},
|
|
11216
11327
|
children: [
|
|
11217
|
-
/* @__PURE__ */ (0,
|
|
11218
|
-
/* @__PURE__ */ (0,
|
|
11219
|
-
/* @__PURE__ */ (0,
|
|
11328
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
11329
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "font-medium", children: thread.author.name }),
|
|
11330
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "text-xs text-muted-foreground", children: formatTime(thread.createdAt) })
|
|
11220
11331
|
] }),
|
|
11221
|
-
quote && /* @__PURE__ */ (0,
|
|
11222
|
-
thread.orphaned && /* @__PURE__ */ (0,
|
|
11223
|
-
thread.resolved && /* @__PURE__ */ (0,
|
|
11224
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
11225
|
-
thread.replies.length > 0 && /* @__PURE__ */ (0,
|
|
11226
|
-
/* @__PURE__ */ (0,
|
|
11227
|
-
/* @__PURE__ */ (0,
|
|
11332
|
+
quote && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("blockquote", { className: "border-l-2 border-border pl-2 text-xs text-muted-foreground line-clamp-2", children: quote }),
|
|
11333
|
+
thread.orphaned && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "text-xs text-destructive", children: "The commented text was deleted." }),
|
|
11334
|
+
thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "text-xs text-muted-foreground", children: "Resolved" }),
|
|
11335
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "whitespace-pre-wrap break-words", children: thread.body }),
|
|
11336
|
+
thread.replies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className: "flex flex-col gap-2 border-l border-border pl-3", role: "list", children: thread.replies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("li", { className: "flex flex-col gap-0.5", "data-reply-id": reply.id, children: [
|
|
11337
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { className: "text-xs", children: [
|
|
11338
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "font-medium", children: reply.author.name }),
|
|
11228
11339
|
" ",
|
|
11229
|
-
/* @__PURE__ */ (0,
|
|
11340
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "text-muted-foreground", children: formatTime(reply.createdAt) })
|
|
11230
11341
|
] }),
|
|
11231
|
-
/* @__PURE__ */ (0,
|
|
11342
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "whitespace-pre-wrap break-words", children: reply.body })
|
|
11232
11343
|
] }, reply.id)) }),
|
|
11233
|
-
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0,
|
|
11234
|
-
/* @__PURE__ */ (0,
|
|
11344
|
+
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex flex-col gap-1", onClick: stop, children: [
|
|
11345
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
11235
11346
|
"textarea",
|
|
11236
11347
|
{
|
|
11237
11348
|
className: textareaClass,
|
|
@@ -11249,9 +11360,9 @@ var CommentThreadCard = ({
|
|
|
11249
11360
|
}
|
|
11250
11361
|
}
|
|
11251
11362
|
),
|
|
11252
|
-
/* @__PURE__ */ (0,
|
|
11253
|
-
isDraft && /* @__PURE__ */ (0,
|
|
11254
|
-
/* @__PURE__ */ (0,
|
|
11363
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-end gap-1", children: [
|
|
11364
|
+
isDraft && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass2, onClick: remove, children: "Cancel" }),
|
|
11365
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
11255
11366
|
"button",
|
|
11256
11367
|
{
|
|
11257
11368
|
type: "button",
|
|
@@ -11263,9 +11374,9 @@ var CommentThreadCard = ({
|
|
|
11263
11374
|
)
|
|
11264
11375
|
] })
|
|
11265
11376
|
] }),
|
|
11266
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
11267
|
-
/* @__PURE__ */ (0,
|
|
11268
|
-
/* @__PURE__ */ (0,
|
|
11377
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-end gap-1", onClick: stop, children: [
|
|
11378
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass2, onClick: () => setResolved(!thread.resolved), children: thread.resolved ? "Reopen" : "Resolve" }),
|
|
11379
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
11269
11380
|
"button",
|
|
11270
11381
|
{
|
|
11271
11382
|
type: "button",
|
|
@@ -11281,7 +11392,7 @@ var CommentThreadCard = ({
|
|
|
11281
11392
|
};
|
|
11282
11393
|
|
|
11283
11394
|
// src/review/ReviewToolbar.tsx
|
|
11284
|
-
var
|
|
11395
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
11285
11396
|
var defaultDescriptionClass = "max-w-[16rem] truncate px-1 text-xs text-muted-foreground";
|
|
11286
11397
|
var buttonClass3 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
11287
11398
|
var ReviewToolbar = ({
|
|
@@ -11294,8 +11405,8 @@ var ReviewToolbar = ({
|
|
|
11294
11405
|
const count = review.changes.length;
|
|
11295
11406
|
const current = review.currentChange;
|
|
11296
11407
|
const index = current ? review.changes.findIndex((c) => c.id === current.id) + 1 : 0;
|
|
11297
|
-
return /* @__PURE__ */ (0,
|
|
11298
|
-
/* @__PURE__ */ (0,
|
|
11408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className, role: "toolbar", "aria-label": "Review", children: [
|
|
11409
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
11299
11410
|
"button",
|
|
11300
11411
|
{
|
|
11301
11412
|
type: "button",
|
|
@@ -11306,8 +11417,8 @@ var ReviewToolbar = ({
|
|
|
11306
11417
|
children: review.enabled ? "Tracking on" : "Track changes"
|
|
11307
11418
|
}
|
|
11308
11419
|
),
|
|
11309
|
-
/* @__PURE__ */ (0,
|
|
11310
|
-
/* @__PURE__ */ (0,
|
|
11420
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
11421
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
11311
11422
|
"button",
|
|
11312
11423
|
{
|
|
11313
11424
|
type: "button",
|
|
@@ -11318,8 +11429,8 @@ var ReviewToolbar = ({
|
|
|
11318
11429
|
children: "\u2039"
|
|
11319
11430
|
}
|
|
11320
11431
|
),
|
|
11321
|
-
/* @__PURE__ */ (0,
|
|
11322
|
-
/* @__PURE__ */ (0,
|
|
11432
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "min-w-[4rem] text-center text-xs text-muted-foreground", "aria-live": "polite", children: count === 0 ? "No changes" : current ? `${index} of ${count}` : `${count} changes` }),
|
|
11433
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
11323
11434
|
"button",
|
|
11324
11435
|
{
|
|
11325
11436
|
type: "button",
|
|
@@ -11330,7 +11441,7 @@ var ReviewToolbar = ({
|
|
|
11330
11441
|
children: "\u203A"
|
|
11331
11442
|
}
|
|
11332
11443
|
),
|
|
11333
|
-
showDescription && current && /* @__PURE__ */ (0,
|
|
11444
|
+
showDescription && current && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
11334
11445
|
"span",
|
|
11335
11446
|
{
|
|
11336
11447
|
className: descriptionClassName,
|
|
@@ -11342,8 +11453,8 @@ var ReviewToolbar = ({
|
|
|
11342
11453
|
]
|
|
11343
11454
|
}
|
|
11344
11455
|
),
|
|
11345
|
-
/* @__PURE__ */ (0,
|
|
11346
|
-
/* @__PURE__ */ (0,
|
|
11456
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
11457
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
11347
11458
|
"button",
|
|
11348
11459
|
{
|
|
11349
11460
|
type: "button",
|
|
@@ -11353,7 +11464,7 @@ var ReviewToolbar = ({
|
|
|
11353
11464
|
children: "Accept"
|
|
11354
11465
|
}
|
|
11355
11466
|
),
|
|
11356
|
-
/* @__PURE__ */ (0,
|
|
11467
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
11357
11468
|
"button",
|
|
11358
11469
|
{
|
|
11359
11470
|
type: "button",
|
|
@@ -11363,18 +11474,18 @@ var ReviewToolbar = ({
|
|
|
11363
11474
|
children: "Reject"
|
|
11364
11475
|
}
|
|
11365
11476
|
),
|
|
11366
|
-
/* @__PURE__ */ (0,
|
|
11367
|
-
/* @__PURE__ */ (0,
|
|
11477
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.acceptAll, children: "Accept all" }),
|
|
11478
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.rejectAll, children: "Reject all" })
|
|
11368
11479
|
] });
|
|
11369
11480
|
};
|
|
11370
11481
|
|
|
11371
11482
|
// src/review/CommentButton.tsx
|
|
11372
|
-
var
|
|
11483
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
11373
11484
|
var CommentButton = ({
|
|
11374
11485
|
editor,
|
|
11375
11486
|
className = "rounded px-2 py-1 text-xs text-popover-foreground hover:bg-muted",
|
|
11376
11487
|
children = "Comment"
|
|
11377
|
-
}) => /* @__PURE__ */ (0,
|
|
11488
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11378
11489
|
"button",
|
|
11379
11490
|
{
|
|
11380
11491
|
type: "button",
|
|
@@ -11386,13 +11497,13 @@ var CommentButton = ({
|
|
|
11386
11497
|
);
|
|
11387
11498
|
|
|
11388
11499
|
// src/review/useDocumentCompare.ts
|
|
11389
|
-
var
|
|
11500
|
+
var import_react73 = require("react");
|
|
11390
11501
|
var import_editor15 = require("@pixerate/editor");
|
|
11391
11502
|
function useDocumentCompare(editor, options) {
|
|
11392
|
-
const [summary, setSummary] = (0,
|
|
11393
|
-
const defaults = (0,
|
|
11503
|
+
const [summary, setSummary] = (0, import_react73.useState)(null);
|
|
11504
|
+
const defaults = (0, import_react73.useRef)(options);
|
|
11394
11505
|
defaults.current = options;
|
|
11395
|
-
const compare = (0,
|
|
11506
|
+
const compare = (0, import_react73.useCallback)(
|
|
11396
11507
|
(original, revised, overrides) => {
|
|
11397
11508
|
if (!editor || editor.isDestroyed) return null;
|
|
11398
11509
|
const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
|
|
@@ -11404,13 +11515,13 @@ function useDocumentCompare(editor, options) {
|
|
|
11404
11515
|
},
|
|
11405
11516
|
[editor]
|
|
11406
11517
|
);
|
|
11407
|
-
const clear = (0,
|
|
11408
|
-
return (0,
|
|
11518
|
+
const clear = (0, import_react73.useCallback)(() => setSummary(null), []);
|
|
11519
|
+
return (0, import_react73.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
11409
11520
|
}
|
|
11410
11521
|
|
|
11411
11522
|
// src/review/TrackedChangesList.tsx
|
|
11412
11523
|
var import_editor16 = require("@pixerate/editor");
|
|
11413
|
-
var
|
|
11524
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
11414
11525
|
var buttonClass4 = "rounded px-1.5 py-0.5 text-xs text-foreground hover:bg-muted disabled:opacity-40";
|
|
11415
11526
|
var TrackedChangesList = ({
|
|
11416
11527
|
editor,
|
|
@@ -11421,18 +11532,18 @@ var TrackedChangesList = ({
|
|
|
11421
11532
|
}) => {
|
|
11422
11533
|
const review = useTrackChanges(editor);
|
|
11423
11534
|
if (review.changes.length === 0) {
|
|
11424
|
-
return /* @__PURE__ */ (0,
|
|
11535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, "data-tracked-changes-list": "", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "pixerate-changes-empty text-xs text-muted-foreground", children: emptyState }) });
|
|
11425
11536
|
}
|
|
11426
|
-
return /* @__PURE__ */ (0,
|
|
11537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { className, role: "list", "aria-label": "Tracked changes", "data-tracked-changes-list": "", children: review.changes.map((change) => {
|
|
11427
11538
|
const active = change.id === review.currentChangeId;
|
|
11428
|
-
return /* @__PURE__ */ (0,
|
|
11539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
11429
11540
|
"li",
|
|
11430
11541
|
{
|
|
11431
11542
|
className: active ? `${itemClassName} ${activeItemClassName}` : itemClassName,
|
|
11432
11543
|
"data-change-type": change.type,
|
|
11433
11544
|
"data-change-id": change.id,
|
|
11434
11545
|
children: [
|
|
11435
|
-
/* @__PURE__ */ (0,
|
|
11546
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
11436
11547
|
"button",
|
|
11437
11548
|
{
|
|
11438
11549
|
type: "button",
|
|
@@ -11440,14 +11551,14 @@ var TrackedChangesList = ({
|
|
|
11440
11551
|
title: `${change.author.name}: ${change.description}`,
|
|
11441
11552
|
onClick: () => review.select(change.id),
|
|
11442
11553
|
children: [
|
|
11443
|
-
/* @__PURE__ */ (0,
|
|
11554
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "font-medium", children: (0, import_editor16.trackedChangeLabel)(change) }),
|
|
11444
11555
|
change.author.name ? ` \xB7 ${change.author.name}` : "",
|
|
11445
|
-
/* @__PURE__ */ (0,
|
|
11556
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "block truncate text-muted-foreground", children: change.description })
|
|
11446
11557
|
]
|
|
11447
11558
|
}
|
|
11448
11559
|
),
|
|
11449
|
-
/* @__PURE__ */ (0,
|
|
11450
|
-
/* @__PURE__ */ (0,
|
|
11560
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.accept(change.id), children: "Accept" }),
|
|
11561
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.reject(change.id), children: "Reject" })
|
|
11451
11562
|
]
|
|
11452
11563
|
},
|
|
11453
11564
|
`${change.type}:${change.id}`
|
|
@@ -11456,12 +11567,12 @@ var TrackedChangesList = ({
|
|
|
11456
11567
|
};
|
|
11457
11568
|
|
|
11458
11569
|
// src/commands/useCommandPalette.ts
|
|
11459
|
-
var
|
|
11570
|
+
var import_react74 = require("react");
|
|
11460
11571
|
var import_commands2 = require("@pixerate/editor/commands");
|
|
11461
11572
|
function useCommandPalette(registry, options = {}) {
|
|
11462
|
-
const optionsRef = (0,
|
|
11573
|
+
const optionsRef = (0, import_react74.useRef)(options);
|
|
11463
11574
|
optionsRef.current = options;
|
|
11464
|
-
const controller = (0,
|
|
11575
|
+
const controller = (0, import_react74.useMemo)(
|
|
11465
11576
|
() => (0, import_commands2.createCommandPaletteController)(registry, {
|
|
11466
11577
|
context: () => {
|
|
11467
11578
|
const c = optionsRef.current.context;
|
|
@@ -11482,9 +11593,9 @@ function useCommandPalette(registry, options = {}) {
|
|
|
11482
11593
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11483
11594
|
[registry]
|
|
11484
11595
|
);
|
|
11485
|
-
const state = (0,
|
|
11596
|
+
const state = (0, import_react74.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
11486
11597
|
const { hotkey, hotkeyTarget } = options;
|
|
11487
|
-
(0,
|
|
11598
|
+
(0, import_react74.useEffect)(() => {
|
|
11488
11599
|
if (!hotkey) return;
|
|
11489
11600
|
const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
|
|
11490
11601
|
if (!target) return;
|
|
@@ -11512,13 +11623,13 @@ function useCommandPalette(registry, options = {}) {
|
|
|
11512
11623
|
}
|
|
11513
11624
|
|
|
11514
11625
|
// src/commands/CommandPalette.tsx
|
|
11515
|
-
var
|
|
11516
|
-
var
|
|
11626
|
+
var import_react75 = __toESM(require("react"), 1);
|
|
11627
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
11517
11628
|
function HighlightedLabel({ item }) {
|
|
11518
|
-
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0,
|
|
11629
|
+
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_jsx_runtime55.Fragment, { children: item.label });
|
|
11519
11630
|
const marked = new Set(item.labelIndices);
|
|
11520
|
-
return /* @__PURE__ */ (0,
|
|
11521
|
-
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0,
|
|
11631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_jsx_runtime55.Fragment, { children: Array.from(item.label).map(
|
|
11632
|
+
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react75.default.Fragment, { children: ch }, i)
|
|
11522
11633
|
) });
|
|
11523
11634
|
}
|
|
11524
11635
|
var CommandPalette = ({
|
|
@@ -11527,22 +11638,22 @@ var CommandPalette = ({
|
|
|
11527
11638
|
emptyMessage = "No matching commands",
|
|
11528
11639
|
className = ""
|
|
11529
11640
|
}) => {
|
|
11530
|
-
const inputRef = (0,
|
|
11531
|
-
const listRef = (0,
|
|
11532
|
-
const baseId = (0,
|
|
11641
|
+
const inputRef = (0, import_react75.useRef)(null);
|
|
11642
|
+
const listRef = (0, import_react75.useRef)(null);
|
|
11643
|
+
const baseId = (0, import_react75.useId)();
|
|
11533
11644
|
const listId = `${baseId}-list`;
|
|
11534
11645
|
const optionId = (index) => `${baseId}-option-${index}`;
|
|
11535
11646
|
const { open, query, items, activeIndex } = palette;
|
|
11536
|
-
(0,
|
|
11647
|
+
(0, import_react75.useEffect)(() => {
|
|
11537
11648
|
if (open) inputRef.current?.focus();
|
|
11538
11649
|
}, [open]);
|
|
11539
|
-
(0,
|
|
11650
|
+
(0, import_react75.useEffect)(() => {
|
|
11540
11651
|
if (!open) return;
|
|
11541
11652
|
const active = listRef.current?.querySelector('[aria-selected="true"]');
|
|
11542
11653
|
active?.scrollIntoView?.({ block: "nearest" });
|
|
11543
11654
|
}, [open, activeIndex]);
|
|
11544
11655
|
if (!open) return null;
|
|
11545
|
-
return /* @__PURE__ */ (0,
|
|
11656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11546
11657
|
"div",
|
|
11547
11658
|
{
|
|
11548
11659
|
className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 px-4 pt-[15vh]",
|
|
@@ -11550,7 +11661,7 @@ var CommandPalette = ({
|
|
|
11550
11661
|
onMouseDown: (e) => {
|
|
11551
11662
|
if (e.target === e.currentTarget) palette.setOpen(false);
|
|
11552
11663
|
},
|
|
11553
|
-
children: /* @__PURE__ */ (0,
|
|
11664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
11554
11665
|
"div",
|
|
11555
11666
|
{
|
|
11556
11667
|
role: "dialog",
|
|
@@ -11559,7 +11670,7 @@ var CommandPalette = ({
|
|
|
11559
11670
|
className: `w-full max-w-lg overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl ${className}`,
|
|
11560
11671
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
11561
11672
|
children: [
|
|
11562
|
-
/* @__PURE__ */ (0,
|
|
11673
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11563
11674
|
"input",
|
|
11564
11675
|
{
|
|
11565
11676
|
ref: inputRef,
|
|
@@ -11579,7 +11690,7 @@ var CommandPalette = ({
|
|
|
11579
11690
|
className: "w-full border-b border-border bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground"
|
|
11580
11691
|
}
|
|
11581
11692
|
),
|
|
11582
|
-
items.length === 0 ? /* @__PURE__ */ (0,
|
|
11693
|
+
items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": "Commands", className: "max-h-80 overflow-y-auto py-1", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
11583
11694
|
"li",
|
|
11584
11695
|
{
|
|
11585
11696
|
id: optionId(index),
|
|
@@ -11594,12 +11705,12 @@ var CommandPalette = ({
|
|
|
11594
11705
|
onClick: () => palette.run(item.id),
|
|
11595
11706
|
className: `flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm ${index === activeIndex ? "bg-muted" : ""} ${item.enabled ? "" : "cursor-default opacity-50"}`,
|
|
11596
11707
|
children: [
|
|
11597
|
-
/* @__PURE__ */ (0,
|
|
11598
|
-
/* @__PURE__ */ (0,
|
|
11599
|
-
item.disabledReason && /* @__PURE__ */ (0,
|
|
11708
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
11709
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(HighlightedLabel, { item }),
|
|
11710
|
+
item.disabledReason && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "ml-2 text-xs text-muted-foreground", "data-disabled-reason": "", children: item.disabledReason })
|
|
11600
11711
|
] }),
|
|
11601
|
-
item.group && /* @__PURE__ */ (0,
|
|
11602
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
11712
|
+
item.group && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "shrink-0 text-xs text-muted-foreground", children: item.group }),
|
|
11713
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("kbd", { className: "shrink-0 rounded border border-border px-1.5 font-mono text-[10px] text-muted-foreground", children: item.shortcut })
|
|
11603
11714
|
]
|
|
11604
11715
|
},
|
|
11605
11716
|
item.id
|
|
@@ -11612,12 +11723,12 @@ var CommandPalette = ({
|
|
|
11612
11723
|
};
|
|
11613
11724
|
|
|
11614
11725
|
// src/commands/useCommandShortcuts.ts
|
|
11615
|
-
var
|
|
11726
|
+
var import_react76 = require("react");
|
|
11616
11727
|
function useCommandShortcuts(registry, options = {}) {
|
|
11617
|
-
const optionsRef = (0,
|
|
11728
|
+
const optionsRef = (0, import_react76.useRef)(options);
|
|
11618
11729
|
optionsRef.current = options;
|
|
11619
11730
|
const { enabled = true, target } = options;
|
|
11620
|
-
(0,
|
|
11731
|
+
(0, import_react76.useEffect)(() => {
|
|
11621
11732
|
if (!registry || !enabled) return;
|
|
11622
11733
|
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
11623
11734
|
if (!eventTarget) return;
|
|
@@ -11635,14 +11746,14 @@ function useCommandShortcuts(registry, options = {}) {
|
|
|
11635
11746
|
}, [registry, enabled, target]);
|
|
11636
11747
|
}
|
|
11637
11748
|
function useRegisterCommands(registry, specs) {
|
|
11638
|
-
(0,
|
|
11749
|
+
(0, import_react76.useEffect)(() => {
|
|
11639
11750
|
if (!registry || !specs || specs.length === 0) return;
|
|
11640
11751
|
return registry.register(specs);
|
|
11641
11752
|
}, [registry, specs]);
|
|
11642
11753
|
}
|
|
11643
11754
|
|
|
11644
11755
|
// src/persistence/useAutosave.ts
|
|
11645
|
-
var
|
|
11756
|
+
var import_react77 = require("react");
|
|
11646
11757
|
var import_persistence = require("@pixerate/editor/persistence");
|
|
11647
11758
|
var IDLE = {
|
|
11648
11759
|
status: "idle",
|
|
@@ -11653,18 +11764,18 @@ var IDLE = {
|
|
|
11653
11764
|
ready: false
|
|
11654
11765
|
};
|
|
11655
11766
|
function useAutosave(options) {
|
|
11656
|
-
const optionsRef = (0,
|
|
11767
|
+
const optionsRef = (0, import_react77.useRef)(options);
|
|
11657
11768
|
optionsRef.current = options;
|
|
11658
11769
|
const { storage, key, history, dirty } = options;
|
|
11659
11770
|
const recover = options.recover !== false;
|
|
11660
11771
|
const flushOnHide = options.flushOnHide !== false;
|
|
11661
11772
|
const ready = options.ready !== false;
|
|
11662
|
-
const [controller, setController] = (0,
|
|
11663
|
-
const [status, setStatus] = (0,
|
|
11664
|
-
const [recovery, setRecovery] = (0,
|
|
11665
|
-
const [pendingRecovery, setPendingRecovery] = (0,
|
|
11666
|
-
const revisionsRef = (0,
|
|
11667
|
-
(0,
|
|
11773
|
+
const [controller, setController] = (0, import_react77.useState)(null);
|
|
11774
|
+
const [status, setStatus] = (0, import_react77.useState)(IDLE);
|
|
11775
|
+
const [recovery, setRecovery] = (0, import_react77.useState)(null);
|
|
11776
|
+
const [pendingRecovery, setPendingRecovery] = (0, import_react77.useState)(recover);
|
|
11777
|
+
const revisionsRef = (0, import_react77.useRef)(null);
|
|
11778
|
+
(0, import_react77.useEffect)(() => {
|
|
11668
11779
|
const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
|
|
11669
11780
|
const o = optionsRef.current;
|
|
11670
11781
|
const instance = (0, import_persistence.createAutosaveController)({
|
|
@@ -11707,10 +11818,10 @@ function useAutosave(options) {
|
|
|
11707
11818
|
if (revisionsRef.current === revisions) revisionsRef.current = null;
|
|
11708
11819
|
};
|
|
11709
11820
|
}, [storage, key, history, dirty, recover]);
|
|
11710
|
-
(0,
|
|
11821
|
+
(0, import_react77.useEffect)(() => {
|
|
11711
11822
|
if (controller && ready && !pendingRecovery) controller.ready();
|
|
11712
11823
|
}, [controller, ready, pendingRecovery]);
|
|
11713
|
-
(0,
|
|
11824
|
+
(0, import_react77.useEffect)(() => {
|
|
11714
11825
|
if (!controller || !flushOnHide || typeof window === "undefined") return;
|
|
11715
11826
|
const flush = () => void controller.flushNow();
|
|
11716
11827
|
const onVisibility = () => {
|
|
@@ -11723,33 +11834,33 @@ function useAutosave(options) {
|
|
|
11723
11834
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
11724
11835
|
};
|
|
11725
11836
|
}, [controller, flushOnHide]);
|
|
11726
|
-
const restore = (0,
|
|
11837
|
+
const restore = (0, import_react77.useCallback)(() => {
|
|
11727
11838
|
const snapshot = recovery?.snapshot;
|
|
11728
11839
|
setRecovery(null);
|
|
11729
11840
|
setPendingRecovery(false);
|
|
11730
11841
|
return snapshot;
|
|
11731
11842
|
}, [recovery]);
|
|
11732
|
-
const discard = (0,
|
|
11843
|
+
const discard = (0, import_react77.useCallback)(async () => {
|
|
11733
11844
|
if (controller) await controller.discardRecovery();
|
|
11734
11845
|
setRecovery(null);
|
|
11735
11846
|
setPendingRecovery(false);
|
|
11736
11847
|
}, [controller]);
|
|
11737
|
-
const flushNow = (0,
|
|
11848
|
+
const flushNow = (0, import_react77.useCallback)(async () => {
|
|
11738
11849
|
await controller?.flushNow();
|
|
11739
11850
|
}, [controller]);
|
|
11740
|
-
const markClean = (0,
|
|
11851
|
+
const markClean = (0, import_react77.useCallback)(async () => {
|
|
11741
11852
|
revisionsRef.current?.markSaved();
|
|
11742
11853
|
await controller?.markClean();
|
|
11743
11854
|
}, [controller]);
|
|
11744
|
-
const notifyChange = (0,
|
|
11855
|
+
const notifyChange = (0, import_react77.useCallback)(() => revisionsRef.current?.bump(), []);
|
|
11745
11856
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
11746
11857
|
}
|
|
11747
11858
|
|
|
11748
11859
|
// src/persistence/useEditorAutosave.ts
|
|
11749
|
-
var
|
|
11860
|
+
var import_react78 = require("react");
|
|
11750
11861
|
var import_persistence2 = require("@pixerate/editor/persistence");
|
|
11751
11862
|
function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
11752
|
-
const storage = (0,
|
|
11863
|
+
const storage = (0, import_react78.useMemo)(
|
|
11753
11864
|
() => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
|
|
11754
11865
|
[options.storage, doc.assets]
|
|
11755
11866
|
);
|
|
@@ -11762,19 +11873,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
11762
11873
|
history: doc
|
|
11763
11874
|
});
|
|
11764
11875
|
const take = autosave.restore;
|
|
11765
|
-
const restore = (0,
|
|
11876
|
+
const restore = (0, import_react78.useCallback)(() => {
|
|
11766
11877
|
const snapshot = take();
|
|
11767
11878
|
return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
|
|
11768
11879
|
}, [take, doc]);
|
|
11769
11880
|
const { markClean: clean, discard: drop } = autosave;
|
|
11770
11881
|
const rawStorage = options.storage;
|
|
11771
|
-
const gcRef = (0,
|
|
11882
|
+
const gcRef = (0, import_react78.useRef)(collectAssetGarbage);
|
|
11772
11883
|
gcRef.current = collectAssetGarbage;
|
|
11773
|
-
const markClean = (0,
|
|
11884
|
+
const markClean = (0, import_react78.useCallback)(async () => {
|
|
11774
11885
|
await clean();
|
|
11775
11886
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
11776
11887
|
}, [clean, rawStorage, doc]);
|
|
11777
|
-
const discard = (0,
|
|
11888
|
+
const discard = (0, import_react78.useCallback)(async () => {
|
|
11778
11889
|
await drop();
|
|
11779
11890
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
11780
11891
|
}, [drop, rawStorage, doc]);
|
|
@@ -11783,7 +11894,7 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
11783
11894
|
|
|
11784
11895
|
// src/persistence/RecoveryPrompt.tsx
|
|
11785
11896
|
var import_persistence3 = require("@pixerate/editor/persistence");
|
|
11786
|
-
var
|
|
11897
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
11787
11898
|
var RecoveryPrompt = ({
|
|
11788
11899
|
recovery,
|
|
11789
11900
|
onRestore,
|
|
@@ -11795,7 +11906,7 @@ var RecoveryPrompt = ({
|
|
|
11795
11906
|
}) => {
|
|
11796
11907
|
if (!recovery) return null;
|
|
11797
11908
|
const { name } = recovery.meta;
|
|
11798
|
-
return /* @__PURE__ */ (0,
|
|
11909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
11799
11910
|
"div",
|
|
11800
11911
|
{
|
|
11801
11912
|
role: "alertdialog",
|
|
@@ -11803,15 +11914,15 @@ var RecoveryPrompt = ({
|
|
|
11803
11914
|
"data-recovery-prompt": "",
|
|
11804
11915
|
className: `flex flex-wrap items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground shadow-sm ${className}`,
|
|
11805
11916
|
children: [
|
|
11806
|
-
/* @__PURE__ */ (0,
|
|
11917
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
11807
11918
|
(0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
|
|
11808
|
-
name ? /* @__PURE__ */ (0,
|
|
11919
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
|
|
11809
11920
|
"(",
|
|
11810
11921
|
name,
|
|
11811
11922
|
")"
|
|
11812
11923
|
] }) : null
|
|
11813
11924
|
] }),
|
|
11814
|
-
/* @__PURE__ */ (0,
|
|
11925
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
11815
11926
|
"button",
|
|
11816
11927
|
{
|
|
11817
11928
|
type: "button",
|
|
@@ -11821,7 +11932,7 @@ var RecoveryPrompt = ({
|
|
|
11821
11932
|
children: restoreLabel
|
|
11822
11933
|
}
|
|
11823
11934
|
),
|
|
11824
|
-
/* @__PURE__ */ (0,
|
|
11935
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
11825
11936
|
"button",
|
|
11826
11937
|
{
|
|
11827
11938
|
type: "button",
|
|
@@ -11837,17 +11948,17 @@ var RecoveryPrompt = ({
|
|
|
11837
11948
|
};
|
|
11838
11949
|
|
|
11839
11950
|
// src/generation/useGenerationPlan.ts
|
|
11840
|
-
var
|
|
11951
|
+
var import_react79 = require("react");
|
|
11841
11952
|
var import_generation = require("@pixerate/editor/generation");
|
|
11842
11953
|
function useGenerationPlan(request, capabilities, options = {}) {
|
|
11843
11954
|
const key = JSON.stringify([request, capabilities, options]);
|
|
11844
|
-
return (0,
|
|
11955
|
+
return (0, import_react79.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
|
|
11845
11956
|
}
|
|
11846
11957
|
function useJobProgress(options) {
|
|
11847
11958
|
const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
|
|
11848
|
-
const [tick, setTick] = (0,
|
|
11959
|
+
const [tick, setTick] = (0, import_react79.useState)(() => Date.now());
|
|
11849
11960
|
const ticking = !done && now === void 0;
|
|
11850
|
-
(0,
|
|
11961
|
+
(0, import_react79.useEffect)(() => {
|
|
11851
11962
|
if (!ticking) return;
|
|
11852
11963
|
setTick(Date.now());
|
|
11853
11964
|
const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
|
|
@@ -11857,9 +11968,9 @@ function useJobProgress(options) {
|
|
|
11857
11968
|
}
|
|
11858
11969
|
|
|
11859
11970
|
// src/generation/GenerationSettings.tsx
|
|
11860
|
-
var
|
|
11971
|
+
var import_react80 = require("react");
|
|
11861
11972
|
var import_generation2 = require("@pixerate/editor/generation");
|
|
11862
|
-
var
|
|
11973
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
11863
11974
|
var inputClass2 = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
|
|
11864
11975
|
function Control({
|
|
11865
11976
|
control,
|
|
@@ -11869,7 +11980,7 @@ function Control({
|
|
|
11869
11980
|
}) {
|
|
11870
11981
|
const shown = value ?? control.defaultValue;
|
|
11871
11982
|
if (control.kind === "checkbox") {
|
|
11872
|
-
return /* @__PURE__ */ (0,
|
|
11983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11873
11984
|
"input",
|
|
11874
11985
|
{
|
|
11875
11986
|
id,
|
|
@@ -11881,7 +11992,7 @@ function Control({
|
|
|
11881
11992
|
);
|
|
11882
11993
|
}
|
|
11883
11994
|
if (control.kind === "select") {
|
|
11884
|
-
return /* @__PURE__ */ (0,
|
|
11995
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11885
11996
|
"select",
|
|
11886
11997
|
{
|
|
11887
11998
|
id,
|
|
@@ -11890,14 +12001,14 @@ function Control({
|
|
|
11890
12001
|
value: shown === void 0 ? "" : String(shown),
|
|
11891
12002
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value)),
|
|
11892
12003
|
children: [
|
|
11893
|
-
shown === void 0 && /* @__PURE__ */ (0,
|
|
11894
|
-
control.options.map((option) => /* @__PURE__ */ (0,
|
|
12004
|
+
shown === void 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("option", { value: "", children: "Default" }),
|
|
12005
|
+
control.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("option", { value: String(option.value), children: option.label }, String(option.value)))
|
|
11895
12006
|
]
|
|
11896
12007
|
}
|
|
11897
12008
|
);
|
|
11898
12009
|
}
|
|
11899
12010
|
if (control.kind === "textarea") {
|
|
11900
|
-
return /* @__PURE__ */ (0,
|
|
12011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11901
12012
|
"textarea",
|
|
11902
12013
|
{
|
|
11903
12014
|
id,
|
|
@@ -11911,8 +12022,8 @@ function Control({
|
|
|
11911
12022
|
);
|
|
11912
12023
|
}
|
|
11913
12024
|
const numeric = typeof shown === "number" ? shown : void 0;
|
|
11914
|
-
return /* @__PURE__ */ (0,
|
|
11915
|
-
/* @__PURE__ */ (0,
|
|
12025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12026
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11916
12027
|
"input",
|
|
11917
12028
|
{
|
|
11918
12029
|
id,
|
|
@@ -11926,7 +12037,7 @@ function Control({
|
|
|
11926
12037
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
|
|
11927
12038
|
}
|
|
11928
12039
|
),
|
|
11929
|
-
control.kind === "range" && /* @__PURE__ */ (0,
|
|
12040
|
+
control.kind === "range" && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "w-10 text-right tabular-nums text-muted-foreground", "data-field-value": "", children: numeric ?? "\u2013" })
|
|
11930
12041
|
] });
|
|
11931
12042
|
}
|
|
11932
12043
|
var GenerationSettings = ({
|
|
@@ -11940,17 +12051,17 @@ var GenerationSettings = ({
|
|
|
11940
12051
|
renderReference,
|
|
11941
12052
|
className = ""
|
|
11942
12053
|
}) => {
|
|
11943
|
-
const baseId = (0,
|
|
11944
|
-
const controls = (0,
|
|
12054
|
+
const baseId = (0, import_react80.useId)();
|
|
12055
|
+
const controls = (0, import_react80.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
|
|
11945
12056
|
const computed = useGenerationPlan(value, capabilities, { strategy });
|
|
11946
12057
|
const plan = planProp ?? computed;
|
|
11947
12058
|
const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
|
|
11948
|
-
return /* @__PURE__ */ (0,
|
|
12059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: `flex flex-col gap-3 text-sm ${className}`, "data-generation-settings": "", "data-model": capabilities.id, children: [
|
|
11949
12060
|
controls.map((control) => {
|
|
11950
12061
|
const id = `${baseId}-${control.key}`;
|
|
11951
|
-
return /* @__PURE__ */ (0,
|
|
11952
|
-
/* @__PURE__ */ (0,
|
|
11953
|
-
/* @__PURE__ */ (0,
|
|
12062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex flex-col gap-1", "data-control": control.key, children: [
|
|
12063
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("label", { htmlFor: id, className: "text-xs font-medium text-muted-foreground", title: control.description, children: control.label }),
|
|
12064
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11954
12065
|
Control,
|
|
11955
12066
|
{
|
|
11956
12067
|
control,
|
|
@@ -11961,23 +12072,23 @@ var GenerationSettings = ({
|
|
|
11961
12072
|
)
|
|
11962
12073
|
] }, control.key);
|
|
11963
12074
|
}),
|
|
11964
|
-
slots.map((slot) => /* @__PURE__ */ (0,
|
|
11965
|
-
/* @__PURE__ */ (0,
|
|
12075
|
+
slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("fieldset", { className: "flex flex-col gap-1", "data-reference-role": slot.role, children: [
|
|
12076
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("legend", { className: "text-xs font-medium text-muted-foreground", title: slot.description, children: [
|
|
11966
12077
|
slot.label,
|
|
11967
12078
|
" ",
|
|
11968
|
-
/* @__PURE__ */ (0,
|
|
12079
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { className: "tabular-nums", "data-reference-count": "", children: [
|
|
11969
12080
|
"(",
|
|
11970
12081
|
slot.references.length,
|
|
11971
12082
|
"/",
|
|
11972
12083
|
slot.max,
|
|
11973
12084
|
")"
|
|
11974
12085
|
] }),
|
|
11975
|
-
slot.min > 0 && /* @__PURE__ */ (0,
|
|
12086
|
+
slot.min > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "text-destructive", children: " *" })
|
|
11976
12087
|
] }),
|
|
11977
|
-
/* @__PURE__ */ (0,
|
|
11978
|
-
slot.references.map((ref) => /* @__PURE__ */ (0,
|
|
11979
|
-
renderReference ? renderReference(ref) : /* @__PURE__ */ (0,
|
|
11980
|
-
/* @__PURE__ */ (0,
|
|
12088
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("ul", { className: "flex flex-wrap gap-1", children: [
|
|
12089
|
+
slot.references.map((ref) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("li", { className: "flex items-center gap-1 rounded border border-border px-1.5 py-0.5", "data-reference-id": ref.id, children: [
|
|
12090
|
+
renderReference ? renderReference(ref) : /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "max-w-[10rem] truncate", children: ref.id }),
|
|
12091
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11981
12092
|
"button",
|
|
11982
12093
|
{
|
|
11983
12094
|
type: "button",
|
|
@@ -11988,7 +12099,7 @@ var GenerationSettings = ({
|
|
|
11988
12099
|
}
|
|
11989
12100
|
)
|
|
11990
12101
|
] }, ref.id)),
|
|
11991
|
-
onAddReference && slot.canAdd && /* @__PURE__ */ (0,
|
|
12102
|
+
onAddReference && slot.canAdd && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11992
12103
|
"button",
|
|
11993
12104
|
{
|
|
11994
12105
|
type: "button",
|
|
@@ -11999,21 +12110,21 @@ var GenerationSettings = ({
|
|
|
11999
12110
|
) })
|
|
12000
12111
|
] })
|
|
12001
12112
|
] }, slot.role)),
|
|
12002
|
-
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0,
|
|
12003
|
-
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0,
|
|
12113
|
+
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { role: "status", className: "flex flex-col gap-0.5 text-xs text-muted-foreground", "data-generation-adjustments": "", children: plan.adjustments.map((adjustment, index) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("li", { "data-adjustment-field": adjustment.field, "data-adjustment-kind": adjustment.kind, children: adjustment.reason }, index)) }),
|
|
12114
|
+
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { role: "alert", className: "flex flex-col gap-0.5 text-xs text-destructive", "data-generation-errors": "", children: plan.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("li", { "data-error-field": error.field, children: error.message }, index)) })
|
|
12004
12115
|
] });
|
|
12005
12116
|
};
|
|
12006
12117
|
|
|
12007
12118
|
// src/generation/JobProgress.tsx
|
|
12008
|
-
var
|
|
12119
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
12009
12120
|
var JobProgress = ({ title, className = "", ...options }) => {
|
|
12010
12121
|
const progress = useJobProgress(options);
|
|
12011
|
-
return /* @__PURE__ */ (0,
|
|
12012
|
-
/* @__PURE__ */ (0,
|
|
12013
|
-
title && /* @__PURE__ */ (0,
|
|
12014
|
-
/* @__PURE__ */ (0,
|
|
12122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: `flex flex-col gap-1 text-sm ${className}`, "data-job-progress": "", "data-done": options.done ? "" : void 0, children: [
|
|
12123
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center justify-between gap-2 text-muted-foreground", children: [
|
|
12124
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "truncate text-foreground", children: title }),
|
|
12125
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { "data-job-progress-label": "", "aria-live": "polite", children: progress.label })
|
|
12015
12126
|
] }),
|
|
12016
|
-
/* @__PURE__ */ (0,
|
|
12127
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
12017
12128
|
"div",
|
|
12018
12129
|
{
|
|
12019
12130
|
role: "progressbar",
|
|
@@ -12023,7 +12134,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
12023
12134
|
"aria-valuenow": progress.percent,
|
|
12024
12135
|
"aria-valuetext": `${progress.percent}%, ${progress.label}`,
|
|
12025
12136
|
className: "h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
12026
|
-
children: /* @__PURE__ */ (0,
|
|
12137
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
12027
12138
|
"div",
|
|
12028
12139
|
{
|
|
12029
12140
|
className: "h-full rounded-full bg-primary transition-[width] duration-500",
|
|
@@ -12036,9 +12147,9 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
12036
12147
|
};
|
|
12037
12148
|
|
|
12038
12149
|
// src/generation/AssetMentionChips.tsx
|
|
12039
|
-
var
|
|
12150
|
+
var import_react81 = require("react");
|
|
12040
12151
|
var import_generation3 = require("@pixerate/editor/generation");
|
|
12041
|
-
var
|
|
12152
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
12042
12153
|
var AssetMentionChips = ({
|
|
12043
12154
|
content,
|
|
12044
12155
|
onChange,
|
|
@@ -12048,14 +12159,14 @@ var AssetMentionChips = ({
|
|
|
12048
12159
|
renderAsset,
|
|
12049
12160
|
className = ""
|
|
12050
12161
|
}) => {
|
|
12051
|
-
const [open, setOpen] = (0,
|
|
12052
|
-
const rootRef = (0,
|
|
12053
|
-
const chips = (0,
|
|
12162
|
+
const [open, setOpen] = (0, import_react81.useState)(null);
|
|
12163
|
+
const rootRef = (0, import_react81.useRef)(null);
|
|
12164
|
+
const chips = (0, import_react81.useMemo)(
|
|
12054
12165
|
() => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
|
|
12055
12166
|
[content, assets, capabilities]
|
|
12056
12167
|
);
|
|
12057
12168
|
const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
|
|
12058
|
-
(0,
|
|
12169
|
+
(0, import_react81.useEffect)(() => {
|
|
12059
12170
|
if (open === null) return;
|
|
12060
12171
|
const onPointer = (event) => {
|
|
12061
12172
|
if (!rootRef.current?.contains(event.target)) setOpen(null);
|
|
@@ -12069,13 +12180,13 @@ var AssetMentionChips = ({
|
|
|
12069
12180
|
onChange((0, import_generation3.setMentionRoleInText)(content, chip2.start, role));
|
|
12070
12181
|
};
|
|
12071
12182
|
if (chips.length === 0) return null;
|
|
12072
|
-
return /* @__PURE__ */ (0,
|
|
12183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { ref: rootRef, className: `flex flex-wrap gap-1.5 ${className}`, "data-asset-mention-chips": "", children: chips.map((chip2) => {
|
|
12073
12184
|
const error = chip2.issues.find((issue) => issue.severity === "error");
|
|
12074
12185
|
const warning = chip2.issues.find((issue) => issue.severity === "warning");
|
|
12075
12186
|
const problem = error ?? warning;
|
|
12076
12187
|
const isOpen = open === chip2.index;
|
|
12077
|
-
return /* @__PURE__ */ (0,
|
|
12078
|
-
/* @__PURE__ */ (0,
|
|
12188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("span", { className: "relative inline-flex", "data-asset-chip": chip2.asset.id, children: [
|
|
12189
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
12079
12190
|
"button",
|
|
12080
12191
|
{
|
|
12081
12192
|
type: "button",
|
|
@@ -12089,8 +12200,8 @@ var AssetMentionChips = ({
|
|
|
12089
12200
|
},
|
|
12090
12201
|
className: `inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs ${error ? "border-red-500/60" : warning ? "border-amber-500/60" : "border-border"} bg-muted/40 hover:bg-muted`,
|
|
12091
12202
|
children: [
|
|
12092
|
-
/* @__PURE__ */ (0,
|
|
12093
|
-
/* @__PURE__ */ (0,
|
|
12203
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: renderAsset ? renderAsset(chip2) : `@${chip2.asset.label ?? chip2.handle}` }),
|
|
12204
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
12094
12205
|
"span",
|
|
12095
12206
|
{
|
|
12096
12207
|
className: `rounded px-1 text-[10px] uppercase tracking-wide ${chip2.role ? "bg-primary/15" : "opacity-60"}`,
|
|
@@ -12101,7 +12212,7 @@ var AssetMentionChips = ({
|
|
|
12101
12212
|
]
|
|
12102
12213
|
}
|
|
12103
12214
|
),
|
|
12104
|
-
isOpen && /* @__PURE__ */ (0,
|
|
12215
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
12105
12216
|
"div",
|
|
12106
12217
|
{
|
|
12107
12218
|
role: "listbox",
|
|
@@ -12112,7 +12223,7 @@ var AssetMentionChips = ({
|
|
|
12112
12223
|
if (e.key === "Escape") setOpen(null);
|
|
12113
12224
|
},
|
|
12114
12225
|
children: [
|
|
12115
|
-
options.map((option) => /* @__PURE__ */ (0,
|
|
12226
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
12116
12227
|
"button",
|
|
12117
12228
|
{
|
|
12118
12229
|
type: "button",
|
|
@@ -12123,13 +12234,13 @@ var AssetMentionChips = ({
|
|
|
12123
12234
|
onClick: () => pick(chip2, option.role),
|
|
12124
12235
|
className: "flex items-center justify-between gap-2 rounded px-2 py-1 text-left hover:bg-muted",
|
|
12125
12236
|
children: [
|
|
12126
|
-
/* @__PURE__ */ (0,
|
|
12127
|
-
option.accepts?.length ? /* @__PURE__ */ (0,
|
|
12237
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: option.label }),
|
|
12238
|
+
option.accepts?.length ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "text-[10px] opacity-60", children: option.accepts.join(", ") }) : null
|
|
12128
12239
|
]
|
|
12129
12240
|
},
|
|
12130
12241
|
option.role
|
|
12131
12242
|
)),
|
|
12132
|
-
/* @__PURE__ */ (0,
|
|
12243
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
12133
12244
|
"button",
|
|
12134
12245
|
{
|
|
12135
12246
|
type: "button",
|
|
@@ -12141,7 +12252,7 @@ var AssetMentionChips = ({
|
|
|
12141
12252
|
children: "No role"
|
|
12142
12253
|
}
|
|
12143
12254
|
),
|
|
12144
|
-
chip2.issues.length > 0 && /* @__PURE__ */ (0,
|
|
12255
|
+
chip2.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("ul", { className: "mt-1 border-t border-border px-2 pt-1 text-[10px]", "data-chip-issues": "", children: chip2.issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : "text-amber-500", children: issue.message }, i)) })
|
|
12145
12256
|
]
|
|
12146
12257
|
}
|
|
12147
12258
|
)
|
|
@@ -12150,15 +12261,15 @@ var AssetMentionChips = ({
|
|
|
12150
12261
|
};
|
|
12151
12262
|
|
|
12152
12263
|
// src/generation/GenerationHistory.tsx
|
|
12153
|
-
var
|
|
12264
|
+
var import_react82 = require("react");
|
|
12154
12265
|
var import_generation4 = require("@pixerate/editor/generation");
|
|
12155
|
-
var
|
|
12266
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
12156
12267
|
function useGenerationRecords(store, filter) {
|
|
12157
|
-
const [records, setRecords] = (0,
|
|
12158
|
-
const [loading, setLoading] = (0,
|
|
12159
|
-
const [error, setError] = (0,
|
|
12268
|
+
const [records, setRecords] = (0, import_react82.useState)([]);
|
|
12269
|
+
const [loading, setLoading] = (0, import_react82.useState)(!!store);
|
|
12270
|
+
const [error, setError] = (0, import_react82.useState)(null);
|
|
12160
12271
|
const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
|
|
12161
|
-
const refresh = (0,
|
|
12272
|
+
const refresh = (0, import_react82.useCallback)(async () => {
|
|
12162
12273
|
if (!store) {
|
|
12163
12274
|
setRecords([]);
|
|
12164
12275
|
setLoading(false);
|
|
@@ -12175,7 +12286,7 @@ function useGenerationRecords(store, filter) {
|
|
|
12175
12286
|
setLoading(false);
|
|
12176
12287
|
}
|
|
12177
12288
|
}, [store, filterKey]);
|
|
12178
|
-
(0,
|
|
12289
|
+
(0, import_react82.useEffect)(() => {
|
|
12179
12290
|
void refresh();
|
|
12180
12291
|
if (!store) return;
|
|
12181
12292
|
return store.subscribe(() => void refresh());
|
|
@@ -12201,21 +12312,21 @@ var GenerationHistory = ({
|
|
|
12201
12312
|
emptyText = "No generations yet.",
|
|
12202
12313
|
className = ""
|
|
12203
12314
|
}) => {
|
|
12204
|
-
const [innerMode, setInnerMode] = (0,
|
|
12315
|
+
const [innerMode, setInnerMode] = (0, import_react82.useState)("exact");
|
|
12205
12316
|
const mode = modeProp ?? innerMode;
|
|
12206
12317
|
const setMode = (next) => {
|
|
12207
12318
|
if (modeProp === void 0) setInnerMode(next);
|
|
12208
12319
|
onModeChange?.(next);
|
|
12209
12320
|
};
|
|
12210
|
-
const options = (0,
|
|
12211
|
-
const results = (0,
|
|
12212
|
-
const models = (0,
|
|
12321
|
+
const options = (0, import_react82.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
|
|
12322
|
+
const results = (0, import_react82.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
|
|
12323
|
+
const models = (0, import_react82.useMemo)(
|
|
12213
12324
|
() => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
|
|
12214
12325
|
[capabilities]
|
|
12215
12326
|
);
|
|
12216
|
-
return /* @__PURE__ */ (0,
|
|
12217
|
-
/* @__PURE__ */ (0,
|
|
12218
|
-
/* @__PURE__ */ (0,
|
|
12327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: `flex flex-col gap-2 text-sm ${className}`, "data-generation-history": "", children: [
|
|
12328
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex items-center gap-2 text-xs", role: "radiogroup", "aria-label": "Recreate mode", children: ["exact", "latest"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("label", { className: "inline-flex items-center gap-1", children: [
|
|
12329
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12219
12330
|
"input",
|
|
12220
12331
|
{
|
|
12221
12332
|
type: "radio",
|
|
@@ -12228,34 +12339,34 @@ var GenerationHistory = ({
|
|
|
12228
12339
|
),
|
|
12229
12340
|
value === "exact" ? "Exact (recorded versions)" : "Latest templates & settings"
|
|
12230
12341
|
] }, value)) }),
|
|
12231
|
-
records.length === 0 && /* @__PURE__ */ (0,
|
|
12232
|
-
/* @__PURE__ */ (0,
|
|
12342
|
+
records.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyText }),
|
|
12343
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("ul", { className: "flex flex-col gap-2", children: records.map((record, i) => {
|
|
12233
12344
|
const result = results[i];
|
|
12234
12345
|
const model = models.find((m) => m.id === record.provenance.modelId);
|
|
12235
12346
|
const blocked = !result.ok;
|
|
12236
|
-
return /* @__PURE__ */ (0,
|
|
12347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
12237
12348
|
"li",
|
|
12238
12349
|
{
|
|
12239
12350
|
className: "rounded-md border border-border p-2",
|
|
12240
12351
|
"data-record": record.id,
|
|
12241
12352
|
"data-drift": result.drift.length,
|
|
12242
12353
|
children: [
|
|
12243
|
-
/* @__PURE__ */ (0,
|
|
12244
|
-
/* @__PURE__ */ (0,
|
|
12245
|
-
/* @__PURE__ */ (0,
|
|
12246
|
-
record.kind !== "generate" && /* @__PURE__ */ (0,
|
|
12354
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs", children: [
|
|
12355
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "font-medium", children: model?.name ?? record.provenance.modelId }),
|
|
12356
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
12357
|
+
record.kind !== "generate" && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("span", { "data-kind": "", children: [
|
|
12247
12358
|
record.kind,
|
|
12248
12359
|
" \xB7 "
|
|
12249
12360
|
] }),
|
|
12250
|
-
/* @__PURE__ */ (0,
|
|
12251
|
-
record.seed !== void 0 && /* @__PURE__ */ (0,
|
|
12361
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("time", { dateTime: record.createdAt, children: record.createdAt.replace("T", " ").slice(0, 16) }),
|
|
12362
|
+
record.seed !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
|
|
12252
12363
|
" \xB7 seed ",
|
|
12253
12364
|
record.seed
|
|
12254
12365
|
] })
|
|
12255
12366
|
] })
|
|
12256
12367
|
] }),
|
|
12257
|
-
/* @__PURE__ */ (0,
|
|
12258
|
-
record.assets.length > 0 && /* @__PURE__ */ (0,
|
|
12368
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "mt-1 line-clamp-3 break-words text-xs", "data-record-prompt": "", children: record.provenance.resolvedPrompt }),
|
|
12369
|
+
record.assets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children: record.assets.map((asset) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
12259
12370
|
"span",
|
|
12260
12371
|
{
|
|
12261
12372
|
className: "rounded-full bg-muted px-2 py-0.5 text-[10px]",
|
|
@@ -12269,16 +12380,16 @@ var GenerationHistory = ({
|
|
|
12269
12380
|
`${asset.role}:${asset.id}`
|
|
12270
12381
|
)) }),
|
|
12271
12382
|
renderPreview?.(record),
|
|
12272
|
-
result.drift.length > 0 && /* @__PURE__ */ (0,
|
|
12273
|
-
/* @__PURE__ */ (0,
|
|
12383
|
+
result.drift.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("ul", { className: "mt-1 flex flex-col gap-0.5 text-[11px]", "data-drift-report": "", children: result.drift.map((item, j) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("li", { className: severityClass[item.severity], "data-drift-type": item.type, children: [
|
|
12384
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("strong", { children: [
|
|
12274
12385
|
import_generation4.DRIFT_TYPE_LABELS[item.type],
|
|
12275
12386
|
":"
|
|
12276
12387
|
] }),
|
|
12277
12388
|
" ",
|
|
12278
12389
|
item.message
|
|
12279
12390
|
] }, j)) }),
|
|
12280
|
-
/* @__PURE__ */ (0,
|
|
12281
|
-
onRecreate && /* @__PURE__ */ (0,
|
|
12391
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "mt-2 flex gap-2", children: [
|
|
12392
|
+
onRecreate && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12282
12393
|
"button",
|
|
12283
12394
|
{
|
|
12284
12395
|
type: "button",
|
|
@@ -12290,7 +12401,7 @@ var GenerationHistory = ({
|
|
|
12290
12401
|
children: "Recreate"
|
|
12291
12402
|
}
|
|
12292
12403
|
),
|
|
12293
|
-
onVariation && /* @__PURE__ */ (0,
|
|
12404
|
+
onVariation && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12294
12405
|
"button",
|
|
12295
12406
|
{
|
|
12296
12407
|
type: "button",
|
|
@@ -12300,7 +12411,7 @@ var GenerationHistory = ({
|
|
|
12300
12411
|
children: "Variation"
|
|
12301
12412
|
}
|
|
12302
12413
|
),
|
|
12303
|
-
onRemove && /* @__PURE__ */ (0,
|
|
12414
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12304
12415
|
"button",
|
|
12305
12416
|
{
|
|
12306
12417
|
type: "button",
|
|
@@ -12320,19 +12431,19 @@ var GenerationHistory = ({
|
|
|
12320
12431
|
};
|
|
12321
12432
|
|
|
12322
12433
|
// src/find-replace/useFindReplace.ts
|
|
12323
|
-
var
|
|
12434
|
+
var import_react83 = require("react");
|
|
12324
12435
|
var import_editor17 = require("@pixerate/editor");
|
|
12325
12436
|
var noopUnsubscribe2 = () => {
|
|
12326
12437
|
};
|
|
12327
12438
|
function useFindReplace(editor) {
|
|
12328
12439
|
const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
|
|
12329
|
-
const subscribe = (0,
|
|
12440
|
+
const subscribe = (0, import_react83.useCallback)(
|
|
12330
12441
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
12331
12442
|
[store]
|
|
12332
12443
|
);
|
|
12333
12444
|
const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
12334
|
-
const snapshot = (0,
|
|
12335
|
-
return (0,
|
|
12445
|
+
const snapshot = (0, import_react83.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
12446
|
+
return (0, import_react83.useMemo)(() => {
|
|
12336
12447
|
const run = (fn) => {
|
|
12337
12448
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
12338
12449
|
};
|
|
@@ -12356,9 +12467,9 @@ function useFindReplace(editor) {
|
|
|
12356
12467
|
}
|
|
12357
12468
|
|
|
12358
12469
|
// src/find-replace/FindReplaceBar.tsx
|
|
12359
|
-
var
|
|
12470
|
+
var import_react84 = require("react");
|
|
12360
12471
|
var import_editor18 = require("@pixerate/editor");
|
|
12361
|
-
var
|
|
12472
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
12362
12473
|
var inputClass3 = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
|
|
12363
12474
|
var buttonClass5 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
12364
12475
|
var toggleClass = (on) => `${buttonClass5} font-mono ${on ? "bg-primary/10 text-primary" : "text-muted-foreground"}`;
|
|
@@ -12371,10 +12482,10 @@ var FindReplaceBar = ({
|
|
|
12371
12482
|
onClose
|
|
12372
12483
|
}) => {
|
|
12373
12484
|
const find = useFindReplace(editor);
|
|
12374
|
-
const findInput = (0,
|
|
12375
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
12485
|
+
const findInput = (0, import_react84.useRef)(null);
|
|
12486
|
+
const [moreOpen, setMoreOpen] = (0, import_react84.useState)(false);
|
|
12376
12487
|
const visible = find.available && (alwaysOpen || find.open);
|
|
12377
|
-
(0,
|
|
12488
|
+
(0, import_react84.useEffect)(() => {
|
|
12378
12489
|
if (!visible || find.focusRequest === 0) return;
|
|
12379
12490
|
findInput.current?.focus();
|
|
12380
12491
|
findInput.current?.select();
|
|
@@ -12412,9 +12523,9 @@ var FindReplaceBar = ({
|
|
|
12412
12523
|
if (isMod(e)) find.replaceAll();
|
|
12413
12524
|
else find.replace();
|
|
12414
12525
|
};
|
|
12415
|
-
return /* @__PURE__ */ (0,
|
|
12416
|
-
/* @__PURE__ */ (0,
|
|
12417
|
-
/* @__PURE__ */ (0,
|
|
12526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className, role: "search", "aria-label": "Find and replace", onKeyDown: onBarKeyDown, children: [
|
|
12527
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12528
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12418
12529
|
"button",
|
|
12419
12530
|
{
|
|
12420
12531
|
type: "button",
|
|
@@ -12425,7 +12536,7 @@ var FindReplaceBar = ({
|
|
|
12425
12536
|
children: showReplace ? "\u25BE" : "\u25B8"
|
|
12426
12537
|
}
|
|
12427
12538
|
),
|
|
12428
|
-
/* @__PURE__ */ (0,
|
|
12539
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12429
12540
|
"input",
|
|
12430
12541
|
{
|
|
12431
12542
|
ref: findInput,
|
|
@@ -12439,7 +12550,7 @@ var FindReplaceBar = ({
|
|
|
12439
12550
|
onKeyDown: onFindKeyDown
|
|
12440
12551
|
}
|
|
12441
12552
|
),
|
|
12442
|
-
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0,
|
|
12553
|
+
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12443
12554
|
"button",
|
|
12444
12555
|
{
|
|
12445
12556
|
type: "button",
|
|
@@ -12452,7 +12563,7 @@ var FindReplaceBar = ({
|
|
|
12452
12563
|
},
|
|
12453
12564
|
t.key
|
|
12454
12565
|
)),
|
|
12455
|
-
/* @__PURE__ */ (0,
|
|
12566
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12456
12567
|
"span",
|
|
12457
12568
|
{
|
|
12458
12569
|
className: `min-w-[5rem] px-1 text-center text-xs ${find.error ? "text-destructive" : "text-muted-foreground"}`,
|
|
@@ -12462,9 +12573,9 @@ var FindReplaceBar = ({
|
|
|
12462
12573
|
children: status
|
|
12463
12574
|
}
|
|
12464
12575
|
),
|
|
12465
|
-
/* @__PURE__ */ (0,
|
|
12466
|
-
/* @__PURE__ */ (0,
|
|
12467
|
-
showMoreOptions && /* @__PURE__ */ (0,
|
|
12576
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Previous match", disabled: !hasMatches, onClick: find.previous, children: "\u2191" }),
|
|
12577
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Next match", disabled: !hasMatches, onClick: find.next, children: "\u2193" }),
|
|
12578
|
+
showMoreOptions && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12468
12579
|
"button",
|
|
12469
12580
|
{
|
|
12470
12581
|
type: "button",
|
|
@@ -12475,10 +12586,10 @@ var FindReplaceBar = ({
|
|
|
12475
12586
|
children: "\u2026"
|
|
12476
12587
|
}
|
|
12477
12588
|
),
|
|
12478
|
-
/* @__PURE__ */ (0,
|
|
12589
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Close find", onClick: close, children: "\xD7" })
|
|
12479
12590
|
] }),
|
|
12480
|
-
showReplace && /* @__PURE__ */ (0,
|
|
12481
|
-
/* @__PURE__ */ (0,
|
|
12591
|
+
showReplace && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "flex items-center gap-1 pl-7", children: [
|
|
12592
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12482
12593
|
"input",
|
|
12483
12594
|
{
|
|
12484
12595
|
type: "text",
|
|
@@ -12490,7 +12601,7 @@ var FindReplaceBar = ({
|
|
|
12490
12601
|
onKeyDown: onReplaceKeyDown
|
|
12491
12602
|
}
|
|
12492
12603
|
),
|
|
12493
|
-
/* @__PURE__ */ (0,
|
|
12604
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12494
12605
|
"button",
|
|
12495
12606
|
{
|
|
12496
12607
|
type: "button",
|
|
@@ -12500,11 +12611,11 @@ var FindReplaceBar = ({
|
|
|
12500
12611
|
children: "Replace"
|
|
12501
12612
|
}
|
|
12502
12613
|
),
|
|
12503
|
-
/* @__PURE__ */ (0,
|
|
12504
|
-
find.lastReplaceCount !== null && /* @__PURE__ */ (0,
|
|
12614
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("button", { type: "button", className: buttonClass5, disabled: !hasMatches, onClick: find.replaceAll, children: "Replace all" }),
|
|
12615
|
+
find.lastReplaceCount !== null && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "px-1 text-xs text-muted-foreground", "aria-live": "polite", children: find.lastReplaceCount === 1 ? "1 replaced" : `${find.lastReplaceCount} replaced` })
|
|
12505
12616
|
] }),
|
|
12506
|
-
showMoreOptions && moreOpen && /* @__PURE__ */ (0,
|
|
12507
|
-
/* @__PURE__ */ (0,
|
|
12617
|
+
showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-xs text-muted-foreground", children: import_editor18.FIND_OPTION_TOGGLES.filter((t) => t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
12618
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12508
12619
|
"input",
|
|
12509
12620
|
{
|
|
12510
12621
|
type: "checkbox",
|
|
@@ -12518,12 +12629,12 @@ var FindReplaceBar = ({
|
|
|
12518
12629
|
};
|
|
12519
12630
|
|
|
12520
12631
|
// src/tables/useTableMenu.ts
|
|
12521
|
-
var
|
|
12632
|
+
var import_react85 = require("react");
|
|
12522
12633
|
var import_editor19 = require("@pixerate/editor");
|
|
12523
12634
|
function useTableMenu(editor) {
|
|
12524
|
-
const store = (0,
|
|
12525
|
-
const snapshot = (0,
|
|
12526
|
-
return (0,
|
|
12635
|
+
const store = (0, import_react85.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
|
|
12636
|
+
const snapshot = (0, import_react85.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
12637
|
+
return (0, import_react85.useMemo)(
|
|
12527
12638
|
() => ({
|
|
12528
12639
|
...snapshot,
|
|
12529
12640
|
run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
|
|
@@ -12534,9 +12645,9 @@ function useTableMenu(editor) {
|
|
|
12534
12645
|
}
|
|
12535
12646
|
|
|
12536
12647
|
// src/tables/TableToolbar.tsx
|
|
12537
|
-
var
|
|
12648
|
+
var import_react86 = __toESM(require("react"), 1);
|
|
12538
12649
|
var import_editor20 = require("@pixerate/editor");
|
|
12539
|
-
var
|
|
12650
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
12540
12651
|
var keepSelection2 = (event) => event.preventDefault();
|
|
12541
12652
|
var TableToolbar = ({
|
|
12542
12653
|
editor,
|
|
@@ -12550,14 +12661,14 @@ var TableToolbar = ({
|
|
|
12550
12661
|
}) => {
|
|
12551
12662
|
const table = useTableMenu(editor);
|
|
12552
12663
|
if (!editor || !table.inTable && !showWhenOutside) return null;
|
|
12553
|
-
return /* @__PURE__ */ (0,
|
|
12664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className, role: "toolbar", "aria-label": "Table", "data-table-toolbar": "", children: items.map((item, index) => {
|
|
12554
12665
|
const status = table.check(item.action, item.params);
|
|
12555
12666
|
const enabled = status === true;
|
|
12556
12667
|
const active = item.active?.(table);
|
|
12557
12668
|
const separator = index > 0 && items[index - 1].group !== item.group;
|
|
12558
|
-
return /* @__PURE__ */ (0,
|
|
12559
|
-
separator && /* @__PURE__ */ (0,
|
|
12560
|
-
/* @__PURE__ */ (0,
|
|
12669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_react86.default.Fragment, { children: [
|
|
12670
|
+
separator && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
|
|
12671
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
12561
12672
|
"button",
|
|
12562
12673
|
{
|
|
12563
12674
|
type: "button",
|
|
@@ -12579,8 +12690,8 @@ var TableToolbar = ({
|
|
|
12579
12690
|
};
|
|
12580
12691
|
|
|
12581
12692
|
// src/tables/InsertTableGrid.tsx
|
|
12582
|
-
var
|
|
12583
|
-
var
|
|
12693
|
+
var import_react87 = require("react");
|
|
12694
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
12584
12695
|
var keepSelection3 = (event) => event.preventDefault();
|
|
12585
12696
|
var InsertTableGrid = ({
|
|
12586
12697
|
editor,
|
|
@@ -12593,14 +12704,14 @@ var InsertTableGrid = ({
|
|
|
12593
12704
|
onInsert
|
|
12594
12705
|
}) => {
|
|
12595
12706
|
const table = useTableMenu(editor);
|
|
12596
|
-
const [hover, setHover] = (0,
|
|
12707
|
+
const [hover, setHover] = (0, import_react87.useState)(null);
|
|
12597
12708
|
const status = table.actions.insertTable;
|
|
12598
12709
|
const disabled = !editor || !status.enabled;
|
|
12599
12710
|
const insert = (size) => {
|
|
12600
12711
|
if (table.run("insertTable", { ...size, withHeaderRow })) onInsert?.(size);
|
|
12601
12712
|
setHover(null);
|
|
12602
12713
|
};
|
|
12603
|
-
return /* @__PURE__ */ (0,
|
|
12714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
|
|
12604
12715
|
"div",
|
|
12605
12716
|
{
|
|
12606
12717
|
className,
|
|
@@ -12610,7 +12721,7 @@ var InsertTableGrid = ({
|
|
|
12610
12721
|
"data-insert-table-grid": "",
|
|
12611
12722
|
onMouseLeave: () => setHover(null),
|
|
12612
12723
|
children: [
|
|
12613
|
-
/* @__PURE__ */ (0,
|
|
12724
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12614
12725
|
"div",
|
|
12615
12726
|
{
|
|
12616
12727
|
role: "grid",
|
|
@@ -12619,7 +12730,7 @@ var InsertTableGrid = ({
|
|
|
12619
12730
|
children: Array.from({ length: rows * cols }, (_, i) => {
|
|
12620
12731
|
const size = { rows: Math.floor(i / cols) + 1, cols: i % cols + 1 };
|
|
12621
12732
|
const active = !!hover && size.rows <= hover.rows && size.cols <= hover.cols;
|
|
12622
|
-
return /* @__PURE__ */ (0,
|
|
12733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12623
12734
|
"button",
|
|
12624
12735
|
{
|
|
12625
12736
|
type: "button",
|
|
@@ -12639,7 +12750,7 @@ var InsertTableGrid = ({
|
|
|
12639
12750
|
})
|
|
12640
12751
|
}
|
|
12641
12752
|
),
|
|
12642
|
-
/* @__PURE__ */ (0,
|
|
12753
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-live": "polite", "data-testid": "insert-table-size", children: disabled ? status.reason : hover ? `${hover.rows} \xD7 ${hover.cols}` : "Insert table" })
|
|
12643
12754
|
]
|
|
12644
12755
|
}
|
|
12645
12756
|
);
|
|
@@ -12647,31 +12758,31 @@ var InsertTableGrid = ({
|
|
|
12647
12758
|
|
|
12648
12759
|
// src/tables/TableBubbleMenu.tsx
|
|
12649
12760
|
var import_editor21 = require("@pixerate/editor");
|
|
12650
|
-
var
|
|
12761
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
12651
12762
|
var TableBubbleMenu = ({
|
|
12652
12763
|
editor,
|
|
12653
12764
|
children,
|
|
12654
12765
|
toolbarProps,
|
|
12655
12766
|
pluginKey = "tableBubbleMenu",
|
|
12656
12767
|
...rest
|
|
12657
|
-
}) => /* @__PURE__ */ (0,
|
|
12768
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor21.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(TableToolbar, { editor, ...toolbarProps }) });
|
|
12658
12769
|
|
|
12659
12770
|
// src/chart-node/ChartNodeView.tsx
|
|
12660
12771
|
var import_client = require("react-dom/client");
|
|
12661
12772
|
|
|
12662
12773
|
// src/chart/ChartCanvas.tsx
|
|
12663
|
-
var
|
|
12774
|
+
var import_react89 = require("react");
|
|
12664
12775
|
var import_chart2 = require("@pixerate/editor/chart");
|
|
12665
12776
|
|
|
12666
12777
|
// src/chart/useChartEditor.ts
|
|
12667
|
-
var
|
|
12778
|
+
var import_react88 = require("react");
|
|
12668
12779
|
var import_chart = require("@pixerate/editor/chart");
|
|
12669
12780
|
function useChartState(controller) {
|
|
12670
|
-
return (0,
|
|
12781
|
+
return (0, import_react88.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
12671
12782
|
}
|
|
12672
12783
|
|
|
12673
12784
|
// src/chart/ChartCanvas.tsx
|
|
12674
|
-
var
|
|
12785
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
12675
12786
|
function renderChartMark(mark, fontFamily, interactive) {
|
|
12676
12787
|
const common = {
|
|
12677
12788
|
"data-role": mark.role,
|
|
@@ -12683,9 +12794,9 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
12683
12794
|
};
|
|
12684
12795
|
switch (mark.kind) {
|
|
12685
12796
|
case "rect":
|
|
12686
|
-
return /* @__PURE__ */ (0,
|
|
12797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("rect", { ...common, x: mark.x, y: mark.y, width: mark.width, height: mark.height, rx: mark.radius, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
12687
12798
|
case "path":
|
|
12688
|
-
return /* @__PURE__ */ (0,
|
|
12799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12689
12800
|
"path",
|
|
12690
12801
|
{
|
|
12691
12802
|
...common,
|
|
@@ -12698,11 +12809,11 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
12698
12809
|
mark.key
|
|
12699
12810
|
);
|
|
12700
12811
|
case "circle":
|
|
12701
|
-
return /* @__PURE__ */ (0,
|
|
12812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
12702
12813
|
case "line":
|
|
12703
|
-
return /* @__PURE__ */ (0,
|
|
12814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("line", { ...common, x1: mark.x1, y1: mark.y1, x2: mark.x2, y2: mark.y2, strokeDasharray: mark.dash, style: { stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
12704
12815
|
case "text":
|
|
12705
|
-
return /* @__PURE__ */ (0,
|
|
12816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12706
12817
|
"text",
|
|
12707
12818
|
{
|
|
12708
12819
|
...common,
|
|
@@ -12719,36 +12830,36 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
12719
12830
|
}
|
|
12720
12831
|
}
|
|
12721
12832
|
function ChartPresenceLayer({ presence }) {
|
|
12722
|
-
const { actors } = (0,
|
|
12723
|
-
return /* @__PURE__ */ (0,
|
|
12724
|
-
/* @__PURE__ */ (0,
|
|
12725
|
-
/* @__PURE__ */ (0,
|
|
12726
|
-
/* @__PURE__ */ (0,
|
|
12727
|
-
/* @__PURE__ */ (0,
|
|
12833
|
+
const { actors } = (0, import_react89.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
12834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
|
|
12835
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 }, transform: a.pressed ? "scale(0.9)" : void 0 }),
|
|
12836
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("g", { transform: "translate(13 16)", children: [
|
|
12837
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("rect", { x: 0, y: 0, rx: 4, height: 18, width: Math.max(28, (a.message ?? a.name).length * 6.4 + 12), style: { fill: a.color } }),
|
|
12838
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("text", { x: 6, y: 9, dominantBaseline: "central", style: { fill: "#ffffff", fontSize: 11, fontWeight: 600, fontFamily: "inherit" }, children: a.message ?? a.name })
|
|
12728
12839
|
] })
|
|
12729
12840
|
] }, a.id)) });
|
|
12730
12841
|
}
|
|
12731
12842
|
function ChartTooltipContent({ tooltip }) {
|
|
12732
|
-
return /* @__PURE__ */ (0,
|
|
12733
|
-
tooltip.title && /* @__PURE__ */ (0,
|
|
12734
|
-
tooltip.items.map((item) => /* @__PURE__ */ (0,
|
|
12735
|
-
/* @__PURE__ */ (0,
|
|
12736
|
-
/* @__PURE__ */ (0,
|
|
12737
|
-
/* @__PURE__ */ (0,
|
|
12843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
12844
|
+
tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
|
|
12845
|
+
tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12846
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
|
|
12847
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
|
|
12848
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
|
|
12738
12849
|
] }, item.seriesId))
|
|
12739
12850
|
] });
|
|
12740
12851
|
}
|
|
12741
12852
|
function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
|
|
12742
12853
|
const state = useChartState(controller);
|
|
12743
|
-
const wrapper = (0,
|
|
12744
|
-
const svg = (0,
|
|
12745
|
-
const drag = (0,
|
|
12746
|
-
const [measured, setMeasured] = (0,
|
|
12747
|
-
const [frozen, setFrozen] = (0,
|
|
12854
|
+
const wrapper = (0, import_react89.useRef)(null);
|
|
12855
|
+
const svg = (0, import_react89.useRef)(null);
|
|
12856
|
+
const drag = (0, import_react89.useRef)(null);
|
|
12857
|
+
const [measured, setMeasured] = (0, import_react89.useState)(null);
|
|
12858
|
+
const [frozen, setFrozen] = (0, import_react89.useState)(null);
|
|
12748
12859
|
const tooltipMode = tooltip === true ? "point" : tooltip || null;
|
|
12749
|
-
const [tip, setTip] = (0,
|
|
12750
|
-
const [tipAt, setTipAt] = (0,
|
|
12751
|
-
(0,
|
|
12860
|
+
const [tip, setTip] = (0, import_react89.useState)(null);
|
|
12861
|
+
const [tipAt, setTipAt] = (0, import_react89.useState)({ left: 0, top: 0, flip: false });
|
|
12862
|
+
(0, import_react89.useEffect)(() => {
|
|
12752
12863
|
const el = wrapper.current;
|
|
12753
12864
|
if (!responsive || !el || typeof ResizeObserver === "undefined") return;
|
|
12754
12865
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -12759,8 +12870,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
12759
12870
|
return () => observer.disconnect();
|
|
12760
12871
|
}, [responsive]);
|
|
12761
12872
|
const sceneWidth = responsive && measured || width;
|
|
12762
|
-
const fullTheme = (0,
|
|
12763
|
-
const scene = (0,
|
|
12873
|
+
const fullTheme = (0, import_react89.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
|
|
12874
|
+
const scene = (0, import_react89.useMemo)(
|
|
12764
12875
|
() => (0, import_chart2.layoutChart)(state.spec, {
|
|
12765
12876
|
width: sceneWidth,
|
|
12766
12877
|
height,
|
|
@@ -12777,8 +12888,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
12777
12888
|
[state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
|
|
12778
12889
|
);
|
|
12779
12890
|
if (sceneRef) sceneRef.current = scene;
|
|
12780
|
-
const byKey = (0,
|
|
12781
|
-
(0,
|
|
12891
|
+
const byKey = (0, import_react89.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
|
|
12892
|
+
(0, import_react89.useEffect)(() => () => drag.current?.end(), []);
|
|
12782
12893
|
const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
|
|
12783
12894
|
const onPointerDown = (e) => {
|
|
12784
12895
|
if (!editable || e.button !== 0) return;
|
|
@@ -12825,8 +12936,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
12825
12936
|
if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
|
|
12826
12937
|
};
|
|
12827
12938
|
const label = state.spec.title || "Chart";
|
|
12828
|
-
return /* @__PURE__ */ (0,
|
|
12829
|
-
/* @__PURE__ */ (0,
|
|
12939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
|
|
12940
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
12830
12941
|
"svg",
|
|
12831
12942
|
{
|
|
12832
12943
|
ref: svg,
|
|
@@ -12845,11 +12956,11 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
12845
12956
|
onKeyDown,
|
|
12846
12957
|
children: [
|
|
12847
12958
|
scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
|
|
12848
|
-
presence && /* @__PURE__ */ (0,
|
|
12959
|
+
presence && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartPresenceLayer, { presence })
|
|
12849
12960
|
]
|
|
12850
12961
|
}
|
|
12851
12962
|
),
|
|
12852
|
-
tip && /* @__PURE__ */ (0,
|
|
12963
|
+
tip && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12853
12964
|
"div",
|
|
12854
12965
|
{
|
|
12855
12966
|
role: "tooltip",
|
|
@@ -12864,14 +12975,14 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
12864
12975
|
borderColor: "var(--border, #e2e8f0)",
|
|
12865
12976
|
fontFamily: scene.theme.fontFamily
|
|
12866
12977
|
},
|
|
12867
|
-
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0,
|
|
12978
|
+
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartTooltipContent, { tooltip: tip })
|
|
12868
12979
|
}
|
|
12869
12980
|
)
|
|
12870
12981
|
] });
|
|
12871
12982
|
}
|
|
12872
12983
|
|
|
12873
12984
|
// src/chart/ChartDataGrid.tsx
|
|
12874
|
-
var
|
|
12985
|
+
var import_react90 = require("react");
|
|
12875
12986
|
var import_chart3 = require("@pixerate/editor/chart");
|
|
12876
12987
|
|
|
12877
12988
|
// src/chart/styles.ts
|
|
@@ -12884,11 +12995,11 @@ var chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
|
|
|
12884
12995
|
var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right text-xs tabular-nums text-foreground focus-visible:bg-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary";
|
|
12885
12996
|
|
|
12886
12997
|
// src/chart/ChartDataGrid.tsx
|
|
12887
|
-
var
|
|
12998
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
12888
12999
|
function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
12889
|
-
const [draft, setDraft] = (0,
|
|
12890
|
-
const typing = (0,
|
|
12891
|
-
(0,
|
|
13000
|
+
const [draft, setDraft] = (0, import_react90.useState)(value);
|
|
13001
|
+
const typing = (0, import_react90.useRef)(false);
|
|
13002
|
+
(0, import_react90.useEffect)(() => {
|
|
12892
13003
|
if (!typing.current) setDraft(value);
|
|
12893
13004
|
}, [value]);
|
|
12894
13005
|
const commit = () => {
|
|
@@ -12897,7 +13008,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
12897
13008
|
if (draft === value) return;
|
|
12898
13009
|
if (onCommit(draft) === false) setDraft(value);
|
|
12899
13010
|
};
|
|
12900
|
-
return /* @__PURE__ */ (0,
|
|
13011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12901
13012
|
"input",
|
|
12902
13013
|
{
|
|
12903
13014
|
...rest,
|
|
@@ -12926,20 +13037,20 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
12926
13037
|
}
|
|
12927
13038
|
function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
12928
13039
|
const { spec } = useChartState(controller);
|
|
12929
|
-
const [columns, setColumns] = (0,
|
|
13040
|
+
const [columns, setColumns] = (0, import_react90.useState)(1);
|
|
12930
13041
|
const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
|
|
12931
13042
|
const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
|
|
12932
13043
|
const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
|
|
12933
13044
|
const commit = (next) => controller.setTreeRows(next).ok;
|
|
12934
|
-
return /* @__PURE__ */ (0,
|
|
12935
|
-
/* @__PURE__ */ (0,
|
|
12936
|
-
/* @__PURE__ */ (0,
|
|
12937
|
-
labels.map((label) => /* @__PURE__ */ (0,
|
|
12938
|
-
/* @__PURE__ */ (0,
|
|
12939
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
|
|
13046
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13047
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { children: [
|
|
13048
|
+
labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
13049
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
13050
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "w-8 border-b border-border" })
|
|
12940
13051
|
] }) }),
|
|
12941
|
-
/* @__PURE__ */ (0,
|
|
12942
|
-
labels.map((_, k) => /* @__PURE__ */ (0,
|
|
13052
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { "data-tree-row": r, children: [
|
|
13053
|
+
labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12943
13054
|
ChartCommitInput,
|
|
12944
13055
|
{
|
|
12945
13056
|
value: row.path[k] ?? "",
|
|
@@ -12950,7 +13061,7 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
12950
13061
|
className: `${chartCellClass} text-left`
|
|
12951
13062
|
}
|
|
12952
13063
|
) }, k)),
|
|
12953
|
-
/* @__PURE__ */ (0,
|
|
13064
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12954
13065
|
ChartCommitInput,
|
|
12955
13066
|
{
|
|
12956
13067
|
value: String(row.value),
|
|
@@ -12963,14 +13074,14 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
12963
13074
|
className: chartCellClass
|
|
12964
13075
|
}
|
|
12965
13076
|
) }),
|
|
12966
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13077
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete item", "aria-label": `Delete ${row.path.join(" / ")}`, "data-action": "tree-remove-row", onClick: () => commit((0, import_chart3.removeChartTreeRow)(rows, r)), children: "\xD7" }) })
|
|
12967
13078
|
] }, r)) })
|
|
12968
13079
|
] }),
|
|
12969
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12970
|
-
/* @__PURE__ */ (0,
|
|
12971
|
-
/* @__PURE__ */ (0,
|
|
12972
|
-
/* @__PURE__ */ (0,
|
|
12973
|
-
/* @__PURE__ */ (0,
|
|
13080
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
13081
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-row", onClick: () => commit((0, import_chart3.addChartTreeRow)(rows)), children: "+ Add item" }),
|
|
13082
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
|
|
13083
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "flex-1" }),
|
|
13084
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "tree-ungroup", title: "Keep the group totals as plain data", onClick: () => controller.setTree([]), children: "Ungroup" })
|
|
12974
13085
|
] })
|
|
12975
13086
|
] });
|
|
12976
13087
|
}
|
|
@@ -12978,30 +13089,30 @@ function ChartLinksGrid({ controller, readOnly = false, className }) {
|
|
|
12978
13089
|
const { spec } = useChartState(controller);
|
|
12979
13090
|
const links = spec.links;
|
|
12980
13091
|
const commit = (next) => controller.setLinks(next).ok;
|
|
12981
|
-
return /* @__PURE__ */ (0,
|
|
12982
|
-
/* @__PURE__ */ (0,
|
|
12983
|
-
/* @__PURE__ */ (0,
|
|
12984
|
-
["Source", "Target"].map((label) => /* @__PURE__ */ (0,
|
|
12985
|
-
/* @__PURE__ */ (0,
|
|
12986
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-links-grid": "", children: [
|
|
13093
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13094
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { children: [
|
|
13095
|
+
["Source", "Target"].map((label) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
13096
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
13097
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "w-8 border-b border-border" })
|
|
12987
13098
|
] }) }),
|
|
12988
|
-
/* @__PURE__ */ (0,
|
|
12989
|
-
["source", "target"].map((field) => /* @__PURE__ */ (0,
|
|
12990
|
-
/* @__PURE__ */ (0,
|
|
12991
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13099
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { children: links.map((link, i) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { "data-link-row": i, children: [
|
|
13100
|
+
["source", "target"].map((field) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ChartCommitInput, { value: link[field], "aria-label": `${field === "source" ? "Source" : "Target"} of flow ${i + 1}`, "data-link-cell": `${i}:${field}`, readOnly, onCommit: (text) => commit((0, import_chart3.setChartLinkField)(links, i, field, text)), className: `${chartCellClass} text-left` }) }, field)),
|
|
13101
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ChartCommitInput, { value: String(link.value), inputMode: "decimal", "aria-label": `Value of ${link.source} \u2192 ${link.target}`, "data-link-cell": `${i}:value`, readOnly, onCommit: (text) => commit((0, import_chart3.setChartLinkField)(links, i, "value", text)), className: chartCellClass }) }),
|
|
13102
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete flow", "aria-label": `Delete ${link.source} \u2192 ${link.target}`, "data-action": "link-remove", onClick: () => controller.removeLink(i), children: "\xD7" }) })
|
|
12992
13103
|
] }, i)) })
|
|
12993
13104
|
] }),
|
|
12994
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12995
|
-
/* @__PURE__ */ (0,
|
|
12996
|
-
/* @__PURE__ */ (0,
|
|
12997
|
-
links.length > 0 && /* @__PURE__ */ (0,
|
|
13105
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
13106
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "link-add", onClick: () => commit((0, import_chart3.addChartLink)(links)), children: "+ Add flow" }),
|
|
13107
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "flex-1" }),
|
|
13108
|
+
links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "links-clear", title: "Keep how much passes through each node as plain data", onClick: () => controller.setLinks([]), children: "Remove flows" })
|
|
12998
13109
|
] })
|
|
12999
13110
|
] });
|
|
13000
13111
|
}
|
|
13001
13112
|
function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
|
|
13002
13113
|
const { spec, selection } = useChartState(controller);
|
|
13003
|
-
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0,
|
|
13004
|
-
if (spec.tree.length) return /* @__PURE__ */ (0,
|
|
13114
|
+
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ChartLinksGrid, { controller, readOnly, className });
|
|
13115
|
+
if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ChartTreeGrid, { controller, readOnly, className });
|
|
13005
13116
|
const canGroup = spec.type === "treemap" || spec.type === "sunburst";
|
|
13006
13117
|
const paste = (row, column) => (e) => {
|
|
13007
13118
|
const text = e.clipboardData?.getData("text/plain") ?? "";
|
|
@@ -13009,15 +13120,15 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13009
13120
|
e.preventDefault();
|
|
13010
13121
|
controller.pasteCells(row, column, text);
|
|
13011
13122
|
};
|
|
13012
|
-
return /* @__PURE__ */ (0,
|
|
13013
|
-
/* @__PURE__ */ (0,
|
|
13014
|
-
/* @__PURE__ */ (0,
|
|
13015
|
-
/* @__PURE__ */ (0,
|
|
13123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", children: [
|
|
13124
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13125
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { children: [
|
|
13126
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: categoryHeader }),
|
|
13016
13127
|
spec.series.map((s, si) => {
|
|
13017
13128
|
const color = (0, import_chart3.chartSeriesColor)(spec, si);
|
|
13018
13129
|
const selected = selection?.kind === "series" && selection.seriesId === s.id;
|
|
13019
|
-
return /* @__PURE__ */ (0,
|
|
13020
|
-
/* @__PURE__ */ (0,
|
|
13130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { "data-series-id": s.id, className: `border-b border-r border-border px-1 py-1 font-medium ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13131
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13021
13132
|
"input",
|
|
13022
13133
|
{
|
|
13023
13134
|
type: "color",
|
|
@@ -13030,7 +13141,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13030
13141
|
className: "h-5 w-5 shrink-0 cursor-pointer rounded border-0 bg-transparent p-0"
|
|
13031
13142
|
}
|
|
13032
13143
|
),
|
|
13033
|
-
/* @__PURE__ */ (0,
|
|
13144
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13034
13145
|
ChartCommitInput,
|
|
13035
13146
|
{
|
|
13036
13147
|
value: s.name,
|
|
@@ -13040,8 +13151,8 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13040
13151
|
className: `${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? "text-muted-foreground line-through" : ""}`
|
|
13041
13152
|
}
|
|
13042
13153
|
),
|
|
13043
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13044
|
-
/* @__PURE__ */ (0,
|
|
13154
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
13155
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13045
13156
|
"button",
|
|
13046
13157
|
{
|
|
13047
13158
|
type: "button",
|
|
@@ -13054,16 +13165,16 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13054
13165
|
children: s.hidden ? "\u25CB" : "\u25CF"
|
|
13055
13166
|
}
|
|
13056
13167
|
),
|
|
13057
|
-
/* @__PURE__ */ (0,
|
|
13168
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete series", "aria-label": `Delete ${s.name}`, "data-action": "remove-series", onClick: () => controller.removeSeries(s.id), children: "\xD7" })
|
|
13058
13169
|
] })
|
|
13059
13170
|
] }) }, s.id);
|
|
13060
13171
|
}),
|
|
13061
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13172
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "w-8 border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Add series", "aria-label": "Add series", "data-action": "add-series", onClick: () => controller.addSeries(), children: "+" }) })
|
|
13062
13173
|
] }) }),
|
|
13063
|
-
/* @__PURE__ */ (0,
|
|
13174
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { children: spec.categories.map((category, i) => {
|
|
13064
13175
|
const rowSelected = selection?.kind === "category" && selection.index === i;
|
|
13065
|
-
return /* @__PURE__ */ (0,
|
|
13066
|
-
/* @__PURE__ */ (0,
|
|
13176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("tr", { "data-category-index": i, className: rowSelected ? "bg-primary/10" : void 0, children: [
|
|
13177
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "border-b border-r border-border p-0 text-left font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13067
13178
|
ChartCommitInput,
|
|
13068
13179
|
{
|
|
13069
13180
|
value: category,
|
|
@@ -13077,7 +13188,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13077
13188
|
spec.series.map((s) => {
|
|
13078
13189
|
const value = s.values[i];
|
|
13079
13190
|
const selected = selection?.kind === "point" && selection.seriesId === s.id && selection.index === i;
|
|
13080
|
-
return /* @__PURE__ */ (0,
|
|
13191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: `border-b border-r border-border p-0 ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13081
13192
|
ChartCommitInput,
|
|
13082
13193
|
{
|
|
13083
13194
|
value: value === null || value === void 0 ? "" : String(value),
|
|
@@ -13092,13 +13203,13 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13092
13203
|
}
|
|
13093
13204
|
) }, s.id);
|
|
13094
13205
|
}),
|
|
13095
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13206
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete category", "aria-label": `Delete ${category}`, "data-action": "remove-category", onClick: () => controller.removeCategory(i), children: "\xD7" }) })
|
|
13096
13207
|
] }, i);
|
|
13097
13208
|
}) })
|
|
13098
13209
|
] }),
|
|
13099
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13100
|
-
/* @__PURE__ */ (0,
|
|
13101
|
-
canGroup && /* @__PURE__ */ (0,
|
|
13210
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "p-1", children: [
|
|
13211
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
|
|
13212
|
+
canGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
13102
13213
|
"button",
|
|
13103
13214
|
{
|
|
13104
13215
|
type: "button",
|
|
@@ -13114,29 +13225,29 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13114
13225
|
}
|
|
13115
13226
|
|
|
13116
13227
|
// src/chart/ChartInspector.tsx
|
|
13117
|
-
var
|
|
13228
|
+
var import_react91 = require("react");
|
|
13118
13229
|
var import_chart4 = require("@pixerate/editor/chart");
|
|
13119
|
-
var
|
|
13230
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
13120
13231
|
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
13121
13232
|
function Field({ label, htmlFor, children }) {
|
|
13122
|
-
return /* @__PURE__ */ (0,
|
|
13123
|
-
/* @__PURE__ */ (0,
|
|
13124
|
-
/* @__PURE__ */ (0,
|
|
13233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
13234
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("label", { htmlFor, className: `${chartLabelClass} w-20 shrink-0`, children: label }),
|
|
13235
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "min-w-0 flex-1", children })
|
|
13125
13236
|
] });
|
|
13126
13237
|
}
|
|
13127
13238
|
function Toggle({ label, checked, onChange, name }) {
|
|
13128
|
-
return /* @__PURE__ */ (0,
|
|
13129
|
-
/* @__PURE__ */ (0,
|
|
13239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("label", { className: "flex cursor-pointer items-center gap-2 text-xs text-foreground", children: [
|
|
13240
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("input", { type: "checkbox", className: "h-3.5 w-3.5 accent-primary", checked, "data-option": name, onChange: (e) => onChange(e.currentTarget.checked) }),
|
|
13130
13241
|
label
|
|
13131
13242
|
] });
|
|
13132
13243
|
}
|
|
13133
13244
|
function Select({ id, value, options, onChange, name, labels }) {
|
|
13134
|
-
return /* @__PURE__ */ (0,
|
|
13245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("select", { id, className: chartInputClass, value, "data-option": name, onChange: (e) => onChange(e.currentTarget.value), children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: o, children: labels?.[o] ?? cap(o) }, o)) });
|
|
13135
13246
|
}
|
|
13136
13247
|
function AxisSection({ controller, axis, value, idBase, horizontal, numeric = false, scales = false }) {
|
|
13137
13248
|
const set = (patch) => controller.setAxis(axis, patch);
|
|
13138
13249
|
const setFormat = (patch) => set({ format: { ...value.format, ...patch } });
|
|
13139
|
-
const bound = (key2) => /* @__PURE__ */ (0,
|
|
13250
|
+
const bound = (key2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13140
13251
|
ChartCommitInput,
|
|
13141
13252
|
{
|
|
13142
13253
|
id: `${idBase}-${axis}-${key2}`,
|
|
@@ -13151,26 +13262,26 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13151
13262
|
const name = axis === "x" ? numeric ? "X axis" : "Category axis" : axis === "y" ? "Value axis" : "Secondary axis";
|
|
13152
13263
|
const valueAxis = axis !== "x" || numeric;
|
|
13153
13264
|
const key = axis === "y2" ? "yAxis2" : `${axis}Axis`;
|
|
13154
|
-
return /* @__PURE__ */ (0,
|
|
13155
|
-
/* @__PURE__ */ (0,
|
|
13156
|
-
/* @__PURE__ */ (0,
|
|
13265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": `axis-${axis}`, children: [
|
|
13266
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
13267
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("h4", { className: "text-xs font-semibold text-foreground", children: [
|
|
13157
13268
|
name,
|
|
13158
|
-
/* @__PURE__ */ (0,
|
|
13269
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
13159
13270
|
"(",
|
|
13160
13271
|
axis === "x" ? horizontal ? "left" : "bottom" : axis === "y2" ? horizontal ? "top" : "right" : horizontal ? "bottom" : "left",
|
|
13161
13272
|
")"
|
|
13162
13273
|
] })
|
|
13163
13274
|
] }),
|
|
13164
|
-
/* @__PURE__ */ (0,
|
|
13275
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Show", name: `${axis}Axis.show`, checked: value.show, onChange: (show) => set({ show }) })
|
|
13165
13276
|
] }),
|
|
13166
|
-
/* @__PURE__ */ (0,
|
|
13167
|
-
/* @__PURE__ */ (0,
|
|
13168
|
-
/* @__PURE__ */ (0,
|
|
13169
|
-
axis === "x" && !numeric && /* @__PURE__ */ (0,
|
|
13170
|
-
scales && /* @__PURE__ */ (0,
|
|
13171
|
-
scales && valueAxis && /* @__PURE__ */ (0,
|
|
13277
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Title", htmlFor: `${idBase}-${axis}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-title`, value: value.title, "data-option": `${axis}Axis.title`, className: chartInputClass, onCommit: (title) => void set({ title }) }) }),
|
|
13278
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
13279
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Grid lines", name: `${key}.gridlines`, checked: value.gridlines, onChange: (gridlines) => set({ gridlines }) }),
|
|
13280
|
+
axis === "x" && !numeric && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Dates", name: "xAxis.kind", checked: value.kind === "date", onChange: (dates) => set({ kind: dates ? "date" : void 0 }) }),
|
|
13281
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Reverse", name: `${key}.reverse`, checked: !!value.reverse, onChange: (reverse) => set({ reverse }) }),
|
|
13282
|
+
scales && valueAxis && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Log scale", name: `${key}.scale`, checked: value.scale === "log", onChange: (log) => set({ scale: log ? "log" : "linear" }) })
|
|
13172
13283
|
] }),
|
|
13173
|
-
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0,
|
|
13284
|
+
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Log base", htmlFor: `${idBase}-${axis}-log-base`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13174
13285
|
ChartCommitInput,
|
|
13175
13286
|
{
|
|
13176
13287
|
id: `${idBase}-${axis}-log-base`,
|
|
@@ -13181,7 +13292,7 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13181
13292
|
onCommit: (text) => set({ logBase: text.trim() === "" ? void 0 : Number(text) }).ok
|
|
13182
13293
|
}
|
|
13183
13294
|
) }),
|
|
13184
|
-
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0,
|
|
13295
|
+
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Step", htmlFor: `${idBase}-${axis}-step`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13185
13296
|
ChartCommitInput,
|
|
13186
13297
|
{
|
|
13187
13298
|
id: `${idBase}-${axis}-step`,
|
|
@@ -13193,14 +13304,14 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13193
13304
|
onCommit: (text) => set({ step: text.trim() === "" ? null : Number(text) }).ok
|
|
13194
13305
|
}
|
|
13195
13306
|
) }),
|
|
13196
|
-
valueAxis && /* @__PURE__ */ (0,
|
|
13197
|
-
/* @__PURE__ */ (0,
|
|
13307
|
+
valueAxis && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
13308
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Min / max", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex gap-1", children: [
|
|
13198
13309
|
bound("min"),
|
|
13199
13310
|
bound("max")
|
|
13200
13311
|
] }) }),
|
|
13201
|
-
/* @__PURE__ */ (0,
|
|
13202
|
-
/* @__PURE__ */ (0,
|
|
13203
|
-
/* @__PURE__ */ (0,
|
|
13312
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Format", htmlFor: `${idBase}-${axis}-format`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex gap-1", children: [
|
|
13313
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-${axis}-format`, name: `${key}.format.style`, value: value.format.style ?? "number", options: import_chart4.CHART_NUMBER_STYLES, onChange: (style) => setFormat({ style }) }),
|
|
13314
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13204
13315
|
ChartCommitInput,
|
|
13205
13316
|
{
|
|
13206
13317
|
value: value.format.decimals === void 0 ? "" : String(value.format.decimals),
|
|
@@ -13219,8 +13330,8 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13219
13330
|
}
|
|
13220
13331
|
)
|
|
13221
13332
|
] }) }),
|
|
13222
|
-
value.format.style === "currency" && /* @__PURE__ */ (0,
|
|
13223
|
-
/* @__PURE__ */ (0,
|
|
13333
|
+
value.format.style === "currency" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Currency", htmlFor: `${idBase}-${axis}-currency`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-currency`, value: value.format.currency ?? "USD", "data-option": `${key}.format.currency`, className: chartInputClass, onCommit: (currency) => void setFormat({ currency: currency.toUpperCase() }) }) }),
|
|
13334
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Code", htmlFor: `${idBase}-${axis}-code`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13224
13335
|
ChartCommitInput,
|
|
13225
13336
|
{
|
|
13226
13337
|
id: `${idBase}-${axis}-code`,
|
|
@@ -13246,15 +13357,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
13246
13357
|
const values = which === "xErrorBars" ? series.x ?? [] : series.values;
|
|
13247
13358
|
const set = (next) => controller.updateSeries(series.id, { [which]: next });
|
|
13248
13359
|
const patch = (p) => bars && set({ ...bars, ...p });
|
|
13249
|
-
return /* @__PURE__ */ (0,
|
|
13250
|
-
/* @__PURE__ */ (0,
|
|
13251
|
-
/* @__PURE__ */ (0,
|
|
13252
|
-
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "space-y-1.5", "data-section": which === "errorBars" ? "error-bars" : "x-error-bars", children: [
|
|
13361
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: which === "errorBars" ? "Error bars" : "X error bars", htmlFor: `${id}-type`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("select", { id: `${id}-type`, className: chartInputClass, value: bars?.type ?? "", "data-option": `${key}.type`, onChange: (e) => set((0, import_chart4.chartErrorBarsOfType)(e.currentTarget.value, bars, values)), children: [
|
|
13362
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "None" }),
|
|
13363
|
+
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: t, children: import_chart4.CHART_ERROR_BAR_LABELS[t] }, t))
|
|
13253
13364
|
] }) }),
|
|
13254
|
-
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0,
|
|
13255
|
-
bars?.type === "custom" && /* @__PURE__ */ (0,
|
|
13256
|
-
/* @__PURE__ */ (0,
|
|
13257
|
-
/* @__PURE__ */ (0,
|
|
13365
|
+
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: bars.type === "percent" ? "Percent" : bars.type === "stddev" ? "Deviations" : "Amount", htmlFor: `${id}-value`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${id}-value`, value: String(bars.value ?? (0, import_chart4.defaultChartErrorBarValue)(bars.type)), inputMode: "decimal", "data-option": `${key}.value`, className: chartInputClass, onCommit: (text) => !!patch({ value: text.trim() === "" ? void 0 : Number(text) })?.ok }) }),
|
|
13366
|
+
bars?.type === "custom" && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
13367
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Plus", htmlFor: `${id}-plus`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${id}-plus`, value: (0, import_chart4.formatChartAmountList)(bars.plus), placeholder: "1, 2, -, 0.5", "data-option": `${key}.plus`, className: chartInputClass, onCommit: (text) => !!patch({ plus: (0, import_chart4.parseChartAmountList)(text) })?.ok }) }),
|
|
13368
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Minus", htmlFor: `${id}-minus`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13258
13369
|
ChartCommitInput,
|
|
13259
13370
|
{
|
|
13260
13371
|
id: `${id}-minus`,
|
|
@@ -13271,15 +13382,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
13271
13382
|
}
|
|
13272
13383
|
) })
|
|
13273
13384
|
] }),
|
|
13274
|
-
bars && /* @__PURE__ */ (0,
|
|
13275
|
-
/* @__PURE__ */ (0,
|
|
13276
|
-
/* @__PURE__ */ (0,
|
|
13385
|
+
bars && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
13386
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("select", { className: `${chartInputClass} flex-1`, "aria-label": "Error bar direction", value: bars.direction ?? "both", "data-option": `${key}.direction`, onChange: (e) => patch({ direction: e.currentTarget.value }), children: import_chart4.CHART_ERROR_BAR_DIRECTIONS.map((d) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: d, children: d === "both" ? "Both ways" : d === "plus" ? "Plus only" : "Minus only" }, d)) }),
|
|
13387
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Caps", name: `${key}.cap`, checked: bars.cap !== false, onChange: (cap2) => patch({ cap: cap2 }) })
|
|
13277
13388
|
] })
|
|
13278
13389
|
] });
|
|
13279
13390
|
}
|
|
13280
13391
|
function ChartInspector({ controller, sections, className }) {
|
|
13281
13392
|
const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
|
|
13282
|
-
const idBase = (0,
|
|
13393
|
+
const idBase = (0, import_react91.useId)();
|
|
13283
13394
|
const show = (section) => !sections || sections.includes(section);
|
|
13284
13395
|
const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
|
|
13285
13396
|
const family = (0, import_chart4.chartFamily)(spec);
|
|
@@ -13294,30 +13405,30 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13294
13405
|
const annotated = scales;
|
|
13295
13406
|
const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
|
|
13296
13407
|
const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
|
|
13297
|
-
return /* @__PURE__ */ (0,
|
|
13298
|
-
show("type") && /* @__PURE__ */ (0,
|
|
13299
|
-
show("style") && /* @__PURE__ */ (0,
|
|
13300
|
-
/* @__PURE__ */ (0,
|
|
13301
|
-
/* @__PURE__ */ (0,
|
|
13302
|
-
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0,
|
|
13408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
|
|
13409
|
+
show("type") && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5", role: "radiogroup", "aria-label": "Chart type", children: import_chart4.CHART_TYPES.map((type) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", role: "radio", "aria-checked": spec.type === type, "data-chart-type": type, className: chartSegmentClass(spec.type === type), onClick: () => controller.setType(type), children: import_chart4.CHART_TYPE_LABELS[type] }, type)) }) }),
|
|
13410
|
+
show("style") && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
|
|
13411
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Layout", htmlFor: `${idBase}-layout`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("select", { id: `${idBase}-layout`, className: chartInputClass, value: "", "data-option": "preset.layout", onChange: (e) => e.currentTarget.value && controller.applyPreset({ layout: e.currentTarget.value }), children: [
|
|
13412
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "Quick layout\u2026" }),
|
|
13413
|
+
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: p.id, title: p.description, children: p.label }, p.id))
|
|
13303
13414
|
] }) }),
|
|
13304
|
-
/* @__PURE__ */ (0,
|
|
13305
|
-
/* @__PURE__ */ (0,
|
|
13306
|
-
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0,
|
|
13415
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Colours", htmlFor: `${idBase}-colors`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("select", { id: `${idBase}-colors`, className: chartInputClass, value: import_chart4.CHART_COLOR_SCHEMES.find((c) => c.palette.join() === spec.palette.join())?.id ?? "", "data-option": "preset.colors", onChange: (e) => e.currentTarget.value && controller.applyPreset({ colors: e.currentTarget.value }), children: [
|
|
13416
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "Custom" }),
|
|
13417
|
+
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: c.id, title: c.description, children: c.label }, c.id))
|
|
13307
13418
|
] }) }),
|
|
13308
|
-
!colorCheck.ok && /* @__PURE__ */ (0,
|
|
13309
|
-
/* @__PURE__ */ (0,
|
|
13419
|
+
!colorCheck.ok && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "text-[11px] leading-snug text-amber-600 dark:text-amber-400", "data-chart-color-warning": "", children: colorCheck.issues[0] }),
|
|
13420
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "transpose", onClick: () => controller.transpose(), children: "Switch rows and columns" })
|
|
13310
13421
|
] }),
|
|
13311
|
-
show("titles") && /* @__PURE__ */ (0,
|
|
13312
|
-
/* @__PURE__ */ (0,
|
|
13313
|
-
/* @__PURE__ */ (0,
|
|
13314
|
-
/* @__PURE__ */ (0,
|
|
13422
|
+
show("titles") && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
|
|
13423
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
|
|
13424
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
|
|
13425
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
|
|
13315
13426
|
] }),
|
|
13316
|
-
show("options") && /* @__PURE__ */ (0,
|
|
13317
|
-
cartesian && /* @__PURE__ */ (0,
|
|
13318
|
-
hasBars && /* @__PURE__ */ (0,
|
|
13319
|
-
hasLines && /* @__PURE__ */ (0,
|
|
13320
|
-
spec.type === "donut" && /* @__PURE__ */ (0,
|
|
13427
|
+
show("options") && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
|
|
13428
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-stacking`, name: "stacking", value: spec.stacking, options: import_chart4.CHART_STACKINGS, labels: { none: "None", stacked: "Stacked", percent: "100%" }, onChange: (stacking) => controller.update({ stacking }) }) }),
|
|
13429
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Bars", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: ["vertical", "horizontal"].map((o) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", "aria-pressed": spec.orientation === o, "data-option": `orientation.${o}`, className: chartSegmentClass(spec.orientation === o), onClick: () => controller.update({ orientation: o }), children: cap(o) }, o)) }) }),
|
|
13430
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Lines", htmlFor: `${idBase}-curve`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-curve`, name: "curve", value: spec.curve, options: import_chart4.CHART_CURVES, onChange: (curve) => controller.update({ curve }) }) }),
|
|
13431
|
+
spec.type === "donut" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Hole", htmlFor: `${idBase}-hole`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13321
13432
|
"input",
|
|
13322
13433
|
{
|
|
13323
13434
|
id: `${idBase}-hole`,
|
|
@@ -13333,7 +13444,7 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13333
13444
|
onChange: (e) => controller.update({ innerRadius: Number(e.currentTarget.value) })
|
|
13334
13445
|
}
|
|
13335
13446
|
) }),
|
|
13336
|
-
hasBars && /* @__PURE__ */ (0,
|
|
13447
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Spacing", htmlFor: `${idBase}-gap`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13337
13448
|
"input",
|
|
13338
13449
|
{
|
|
13339
13450
|
id: `${idBase}-gap`,
|
|
@@ -13349,9 +13460,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13349
13460
|
onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
|
|
13350
13461
|
}
|
|
13351
13462
|
) }),
|
|
13352
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13353
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13354
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13463
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Map", htmlFor: `${idBase}-map`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("select", { id: `${idBase}-map`, className: chartInputClass, value: spec.map, "data-option": "map", onChange: (e) => controller.update({ map: e.currentTarget.value }), children: [.../* @__PURE__ */ new Set([spec.map, ...(0, import_chart4.listChartMaps)().map((m) => m.id)])].map((id) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: id, children: (0, import_chart4.listChartMaps)().find((m) => m.id === id)?.name ?? `${id} (not loaded)` }, id)) }) }),
|
|
13464
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Classes", htmlFor: `${idBase}-map-steps`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-map-steps`, value: String(spec.mapSteps), inputMode: "numeric", "data-option": "mapSteps", disabled: spec.mapThresholds.length > 0, className: chartInputClass, onCommit: (text) => controller.update({ mapSteps: Number(text) }).ok }) }),
|
|
13465
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Breaks", htmlFor: `${idBase}-map-breaks`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13355
13466
|
ChartCommitInput,
|
|
13356
13467
|
{
|
|
13357
13468
|
id: `${idBase}-map-breaks`,
|
|
@@ -13362,10 +13473,10 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13362
13473
|
onCommit: (text) => controller.update({ mapThresholds: text.trim() ? text.split(",").map((t) => Number(t.trim())) : [] }).ok
|
|
13363
13474
|
}
|
|
13364
13475
|
) }),
|
|
13365
|
-
spec.type === "barrace" && /* @__PURE__ */ (0,
|
|
13366
|
-
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0,
|
|
13367
|
-
/* @__PURE__ */ (0,
|
|
13368
|
-
/* @__PURE__ */ (0,
|
|
13476
|
+
spec.type === "barrace" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Bars", htmlFor: `${idBase}-race-top`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-race-top`, value: String(spec.raceTopN), inputMode: "numeric", "data-option": "raceTopN", className: chartInputClass, onCommit: (text) => controller.update({ raceTopN: Number(text) }).ok }) }),
|
|
13477
|
+
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Time", htmlFor: `${idBase}-race-frame`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13478
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "race-play", "aria-label": racePlaying ? "Pause the race" : "Play the race", onClick: () => racePlaying ? controller.pauseRace() : controller.playRace(), children: racePlaying ? "Pause" : "Play" }),
|
|
13479
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13369
13480
|
"input",
|
|
13370
13481
|
{
|
|
13371
13482
|
id: `${idBase}-race-frame`,
|
|
@@ -13380,13 +13491,13 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13380
13491
|
onChange: (e) => controller.setRaceFrame(Number(e.currentTarget.value))
|
|
13381
13492
|
}
|
|
13382
13493
|
),
|
|
13383
|
-
/* @__PURE__ */ (0,
|
|
13494
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "w-12 shrink-0 truncate text-right tabular-nums text-muted-foreground", "data-race-time": "", children: spec.categories[Math.round(raceFrame ?? spec.categories.length - 1)] })
|
|
13384
13495
|
] }) }),
|
|
13385
|
-
spec.type === "sankey" && /* @__PURE__ */ (0,
|
|
13386
|
-
spec.type === "sunburst" && /* @__PURE__ */ (0,
|
|
13387
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
13388
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
13389
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13496
|
+
spec.type === "sankey" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Flows", htmlFor: `${idBase}-sankey-color`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-sankey-color`, name: "sankeyLinkColor", value: spec.sankeyLinkColor, options: import_chart4.CHART_SANKEY_LINK_COLORS, labels: { source: "Coloured by source", target: "Coloured by target", gray: "Grey" }, onChange: (sankeyLinkColor) => controller.update({ sankeyLinkColor }) }) }),
|
|
13497
|
+
spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
|
|
13498
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-likert-neutral`, name: "likertNeutral", value: spec.likertNeutral, options: import_chart4.CHART_LIKERT_NEUTRALS, labels: { split: "Across the centre", separate: "In its own column" }, onChange: (likertNeutral) => controller.update({ likertNeutral }) }) }),
|
|
13499
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-likert-sort`, name: "likertSort", value: spec.likertSort, options: import_chart4.CHART_LIKERT_SORTS, labels: { none: "As entered", positive: "Most agreement first", negative: "Most disagreement first" }, onChange: (likertSort) => controller.update({ likertSort }) }) }),
|
|
13500
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13390
13501
|
"input",
|
|
13391
13502
|
{
|
|
13392
13503
|
id: `${idBase}-parliament-arc`,
|
|
@@ -13402,34 +13513,34 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13402
13513
|
onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
|
|
13403
13514
|
}
|
|
13404
13515
|
) }),
|
|
13405
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13406
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13407
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
13408
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
13409
|
-
spec.dataLabels && hasBars && /* @__PURE__ */ (0,
|
|
13410
|
-
spec.type === "histogram" && /* @__PURE__ */ (0,
|
|
13411
|
-
/* @__PURE__ */ (0,
|
|
13412
|
-
spec.type === "waterfall" && /* @__PURE__ */ (0,
|
|
13413
|
-
hasLines && /* @__PURE__ */ (0,
|
|
13414
|
-
oneSeries && /* @__PURE__ */ (0,
|
|
13415
|
-
/* @__PURE__ */ (0,
|
|
13516
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-parliament-majority`, value: spec.parliamentMajority === null ? "" : String(spec.parliamentMajority), placeholder: "Half plus one", inputMode: "numeric", "data-option": "parliamentMajority", className: chartInputClass, onCommit: (text) => controller.update({ parliamentMajority: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
13517
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
|
|
13518
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-radar-ticks`, value: spec.radarTicks === null ? "" : String(spec.radarTicks), placeholder: "Auto", inputMode: "numeric", "data-option": "radarTicks", className: chartInputClass, onCommit: (text) => controller.update({ radarTicks: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
13519
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-radar-graticule`, name: "radarGraticule", value: spec.radarGraticule, options: import_chart4.CHART_RADAR_GRATICULES, labels: { polygon: "Polygons", circle: "Circles" }, onChange: (radarGraticule) => controller.update({ radarGraticule }) }) }),
|
|
13520
|
+
spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
|
|
13521
|
+
spec.type === "histogram" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Bins", htmlFor: `${idBase}-bins`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-bins`, value: spec.bins === null ? "" : String(spec.bins), placeholder: "Auto", inputMode: "numeric", "data-option": "bins", className: chartInputClass, onCommit: (text) => controller.update({ bins: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
13522
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
13523
|
+
spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
|
|
13524
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
|
|
13525
|
+
oneSeries && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
|
|
13526
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
|
|
13416
13527
|
] })
|
|
13417
13528
|
] }),
|
|
13418
|
-
show("legend") && /* @__PURE__ */ (0,
|
|
13419
|
-
/* @__PURE__ */ (0,
|
|
13420
|
-
/* @__PURE__ */ (0,
|
|
13421
|
-
/* @__PURE__ */ (0,
|
|
13529
|
+
show("legend") && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "legend", children: [
|
|
13530
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
13531
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Legend" }),
|
|
13532
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Show", name: "legend.show", checked: spec.legend.show, onChange: (v) => controller.setLegend({ show: v }) })
|
|
13422
13533
|
] }),
|
|
13423
|
-
spec.legend.show && /* @__PURE__ */ (0,
|
|
13534
|
+
spec.legend.show && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: import_chart4.CHART_LEGEND_POSITIONS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("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)) })
|
|
13424
13535
|
] }),
|
|
13425
|
-
show("axes") && hasAxes && /* @__PURE__ */ (0,
|
|
13426
|
-
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0,
|
|
13427
|
-
/* @__PURE__ */ (0,
|
|
13428
|
-
usesSecondary && /* @__PURE__ */ (0,
|
|
13536
|
+
show("axes") && hasAxes && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
13537
|
+
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AxisSection, { controller, axis: "x", value: spec.xAxis, idBase, horizontal: spec.orientation === "horizontal", numeric: family === "xy", scales }),
|
|
13538
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
|
|
13539
|
+
usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
|
|
13429
13540
|
] }),
|
|
13430
|
-
show("annotations") && annotated && /* @__PURE__ */ (0,
|
|
13431
|
-
/* @__PURE__ */ (0,
|
|
13432
|
-
/* @__PURE__ */ (0,
|
|
13541
|
+
show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
|
|
13542
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
|
|
13543
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13433
13544
|
ChartCommitInput,
|
|
13434
13545
|
{
|
|
13435
13546
|
id: `${idBase}-highlight`,
|
|
@@ -13440,27 +13551,27 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13440
13551
|
onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
|
|
13441
13552
|
}
|
|
13442
13553
|
) }),
|
|
13443
|
-
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0,
|
|
13444
|
-
/* @__PURE__ */ (0,
|
|
13445
|
-
/* @__PURE__ */ (0,
|
|
13446
|
-
/* @__PURE__ */ (0,
|
|
13554
|
+
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
|
|
13555
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { value: String(line.value), "aria-label": "Line value", inputMode: "decimal", "data-option": `referenceLine.${i}.value`, className: `${chartInputClass} w-16 shrink-0`, onCommit: (text) => controller.updateReferenceLine(i, { value: Number(text) }).ok }),
|
|
13556
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { value: line.label ?? "", "aria-label": "Line label", placeholder: "Label", "data-option": `referenceLine.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceLine(i, { label: text || null }).ok }),
|
|
13557
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
|
|
13447
13558
|
] }, `line-${i}`)),
|
|
13448
|
-
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0,
|
|
13449
|
-
/* @__PURE__ */ (0,
|
|
13450
|
-
/* @__PURE__ */ (0,
|
|
13451
|
-
/* @__PURE__ */ (0,
|
|
13452
|
-
/* @__PURE__ */ (0,
|
|
13559
|
+
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
|
|
13560
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { value: String(band.from), "aria-label": "Band from", inputMode: "decimal", "data-option": `referenceBand.${i}.from`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { from: Number(text) }).ok }),
|
|
13561
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { value: String(band.to), "aria-label": "Band to", inputMode: "decimal", "data-option": `referenceBand.${i}.to`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { to: Number(text) }).ok }),
|
|
13562
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { value: band.label ?? "", "aria-label": "Band label", placeholder: "Label", "data-option": `referenceBand.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceBand(i, { label: text || null }).ok }),
|
|
13563
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
|
|
13453
13564
|
] }, `band-${i}`)),
|
|
13454
|
-
/* @__PURE__ */ (0,
|
|
13455
|
-
/* @__PURE__ */ (0,
|
|
13456
|
-
/* @__PURE__ */ (0,
|
|
13565
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex gap-1", children: [
|
|
13566
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
|
|
13567
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
|
|
13457
13568
|
] })
|
|
13458
13569
|
] }),
|
|
13459
|
-
show("series") && selectedSeries && /* @__PURE__ */ (0,
|
|
13460
|
-
/* @__PURE__ */ (0,
|
|
13461
|
-
/* @__PURE__ */ (0,
|
|
13462
|
-
/* @__PURE__ */ (0,
|
|
13463
|
-
/* @__PURE__ */ (0,
|
|
13570
|
+
show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
|
|
13571
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
|
|
13572
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
|
|
13573
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13574
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13464
13575
|
"input",
|
|
13465
13576
|
{
|
|
13466
13577
|
id: `${idBase}-series-color`,
|
|
@@ -13473,9 +13584,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13473
13584
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
|
|
13474
13585
|
}
|
|
13475
13586
|
),
|
|
13476
|
-
selectedSeries.color && /* @__PURE__ */ (0,
|
|
13587
|
+
selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
|
|
13477
13588
|
] }) }),
|
|
13478
|
-
cartesian && /* @__PURE__ */ (0,
|
|
13589
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
13479
13590
|
"select",
|
|
13480
13591
|
{
|
|
13481
13592
|
id: `${idBase}-series-type`,
|
|
@@ -13484,12 +13595,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13484
13595
|
"data-option": "series.type",
|
|
13485
13596
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { type: e.currentTarget.value || null }),
|
|
13486
13597
|
children: [
|
|
13487
|
-
/* @__PURE__ */ (0,
|
|
13488
|
-
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13598
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "Chart type" }),
|
|
13599
|
+
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: t, children: import_chart4.CHART_TYPE_LABELS[t] }, t))
|
|
13489
13600
|
]
|
|
13490
13601
|
}
|
|
13491
13602
|
) }),
|
|
13492
|
-
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0,
|
|
13603
|
+
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Marker", htmlFor: `${idBase}-series-marker`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
13493
13604
|
"select",
|
|
13494
13605
|
{
|
|
13495
13606
|
id: `${idBase}-series-marker`,
|
|
@@ -13498,12 +13609,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13498
13609
|
"data-option": "series.marker",
|
|
13499
13610
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { marker: e.currentTarget.value || null }),
|
|
13500
13611
|
children: [
|
|
13501
|
-
/* @__PURE__ */ (0,
|
|
13502
|
-
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0,
|
|
13612
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "Default" }),
|
|
13613
|
+
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: m, children: cap(m) }, m))
|
|
13503
13614
|
]
|
|
13504
13615
|
}
|
|
13505
13616
|
) }),
|
|
13506
|
-
annotated && calloutIndex !== null && /* @__PURE__ */ (0,
|
|
13617
|
+
annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
13507
13618
|
ChartCommitInput,
|
|
13508
13619
|
{
|
|
13509
13620
|
id: `${idBase}-series-callout`,
|
|
@@ -13514,15 +13625,15 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13514
13625
|
onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
|
|
13515
13626
|
}
|
|
13516
13627
|
) }),
|
|
13517
|
-
scales && /* @__PURE__ */ (0,
|
|
13518
|
-
family === "xy" && /* @__PURE__ */ (0,
|
|
13519
|
-
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0,
|
|
13520
|
-
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0,
|
|
13521
|
-
/* @__PURE__ */ (0,
|
|
13522
|
-
/* @__PURE__ */ (0,
|
|
13523
|
-
/* @__PURE__ */ (0,
|
|
13628
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
|
|
13629
|
+
family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
|
|
13630
|
+
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
|
|
13631
|
+
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex items-center gap-1", "data-trendline": i, children: [
|
|
13632
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "flex-1 truncate text-muted-foreground", children: (0, import_chart4.chartTrendlineName)(t, selectedSeries.name) }),
|
|
13633
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "R\xB2", name: `trendline.${i}.showR2`, checked: !!t.showR2, onChange: (showR2) => controller.updateTrendline(selectedSeries.id, i, { showR2 }) }),
|
|
13634
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete trendline", "data-action": "trendline-delete", onClick: () => controller.removeTrendline(selectedSeries.id, i), children: "\xD7" })
|
|
13524
13635
|
] }, i)),
|
|
13525
|
-
/* @__PURE__ */ (0,
|
|
13636
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
13526
13637
|
"select",
|
|
13527
13638
|
{
|
|
13528
13639
|
className: chartInputClass,
|
|
@@ -13531,32 +13642,32 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13531
13642
|
"data-option": "trendline.add",
|
|
13532
13643
|
onChange: (e) => e.currentTarget.value && controller.addTrendline(selectedSeries.id, { type: e.currentTarget.value }),
|
|
13533
13644
|
children: [
|
|
13534
|
-
/* @__PURE__ */ (0,
|
|
13535
|
-
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13645
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: "", children: "Add trendline\u2026" }),
|
|
13646
|
+
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("option", { value: t, children: cap(t.replace("-", " ")) }, t))
|
|
13536
13647
|
]
|
|
13537
13648
|
}
|
|
13538
13649
|
)
|
|
13539
13650
|
] }),
|
|
13540
|
-
/* @__PURE__ */ (0,
|
|
13541
|
-
/* @__PURE__ */ (0,
|
|
13542
|
-
family === "cartesian" && /* @__PURE__ */ (0,
|
|
13543
|
-
/* @__PURE__ */ (0,
|
|
13544
|
-
/* @__PURE__ */ (0,
|
|
13545
|
-
/* @__PURE__ */ (0,
|
|
13546
|
-
/* @__PURE__ */ (0,
|
|
13651
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
13652
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Hidden", name: "series.hidden", checked: !!selectedSeries.hidden, onChange: (hidden) => controller.updateSeries(selectedSeries.id, { hidden }) }),
|
|
13653
|
+
family === "cartesian" && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Toggle, { label: "Secondary axis", name: "series.axis", checked: selectedSeries.axis === "secondary", onChange: (secondary) => controller.updateSeries(selectedSeries.id, { axis: secondary ? "secondary" : null }) }),
|
|
13654
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "flex-1" }),
|
|
13655
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, disabled: seriesIndex <= 0, "aria-label": "Move series earlier", "data-action": "series-up", onClick: () => controller.moveSeries(selectedSeries.id, seriesIndex - 1), children: "\u2191" }),
|
|
13656
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: chartButtonClass, disabled: seriesIndex >= spec.series.length - 1, "aria-label": "Move series later", "data-action": "series-down", onClick: () => controller.moveSeries(selectedSeries.id, seriesIndex + 1), children: "\u2193" }),
|
|
13657
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("button", { type: "button", className: `${chartButtonClass} text-destructive`, "data-action": "series-delete", onClick: () => controller.removeSeries(selectedSeries.id), children: "Delete" })
|
|
13547
13658
|
] })
|
|
13548
13659
|
] })
|
|
13549
13660
|
] });
|
|
13550
13661
|
}
|
|
13551
13662
|
|
|
13552
13663
|
// src/chart-node/ChartNodeView.tsx
|
|
13553
|
-
var
|
|
13664
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
13554
13665
|
function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
13555
13666
|
const { controller, editing, editable, selected, width, height, setEditing } = state;
|
|
13556
13667
|
const open = () => {
|
|
13557
13668
|
if (editable && !editing) setEditing(true);
|
|
13558
13669
|
};
|
|
13559
|
-
return /* @__PURE__ */ (0,
|
|
13670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
|
|
13560
13671
|
"div",
|
|
13561
13672
|
{
|
|
13562
13673
|
className: `not-prose my-2 rounded-md border bg-background p-1 ${selected ? "border-primary ring-1 ring-primary" : "border-border"}`,
|
|
@@ -13569,24 +13680,24 @@ function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
|
13569
13680
|
}
|
|
13570
13681
|
},
|
|
13571
13682
|
children: [
|
|
13572
|
-
editing && /* @__PURE__ */ (0,
|
|
13573
|
-
/* @__PURE__ */ (0,
|
|
13574
|
-
/* @__PURE__ */ (0,
|
|
13683
|
+
editing && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "mb-1 flex items-center justify-between gap-2 px-1", "data-chart-node-toolbar": "", children: [
|
|
13684
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "text-xs text-muted-foreground", children: "Editing chart" }),
|
|
13685
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "done", onClick: () => setEditing(false), children: "Done" })
|
|
13575
13686
|
] }),
|
|
13576
|
-
/* @__PURE__ */ (0,
|
|
13687
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
13577
13688
|
"div",
|
|
13578
13689
|
{
|
|
13579
13690
|
className: editable && !editing ? "cursor-pointer" : void 0,
|
|
13580
13691
|
onClick: open,
|
|
13581
13692
|
title: editable && !editing ? "Click to edit the chart" : void 0,
|
|
13582
13693
|
"data-chart-node-canvas": "",
|
|
13583
|
-
children: /* @__PURE__ */ (0,
|
|
13694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChartCanvas, { controller, width: width ?? 640, height, responsive: width === null, editable: editing, theme })
|
|
13584
13695
|
}
|
|
13585
13696
|
),
|
|
13586
13697
|
editing && // Wraps by the document's width, not the viewport's: side by side when there is room.
|
|
13587
|
-
/* @__PURE__ */ (0,
|
|
13588
|
-
showDataGrid && /* @__PURE__ */ (0,
|
|
13589
|
-
/* @__PURE__ */ (0,
|
|
13698
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "mt-2 flex flex-wrap items-start gap-2", "data-chart-node-panel": "", children: [
|
|
13699
|
+
showDataGrid && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "min-w-0 flex-[1_1_20rem] overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChartDataGrid, { controller }) }),
|
|
13700
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChartInspector, { controller, className: "max-h-96 min-w-0 flex-[1_1_16rem] overflow-y-auto rounded-md border border-border p-3" })
|
|
13590
13701
|
] })
|
|
13591
13702
|
]
|
|
13592
13703
|
}
|
|
@@ -13604,7 +13715,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
13604
13715
|
scheduled = true;
|
|
13605
13716
|
queueMicrotask(() => {
|
|
13606
13717
|
scheduled = false;
|
|
13607
|
-
if (!destroyed) root.render(/* @__PURE__ */ (0,
|
|
13718
|
+
if (!destroyed) root.render(/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Component, { ...props, state: latest }));
|
|
13608
13719
|
});
|
|
13609
13720
|
};
|
|
13610
13721
|
schedule();
|
|
@@ -13622,10 +13733,10 @@ function createReactChartNodeView(options = {}) {
|
|
|
13622
13733
|
}
|
|
13623
13734
|
|
|
13624
13735
|
// src/style/useStyle.ts
|
|
13625
|
-
var
|
|
13736
|
+
var import_react92 = require("react");
|
|
13626
13737
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
13627
13738
|
function useResolverTask(styles, run, deliver, deps) {
|
|
13628
|
-
(0,
|
|
13739
|
+
(0, import_react92.useEffect)(() => {
|
|
13629
13740
|
if (!styles || !run) {
|
|
13630
13741
|
deliver({ value: null, error: null });
|
|
13631
13742
|
return;
|
|
@@ -13652,7 +13763,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
13652
13763
|
}, [styles, ...deps]);
|
|
13653
13764
|
}
|
|
13654
13765
|
function useStyle(styles, domain) {
|
|
13655
|
-
const [result, setResult] = (0,
|
|
13766
|
+
const [result, setResult] = (0, import_react92.useState)({ style: null, error: null });
|
|
13656
13767
|
useResolverTask(
|
|
13657
13768
|
styles,
|
|
13658
13769
|
(s) => s.resolve(domain),
|
|
@@ -13662,7 +13773,7 @@ function useStyle(styles, domain) {
|
|
|
13662
13773
|
return result;
|
|
13663
13774
|
}
|
|
13664
13775
|
function useStyleFindings(styles, domain, state) {
|
|
13665
|
-
const [result, setResult] = (0,
|
|
13776
|
+
const [result, setResult] = (0, import_react92.useState)({ report: null, style: null, error: null });
|
|
13666
13777
|
useResolverTask(
|
|
13667
13778
|
styles,
|
|
13668
13779
|
(s) => s.check(domain, state),
|
|
@@ -13679,7 +13790,7 @@ function useStyleFindings(styles, domain, state) {
|
|
|
13679
13790
|
}
|
|
13680
13791
|
|
|
13681
13792
|
// src/style/StyleFindings.tsx
|
|
13682
|
-
var
|
|
13793
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
13683
13794
|
var SEVERITY_CLASS = {
|
|
13684
13795
|
error: "text-destructive",
|
|
13685
13796
|
warning: "text-amber-600",
|
|
@@ -13688,24 +13799,24 @@ var SEVERITY_CLASS = {
|
|
|
13688
13799
|
function StyleFindings({ report, onSelect, title = "House style", className = "" }) {
|
|
13689
13800
|
if (!report) return null;
|
|
13690
13801
|
const { findings, ran, skipped } = report;
|
|
13691
|
-
return /* @__PURE__ */ (0,
|
|
13692
|
-
/* @__PURE__ */ (0,
|
|
13693
|
-
findings.length > 0 && /* @__PURE__ */ (0,
|
|
13802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("section", { "data-style-findings": "", "aria-label": title, className: `flex flex-col gap-1.5 text-xs text-foreground ${className}`, children: [
|
|
13803
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("h3", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
|
|
13804
|
+
findings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("ul", { className: "flex flex-col gap-1", children: findings.map((finding, i) => {
|
|
13694
13805
|
const selectable = finding.target !== void 0 && !!onSelect;
|
|
13695
|
-
const body = /* @__PURE__ */ (0,
|
|
13696
|
-
/* @__PURE__ */ (0,
|
|
13697
|
-
/* @__PURE__ */ (0,
|
|
13698
|
-
/* @__PURE__ */ (0,
|
|
13699
|
-
/* @__PURE__ */ (0,
|
|
13700
|
-
/* @__PURE__ */ (0,
|
|
13701
|
-
finding.layer && /* @__PURE__ */ (0,
|
|
13806
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
13807
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { "data-style-severity": finding.severity, className: `shrink-0 font-semibold uppercase text-[10px] ${SEVERITY_CLASS[finding.severity]}`, children: finding.severity }),
|
|
13808
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "flex min-w-0 flex-col", children: [
|
|
13809
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { "data-style-message": "", children: finding.message }),
|
|
13810
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
13811
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("code", { children: finding.check }),
|
|
13812
|
+
finding.layer && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
13702
13813
|
" \xB7 ",
|
|
13703
13814
|
finding.layer
|
|
13704
13815
|
] })
|
|
13705
13816
|
] })
|
|
13706
13817
|
] })
|
|
13707
13818
|
] });
|
|
13708
|
-
return /* @__PURE__ */ (0,
|
|
13819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("li", { "data-style-finding": finding.check, children: selectable ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13709
13820
|
"button",
|
|
13710
13821
|
{
|
|
13711
13822
|
type: "button",
|
|
@@ -13713,19 +13824,19 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
13713
13824
|
onClick: () => onSelect(finding),
|
|
13714
13825
|
children: body
|
|
13715
13826
|
}
|
|
13716
|
-
) : /* @__PURE__ */ (0,
|
|
13827
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "flex items-start gap-2 rounded border border-border px-2 py-1", children: body }) }, `${finding.check}-${i}`);
|
|
13717
13828
|
}) }),
|
|
13718
|
-
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0,
|
|
13829
|
+
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("p", { "data-style-clear": "", className: "text-emerald-600", children: [
|
|
13719
13830
|
"All clear: ",
|
|
13720
13831
|
ran.length,
|
|
13721
13832
|
" ",
|
|
13722
13833
|
ran.length === 1 ? "check" : "checks",
|
|
13723
13834
|
" passed."
|
|
13724
13835
|
] }),
|
|
13725
|
-
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0,
|
|
13726
|
-
skipped.length > 0 && /* @__PURE__ */ (0,
|
|
13836
|
+
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { className: "text-muted-foreground", children: "No house-style checks apply." }),
|
|
13837
|
+
skipped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("ul", { "data-style-skipped": "", "aria-label": "Skipped checks", className: "flex flex-col gap-0.5 text-muted-foreground", children: skipped.map((s) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("li", { "data-style-skipped-check": s.check, children: [
|
|
13727
13838
|
"Skipped ",
|
|
13728
|
-
/* @__PURE__ */ (0,
|
|
13839
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("code", { children: s.check }),
|
|
13729
13840
|
": ",
|
|
13730
13841
|
s.reason
|
|
13731
13842
|
] }, s.check)) })
|
|
@@ -13775,6 +13886,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
13775
13886
|
NameManager,
|
|
13776
13887
|
OutlinePanel,
|
|
13777
13888
|
PaintGradientEditor,
|
|
13889
|
+
PathsPanel,
|
|
13778
13890
|
PresenceLayer,
|
|
13779
13891
|
RecoveryPrompt,
|
|
13780
13892
|
RefineEdgePanel,
|