@pixerate/editor-react 0.121.0 → 0.122.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-CQXZVIV7.js → chunk-VR3JON4V.js} +417 -295
- package/dist/image-editor/ChannelsPanel.d.cts +15 -0
- package/dist/image-editor/ChannelsPanel.d.ts +15 -0
- package/dist/image-editor/index.cjs +425 -303
- 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 +945 -823
- package/dist/index.js +3 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
AssetMentionChips: () => AssetMentionChips,
|
|
37
37
|
BrushOptionsBar: () => BrushOptionsBar,
|
|
38
38
|
BubbleMenu: () => BubbleMenu,
|
|
39
|
+
ChannelsPanel: () => ChannelsPanel,
|
|
39
40
|
ChartNodeView: () => ChartNodeView,
|
|
40
41
|
ColorProfilePanel: () => ColorProfilePanel,
|
|
41
42
|
CommandPalette: () => CommandPalette,
|
|
@@ -4039,8 +4040,8 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
4039
4040
|
}
|
|
4040
4041
|
|
|
4041
4042
|
// src/image-editor/ImageEditor.tsx
|
|
4042
|
-
var
|
|
4043
|
-
var
|
|
4043
|
+
var import_react67 = __toESM(require("react"), 1);
|
|
4044
|
+
var import_image_editor20 = require("@pixerate/editor/image-editor");
|
|
4044
4045
|
|
|
4045
4046
|
// src/image-editor/ImageEditorCanvas.tsx
|
|
4046
4047
|
var import_react41 = require("react");
|
|
@@ -4417,6 +4418,10 @@ var ImageEditorCanvas = ({
|
|
|
4417
4418
|
if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
|
|
4418
4419
|
if (window.getSelection?.()?.toString()) return;
|
|
4419
4420
|
const gesture = selectionGestureRef.current;
|
|
4421
|
+
if ((0, import_image_editor2.handleQuickMaskKey)(controller, e)) {
|
|
4422
|
+
e.preventDefault();
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4420
4425
|
if ((0, import_image_editor2.handleSelectionShortcut)(controller, e, (message2) => report("select", message2))) {
|
|
4421
4426
|
e.preventDefault();
|
|
4422
4427
|
return;
|
|
@@ -8750,14 +8755,129 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
8750
8755
|
] });
|
|
8751
8756
|
};
|
|
8752
8757
|
|
|
8753
|
-
// src/image-editor/
|
|
8758
|
+
// src/image-editor/ChannelsPanel.tsx
|
|
8754
8759
|
var import_react63 = require("react");
|
|
8755
8760
|
var import_image_editor16 = require("@pixerate/editor/image-editor");
|
|
8756
8761
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8762
|
+
var btn2 = (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"}`;
|
|
8763
|
+
var ChannelThumb = ({ channel, size }) => {
|
|
8764
|
+
const ref = (0, import_react63.useRef)(null);
|
|
8765
|
+
(0, import_react63.useEffect)(() => {
|
|
8766
|
+
const canvas = ref.current;
|
|
8767
|
+
const ctx = canvas?.getContext("2d");
|
|
8768
|
+
if (!canvas || !ctx || typeof ctx.createImageData !== "function") return;
|
|
8769
|
+
const px = (0, import_image_editor16.channelThumbnail)(channel, 64);
|
|
8770
|
+
canvas.width = px.width;
|
|
8771
|
+
canvas.height = px.height;
|
|
8772
|
+
const img = ctx.createImageData(px.width, px.height);
|
|
8773
|
+
img.data.set(px.data);
|
|
8774
|
+
ctx.putImageData(img, 0, 0);
|
|
8775
|
+
}, [channel.mask]);
|
|
8776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("canvas", { ref, "aria-hidden": "true", style: { width: size, height: size }, className: "shrink-0 rounded object-contain ring-1 ring-border bg-black" });
|
|
8777
|
+
};
|
|
8778
|
+
var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
8779
|
+
const [, setTick] = (0, import_react63.useState)(0);
|
|
8780
|
+
(0, import_react63.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
8781
|
+
const [activeId, setActiveId] = (0, import_react63.useState)(null);
|
|
8782
|
+
const [renaming, setRenaming] = (0, import_react63.useState)(null);
|
|
8783
|
+
const [error, setError] = (0, import_react63.useState)(null);
|
|
8784
|
+
const channels = controller.getChannels();
|
|
8785
|
+
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
8786
|
+
const hasSelection = Boolean(controller.getSelection());
|
|
8787
|
+
const quickMask = controller.quickMaskEditing;
|
|
8788
|
+
const attempt = (fn) => {
|
|
8789
|
+
setError(null);
|
|
8790
|
+
try {
|
|
8791
|
+
fn();
|
|
8792
|
+
} catch (err) {
|
|
8793
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
8794
|
+
}
|
|
8795
|
+
};
|
|
8796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
8797
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
8798
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
8799
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-pressed": quickMask, className: btn2(quickMask), title: "Paint the selection: white selects, black deselects (Q)", onClick: () => controller.setQuickMaskMode(!quickMask), children: "Quick Mask" })
|
|
8800
|
+
] }),
|
|
8801
|
+
channels.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "text-muted-foreground", children: "No channels. Save a selection to keep it." }),
|
|
8802
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: channels.map((c) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
8803
|
+
"li",
|
|
8804
|
+
{
|
|
8805
|
+
"data-testid": "channel-row",
|
|
8806
|
+
"aria-current": c.id === activeId ? "true" : void 0,
|
|
8807
|
+
className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${c.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
|
|
8808
|
+
onClick: (e) => {
|
|
8809
|
+
setActiveId(c.id);
|
|
8810
|
+
attempt(() => controller.loadSelectionFromChannel(c.id, { mode: (0, import_image_editor16.selectionModeFromModifiers)(e, "replace") }));
|
|
8811
|
+
},
|
|
8812
|
+
onDoubleClick: () => setRenaming(c.id),
|
|
8813
|
+
children: [
|
|
8814
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8815
|
+
"button",
|
|
8816
|
+
{
|
|
8817
|
+
type: "button",
|
|
8818
|
+
"aria-label": `${c.visible ? "Hide" : "Show"} ${c.name}`,
|
|
8819
|
+
"aria-pressed": c.visible,
|
|
8820
|
+
className: "w-4 text-muted-foreground",
|
|
8821
|
+
onClick: (e) => {
|
|
8822
|
+
e.stopPropagation();
|
|
8823
|
+
attempt(() => controller.setChannelProperties(c.id, { visible: !c.visible }));
|
|
8824
|
+
},
|
|
8825
|
+
children: c.visible ? "\u25CF" : "\u25CB"
|
|
8826
|
+
}
|
|
8827
|
+
),
|
|
8828
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChannelThumb, { channel: c, size: thumbnailSize }),
|
|
8829
|
+
renaming === c.id ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8830
|
+
"input",
|
|
8831
|
+
{
|
|
8832
|
+
autoFocus: true,
|
|
8833
|
+
"aria-label": "Channel name",
|
|
8834
|
+
defaultValue: c.name,
|
|
8835
|
+
className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
|
|
8836
|
+
onClick: (e) => e.stopPropagation(),
|
|
8837
|
+
onBlur: (e) => {
|
|
8838
|
+
setRenaming(null);
|
|
8839
|
+
if (e.currentTarget.value.trim() && e.currentTarget.value !== c.name) attempt(() => controller.setChannelProperties(c.id, { name: e.currentTarget.value }));
|
|
8840
|
+
},
|
|
8841
|
+
onKeyDown: (e) => {
|
|
8842
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
8843
|
+
if (e.key === "Escape") setRenaming(null);
|
|
8844
|
+
}
|
|
8845
|
+
}
|
|
8846
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "min-w-0 flex-1 truncate", children: c.name })
|
|
8847
|
+
]
|
|
8848
|
+
},
|
|
8849
|
+
c.id
|
|
8850
|
+
)) }),
|
|
8851
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
8852
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !hasSelection, onClick: () => attempt(() => setActiveId(controller.saveSelection().id)), children: "Save Selection" }),
|
|
8853
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !active || !hasSelection, title: "Add the selection to the channel", onClick: () => attempt(() => controller.saveSelection({ channelId: active.id, mode: "add" })), children: "Add to Channel" }),
|
|
8854
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !active, onClick: () => attempt(() => setActiveId(controller.duplicateChannel(active.id).id)), children: "Duplicate" }),
|
|
8855
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8856
|
+
"button",
|
|
8857
|
+
{
|
|
8858
|
+
type: "button",
|
|
8859
|
+
className: btn2(),
|
|
8860
|
+
disabled: !active,
|
|
8861
|
+
onClick: () => attempt(() => {
|
|
8862
|
+
controller.deleteChannel(active.id);
|
|
8863
|
+
setActiveId(null);
|
|
8864
|
+
}),
|
|
8865
|
+
children: "Delete"
|
|
8866
|
+
}
|
|
8867
|
+
)
|
|
8868
|
+
] }),
|
|
8869
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
8870
|
+
] });
|
|
8871
|
+
};
|
|
8872
|
+
|
|
8873
|
+
// src/image-editor/FreeTransformOptionsBar.tsx
|
|
8874
|
+
var import_react64 = require("react");
|
|
8875
|
+
var import_image_editor17 = require("@pixerate/editor/image-editor");
|
|
8876
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8757
8877
|
var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
|
|
8758
8878
|
var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
8759
|
-
const [, setTick] = (0,
|
|
8760
|
-
(0,
|
|
8879
|
+
const [, setTick] = (0, import_react64.useState)(0);
|
|
8880
|
+
(0, import_react64.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
|
|
8761
8881
|
const bar = tool.bar();
|
|
8762
8882
|
if (!tool.active || !bar) return null;
|
|
8763
8883
|
const warp = tool.warpBar();
|
|
@@ -8769,17 +8889,17 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8769
8889
|
const v = Number(raw);
|
|
8770
8890
|
if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
|
|
8771
8891
|
};
|
|
8772
|
-
return /* @__PURE__ */ (0,
|
|
8773
|
-
/* @__PURE__ */ (0,
|
|
8774
|
-
/* @__PURE__ */ (0,
|
|
8775
|
-
tool.mode === "warp" && /* @__PURE__ */ (0,
|
|
8776
|
-
/* @__PURE__ */ (0,
|
|
8777
|
-
/* @__PURE__ */ (0,
|
|
8778
|
-
/* @__PURE__ */ (0,
|
|
8892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.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: [
|
|
8893
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor17.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime44.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)) }),
|
|
8894
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor17.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime44.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)) }),
|
|
8895
|
+
tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
|
|
8896
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8897
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Warp" }),
|
|
8898
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: imageFieldClass, children: import_image_editor17.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: o.id, children: o.label }, o.id)) })
|
|
8779
8899
|
] }),
|
|
8780
|
-
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0,
|
|
8781
|
-
/* @__PURE__ */ (0,
|
|
8782
|
-
/* @__PURE__ */ (0,
|
|
8900
|
+
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8901
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
|
|
8902
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8783
8903
|
"input",
|
|
8784
8904
|
{
|
|
8785
8905
|
type: "number",
|
|
@@ -8800,9 +8920,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8800
8920
|
},
|
|
8801
8921
|
`${k}:${warp[k]}`
|
|
8802
8922
|
),
|
|
8803
|
-
/* @__PURE__ */ (0,
|
|
8923
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "%" })
|
|
8804
8924
|
] }, k)),
|
|
8805
|
-
/* @__PURE__ */ (0,
|
|
8925
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8806
8926
|
"button",
|
|
8807
8927
|
{
|
|
8808
8928
|
type: "button",
|
|
@@ -8814,26 +8934,26 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8814
8934
|
children: "Vertical"
|
|
8815
8935
|
}
|
|
8816
8936
|
),
|
|
8817
|
-
/* @__PURE__ */ (0,
|
|
8818
|
-
/* @__PURE__ */ (0,
|
|
8819
|
-
/* @__PURE__ */ (0,
|
|
8937
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8938
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Grid" }),
|
|
8939
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8820
8940
|
"select",
|
|
8821
8941
|
{
|
|
8822
8942
|
"aria-label": "Warp grid",
|
|
8823
|
-
value:
|
|
8943
|
+
value: import_image_editor17.WARP_GRID_OPTIONS.find((g) => g.columns === warp.columns && g.rows === warp.rows)?.id ?? "1x1",
|
|
8824
8944
|
onChange: (e) => {
|
|
8825
|
-
const g =
|
|
8945
|
+
const g = import_image_editor17.WARP_GRID_OPTIONS.find((o) => o.id === e.target.value);
|
|
8826
8946
|
tool.setWarp({ columns: g.columns, rows: g.rows });
|
|
8827
8947
|
},
|
|
8828
8948
|
className: imageFieldClass,
|
|
8829
|
-
children:
|
|
8949
|
+
children: import_image_editor17.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: g.id, children: g.label }, g.id))
|
|
8830
8950
|
}
|
|
8831
8951
|
)
|
|
8832
8952
|
] })
|
|
8833
8953
|
] }),
|
|
8834
|
-
tool.mode !== "warp" &&
|
|
8835
|
-
/* @__PURE__ */ (0,
|
|
8836
|
-
/* @__PURE__ */ (0,
|
|
8954
|
+
tool.mode !== "warp" && import_image_editor17.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
|
|
8955
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: f.label }),
|
|
8956
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8837
8957
|
"input",
|
|
8838
8958
|
{
|
|
8839
8959
|
type: "number",
|
|
@@ -8853,8 +8973,8 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8853
8973
|
},
|
|
8854
8974
|
`${f.id}:${round(bar[f.id], f.unit)}`
|
|
8855
8975
|
),
|
|
8856
|
-
/* @__PURE__ */ (0,
|
|
8857
|
-
f.id === "scaleX" && /* @__PURE__ */ (0,
|
|
8976
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: f.unit }),
|
|
8977
|
+
f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8858
8978
|
"button",
|
|
8859
8979
|
{
|
|
8860
8980
|
type: "button",
|
|
@@ -8869,33 +8989,33 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8869
8989
|
}
|
|
8870
8990
|
)
|
|
8871
8991
|
] }, f.id)),
|
|
8872
|
-
/* @__PURE__ */ (0,
|
|
8873
|
-
/* @__PURE__ */ (0,
|
|
8874
|
-
/* @__PURE__ */ (0,
|
|
8992
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8993
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Interpolation" }),
|
|
8994
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8875
8995
|
"select",
|
|
8876
8996
|
{
|
|
8877
8997
|
"aria-label": "Interpolation",
|
|
8878
8998
|
value: tool.interpolation,
|
|
8879
8999
|
onChange: (e) => tool.setInterpolation(e.target.value),
|
|
8880
9000
|
className: imageFieldClass,
|
|
8881
|
-
children:
|
|
9001
|
+
children: import_image_editor17.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
|
|
8882
9002
|
}
|
|
8883
9003
|
)
|
|
8884
9004
|
] }),
|
|
8885
|
-
/* @__PURE__ */ (0,
|
|
8886
|
-
/* @__PURE__ */ (0,
|
|
8887
|
-
tool.error && /* @__PURE__ */ (0,
|
|
9005
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.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" }),
|
|
9006
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", title: "Cancel (Esc)", className: imageChipClass(false), onClick: () => tool.cancel(), children: "Cancel" }),
|
|
9007
|
+
tool.error && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { role: "alert", className: "text-destructive", children: tool.error })
|
|
8888
9008
|
] });
|
|
8889
9009
|
};
|
|
8890
9010
|
|
|
8891
9011
|
// src/image-editor/ShapeOptionsBar.tsx
|
|
8892
|
-
var
|
|
8893
|
-
var
|
|
8894
|
-
var
|
|
9012
|
+
var import_react65 = require("react");
|
|
9013
|
+
var import_image_editor18 = require("@pixerate/editor/image-editor");
|
|
9014
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8895
9015
|
var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
8896
|
-
const [, setTick] = (0,
|
|
8897
|
-
(0,
|
|
8898
|
-
const [error, setError] = (0,
|
|
9016
|
+
const [, setTick] = (0, import_react65.useState)(0);
|
|
9017
|
+
(0, import_react65.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9018
|
+
const [error, setError] = (0, import_react65.useState)(null);
|
|
8899
9019
|
const active = controller.getActiveLayer();
|
|
8900
9020
|
const shapeId = active?.type === "shape" ? active.id : null;
|
|
8901
9021
|
const set = (change) => {
|
|
@@ -8903,28 +9023,28 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
8903
9023
|
if (!shapeId) return;
|
|
8904
9024
|
try {
|
|
8905
9025
|
setError(null);
|
|
8906
|
-
(0,
|
|
9026
|
+
(0, import_image_editor18.applyShapeOptions)(controller, shapeId, change);
|
|
8907
9027
|
} catch (e) {
|
|
8908
9028
|
setError(e instanceof Error ? e.message : String(e));
|
|
8909
9029
|
}
|
|
8910
9030
|
};
|
|
8911
9031
|
const num = (v, min, max) => Math.max(min, Math.min(max, Number(v) || min));
|
|
8912
|
-
return /* @__PURE__ */ (0,
|
|
8913
|
-
/* @__PURE__ */ (0,
|
|
8914
|
-
/* @__PURE__ */ (0,
|
|
8915
|
-
/* @__PURE__ */ (0,
|
|
8916
|
-
/* @__PURE__ */ (0,
|
|
9032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "shape-options", children: [
|
|
9033
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor18.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: imageChipClass(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor18.SHAPE_KIND_LABELS[k] }, k)) }),
|
|
9034
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9035
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9036
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
|
|
8917
9037
|
"Fill",
|
|
8918
|
-
/* @__PURE__ */ (0,
|
|
9038
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
|
|
8919
9039
|
] }),
|
|
8920
|
-
/* @__PURE__ */ (0,
|
|
8921
|
-
/* @__PURE__ */ (0,
|
|
9040
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9041
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
|
|
8922
9042
|
"Stroke",
|
|
8923
|
-
/* @__PURE__ */ (0,
|
|
9043
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
|
|
8924
9044
|
] }),
|
|
8925
|
-
/* @__PURE__ */ (0,
|
|
9045
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8926
9046
|
"Width",
|
|
8927
|
-
/* @__PURE__ */ (0,
|
|
9047
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8928
9048
|
"input",
|
|
8929
9049
|
{
|
|
8930
9050
|
type: "number",
|
|
@@ -8938,51 +9058,51 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
8938
9058
|
)
|
|
8939
9059
|
] })
|
|
8940
9060
|
] }),
|
|
8941
|
-
/* @__PURE__ */ (0,
|
|
8942
|
-
options.kind === "rect" && /* @__PURE__ */ (0,
|
|
9061
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9062
|
+
options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8943
9063
|
"Radius",
|
|
8944
|
-
/* @__PURE__ */ (0,
|
|
9064
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.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}` })
|
|
8945
9065
|
] }),
|
|
8946
|
-
options.kind === "polygon" && /* @__PURE__ */ (0,
|
|
9066
|
+
options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8947
9067
|
"Sides",
|
|
8948
|
-
/* @__PURE__ */ (0,
|
|
9068
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.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}` })
|
|
8949
9069
|
] }),
|
|
8950
|
-
options.kind === "star" && /* @__PURE__ */ (0,
|
|
8951
|
-
/* @__PURE__ */ (0,
|
|
9070
|
+
options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
9071
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8952
9072
|
"Points",
|
|
8953
|
-
/* @__PURE__ */ (0,
|
|
9073
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.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}` })
|
|
8954
9074
|
] }),
|
|
8955
|
-
/* @__PURE__ */ (0,
|
|
9075
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8956
9076
|
"Inner",
|
|
8957
|
-
/* @__PURE__ */ (0,
|
|
9077
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageRange, { label: "Inner radius", min: 0.05, max: 1, step: 0.05, value: options.innerRatio, onChange: (v) => set({ innerRatio: v }) })
|
|
8958
9078
|
] })
|
|
8959
9079
|
] }),
|
|
8960
|
-
options.kind === "line" && /* @__PURE__ */ (0,
|
|
8961
|
-
/* @__PURE__ */ (0,
|
|
9080
|
+
options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
9081
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8962
9082
|
"Weight",
|
|
8963
|
-
/* @__PURE__ */ (0,
|
|
9083
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.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}` })
|
|
8964
9084
|
] }),
|
|
8965
|
-
/* @__PURE__ */ (0,
|
|
8966
|
-
/* @__PURE__ */ (0,
|
|
9085
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9086
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Arrowhead", checked: options.arrow, onChange: (on) => set({ arrow: on }) }),
|
|
8967
9087
|
"Arrowhead"
|
|
8968
9088
|
] })
|
|
8969
9089
|
] })
|
|
8970
9090
|
] }),
|
|
8971
|
-
/* @__PURE__ */ (0,
|
|
8972
|
-
error && /* @__PURE__ */ (0,
|
|
9091
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.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." }),
|
|
9092
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
8973
9093
|
] });
|
|
8974
9094
|
};
|
|
8975
9095
|
|
|
8976
9096
|
// src/image-editor/TypeOptionsBar.tsx
|
|
8977
|
-
var
|
|
8978
|
-
var
|
|
8979
|
-
var
|
|
9097
|
+
var import_react66 = require("react");
|
|
9098
|
+
var import_image_editor19 = require("@pixerate/editor/image-editor");
|
|
9099
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
8980
9100
|
var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
|
|
8981
9101
|
var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
|
|
8982
|
-
const [, setTick] = (0,
|
|
8983
|
-
(0,
|
|
8984
|
-
(0,
|
|
8985
|
-
const [error, setError] = (0,
|
|
9102
|
+
const [, setTick] = (0, import_react66.useState)(0);
|
|
9103
|
+
(0, import_react66.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9104
|
+
(0, import_react66.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
|
|
9105
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
8986
9106
|
const active = controller.getActiveLayer();
|
|
8987
9107
|
const typeId = !session && active?.type === "type" ? active.id : null;
|
|
8988
9108
|
const here = session?.alive ? session.styleHere() : {};
|
|
@@ -9014,11 +9134,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9014
9134
|
setError(e instanceof Error ? e.message : String(e));
|
|
9015
9135
|
}
|
|
9016
9136
|
};
|
|
9017
|
-
return /* @__PURE__ */ (0,
|
|
9018
|
-
/* @__PURE__ */ (0,
|
|
9019
|
-
/* @__PURE__ */ (0,
|
|
9137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "type-options", children: [
|
|
9138
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
9139
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9020
9140
|
"Font",
|
|
9021
|
-
/* @__PURE__ */ (0,
|
|
9141
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9022
9142
|
"input",
|
|
9023
9143
|
{
|
|
9024
9144
|
list: "pixerate-type-fonts",
|
|
@@ -9028,11 +9148,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9028
9148
|
className: "w-32 rounded border border-border bg-background px-1 py-0.5"
|
|
9029
9149
|
}
|
|
9030
9150
|
),
|
|
9031
|
-
/* @__PURE__ */ (0,
|
|
9151
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: f }, f)) })
|
|
9032
9152
|
] }),
|
|
9033
|
-
/* @__PURE__ */ (0,
|
|
9153
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9034
9154
|
"Size",
|
|
9035
|
-
/* @__PURE__ */ (0,
|
|
9155
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
9036
9156
|
"input",
|
|
9037
9157
|
{
|
|
9038
9158
|
type: "number",
|
|
@@ -9045,24 +9165,24 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
9045
9165
|
}
|
|
9046
9166
|
)
|
|
9047
9167
|
] }),
|
|
9048
|
-
/* @__PURE__ */ (0,
|
|
9049
|
-
/* @__PURE__ */ (0,
|
|
9050
|
-
/* @__PURE__ */ (0,
|
|
9168
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.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" }),
|
|
9169
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
|
|
9170
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
|
|
9051
9171
|
] }),
|
|
9052
|
-
/* @__PURE__ */ (0,
|
|
9053
|
-
/* @__PURE__ */ (0,
|
|
9054
|
-
missing.length > 0 && /* @__PURE__ */ (0,
|
|
9172
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor19.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
|
|
9173
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
|
|
9174
|
+
missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
|
|
9055
9175
|
"Missing ",
|
|
9056
9176
|
missing.length === 1 ? "font" : "fonts",
|
|
9057
9177
|
": ",
|
|
9058
9178
|
missing.join(", ")
|
|
9059
9179
|
] }),
|
|
9060
|
-
error && /* @__PURE__ */ (0,
|
|
9180
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9061
9181
|
] });
|
|
9062
9182
|
};
|
|
9063
9183
|
|
|
9064
9184
|
// src/image-editor/ImageEditor.tsx
|
|
9065
|
-
var
|
|
9185
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9066
9186
|
var ImageEditor = ({
|
|
9067
9187
|
editor: externalEditor,
|
|
9068
9188
|
src,
|
|
@@ -9086,51 +9206,51 @@ var ImageEditor = ({
|
|
|
9086
9206
|
const effectsShown = !!controller.effectsProvider || state.layers.some(function has(l) {
|
|
9087
9207
|
return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
|
|
9088
9208
|
});
|
|
9089
|
-
const legacyProcess = (0,
|
|
9090
|
-
const [activeTab, setActiveTab] = (0,
|
|
9091
|
-
const rootRef = (0,
|
|
9209
|
+
const legacyProcess = (0, import_image_editor20.normalizeProcessVersion)(state.adjustments.process) < import_image_editor20.LATEST_PROCESS_VERSION;
|
|
9210
|
+
const [activeTab, setActiveTab] = (0, import_react67.useState)("crop");
|
|
9211
|
+
const rootRef = (0, import_react67.useRef)(null);
|
|
9092
9212
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
9093
|
-
const activeTabRef = (0,
|
|
9213
|
+
const activeTabRef = (0, import_react67.useRef)(activeTab);
|
|
9094
9214
|
activeTabRef.current = activeTab;
|
|
9095
9215
|
const openPanel = async (ref) => {
|
|
9096
9216
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
9097
9217
|
rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
|
|
9098
9218
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
9099
9219
|
};
|
|
9100
|
-
const [activeCropRatio, setActiveCropRatio] = (0,
|
|
9101
|
-
const [selectionOptions, setSelectionOptions] = (0,
|
|
9102
|
-
const [shapeOptions, setShapeOptions] = (0,
|
|
9103
|
-
const [typeOptions, setTypeOptions] = (0,
|
|
9104
|
-
const [typeSession, setTypeSession] = (0,
|
|
9105
|
-
const [selectionError, setSelectionError] = (0,
|
|
9106
|
-
const [paintError, setPaintError] = (0,
|
|
9107
|
-
const [shapeTypeError, setShapeTypeError] = (0,
|
|
9220
|
+
const [activeCropRatio, setActiveCropRatio] = (0, import_react67.useState)(null);
|
|
9221
|
+
const [selectionOptions, setSelectionOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_SELECTION_TOOL_OPTIONS);
|
|
9222
|
+
const [shapeOptions, setShapeOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_SHAPE_TOOL_OPTIONS);
|
|
9223
|
+
const [typeOptions, setTypeOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_TYPE_TOOL_OPTIONS);
|
|
9224
|
+
const [typeSession, setTypeSession] = (0, import_react67.useState)(null);
|
|
9225
|
+
const [selectionError, setSelectionError] = (0, import_react67.useState)(null);
|
|
9226
|
+
const [paintError, setPaintError] = (0, import_react67.useState)(null);
|
|
9227
|
+
const [shapeTypeError, setShapeTypeError] = (0, import_react67.useState)(null);
|
|
9108
9228
|
const handleCanvasError = (source, message2) => {
|
|
9109
9229
|
if (source === "paint") setPaintError(message2);
|
|
9110
9230
|
else if (source === "select") setSelectionError(message2);
|
|
9111
9231
|
else setShapeTypeError(message2);
|
|
9112
9232
|
};
|
|
9113
9233
|
const finishTyping = () => setTypeSession(null);
|
|
9114
|
-
const transformToolRef = (0,
|
|
9115
|
-
const transformControllerRef = (0,
|
|
9234
|
+
const transformToolRef = (0, import_react67.useRef)(null);
|
|
9235
|
+
const transformControllerRef = (0, import_react67.useRef)(controller);
|
|
9116
9236
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
9117
9237
|
transformToolRef.current?.cancel();
|
|
9118
|
-
transformToolRef.current = new
|
|
9238
|
+
transformToolRef.current = new import_image_editor20.FreeTransformTool(controller, {
|
|
9119
9239
|
schedule: (run) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(run) : run()
|
|
9120
9240
|
});
|
|
9121
9241
|
transformControllerRef.current = controller;
|
|
9122
9242
|
}
|
|
9123
9243
|
const transformTool = transformToolRef.current;
|
|
9124
|
-
const [, setTransformTick] = (0,
|
|
9125
|
-
(0,
|
|
9126
|
-
(0,
|
|
9127
|
-
const [inpaintPrompt, setInpaintPrompt] = (0,
|
|
9128
|
-
const [inpaintMaskMode, setInpaintMaskMode] = (0,
|
|
9129
|
-
const [isRemovingBg, setIsRemovingBg] = (0,
|
|
9130
|
-
const [isInpainting, setIsInpainting] = (0,
|
|
9131
|
-
const [aiError, setAiError] = (0,
|
|
9132
|
-
const [aiSuccess, setAiSuccess] = (0,
|
|
9133
|
-
const [aiTarget, setAiTarget] = (0,
|
|
9244
|
+
const [, setTransformTick] = (0, import_react67.useState)(0);
|
|
9245
|
+
(0, import_react67.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
|
|
9246
|
+
(0, import_react67.useEffect)(() => () => transformToolRef.current?.cancel(), []);
|
|
9247
|
+
const [inpaintPrompt, setInpaintPrompt] = (0, import_react67.useState)("");
|
|
9248
|
+
const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react67.useState)("annotations");
|
|
9249
|
+
const [isRemovingBg, setIsRemovingBg] = (0, import_react67.useState)(false);
|
|
9250
|
+
const [isInpainting, setIsInpainting] = (0, import_react67.useState)(false);
|
|
9251
|
+
const [aiError, setAiError] = (0, import_react67.useState)(null);
|
|
9252
|
+
const [aiSuccess, setAiSuccess] = (0, import_react67.useState)(null);
|
|
9253
|
+
const [aiTarget, setAiTarget] = (0, import_react67.useState)("auto");
|
|
9134
9254
|
const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
|
|
9135
9255
|
const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
|
|
9136
9256
|
const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
|
|
@@ -9193,11 +9313,11 @@ var ImageEditor = ({
|
|
|
9193
9313
|
setIsInpainting(false);
|
|
9194
9314
|
}
|
|
9195
9315
|
};
|
|
9196
|
-
const [activeColor, setActiveColor] = (0,
|
|
9197
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
9198
|
-
const [fontSize, setFontSize] = (0,
|
|
9199
|
-
const [textInput, setTextInput] = (0,
|
|
9200
|
-
(0,
|
|
9316
|
+
const [activeColor, setActiveColor] = (0, import_react67.useState)("#ef4444");
|
|
9317
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react67.useState)(3);
|
|
9318
|
+
const [fontSize, setFontSize] = (0, import_react67.useState)(24);
|
|
9319
|
+
const [textInput, setTextInput] = (0, import_react67.useState)("");
|
|
9320
|
+
(0, import_react67.useEffect)(() => {
|
|
9201
9321
|
if (activeTab === "crop" && editor.state.activeTool !== "crop") {
|
|
9202
9322
|
editor.setTool("crop");
|
|
9203
9323
|
}
|
|
@@ -9225,16 +9345,16 @@ var ImageEditor = ({
|
|
|
9225
9345
|
link.click();
|
|
9226
9346
|
}
|
|
9227
9347
|
};
|
|
9228
|
-
return /* @__PURE__ */ (0,
|
|
9348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9229
9349
|
"div",
|
|
9230
9350
|
{
|
|
9231
9351
|
ref: rootRef,
|
|
9232
9352
|
className: `${imageEditorFrameClass} ${className}`,
|
|
9233
9353
|
style,
|
|
9234
9354
|
children: [
|
|
9235
|
-
/* @__PURE__ */ (0,
|
|
9236
|
-
/* @__PURE__ */ (0,
|
|
9237
|
-
/* @__PURE__ */ (0,
|
|
9355
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: imageEditorHeaderClass, children: [
|
|
9356
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { role: "tablist", className: imageTabListClass, children: [
|
|
9357
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9238
9358
|
"button",
|
|
9239
9359
|
{
|
|
9240
9360
|
type: "button",
|
|
@@ -9249,7 +9369,7 @@ var ImageEditor = ({
|
|
|
9249
9369
|
children: "Transform & Crop"
|
|
9250
9370
|
}
|
|
9251
9371
|
),
|
|
9252
|
-
/* @__PURE__ */ (0,
|
|
9372
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9253
9373
|
"button",
|
|
9254
9374
|
{
|
|
9255
9375
|
type: "button",
|
|
@@ -9264,7 +9384,7 @@ var ImageEditor = ({
|
|
|
9264
9384
|
children: "Adjustments"
|
|
9265
9385
|
}
|
|
9266
9386
|
),
|
|
9267
|
-
/* @__PURE__ */ (0,
|
|
9387
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9268
9388
|
"button",
|
|
9269
9389
|
{
|
|
9270
9390
|
type: "button",
|
|
@@ -9279,7 +9399,7 @@ var ImageEditor = ({
|
|
|
9279
9399
|
children: "Layers"
|
|
9280
9400
|
}
|
|
9281
9401
|
),
|
|
9282
|
-
/* @__PURE__ */ (0,
|
|
9402
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9283
9403
|
"button",
|
|
9284
9404
|
{
|
|
9285
9405
|
type: "button",
|
|
@@ -9294,7 +9414,7 @@ var ImageEditor = ({
|
|
|
9294
9414
|
children: "Paint"
|
|
9295
9415
|
}
|
|
9296
9416
|
),
|
|
9297
|
-
/* @__PURE__ */ (0,
|
|
9417
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9298
9418
|
"button",
|
|
9299
9419
|
{
|
|
9300
9420
|
type: "button",
|
|
@@ -9309,7 +9429,7 @@ var ImageEditor = ({
|
|
|
9309
9429
|
children: "Select & Mask"
|
|
9310
9430
|
}
|
|
9311
9431
|
),
|
|
9312
|
-
/* @__PURE__ */ (0,
|
|
9432
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9313
9433
|
"button",
|
|
9314
9434
|
{
|
|
9315
9435
|
type: "button",
|
|
@@ -9324,7 +9444,7 @@ var ImageEditor = ({
|
|
|
9324
9444
|
children: "Annotations"
|
|
9325
9445
|
}
|
|
9326
9446
|
),
|
|
9327
|
-
/* @__PURE__ */ (0,
|
|
9447
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9328
9448
|
"button",
|
|
9329
9449
|
{
|
|
9330
9450
|
type: "button",
|
|
@@ -9339,7 +9459,7 @@ var ImageEditor = ({
|
|
|
9339
9459
|
children: "Depth Mask"
|
|
9340
9460
|
}
|
|
9341
9461
|
),
|
|
9342
|
-
/* @__PURE__ */ (0,
|
|
9462
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9343
9463
|
"button",
|
|
9344
9464
|
{
|
|
9345
9465
|
type: "button",
|
|
@@ -9352,14 +9472,14 @@ var ImageEditor = ({
|
|
|
9352
9472
|
"aria-selected": activeTab === "ai",
|
|
9353
9473
|
className: `${imageTabClass(activeTab === "ai")} flex items-center gap-1.5`,
|
|
9354
9474
|
children: [
|
|
9355
|
-
/* @__PURE__ */ (0,
|
|
9475
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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_runtime47.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" }) }),
|
|
9356
9476
|
"AI Tools"
|
|
9357
9477
|
]
|
|
9358
9478
|
}
|
|
9359
9479
|
)
|
|
9360
9480
|
] }),
|
|
9361
|
-
/* @__PURE__ */ (0,
|
|
9362
|
-
/* @__PURE__ */ (0,
|
|
9481
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
9482
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9363
9483
|
"button",
|
|
9364
9484
|
{
|
|
9365
9485
|
type: "button",
|
|
@@ -9370,7 +9490,7 @@ var ImageEditor = ({
|
|
|
9370
9490
|
children: "\u21A9"
|
|
9371
9491
|
}
|
|
9372
9492
|
),
|
|
9373
|
-
/* @__PURE__ */ (0,
|
|
9493
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9374
9494
|
"button",
|
|
9375
9495
|
{
|
|
9376
9496
|
type: "button",
|
|
@@ -9381,7 +9501,7 @@ var ImageEditor = ({
|
|
|
9381
9501
|
children: "\u21AA"
|
|
9382
9502
|
}
|
|
9383
9503
|
),
|
|
9384
|
-
/* @__PURE__ */ (0,
|
|
9504
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9385
9505
|
"button",
|
|
9386
9506
|
{
|
|
9387
9507
|
type: "button",
|
|
@@ -9390,8 +9510,8 @@ var ImageEditor = ({
|
|
|
9390
9510
|
children: "Reset"
|
|
9391
9511
|
}
|
|
9392
9512
|
),
|
|
9393
|
-
/* @__PURE__ */ (0,
|
|
9394
|
-
/* @__PURE__ */ (0,
|
|
9513
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
9514
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9395
9515
|
"button",
|
|
9396
9516
|
{
|
|
9397
9517
|
type: "button",
|
|
@@ -9401,11 +9521,11 @@ var ImageEditor = ({
|
|
|
9401
9521
|
children: "-"
|
|
9402
9522
|
}
|
|
9403
9523
|
),
|
|
9404
|
-
/* @__PURE__ */ (0,
|
|
9524
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono text-muted-foreground w-10 text-center", children: [
|
|
9405
9525
|
Math.round(state.zoom * 100),
|
|
9406
9526
|
"%"
|
|
9407
9527
|
] }),
|
|
9408
|
-
/* @__PURE__ */ (0,
|
|
9528
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9409
9529
|
"button",
|
|
9410
9530
|
{
|
|
9411
9531
|
type: "button",
|
|
@@ -9415,8 +9535,8 @@ var ImageEditor = ({
|
|
|
9415
9535
|
children: "+"
|
|
9416
9536
|
}
|
|
9417
9537
|
),
|
|
9418
|
-
/* @__PURE__ */ (0,
|
|
9419
|
-
/* @__PURE__ */ (0,
|
|
9538
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
9539
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9420
9540
|
"button",
|
|
9421
9541
|
{
|
|
9422
9542
|
type: "button",
|
|
@@ -9427,7 +9547,7 @@ var ImageEditor = ({
|
|
|
9427
9547
|
children: "Hold Compare"
|
|
9428
9548
|
}
|
|
9429
9549
|
),
|
|
9430
|
-
/* @__PURE__ */ (0,
|
|
9550
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9431
9551
|
"button",
|
|
9432
9552
|
{
|
|
9433
9553
|
type: "button",
|
|
@@ -9438,10 +9558,10 @@ var ImageEditor = ({
|
|
|
9438
9558
|
)
|
|
9439
9559
|
] })
|
|
9440
9560
|
] }),
|
|
9441
|
-
transformTool.active && /* @__PURE__ */ (0,
|
|
9442
|
-
!transformTool.active && transformTool.error && /* @__PURE__ */ (0,
|
|
9443
|
-
/* @__PURE__ */ (0,
|
|
9444
|
-
/* @__PURE__ */ (0,
|
|
9561
|
+
transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-border bg-background/95 px-4 py-2" }),
|
|
9562
|
+
!transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { role: "alert", className: imageErrorBannerClass, children: transformTool.error }),
|
|
9563
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
|
|
9564
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9445
9565
|
ImageEditorCanvas,
|
|
9446
9566
|
{
|
|
9447
9567
|
editor,
|
|
@@ -9465,11 +9585,11 @@ var ImageEditor = ({
|
|
|
9465
9585
|
className: "flex-1 h-[360px] md:h-full min-h-[320px] bg-muted"
|
|
9466
9586
|
}
|
|
9467
9587
|
),
|
|
9468
|
-
/* @__PURE__ */ (0,
|
|
9469
|
-
activeTab === "crop" && /* @__PURE__ */ (0,
|
|
9470
|
-
/* @__PURE__ */ (0,
|
|
9471
|
-
/* @__PURE__ */ (0,
|
|
9472
|
-
/* @__PURE__ */ (0,
|
|
9588
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: imageSidebarClass, children: [
|
|
9589
|
+
activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
9590
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Aspect Ratio Presets" }),
|
|
9591
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
|
|
9592
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9473
9593
|
"button",
|
|
9474
9594
|
{
|
|
9475
9595
|
type: "button",
|
|
@@ -9481,7 +9601,7 @@ var ImageEditor = ({
|
|
|
9481
9601
|
children: "Freeform"
|
|
9482
9602
|
}
|
|
9483
9603
|
),
|
|
9484
|
-
/* @__PURE__ */ (0,
|
|
9604
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9485
9605
|
"button",
|
|
9486
9606
|
{
|
|
9487
9607
|
type: "button",
|
|
@@ -9493,7 +9613,7 @@ var ImageEditor = ({
|
|
|
9493
9613
|
children: "1:1 Square"
|
|
9494
9614
|
}
|
|
9495
9615
|
),
|
|
9496
|
-
/* @__PURE__ */ (0,
|
|
9616
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9497
9617
|
"button",
|
|
9498
9618
|
{
|
|
9499
9619
|
type: "button",
|
|
@@ -9505,7 +9625,7 @@ var ImageEditor = ({
|
|
|
9505
9625
|
children: "4:3 Standard"
|
|
9506
9626
|
}
|
|
9507
9627
|
),
|
|
9508
|
-
/* @__PURE__ */ (0,
|
|
9628
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9509
9629
|
"button",
|
|
9510
9630
|
{
|
|
9511
9631
|
type: "button",
|
|
@@ -9517,7 +9637,7 @@ var ImageEditor = ({
|
|
|
9517
9637
|
children: "16:9 Wide"
|
|
9518
9638
|
}
|
|
9519
9639
|
),
|
|
9520
|
-
/* @__PURE__ */ (0,
|
|
9640
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9521
9641
|
"button",
|
|
9522
9642
|
{
|
|
9523
9643
|
type: "button",
|
|
@@ -9529,7 +9649,7 @@ var ImageEditor = ({
|
|
|
9529
9649
|
children: "3:2 Photo"
|
|
9530
9650
|
}
|
|
9531
9651
|
),
|
|
9532
|
-
/* @__PURE__ */ (0,
|
|
9652
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9533
9653
|
"button",
|
|
9534
9654
|
{
|
|
9535
9655
|
type: "button",
|
|
@@ -9542,10 +9662,10 @@ var ImageEditor = ({
|
|
|
9542
9662
|
}
|
|
9543
9663
|
)
|
|
9544
9664
|
] }),
|
|
9545
|
-
/* @__PURE__ */ (0,
|
|
9546
|
-
/* @__PURE__ */ (0,
|
|
9547
|
-
/* @__PURE__ */ (0,
|
|
9548
|
-
/* @__PURE__ */ (0,
|
|
9665
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9666
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Orientation & Flips" }),
|
|
9667
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
9668
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9549
9669
|
"button",
|
|
9550
9670
|
{
|
|
9551
9671
|
type: "button",
|
|
@@ -9554,7 +9674,7 @@ var ImageEditor = ({
|
|
|
9554
9674
|
children: "Rotate -90\xB0"
|
|
9555
9675
|
}
|
|
9556
9676
|
),
|
|
9557
|
-
/* @__PURE__ */ (0,
|
|
9677
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9558
9678
|
"button",
|
|
9559
9679
|
{
|
|
9560
9680
|
type: "button",
|
|
@@ -9563,7 +9683,7 @@ var ImageEditor = ({
|
|
|
9563
9683
|
children: "Rotate +90\xB0"
|
|
9564
9684
|
}
|
|
9565
9685
|
),
|
|
9566
|
-
/* @__PURE__ */ (0,
|
|
9686
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9567
9687
|
"button",
|
|
9568
9688
|
{
|
|
9569
9689
|
type: "button",
|
|
@@ -9572,7 +9692,7 @@ var ImageEditor = ({
|
|
|
9572
9692
|
children: "Flip Horizontal"
|
|
9573
9693
|
}
|
|
9574
9694
|
),
|
|
9575
|
-
/* @__PURE__ */ (0,
|
|
9695
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9576
9696
|
"button",
|
|
9577
9697
|
{
|
|
9578
9698
|
type: "button",
|
|
@@ -9583,10 +9703,10 @@ var ImageEditor = ({
|
|
|
9583
9703
|
)
|
|
9584
9704
|
] })
|
|
9585
9705
|
] }),
|
|
9586
|
-
activeTab === "adjust" && /* @__PURE__ */ (0,
|
|
9587
|
-
/* @__PURE__ */ (0,
|
|
9588
|
-
/* @__PURE__ */ (0,
|
|
9589
|
-
/* @__PURE__ */ (0,
|
|
9706
|
+
activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9707
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9708
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Color Adjustments" }),
|
|
9709
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9590
9710
|
"button",
|
|
9591
9711
|
{
|
|
9592
9712
|
type: "button",
|
|
@@ -9596,25 +9716,25 @@ var ImageEditor = ({
|
|
|
9596
9716
|
}
|
|
9597
9717
|
)
|
|
9598
9718
|
] }),
|
|
9599
|
-
/* @__PURE__ */ (0,
|
|
9600
|
-
|
|
9601
|
-
/* @__PURE__ */ (0,
|
|
9719
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Histogram, { histogram: editor.histogram }),
|
|
9720
|
+
import_image_editor20.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_react67.default.Fragment, { children: [
|
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9602
9722
|
ControlSlider,
|
|
9603
9723
|
{
|
|
9604
9724
|
spec,
|
|
9605
|
-
value: (0,
|
|
9725
|
+
value: (0, import_image_editor20.readAdjustmentControls)(state.adjustments)[spec.id],
|
|
9606
9726
|
disabled: spec.requiresProcess !== void 0 && legacyProcess,
|
|
9607
9727
|
onChange: (v) => editor.setAdjustments({ [spec.id]: v })
|
|
9608
9728
|
}
|
|
9609
9729
|
),
|
|
9610
|
-
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0,
|
|
9730
|
+
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9611
9731
|
"div",
|
|
9612
9732
|
{
|
|
9613
9733
|
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",
|
|
9614
9734
|
"data-testid": "image-editor-process-notice",
|
|
9615
9735
|
children: [
|
|
9616
|
-
/* @__PURE__ */ (0,
|
|
9617
|
-
/* @__PURE__ */ (0,
|
|
9736
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
|
|
9737
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9618
9738
|
"button",
|
|
9619
9739
|
{
|
|
9620
9740
|
type: "button",
|
|
@@ -9627,7 +9747,7 @@ var ImageEditor = ({
|
|
|
9627
9747
|
}
|
|
9628
9748
|
)
|
|
9629
9749
|
] }, spec.id)),
|
|
9630
|
-
/* @__PURE__ */ (0,
|
|
9750
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9631
9751
|
AdjustmentLayersPanel,
|
|
9632
9752
|
{
|
|
9633
9753
|
controller,
|
|
@@ -9636,9 +9756,9 @@ var ImageEditor = ({
|
|
|
9636
9756
|
}
|
|
9637
9757
|
) })
|
|
9638
9758
|
] }),
|
|
9639
|
-
activeTab === "layers" && /* @__PURE__ */ (0,
|
|
9640
|
-
/* @__PURE__ */ (0,
|
|
9641
|
-
/* @__PURE__ */ (0,
|
|
9759
|
+
activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9760
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Layers" }),
|
|
9761
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9642
9762
|
"button",
|
|
9643
9763
|
{
|
|
9644
9764
|
type: "button",
|
|
@@ -9649,15 +9769,15 @@ var ImageEditor = ({
|
|
|
9649
9769
|
children: "Free Transform"
|
|
9650
9770
|
}
|
|
9651
9771
|
),
|
|
9652
|
-
/* @__PURE__ */ (0,
|
|
9653
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
9654
|
-
/* @__PURE__ */ (0,
|
|
9655
|
-
/* @__PURE__ */ (0,
|
|
9772
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LayersPanel, { controller }),
|
|
9773
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ImageProviderEffectsPanel, { controller, className: imageSectionClass }),
|
|
9774
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Colour" }),
|
|
9775
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ColorProfilePanel, { controller })
|
|
9656
9776
|
] }),
|
|
9657
|
-
activeTab === "paint" && /* @__PURE__ */ (0,
|
|
9658
|
-
/* @__PURE__ */ (0,
|
|
9659
|
-
/* @__PURE__ */ (0,
|
|
9660
|
-
/* @__PURE__ */ (0,
|
|
9777
|
+
activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9778
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Paint" }),
|
|
9779
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrushOptionsBar, { controller }),
|
|
9780
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9661
9781
|
"button",
|
|
9662
9782
|
{
|
|
9663
9783
|
type: "button",
|
|
@@ -9668,12 +9788,12 @@ var ImageEditor = ({
|
|
|
9668
9788
|
children: "Free Transform"
|
|
9669
9789
|
}
|
|
9670
9790
|
),
|
|
9671
|
-
paintError && /* @__PURE__ */ (0,
|
|
9672
|
-
/* @__PURE__ */ (0,
|
|
9791
|
+
paintError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "paint-error", children: paintError }),
|
|
9792
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LayersPanel, { controller }) })
|
|
9673
9793
|
] }),
|
|
9674
|
-
activeTab === "annotate" && /* @__PURE__ */ (0,
|
|
9675
|
-
/* @__PURE__ */ (0,
|
|
9676
|
-
/* @__PURE__ */ (0,
|
|
9794
|
+
activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9795
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
|
|
9796
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9677
9797
|
"button",
|
|
9678
9798
|
{
|
|
9679
9799
|
type: "button",
|
|
@@ -9684,13 +9804,13 @@ var ImageEditor = ({
|
|
|
9684
9804
|
},
|
|
9685
9805
|
t
|
|
9686
9806
|
)) }),
|
|
9687
|
-
state.activeTool === "shape" && /* @__PURE__ */ (0,
|
|
9688
|
-
state.activeTool === "type" && /* @__PURE__ */ (0,
|
|
9689
|
-
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0,
|
|
9690
|
-
shapeTypeError && /* @__PURE__ */ (0,
|
|
9691
|
-
/* @__PURE__ */ (0,
|
|
9692
|
-
/* @__PURE__ */ (0,
|
|
9693
|
-
/* @__PURE__ */ (0,
|
|
9807
|
+
state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
|
|
9808
|
+
state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
|
|
9809
|
+
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime47.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" }),
|
|
9810
|
+
shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "shape-type-error", children: shapeTypeError }),
|
|
9811
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9812
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Draw & Annotate" }),
|
|
9813
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9694
9814
|
"button",
|
|
9695
9815
|
{
|
|
9696
9816
|
type: "button",
|
|
@@ -9700,18 +9820,18 @@ var ImageEditor = ({
|
|
|
9700
9820
|
},
|
|
9701
9821
|
t
|
|
9702
9822
|
)) }),
|
|
9703
|
-
/* @__PURE__ */ (0,
|
|
9704
|
-
/* @__PURE__ */ (0,
|
|
9705
|
-
/* @__PURE__ */ (0,
|
|
9706
|
-
/* @__PURE__ */ (0,
|
|
9707
|
-
/* @__PURE__ */ (0,
|
|
9708
|
-
/* @__PURE__ */ (0,
|
|
9709
|
-
/* @__PURE__ */ (0,
|
|
9823
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
|
|
9824
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
|
|
9825
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
|
|
9826
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex-1 ml-2", children: [
|
|
9827
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
|
|
9828
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Width:" }),
|
|
9829
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9710
9830
|
strokeWidth,
|
|
9711
9831
|
"px"
|
|
9712
9832
|
] })
|
|
9713
9833
|
] }),
|
|
9714
|
-
/* @__PURE__ */ (0,
|
|
9834
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9715
9835
|
"input",
|
|
9716
9836
|
{
|
|
9717
9837
|
type: "range",
|
|
@@ -9724,10 +9844,10 @@ var ImageEditor = ({
|
|
|
9724
9844
|
)
|
|
9725
9845
|
] })
|
|
9726
9846
|
] }),
|
|
9727
|
-
/* @__PURE__ */ (0,
|
|
9728
|
-
/* @__PURE__ */ (0,
|
|
9729
|
-
/* @__PURE__ */ (0,
|
|
9730
|
-
/* @__PURE__ */ (0,
|
|
9847
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9848
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Add Text" }),
|
|
9849
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-2", children: [
|
|
9850
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9731
9851
|
"input",
|
|
9732
9852
|
{
|
|
9733
9853
|
type: "text",
|
|
@@ -9738,7 +9858,7 @@ var ImageEditor = ({
|
|
|
9738
9858
|
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"
|
|
9739
9859
|
}
|
|
9740
9860
|
),
|
|
9741
|
-
/* @__PURE__ */ (0,
|
|
9861
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9742
9862
|
"button",
|
|
9743
9863
|
{
|
|
9744
9864
|
type: "button",
|
|
@@ -9748,14 +9868,14 @@ var ImageEditor = ({
|
|
|
9748
9868
|
}
|
|
9749
9869
|
)
|
|
9750
9870
|
] }),
|
|
9751
|
-
/* @__PURE__ */ (0,
|
|
9752
|
-
/* @__PURE__ */ (0,
|
|
9753
|
-
/* @__PURE__ */ (0,
|
|
9871
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between text-muted-foreground", children: [
|
|
9872
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Font Size:" }),
|
|
9873
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9754
9874
|
fontSize,
|
|
9755
9875
|
"px"
|
|
9756
9876
|
] })
|
|
9757
9877
|
] }),
|
|
9758
|
-
/* @__PURE__ */ (0,
|
|
9878
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9759
9879
|
"input",
|
|
9760
9880
|
{
|
|
9761
9881
|
type: "range",
|
|
@@ -9766,14 +9886,14 @@ var ImageEditor = ({
|
|
|
9766
9886
|
className: imageRangeClass
|
|
9767
9887
|
}
|
|
9768
9888
|
),
|
|
9769
|
-
/* @__PURE__ */ (0,
|
|
9770
|
-
/* @__PURE__ */ (0,
|
|
9771
|
-
/* @__PURE__ */ (0,
|
|
9889
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9890
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9891
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
9772
9892
|
"Layers (",
|
|
9773
9893
|
state.annotations.length,
|
|
9774
9894
|
")"
|
|
9775
9895
|
] }),
|
|
9776
|
-
state.selectedAnnotationId && /* @__PURE__ */ (0,
|
|
9896
|
+
state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9777
9897
|
"button",
|
|
9778
9898
|
{
|
|
9779
9899
|
type: "button",
|
|
@@ -9782,7 +9902,7 @@ var ImageEditor = ({
|
|
|
9782
9902
|
children: "Delete Selected"
|
|
9783
9903
|
}
|
|
9784
9904
|
),
|
|
9785
|
-
state.annotations.length > 0 && /* @__PURE__ */ (0,
|
|
9905
|
+
state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9786
9906
|
"button",
|
|
9787
9907
|
{
|
|
9788
9908
|
type: "button",
|
|
@@ -9793,10 +9913,10 @@ var ImageEditor = ({
|
|
|
9793
9913
|
)
|
|
9794
9914
|
] })
|
|
9795
9915
|
] }),
|
|
9796
|
-
activeTab === "depth" && /* @__PURE__ */ (0,
|
|
9797
|
-
/* @__PURE__ */ (0,
|
|
9798
|
-
/* @__PURE__ */ (0,
|
|
9799
|
-
/* @__PURE__ */ (0,
|
|
9916
|
+
activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9917
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9918
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Depth Masking" }),
|
|
9919
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9800
9920
|
"button",
|
|
9801
9921
|
{
|
|
9802
9922
|
type: "button",
|
|
@@ -9806,8 +9926,8 @@ var ImageEditor = ({
|
|
|
9806
9926
|
}
|
|
9807
9927
|
)
|
|
9808
9928
|
] }),
|
|
9809
|
-
/* @__PURE__ */ (0,
|
|
9810
|
-
/* @__PURE__ */ (0,
|
|
9929
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground", children: [
|
|
9930
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9811
9931
|
"input",
|
|
9812
9932
|
{
|
|
9813
9933
|
type: "checkbox",
|
|
@@ -9816,12 +9936,12 @@ var ImageEditor = ({
|
|
|
9816
9936
|
className: "rounded accent-primary"
|
|
9817
9937
|
}
|
|
9818
9938
|
),
|
|
9819
|
-
/* @__PURE__ */ (0,
|
|
9939
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Enable Depth / Alpha Mask" })
|
|
9820
9940
|
] }),
|
|
9821
|
-
state.depthMask.enabled && /* @__PURE__ */ (0,
|
|
9822
|
-
/* @__PURE__ */ (0,
|
|
9823
|
-
/* @__PURE__ */ (0,
|
|
9824
|
-
/* @__PURE__ */ (0,
|
|
9941
|
+
state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
9942
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9943
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { className: "text-muted-foreground block mb-1", children: "Mask Image URL:" }),
|
|
9944
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9825
9945
|
"input",
|
|
9826
9946
|
{
|
|
9827
9947
|
type: "text",
|
|
@@ -9832,8 +9952,8 @@ var ImageEditor = ({
|
|
|
9832
9952
|
}
|
|
9833
9953
|
)
|
|
9834
9954
|
] }),
|
|
9835
|
-
/* @__PURE__ */ (0,
|
|
9836
|
-
/* @__PURE__ */ (0,
|
|
9955
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-2", children: [
|
|
9956
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9837
9957
|
"button",
|
|
9838
9958
|
{
|
|
9839
9959
|
type: "button",
|
|
@@ -9842,7 +9962,7 @@ var ImageEditor = ({
|
|
|
9842
9962
|
children: "Threshold Mode"
|
|
9843
9963
|
}
|
|
9844
9964
|
),
|
|
9845
|
-
/* @__PURE__ */ (0,
|
|
9965
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9846
9966
|
"button",
|
|
9847
9967
|
{
|
|
9848
9968
|
type: "button",
|
|
@@ -9852,12 +9972,12 @@ var ImageEditor = ({
|
|
|
9852
9972
|
}
|
|
9853
9973
|
)
|
|
9854
9974
|
] }),
|
|
9855
|
-
/* @__PURE__ */ (0,
|
|
9856
|
-
/* @__PURE__ */ (0,
|
|
9857
|
-
/* @__PURE__ */ (0,
|
|
9858
|
-
/* @__PURE__ */ (0,
|
|
9975
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9976
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
9977
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Depth Start (Lower):" }),
|
|
9978
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
|
|
9859
9979
|
] }),
|
|
9860
|
-
/* @__PURE__ */ (0,
|
|
9980
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9861
9981
|
"input",
|
|
9862
9982
|
{
|
|
9863
9983
|
type: "range",
|
|
@@ -9871,12 +9991,12 @@ var ImageEditor = ({
|
|
|
9871
9991
|
}
|
|
9872
9992
|
)
|
|
9873
9993
|
] }),
|
|
9874
|
-
/* @__PURE__ */ (0,
|
|
9875
|
-
/* @__PURE__ */ (0,
|
|
9876
|
-
/* @__PURE__ */ (0,
|
|
9877
|
-
/* @__PURE__ */ (0,
|
|
9994
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9995
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
9996
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Depth Stop (Upper):" }),
|
|
9997
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
|
|
9878
9998
|
] }),
|
|
9879
|
-
/* @__PURE__ */ (0,
|
|
9999
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9880
10000
|
"input",
|
|
9881
10001
|
{
|
|
9882
10002
|
type: "range",
|
|
@@ -9890,12 +10010,12 @@ var ImageEditor = ({
|
|
|
9890
10010
|
}
|
|
9891
10011
|
)
|
|
9892
10012
|
] }),
|
|
9893
|
-
/* @__PURE__ */ (0,
|
|
9894
|
-
/* @__PURE__ */ (0,
|
|
9895
|
-
/* @__PURE__ */ (0,
|
|
9896
|
-
/* @__PURE__ */ (0,
|
|
10013
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
10014
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
10015
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Softness:" }),
|
|
10016
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
|
|
9897
10017
|
] }),
|
|
9898
|
-
/* @__PURE__ */ (0,
|
|
10018
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9899
10019
|
"input",
|
|
9900
10020
|
{
|
|
9901
10021
|
type: "range",
|
|
@@ -9907,8 +10027,8 @@ var ImageEditor = ({
|
|
|
9907
10027
|
}
|
|
9908
10028
|
)
|
|
9909
10029
|
] }),
|
|
9910
|
-
/* @__PURE__ */ (0,
|
|
9911
|
-
/* @__PURE__ */ (0,
|
|
10030
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground mt-1", children: [
|
|
10031
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9912
10032
|
"input",
|
|
9913
10033
|
{
|
|
9914
10034
|
type: "checkbox",
|
|
@@ -9917,12 +10037,12 @@ var ImageEditor = ({
|
|
|
9917
10037
|
className: "rounded accent-primary"
|
|
9918
10038
|
}
|
|
9919
10039
|
),
|
|
9920
|
-
/* @__PURE__ */ (0,
|
|
10040
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Invert Mask" })
|
|
9921
10041
|
] })
|
|
9922
10042
|
] })
|
|
9923
10043
|
] }),
|
|
9924
|
-
activeTab === "select" && /* @__PURE__ */ (0,
|
|
9925
|
-
/* @__PURE__ */ (0,
|
|
10044
|
+
activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10045
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9926
10046
|
SelectionOptionsBar,
|
|
9927
10047
|
{
|
|
9928
10048
|
controller,
|
|
@@ -9933,9 +10053,9 @@ var ImageEditor = ({
|
|
|
9933
10053
|
selectionDisplay: state.selectionDisplay
|
|
9934
10054
|
}
|
|
9935
10055
|
),
|
|
9936
|
-
selectionError && /* @__PURE__ */ (0,
|
|
9937
|
-
/* @__PURE__ */ (0,
|
|
9938
|
-
/* @__PURE__ */ (0,
|
|
10056
|
+
selectionError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
|
|
10057
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-1", children: [
|
|
10058
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9939
10059
|
"button",
|
|
9940
10060
|
{
|
|
9941
10061
|
type: "button",
|
|
@@ -9946,7 +10066,7 @@ var ImageEditor = ({
|
|
|
9946
10066
|
children: "Transform Selection"
|
|
9947
10067
|
}
|
|
9948
10068
|
),
|
|
9949
|
-
/* @__PURE__ */ (0,
|
|
10069
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9950
10070
|
"button",
|
|
9951
10071
|
{
|
|
9952
10072
|
type: "button",
|
|
@@ -9958,12 +10078,13 @@ var ImageEditor = ({
|
|
|
9958
10078
|
}
|
|
9959
10079
|
)
|
|
9960
10080
|
] }),
|
|
9961
|
-
/* @__PURE__ */ (0,
|
|
10081
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers }),
|
|
10082
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ChannelsPanel, { controller })
|
|
9962
10083
|
] }),
|
|
9963
|
-
activeTab === "ai" && /* @__PURE__ */ (0,
|
|
9964
|
-
/* @__PURE__ */ (0,
|
|
9965
|
-
/* @__PURE__ */ (0,
|
|
9966
|
-
/* @__PURE__ */ (0,
|
|
10084
|
+
activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10085
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center justify-between gap-2 text-foreground", children: [
|
|
10086
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Results go to" }),
|
|
10087
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9967
10088
|
"select",
|
|
9968
10089
|
{
|
|
9969
10090
|
"aria-label": "AI result target",
|
|
@@ -9971,54 +10092,54 @@ var ImageEditor = ({
|
|
|
9971
10092
|
onChange: (e) => setAiTarget(e.target.value),
|
|
9972
10093
|
className: imageSelectClass,
|
|
9973
10094
|
children: [
|
|
9974
|
-
/* @__PURE__ */ (0,
|
|
9975
|
-
/* @__PURE__ */ (0,
|
|
9976
|
-
/* @__PURE__ */ (0,
|
|
10095
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
|
|
10096
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
|
|
10097
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "replace", children: "Replace image" })
|
|
9977
10098
|
]
|
|
9978
10099
|
}
|
|
9979
10100
|
)
|
|
9980
10101
|
] }),
|
|
9981
|
-
/* @__PURE__ */ (0,
|
|
9982
|
-
/* @__PURE__ */ (0,
|
|
9983
|
-
/* @__PURE__ */ (0,
|
|
9984
|
-
/* @__PURE__ */ (0,
|
|
10102
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
10103
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10104
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
10105
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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_runtime47.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" }) }),
|
|
9985
10106
|
"Background Removal"
|
|
9986
10107
|
] }),
|
|
9987
|
-
isRemovingBg && /* @__PURE__ */ (0,
|
|
10108
|
+
isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime47.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..." })
|
|
9988
10109
|
] }),
|
|
9989
|
-
/* @__PURE__ */ (0,
|
|
9990
|
-
/* @__PURE__ */ (0,
|
|
10110
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
|
|
10111
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9991
10112
|
"button",
|
|
9992
10113
|
{
|
|
9993
10114
|
type: "button",
|
|
9994
10115
|
onClick: handleRemoveBackground,
|
|
9995
10116
|
disabled: isRemovingBg || isInpainting,
|
|
9996
10117
|
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",
|
|
9997
|
-
children: isRemovingBg ? /* @__PURE__ */ (0,
|
|
9998
|
-
/* @__PURE__ */ (0,
|
|
10118
|
+
children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10119
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSpinnerClass }),
|
|
9999
10120
|
"Removing Background..."
|
|
10000
|
-
] }) : /* @__PURE__ */ (0,
|
|
10001
|
-
/* @__PURE__ */ (0,
|
|
10121
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10122
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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_runtime47.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" }) }),
|
|
10002
10123
|
"Remove Background"
|
|
10003
10124
|
] })
|
|
10004
10125
|
}
|
|
10005
10126
|
)
|
|
10006
10127
|
] }),
|
|
10007
|
-
/* @__PURE__ */ (0,
|
|
10008
|
-
/* @__PURE__ */ (0,
|
|
10009
|
-
/* @__PURE__ */ (0,
|
|
10010
|
-
/* @__PURE__ */ (0,
|
|
10011
|
-
/* @__PURE__ */ (0,
|
|
10012
|
-
/* @__PURE__ */ (0,
|
|
10128
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
10129
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10130
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
10131
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
10132
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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" }),
|
|
10133
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "m14 7 3 3" })
|
|
10013
10134
|
] }),
|
|
10014
10135
|
"Generative Inpainting"
|
|
10015
10136
|
] }),
|
|
10016
|
-
isInpainting && /* @__PURE__ */ (0,
|
|
10137
|
+
isInpainting && /* @__PURE__ */ (0, import_jsx_runtime47.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..." })
|
|
10017
10138
|
] }),
|
|
10018
|
-
/* @__PURE__ */ (0,
|
|
10019
|
-
/* @__PURE__ */ (0,
|
|
10020
|
-
/* @__PURE__ */ (0,
|
|
10021
|
-
/* @__PURE__ */ (0,
|
|
10139
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
|
|
10140
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
10141
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-foreground text-[11px] font-medium", children: "Prompt" }),
|
|
10142
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10022
10143
|
"textarea",
|
|
10023
10144
|
{
|
|
10024
10145
|
id: "ai-inpaint-prompt-react",
|
|
@@ -10030,10 +10151,10 @@ var ImageEditor = ({
|
|
|
10030
10151
|
}
|
|
10031
10152
|
)
|
|
10032
10153
|
] }),
|
|
10033
|
-
/* @__PURE__ */ (0,
|
|
10034
|
-
/* @__PURE__ */ (0,
|
|
10035
|
-
/* @__PURE__ */ (0,
|
|
10036
|
-
/* @__PURE__ */ (0,
|
|
10154
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
10155
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-foreground text-[11px] font-medium", children: "Target Mask Region" }),
|
|
10156
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
|
|
10157
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
10037
10158
|
"button",
|
|
10038
10159
|
{
|
|
10039
10160
|
type: "button",
|
|
@@ -10046,7 +10167,7 @@ var ImageEditor = ({
|
|
|
10046
10167
|
]
|
|
10047
10168
|
}
|
|
10048
10169
|
),
|
|
10049
|
-
/* @__PURE__ */ (0,
|
|
10170
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
10050
10171
|
"button",
|
|
10051
10172
|
{
|
|
10052
10173
|
type: "button",
|
|
@@ -10061,25 +10182,25 @@ var ImageEditor = ({
|
|
|
10061
10182
|
)
|
|
10062
10183
|
] })
|
|
10063
10184
|
] }),
|
|
10064
|
-
/* @__PURE__ */ (0,
|
|
10185
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10065
10186
|
"button",
|
|
10066
10187
|
{
|
|
10067
10188
|
type: "button",
|
|
10068
10189
|
onClick: handleInpaint,
|
|
10069
10190
|
disabled: isInpainting || isRemovingBg || !inpaintPrompt.trim(),
|
|
10070
10191
|
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",
|
|
10071
|
-
children: isInpainting ? /* @__PURE__ */ (0,
|
|
10072
|
-
/* @__PURE__ */ (0,
|
|
10192
|
+
children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10193
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSpinnerClass }),
|
|
10073
10194
|
"Generating Inpaint..."
|
|
10074
|
-
] }) : /* @__PURE__ */ (0,
|
|
10075
|
-
/* @__PURE__ */ (0,
|
|
10195
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10196
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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_runtime47.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" }) }),
|
|
10076
10197
|
"Apply Inpainting"
|
|
10077
10198
|
] })
|
|
10078
10199
|
}
|
|
10079
10200
|
)
|
|
10080
10201
|
] }),
|
|
10081
|
-
aiError && /* @__PURE__ */ (0,
|
|
10082
|
-
aiSuccess && /* @__PURE__ */ (0,
|
|
10202
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "p-2.5 rounded-lg bg-destructive/10 border border-destructive/40 text-destructive text-[11px]", children: aiError }),
|
|
10203
|
+
aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-600 text-[11px]", children: aiSuccess })
|
|
10083
10204
|
] })
|
|
10084
10205
|
] })
|
|
10085
10206
|
] })
|
|
@@ -10089,7 +10210,7 @@ var ImageEditor = ({
|
|
|
10089
10210
|
};
|
|
10090
10211
|
|
|
10091
10212
|
// src/review/useReview.ts
|
|
10092
|
-
var
|
|
10213
|
+
var import_react68 = require("react");
|
|
10093
10214
|
var import_editor13 = require("@pixerate/editor");
|
|
10094
10215
|
var EMPTY_COMMENTS = Object.freeze({
|
|
10095
10216
|
threads: [],
|
|
@@ -10108,23 +10229,23 @@ function isCommentStore(value) {
|
|
|
10108
10229
|
}
|
|
10109
10230
|
function useComments(source) {
|
|
10110
10231
|
const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
|
|
10111
|
-
const subscribe = (0,
|
|
10232
|
+
const subscribe = (0, import_react68.useCallback)(
|
|
10112
10233
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
10113
10234
|
[store]
|
|
10114
10235
|
);
|
|
10115
10236
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
10116
|
-
const snapshot = (0,
|
|
10117
|
-
return (0,
|
|
10237
|
+
const snapshot = (0, import_react68.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
10238
|
+
return (0, import_react68.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
10118
10239
|
}
|
|
10119
10240
|
function useTrackChanges(editor) {
|
|
10120
10241
|
const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
|
|
10121
|
-
const subscribe = (0,
|
|
10242
|
+
const subscribe = (0, import_react68.useCallback)(
|
|
10122
10243
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
10123
10244
|
[store]
|
|
10124
10245
|
);
|
|
10125
10246
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
10126
|
-
const snapshot = (0,
|
|
10127
|
-
return (0,
|
|
10247
|
+
const snapshot = (0, import_react68.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
10248
|
+
return (0, import_react68.useMemo)(() => {
|
|
10128
10249
|
const run = (fn) => () => {
|
|
10129
10250
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
10130
10251
|
};
|
|
@@ -10147,9 +10268,9 @@ function useTrackChanges(editor) {
|
|
|
10147
10268
|
}
|
|
10148
10269
|
|
|
10149
10270
|
// src/review/CommentsPanel.tsx
|
|
10150
|
-
var
|
|
10271
|
+
var import_react69 = require("react");
|
|
10151
10272
|
var import_editor14 = require("@pixerate/editor");
|
|
10152
|
-
var
|
|
10273
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
10153
10274
|
var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
|
|
10154
10275
|
var primaryButtonClass = "rounded px-2 py-1 text-xs bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50";
|
|
10155
10276
|
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";
|
|
@@ -10163,18 +10284,18 @@ var CommentsPanel = ({
|
|
|
10163
10284
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
10164
10285
|
}) => {
|
|
10165
10286
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
10166
|
-
const [showResolved, setShowResolved] = (0,
|
|
10287
|
+
const [showResolved, setShowResolved] = (0, import_react69.useState)(showResolvedInitial);
|
|
10167
10288
|
const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
10168
10289
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
10169
10290
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
10170
|
-
return /* @__PURE__ */ (0,
|
|
10171
|
-
/* @__PURE__ */ (0,
|
|
10172
|
-
/* @__PURE__ */ (0,
|
|
10291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("aside", { className, "aria-label": "Comments", children: [
|
|
10292
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
10293
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
10173
10294
|
threads.length - resolvedCount,
|
|
10174
10295
|
" open",
|
|
10175
10296
|
resolvedCount > 0 ? ` \xB7 ${resolvedCount} resolved` : ""
|
|
10176
10297
|
] }),
|
|
10177
|
-
resolvedCount > 0 && /* @__PURE__ */ (0,
|
|
10298
|
+
resolvedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10178
10299
|
"button",
|
|
10179
10300
|
{
|
|
10180
10301
|
type: "button",
|
|
@@ -10185,7 +10306,7 @@ var CommentsPanel = ({
|
|
|
10185
10306
|
}
|
|
10186
10307
|
)
|
|
10187
10308
|
] }),
|
|
10188
|
-
visible.length === 0 ? /* @__PURE__ */ (0,
|
|
10309
|
+
visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("ul", { className: "flex flex-col gap-2", role: "list", children: visible.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10189
10310
|
CommentThreadCard,
|
|
10190
10311
|
{
|
|
10191
10312
|
thread,
|
|
@@ -10207,7 +10328,7 @@ var CommentThreadCard = ({
|
|
|
10207
10328
|
author,
|
|
10208
10329
|
formatTime
|
|
10209
10330
|
}) => {
|
|
10210
|
-
const [draft, setDraft] = (0,
|
|
10331
|
+
const [draft, setDraft] = (0, import_react69.useState)("");
|
|
10211
10332
|
const isDraft = thread.body === "";
|
|
10212
10333
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
10213
10334
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -10233,7 +10354,7 @@ var CommentThreadCard = ({
|
|
|
10233
10354
|
setDraft("");
|
|
10234
10355
|
};
|
|
10235
10356
|
const stop = (e) => e.stopPropagation();
|
|
10236
|
-
return /* @__PURE__ */ (0,
|
|
10357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
10237
10358
|
"li",
|
|
10238
10359
|
{
|
|
10239
10360
|
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" : ""}`,
|
|
@@ -10249,24 +10370,24 @@ var CommentThreadCard = ({
|
|
|
10249
10370
|
}
|
|
10250
10371
|
},
|
|
10251
10372
|
children: [
|
|
10252
|
-
/* @__PURE__ */ (0,
|
|
10253
|
-
/* @__PURE__ */ (0,
|
|
10254
|
-
/* @__PURE__ */ (0,
|
|
10373
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
10374
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-medium", children: thread.author.name }),
|
|
10375
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-muted-foreground", children: formatTime(thread.createdAt) })
|
|
10255
10376
|
] }),
|
|
10256
|
-
quote && /* @__PURE__ */ (0,
|
|
10257
|
-
thread.orphaned && /* @__PURE__ */ (0,
|
|
10258
|
-
thread.resolved && /* @__PURE__ */ (0,
|
|
10259
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
10260
|
-
thread.replies.length > 0 && /* @__PURE__ */ (0,
|
|
10261
|
-
/* @__PURE__ */ (0,
|
|
10262
|
-
/* @__PURE__ */ (0,
|
|
10377
|
+
quote && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("blockquote", { className: "border-l-2 border-border pl-2 text-xs text-muted-foreground line-clamp-2", children: quote }),
|
|
10378
|
+
thread.orphaned && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-destructive", children: "The commented text was deleted." }),
|
|
10379
|
+
thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-muted-foreground", children: "Resolved" }),
|
|
10380
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "whitespace-pre-wrap break-words", children: thread.body }),
|
|
10381
|
+
thread.replies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.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_runtime48.jsxs)("li", { className: "flex flex-col gap-0.5", "data-reply-id": reply.id, children: [
|
|
10382
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "text-xs", children: [
|
|
10383
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-medium", children: reply.author.name }),
|
|
10263
10384
|
" ",
|
|
10264
|
-
/* @__PURE__ */ (0,
|
|
10385
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-muted-foreground", children: formatTime(reply.createdAt) })
|
|
10265
10386
|
] }),
|
|
10266
|
-
/* @__PURE__ */ (0,
|
|
10387
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "whitespace-pre-wrap break-words", children: reply.body })
|
|
10267
10388
|
] }, reply.id)) }),
|
|
10268
|
-
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0,
|
|
10269
|
-
/* @__PURE__ */ (0,
|
|
10389
|
+
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-col gap-1", onClick: stop, children: [
|
|
10390
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10270
10391
|
"textarea",
|
|
10271
10392
|
{
|
|
10272
10393
|
className: textareaClass,
|
|
@@ -10284,9 +10405,9 @@ var CommentThreadCard = ({
|
|
|
10284
10405
|
}
|
|
10285
10406
|
}
|
|
10286
10407
|
),
|
|
10287
|
-
/* @__PURE__ */ (0,
|
|
10288
|
-
isDraft && /* @__PURE__ */ (0,
|
|
10289
|
-
/* @__PURE__ */ (0,
|
|
10408
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex justify-end gap-1", children: [
|
|
10409
|
+
isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: buttonClass2, onClick: remove, children: "Cancel" }),
|
|
10410
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10290
10411
|
"button",
|
|
10291
10412
|
{
|
|
10292
10413
|
type: "button",
|
|
@@ -10298,9 +10419,9 @@ var CommentThreadCard = ({
|
|
|
10298
10419
|
)
|
|
10299
10420
|
] })
|
|
10300
10421
|
] }),
|
|
10301
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
10302
|
-
/* @__PURE__ */ (0,
|
|
10303
|
-
/* @__PURE__ */ (0,
|
|
10422
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex justify-end gap-1", onClick: stop, children: [
|
|
10423
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: buttonClass2, onClick: () => setResolved(!thread.resolved), children: thread.resolved ? "Reopen" : "Resolve" }),
|
|
10424
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10304
10425
|
"button",
|
|
10305
10426
|
{
|
|
10306
10427
|
type: "button",
|
|
@@ -10316,7 +10437,7 @@ var CommentThreadCard = ({
|
|
|
10316
10437
|
};
|
|
10317
10438
|
|
|
10318
10439
|
// src/review/ReviewToolbar.tsx
|
|
10319
|
-
var
|
|
10440
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
10320
10441
|
var defaultDescriptionClass = "max-w-[16rem] truncate px-1 text-xs text-muted-foreground";
|
|
10321
10442
|
var buttonClass3 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
10322
10443
|
var ReviewToolbar = ({
|
|
@@ -10329,8 +10450,8 @@ var ReviewToolbar = ({
|
|
|
10329
10450
|
const count = review.changes.length;
|
|
10330
10451
|
const current = review.currentChange;
|
|
10331
10452
|
const index = current ? review.changes.findIndex((c) => c.id === current.id) + 1 : 0;
|
|
10332
|
-
return /* @__PURE__ */ (0,
|
|
10333
|
-
/* @__PURE__ */ (0,
|
|
10453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className, role: "toolbar", "aria-label": "Review", children: [
|
|
10454
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10334
10455
|
"button",
|
|
10335
10456
|
{
|
|
10336
10457
|
type: "button",
|
|
@@ -10341,8 +10462,8 @@ var ReviewToolbar = ({
|
|
|
10341
10462
|
children: review.enabled ? "Tracking on" : "Track changes"
|
|
10342
10463
|
}
|
|
10343
10464
|
),
|
|
10344
|
-
/* @__PURE__ */ (0,
|
|
10345
|
-
/* @__PURE__ */ (0,
|
|
10465
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
10466
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10346
10467
|
"button",
|
|
10347
10468
|
{
|
|
10348
10469
|
type: "button",
|
|
@@ -10353,8 +10474,8 @@ var ReviewToolbar = ({
|
|
|
10353
10474
|
children: "\u2039"
|
|
10354
10475
|
}
|
|
10355
10476
|
),
|
|
10356
|
-
/* @__PURE__ */ (0,
|
|
10357
|
-
/* @__PURE__ */ (0,
|
|
10477
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.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` }),
|
|
10478
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10358
10479
|
"button",
|
|
10359
10480
|
{
|
|
10360
10481
|
type: "button",
|
|
@@ -10365,7 +10486,7 @@ var ReviewToolbar = ({
|
|
|
10365
10486
|
children: "\u203A"
|
|
10366
10487
|
}
|
|
10367
10488
|
),
|
|
10368
|
-
showDescription && current && /* @__PURE__ */ (0,
|
|
10489
|
+
showDescription && current && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
10369
10490
|
"span",
|
|
10370
10491
|
{
|
|
10371
10492
|
className: descriptionClassName,
|
|
@@ -10377,8 +10498,8 @@ var ReviewToolbar = ({
|
|
|
10377
10498
|
]
|
|
10378
10499
|
}
|
|
10379
10500
|
),
|
|
10380
|
-
/* @__PURE__ */ (0,
|
|
10381
|
-
/* @__PURE__ */ (0,
|
|
10501
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
10502
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10382
10503
|
"button",
|
|
10383
10504
|
{
|
|
10384
10505
|
type: "button",
|
|
@@ -10388,7 +10509,7 @@ var ReviewToolbar = ({
|
|
|
10388
10509
|
children: "Accept"
|
|
10389
10510
|
}
|
|
10390
10511
|
),
|
|
10391
|
-
/* @__PURE__ */ (0,
|
|
10512
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10392
10513
|
"button",
|
|
10393
10514
|
{
|
|
10394
10515
|
type: "button",
|
|
@@ -10398,18 +10519,18 @@ var ReviewToolbar = ({
|
|
|
10398
10519
|
children: "Reject"
|
|
10399
10520
|
}
|
|
10400
10521
|
),
|
|
10401
|
-
/* @__PURE__ */ (0,
|
|
10402
|
-
/* @__PURE__ */ (0,
|
|
10522
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.acceptAll, children: "Accept all" }),
|
|
10523
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.rejectAll, children: "Reject all" })
|
|
10403
10524
|
] });
|
|
10404
10525
|
};
|
|
10405
10526
|
|
|
10406
10527
|
// src/review/CommentButton.tsx
|
|
10407
|
-
var
|
|
10528
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
10408
10529
|
var CommentButton = ({
|
|
10409
10530
|
editor,
|
|
10410
10531
|
className = "rounded px-2 py-1 text-xs text-popover-foreground hover:bg-muted",
|
|
10411
10532
|
children = "Comment"
|
|
10412
|
-
}) => /* @__PURE__ */ (0,
|
|
10533
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10413
10534
|
"button",
|
|
10414
10535
|
{
|
|
10415
10536
|
type: "button",
|
|
@@ -10421,13 +10542,13 @@ var CommentButton = ({
|
|
|
10421
10542
|
);
|
|
10422
10543
|
|
|
10423
10544
|
// src/review/useDocumentCompare.ts
|
|
10424
|
-
var
|
|
10545
|
+
var import_react70 = require("react");
|
|
10425
10546
|
var import_editor15 = require("@pixerate/editor");
|
|
10426
10547
|
function useDocumentCompare(editor, options) {
|
|
10427
|
-
const [summary, setSummary] = (0,
|
|
10428
|
-
const defaults = (0,
|
|
10548
|
+
const [summary, setSummary] = (0, import_react70.useState)(null);
|
|
10549
|
+
const defaults = (0, import_react70.useRef)(options);
|
|
10429
10550
|
defaults.current = options;
|
|
10430
|
-
const compare = (0,
|
|
10551
|
+
const compare = (0, import_react70.useCallback)(
|
|
10431
10552
|
(original, revised, overrides) => {
|
|
10432
10553
|
if (!editor || editor.isDestroyed) return null;
|
|
10433
10554
|
const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
|
|
@@ -10439,13 +10560,13 @@ function useDocumentCompare(editor, options) {
|
|
|
10439
10560
|
},
|
|
10440
10561
|
[editor]
|
|
10441
10562
|
);
|
|
10442
|
-
const clear = (0,
|
|
10443
|
-
return (0,
|
|
10563
|
+
const clear = (0, import_react70.useCallback)(() => setSummary(null), []);
|
|
10564
|
+
return (0, import_react70.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
10444
10565
|
}
|
|
10445
10566
|
|
|
10446
10567
|
// src/review/TrackedChangesList.tsx
|
|
10447
10568
|
var import_editor16 = require("@pixerate/editor");
|
|
10448
|
-
var
|
|
10569
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
10449
10570
|
var buttonClass4 = "rounded px-1.5 py-0.5 text-xs text-foreground hover:bg-muted disabled:opacity-40";
|
|
10450
10571
|
var TrackedChangesList = ({
|
|
10451
10572
|
editor,
|
|
@@ -10456,18 +10577,18 @@ var TrackedChangesList = ({
|
|
|
10456
10577
|
}) => {
|
|
10457
10578
|
const review = useTrackChanges(editor);
|
|
10458
10579
|
if (review.changes.length === 0) {
|
|
10459
|
-
return /* @__PURE__ */ (0,
|
|
10580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, "data-tracked-changes-list": "", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "pixerate-changes-empty text-xs text-muted-foreground", children: emptyState }) });
|
|
10460
10581
|
}
|
|
10461
|
-
return /* @__PURE__ */ (0,
|
|
10582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className, role: "list", "aria-label": "Tracked changes", "data-tracked-changes-list": "", children: review.changes.map((change) => {
|
|
10462
10583
|
const active = change.id === review.currentChangeId;
|
|
10463
|
-
return /* @__PURE__ */ (0,
|
|
10584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
10464
10585
|
"li",
|
|
10465
10586
|
{
|
|
10466
10587
|
className: active ? `${itemClassName} ${activeItemClassName}` : itemClassName,
|
|
10467
10588
|
"data-change-type": change.type,
|
|
10468
10589
|
"data-change-id": change.id,
|
|
10469
10590
|
children: [
|
|
10470
|
-
/* @__PURE__ */ (0,
|
|
10591
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
10471
10592
|
"button",
|
|
10472
10593
|
{
|
|
10473
10594
|
type: "button",
|
|
@@ -10475,14 +10596,14 @@ var TrackedChangesList = ({
|
|
|
10475
10596
|
title: `${change.author.name}: ${change.description}`,
|
|
10476
10597
|
onClick: () => review.select(change.id),
|
|
10477
10598
|
children: [
|
|
10478
|
-
/* @__PURE__ */ (0,
|
|
10599
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "font-medium", children: (0, import_editor16.trackedChangeLabel)(change) }),
|
|
10479
10600
|
change.author.name ? ` \xB7 ${change.author.name}` : "",
|
|
10480
|
-
/* @__PURE__ */ (0,
|
|
10601
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "block truncate text-muted-foreground", children: change.description })
|
|
10481
10602
|
]
|
|
10482
10603
|
}
|
|
10483
10604
|
),
|
|
10484
|
-
/* @__PURE__ */ (0,
|
|
10485
|
-
/* @__PURE__ */ (0,
|
|
10605
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.accept(change.id), children: "Accept" }),
|
|
10606
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.reject(change.id), children: "Reject" })
|
|
10486
10607
|
]
|
|
10487
10608
|
},
|
|
10488
10609
|
`${change.type}:${change.id}`
|
|
@@ -10491,12 +10612,12 @@ var TrackedChangesList = ({
|
|
|
10491
10612
|
};
|
|
10492
10613
|
|
|
10493
10614
|
// src/commands/useCommandPalette.ts
|
|
10494
|
-
var
|
|
10615
|
+
var import_react71 = require("react");
|
|
10495
10616
|
var import_commands2 = require("@pixerate/editor/commands");
|
|
10496
10617
|
function useCommandPalette(registry, options = {}) {
|
|
10497
|
-
const optionsRef = (0,
|
|
10618
|
+
const optionsRef = (0, import_react71.useRef)(options);
|
|
10498
10619
|
optionsRef.current = options;
|
|
10499
|
-
const controller = (0,
|
|
10620
|
+
const controller = (0, import_react71.useMemo)(
|
|
10500
10621
|
() => (0, import_commands2.createCommandPaletteController)(registry, {
|
|
10501
10622
|
context: () => {
|
|
10502
10623
|
const c = optionsRef.current.context;
|
|
@@ -10517,9 +10638,9 @@ function useCommandPalette(registry, options = {}) {
|
|
|
10517
10638
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10518
10639
|
[registry]
|
|
10519
10640
|
);
|
|
10520
|
-
const state = (0,
|
|
10641
|
+
const state = (0, import_react71.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
10521
10642
|
const { hotkey, hotkeyTarget } = options;
|
|
10522
|
-
(0,
|
|
10643
|
+
(0, import_react71.useEffect)(() => {
|
|
10523
10644
|
if (!hotkey) return;
|
|
10524
10645
|
const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
|
|
10525
10646
|
if (!target) return;
|
|
@@ -10547,13 +10668,13 @@ function useCommandPalette(registry, options = {}) {
|
|
|
10547
10668
|
}
|
|
10548
10669
|
|
|
10549
10670
|
// src/commands/CommandPalette.tsx
|
|
10550
|
-
var
|
|
10551
|
-
var
|
|
10671
|
+
var import_react72 = __toESM(require("react"), 1);
|
|
10672
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
10552
10673
|
function HighlightedLabel({ item }) {
|
|
10553
|
-
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0,
|
|
10674
|
+
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: item.label });
|
|
10554
10675
|
const marked = new Set(item.labelIndices);
|
|
10555
|
-
return /* @__PURE__ */ (0,
|
|
10556
|
-
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0,
|
|
10676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: Array.from(item.label).map(
|
|
10677
|
+
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react72.default.Fragment, { children: ch }, i)
|
|
10557
10678
|
) });
|
|
10558
10679
|
}
|
|
10559
10680
|
var CommandPalette = ({
|
|
@@ -10562,22 +10683,22 @@ var CommandPalette = ({
|
|
|
10562
10683
|
emptyMessage = "No matching commands",
|
|
10563
10684
|
className = ""
|
|
10564
10685
|
}) => {
|
|
10565
|
-
const inputRef = (0,
|
|
10566
|
-
const listRef = (0,
|
|
10567
|
-
const baseId = (0,
|
|
10686
|
+
const inputRef = (0, import_react72.useRef)(null);
|
|
10687
|
+
const listRef = (0, import_react72.useRef)(null);
|
|
10688
|
+
const baseId = (0, import_react72.useId)();
|
|
10568
10689
|
const listId = `${baseId}-list`;
|
|
10569
10690
|
const optionId = (index) => `${baseId}-option-${index}`;
|
|
10570
10691
|
const { open, query, items, activeIndex } = palette;
|
|
10571
|
-
(0,
|
|
10692
|
+
(0, import_react72.useEffect)(() => {
|
|
10572
10693
|
if (open) inputRef.current?.focus();
|
|
10573
10694
|
}, [open]);
|
|
10574
|
-
(0,
|
|
10695
|
+
(0, import_react72.useEffect)(() => {
|
|
10575
10696
|
if (!open) return;
|
|
10576
10697
|
const active = listRef.current?.querySelector('[aria-selected="true"]');
|
|
10577
10698
|
active?.scrollIntoView?.({ block: "nearest" });
|
|
10578
10699
|
}, [open, activeIndex]);
|
|
10579
10700
|
if (!open) return null;
|
|
10580
|
-
return /* @__PURE__ */ (0,
|
|
10701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10581
10702
|
"div",
|
|
10582
10703
|
{
|
|
10583
10704
|
className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 px-4 pt-[15vh]",
|
|
@@ -10585,7 +10706,7 @@ var CommandPalette = ({
|
|
|
10585
10706
|
onMouseDown: (e) => {
|
|
10586
10707
|
if (e.target === e.currentTarget) palette.setOpen(false);
|
|
10587
10708
|
},
|
|
10588
|
-
children: /* @__PURE__ */ (0,
|
|
10709
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
10589
10710
|
"div",
|
|
10590
10711
|
{
|
|
10591
10712
|
role: "dialog",
|
|
@@ -10594,7 +10715,7 @@ var CommandPalette = ({
|
|
|
10594
10715
|
className: `w-full max-w-lg overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl ${className}`,
|
|
10595
10716
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
10596
10717
|
children: [
|
|
10597
|
-
/* @__PURE__ */ (0,
|
|
10718
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10598
10719
|
"input",
|
|
10599
10720
|
{
|
|
10600
10721
|
ref: inputRef,
|
|
@@ -10614,7 +10735,7 @@ var CommandPalette = ({
|
|
|
10614
10735
|
className: "w-full border-b border-border bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground"
|
|
10615
10736
|
}
|
|
10616
10737
|
),
|
|
10617
|
-
items.length === 0 ? /* @__PURE__ */ (0,
|
|
10738
|
+
items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime52.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_runtime52.jsxs)(
|
|
10618
10739
|
"li",
|
|
10619
10740
|
{
|
|
10620
10741
|
id: optionId(index),
|
|
@@ -10629,12 +10750,12 @@ var CommandPalette = ({
|
|
|
10629
10750
|
onClick: () => palette.run(item.id),
|
|
10630
10751
|
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"}`,
|
|
10631
10752
|
children: [
|
|
10632
|
-
/* @__PURE__ */ (0,
|
|
10633
|
-
/* @__PURE__ */ (0,
|
|
10634
|
-
item.disabledReason && /* @__PURE__ */ (0,
|
|
10753
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
10754
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(HighlightedLabel, { item }),
|
|
10755
|
+
item.disabledReason && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "ml-2 text-xs text-muted-foreground", "data-disabled-reason": "", children: item.disabledReason })
|
|
10635
10756
|
] }),
|
|
10636
|
-
item.group && /* @__PURE__ */ (0,
|
|
10637
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
10757
|
+
item.group && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "shrink-0 text-xs text-muted-foreground", children: item.group }),
|
|
10758
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("kbd", { className: "shrink-0 rounded border border-border px-1.5 font-mono text-[10px] text-muted-foreground", children: item.shortcut })
|
|
10638
10759
|
]
|
|
10639
10760
|
},
|
|
10640
10761
|
item.id
|
|
@@ -10647,12 +10768,12 @@ var CommandPalette = ({
|
|
|
10647
10768
|
};
|
|
10648
10769
|
|
|
10649
10770
|
// src/commands/useCommandShortcuts.ts
|
|
10650
|
-
var
|
|
10771
|
+
var import_react73 = require("react");
|
|
10651
10772
|
function useCommandShortcuts(registry, options = {}) {
|
|
10652
|
-
const optionsRef = (0,
|
|
10773
|
+
const optionsRef = (0, import_react73.useRef)(options);
|
|
10653
10774
|
optionsRef.current = options;
|
|
10654
10775
|
const { enabled = true, target } = options;
|
|
10655
|
-
(0,
|
|
10776
|
+
(0, import_react73.useEffect)(() => {
|
|
10656
10777
|
if (!registry || !enabled) return;
|
|
10657
10778
|
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
10658
10779
|
if (!eventTarget) return;
|
|
@@ -10670,14 +10791,14 @@ function useCommandShortcuts(registry, options = {}) {
|
|
|
10670
10791
|
}, [registry, enabled, target]);
|
|
10671
10792
|
}
|
|
10672
10793
|
function useRegisterCommands(registry, specs) {
|
|
10673
|
-
(0,
|
|
10794
|
+
(0, import_react73.useEffect)(() => {
|
|
10674
10795
|
if (!registry || !specs || specs.length === 0) return;
|
|
10675
10796
|
return registry.register(specs);
|
|
10676
10797
|
}, [registry, specs]);
|
|
10677
10798
|
}
|
|
10678
10799
|
|
|
10679
10800
|
// src/persistence/useAutosave.ts
|
|
10680
|
-
var
|
|
10801
|
+
var import_react74 = require("react");
|
|
10681
10802
|
var import_persistence = require("@pixerate/editor/persistence");
|
|
10682
10803
|
var IDLE = {
|
|
10683
10804
|
status: "idle",
|
|
@@ -10688,18 +10809,18 @@ var IDLE = {
|
|
|
10688
10809
|
ready: false
|
|
10689
10810
|
};
|
|
10690
10811
|
function useAutosave(options) {
|
|
10691
|
-
const optionsRef = (0,
|
|
10812
|
+
const optionsRef = (0, import_react74.useRef)(options);
|
|
10692
10813
|
optionsRef.current = options;
|
|
10693
10814
|
const { storage, key, history, dirty } = options;
|
|
10694
10815
|
const recover = options.recover !== false;
|
|
10695
10816
|
const flushOnHide = options.flushOnHide !== false;
|
|
10696
10817
|
const ready = options.ready !== false;
|
|
10697
|
-
const [controller, setController] = (0,
|
|
10698
|
-
const [status, setStatus] = (0,
|
|
10699
|
-
const [recovery, setRecovery] = (0,
|
|
10700
|
-
const [pendingRecovery, setPendingRecovery] = (0,
|
|
10701
|
-
const revisionsRef = (0,
|
|
10702
|
-
(0,
|
|
10818
|
+
const [controller, setController] = (0, import_react74.useState)(null);
|
|
10819
|
+
const [status, setStatus] = (0, import_react74.useState)(IDLE);
|
|
10820
|
+
const [recovery, setRecovery] = (0, import_react74.useState)(null);
|
|
10821
|
+
const [pendingRecovery, setPendingRecovery] = (0, import_react74.useState)(recover);
|
|
10822
|
+
const revisionsRef = (0, import_react74.useRef)(null);
|
|
10823
|
+
(0, import_react74.useEffect)(() => {
|
|
10703
10824
|
const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
|
|
10704
10825
|
const o = optionsRef.current;
|
|
10705
10826
|
const instance = (0, import_persistence.createAutosaveController)({
|
|
@@ -10742,10 +10863,10 @@ function useAutosave(options) {
|
|
|
10742
10863
|
if (revisionsRef.current === revisions) revisionsRef.current = null;
|
|
10743
10864
|
};
|
|
10744
10865
|
}, [storage, key, history, dirty, recover]);
|
|
10745
|
-
(0,
|
|
10866
|
+
(0, import_react74.useEffect)(() => {
|
|
10746
10867
|
if (controller && ready && !pendingRecovery) controller.ready();
|
|
10747
10868
|
}, [controller, ready, pendingRecovery]);
|
|
10748
|
-
(0,
|
|
10869
|
+
(0, import_react74.useEffect)(() => {
|
|
10749
10870
|
if (!controller || !flushOnHide || typeof window === "undefined") return;
|
|
10750
10871
|
const flush = () => void controller.flushNow();
|
|
10751
10872
|
const onVisibility = () => {
|
|
@@ -10758,33 +10879,33 @@ function useAutosave(options) {
|
|
|
10758
10879
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
10759
10880
|
};
|
|
10760
10881
|
}, [controller, flushOnHide]);
|
|
10761
|
-
const restore = (0,
|
|
10882
|
+
const restore = (0, import_react74.useCallback)(() => {
|
|
10762
10883
|
const snapshot = recovery?.snapshot;
|
|
10763
10884
|
setRecovery(null);
|
|
10764
10885
|
setPendingRecovery(false);
|
|
10765
10886
|
return snapshot;
|
|
10766
10887
|
}, [recovery]);
|
|
10767
|
-
const discard = (0,
|
|
10888
|
+
const discard = (0, import_react74.useCallback)(async () => {
|
|
10768
10889
|
if (controller) await controller.discardRecovery();
|
|
10769
10890
|
setRecovery(null);
|
|
10770
10891
|
setPendingRecovery(false);
|
|
10771
10892
|
}, [controller]);
|
|
10772
|
-
const flushNow = (0,
|
|
10893
|
+
const flushNow = (0, import_react74.useCallback)(async () => {
|
|
10773
10894
|
await controller?.flushNow();
|
|
10774
10895
|
}, [controller]);
|
|
10775
|
-
const markClean = (0,
|
|
10896
|
+
const markClean = (0, import_react74.useCallback)(async () => {
|
|
10776
10897
|
revisionsRef.current?.markSaved();
|
|
10777
10898
|
await controller?.markClean();
|
|
10778
10899
|
}, [controller]);
|
|
10779
|
-
const notifyChange = (0,
|
|
10900
|
+
const notifyChange = (0, import_react74.useCallback)(() => revisionsRef.current?.bump(), []);
|
|
10780
10901
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
10781
10902
|
}
|
|
10782
10903
|
|
|
10783
10904
|
// src/persistence/useEditorAutosave.ts
|
|
10784
|
-
var
|
|
10905
|
+
var import_react75 = require("react");
|
|
10785
10906
|
var import_persistence2 = require("@pixerate/editor/persistence");
|
|
10786
10907
|
function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
10787
|
-
const storage = (0,
|
|
10908
|
+
const storage = (0, import_react75.useMemo)(
|
|
10788
10909
|
() => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
|
|
10789
10910
|
[options.storage, doc.assets]
|
|
10790
10911
|
);
|
|
@@ -10797,19 +10918,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
10797
10918
|
history: doc
|
|
10798
10919
|
});
|
|
10799
10920
|
const take = autosave.restore;
|
|
10800
|
-
const restore = (0,
|
|
10921
|
+
const restore = (0, import_react75.useCallback)(() => {
|
|
10801
10922
|
const snapshot = take();
|
|
10802
10923
|
return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
|
|
10803
10924
|
}, [take, doc]);
|
|
10804
10925
|
const { markClean: clean, discard: drop } = autosave;
|
|
10805
10926
|
const rawStorage = options.storage;
|
|
10806
|
-
const gcRef = (0,
|
|
10927
|
+
const gcRef = (0, import_react75.useRef)(collectAssetGarbage);
|
|
10807
10928
|
gcRef.current = collectAssetGarbage;
|
|
10808
|
-
const markClean = (0,
|
|
10929
|
+
const markClean = (0, import_react75.useCallback)(async () => {
|
|
10809
10930
|
await clean();
|
|
10810
10931
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
10811
10932
|
}, [clean, rawStorage, doc]);
|
|
10812
|
-
const discard = (0,
|
|
10933
|
+
const discard = (0, import_react75.useCallback)(async () => {
|
|
10813
10934
|
await drop();
|
|
10814
10935
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
10815
10936
|
}, [drop, rawStorage, doc]);
|
|
@@ -10818,7 +10939,7 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
10818
10939
|
|
|
10819
10940
|
// src/persistence/RecoveryPrompt.tsx
|
|
10820
10941
|
var import_persistence3 = require("@pixerate/editor/persistence");
|
|
10821
|
-
var
|
|
10942
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
10822
10943
|
var RecoveryPrompt = ({
|
|
10823
10944
|
recovery,
|
|
10824
10945
|
onRestore,
|
|
@@ -10830,7 +10951,7 @@ var RecoveryPrompt = ({
|
|
|
10830
10951
|
}) => {
|
|
10831
10952
|
if (!recovery) return null;
|
|
10832
10953
|
const { name } = recovery.meta;
|
|
10833
|
-
return /* @__PURE__ */ (0,
|
|
10954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
10834
10955
|
"div",
|
|
10835
10956
|
{
|
|
10836
10957
|
role: "alertdialog",
|
|
@@ -10838,15 +10959,15 @@ var RecoveryPrompt = ({
|
|
|
10838
10959
|
"data-recovery-prompt": "",
|
|
10839
10960
|
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}`,
|
|
10840
10961
|
children: [
|
|
10841
|
-
/* @__PURE__ */ (0,
|
|
10962
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
10842
10963
|
(0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
|
|
10843
|
-
name ? /* @__PURE__ */ (0,
|
|
10964
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
|
|
10844
10965
|
"(",
|
|
10845
10966
|
name,
|
|
10846
10967
|
")"
|
|
10847
10968
|
] }) : null
|
|
10848
10969
|
] }),
|
|
10849
|
-
/* @__PURE__ */ (0,
|
|
10970
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10850
10971
|
"button",
|
|
10851
10972
|
{
|
|
10852
10973
|
type: "button",
|
|
@@ -10856,7 +10977,7 @@ var RecoveryPrompt = ({
|
|
|
10856
10977
|
children: restoreLabel
|
|
10857
10978
|
}
|
|
10858
10979
|
),
|
|
10859
|
-
/* @__PURE__ */ (0,
|
|
10980
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10860
10981
|
"button",
|
|
10861
10982
|
{
|
|
10862
10983
|
type: "button",
|
|
@@ -10872,17 +10993,17 @@ var RecoveryPrompt = ({
|
|
|
10872
10993
|
};
|
|
10873
10994
|
|
|
10874
10995
|
// src/generation/useGenerationPlan.ts
|
|
10875
|
-
var
|
|
10996
|
+
var import_react76 = require("react");
|
|
10876
10997
|
var import_generation = require("@pixerate/editor/generation");
|
|
10877
10998
|
function useGenerationPlan(request, capabilities, options = {}) {
|
|
10878
10999
|
const key = JSON.stringify([request, capabilities, options]);
|
|
10879
|
-
return (0,
|
|
11000
|
+
return (0, import_react76.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
|
|
10880
11001
|
}
|
|
10881
11002
|
function useJobProgress(options) {
|
|
10882
11003
|
const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
|
|
10883
|
-
const [tick, setTick] = (0,
|
|
11004
|
+
const [tick, setTick] = (0, import_react76.useState)(() => Date.now());
|
|
10884
11005
|
const ticking = !done && now === void 0;
|
|
10885
|
-
(0,
|
|
11006
|
+
(0, import_react76.useEffect)(() => {
|
|
10886
11007
|
if (!ticking) return;
|
|
10887
11008
|
setTick(Date.now());
|
|
10888
11009
|
const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
|
|
@@ -10892,9 +11013,9 @@ function useJobProgress(options) {
|
|
|
10892
11013
|
}
|
|
10893
11014
|
|
|
10894
11015
|
// src/generation/GenerationSettings.tsx
|
|
10895
|
-
var
|
|
11016
|
+
var import_react77 = require("react");
|
|
10896
11017
|
var import_generation2 = require("@pixerate/editor/generation");
|
|
10897
|
-
var
|
|
11018
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
10898
11019
|
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";
|
|
10899
11020
|
function Control({
|
|
10900
11021
|
control,
|
|
@@ -10904,7 +11025,7 @@ function Control({
|
|
|
10904
11025
|
}) {
|
|
10905
11026
|
const shown = value ?? control.defaultValue;
|
|
10906
11027
|
if (control.kind === "checkbox") {
|
|
10907
|
-
return /* @__PURE__ */ (0,
|
|
11028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10908
11029
|
"input",
|
|
10909
11030
|
{
|
|
10910
11031
|
id,
|
|
@@ -10916,7 +11037,7 @@ function Control({
|
|
|
10916
11037
|
);
|
|
10917
11038
|
}
|
|
10918
11039
|
if (control.kind === "select") {
|
|
10919
|
-
return /* @__PURE__ */ (0,
|
|
11040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
10920
11041
|
"select",
|
|
10921
11042
|
{
|
|
10922
11043
|
id,
|
|
@@ -10925,14 +11046,14 @@ function Control({
|
|
|
10925
11046
|
value: shown === void 0 ? "" : String(shown),
|
|
10926
11047
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value)),
|
|
10927
11048
|
children: [
|
|
10928
|
-
shown === void 0 && /* @__PURE__ */ (0,
|
|
10929
|
-
control.options.map((option) => /* @__PURE__ */ (0,
|
|
11049
|
+
shown === void 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("option", { value: "", children: "Default" }),
|
|
11050
|
+
control.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("option", { value: String(option.value), children: option.label }, String(option.value)))
|
|
10930
11051
|
]
|
|
10931
11052
|
}
|
|
10932
11053
|
);
|
|
10933
11054
|
}
|
|
10934
11055
|
if (control.kind === "textarea") {
|
|
10935
|
-
return /* @__PURE__ */ (0,
|
|
11056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10936
11057
|
"textarea",
|
|
10937
11058
|
{
|
|
10938
11059
|
id,
|
|
@@ -10946,8 +11067,8 @@ function Control({
|
|
|
10946
11067
|
);
|
|
10947
11068
|
}
|
|
10948
11069
|
const numeric = typeof shown === "number" ? shown : void 0;
|
|
10949
|
-
return /* @__PURE__ */ (0,
|
|
10950
|
-
/* @__PURE__ */ (0,
|
|
11070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11071
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10951
11072
|
"input",
|
|
10952
11073
|
{
|
|
10953
11074
|
id,
|
|
@@ -10961,7 +11082,7 @@ function Control({
|
|
|
10961
11082
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
|
|
10962
11083
|
}
|
|
10963
11084
|
),
|
|
10964
|
-
control.kind === "range" && /* @__PURE__ */ (0,
|
|
11085
|
+
control.kind === "range" && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "w-10 text-right tabular-nums text-muted-foreground", "data-field-value": "", children: numeric ?? "\u2013" })
|
|
10965
11086
|
] });
|
|
10966
11087
|
}
|
|
10967
11088
|
var GenerationSettings = ({
|
|
@@ -10975,17 +11096,17 @@ var GenerationSettings = ({
|
|
|
10975
11096
|
renderReference,
|
|
10976
11097
|
className = ""
|
|
10977
11098
|
}) => {
|
|
10978
|
-
const baseId = (0,
|
|
10979
|
-
const controls = (0,
|
|
11099
|
+
const baseId = (0, import_react77.useId)();
|
|
11100
|
+
const controls = (0, import_react77.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
|
|
10980
11101
|
const computed = useGenerationPlan(value, capabilities, { strategy });
|
|
10981
11102
|
const plan = planProp ?? computed;
|
|
10982
11103
|
const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
|
|
10983
|
-
return /* @__PURE__ */ (0,
|
|
11104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: `flex flex-col gap-3 text-sm ${className}`, "data-generation-settings": "", "data-model": capabilities.id, children: [
|
|
10984
11105
|
controls.map((control) => {
|
|
10985
11106
|
const id = `${baseId}-${control.key}`;
|
|
10986
|
-
return /* @__PURE__ */ (0,
|
|
10987
|
-
/* @__PURE__ */ (0,
|
|
10988
|
-
/* @__PURE__ */ (0,
|
|
11107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex flex-col gap-1", "data-control": control.key, children: [
|
|
11108
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("label", { htmlFor: id, className: "text-xs font-medium text-muted-foreground", title: control.description, children: control.label }),
|
|
11109
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10989
11110
|
Control,
|
|
10990
11111
|
{
|
|
10991
11112
|
control,
|
|
@@ -10996,23 +11117,23 @@ var GenerationSettings = ({
|
|
|
10996
11117
|
)
|
|
10997
11118
|
] }, control.key);
|
|
10998
11119
|
}),
|
|
10999
|
-
slots.map((slot) => /* @__PURE__ */ (0,
|
|
11000
|
-
/* @__PURE__ */ (0,
|
|
11120
|
+
slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("fieldset", { className: "flex flex-col gap-1", "data-reference-role": slot.role, children: [
|
|
11121
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("legend", { className: "text-xs font-medium text-muted-foreground", title: slot.description, children: [
|
|
11001
11122
|
slot.label,
|
|
11002
11123
|
" ",
|
|
11003
|
-
/* @__PURE__ */ (0,
|
|
11124
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "tabular-nums", "data-reference-count": "", children: [
|
|
11004
11125
|
"(",
|
|
11005
11126
|
slot.references.length,
|
|
11006
11127
|
"/",
|
|
11007
11128
|
slot.max,
|
|
11008
11129
|
")"
|
|
11009
11130
|
] }),
|
|
11010
|
-
slot.min > 0 && /* @__PURE__ */ (0,
|
|
11131
|
+
slot.min > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-destructive", children: " *" })
|
|
11011
11132
|
] }),
|
|
11012
|
-
/* @__PURE__ */ (0,
|
|
11013
|
-
slot.references.map((ref) => /* @__PURE__ */ (0,
|
|
11014
|
-
renderReference ? renderReference(ref) : /* @__PURE__ */ (0,
|
|
11015
|
-
/* @__PURE__ */ (0,
|
|
11133
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("ul", { className: "flex flex-wrap gap-1", children: [
|
|
11134
|
+
slot.references.map((ref) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("li", { className: "flex items-center gap-1 rounded border border-border px-1.5 py-0.5", "data-reference-id": ref.id, children: [
|
|
11135
|
+
renderReference ? renderReference(ref) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "max-w-[10rem] truncate", children: ref.id }),
|
|
11136
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11016
11137
|
"button",
|
|
11017
11138
|
{
|
|
11018
11139
|
type: "button",
|
|
@@ -11023,7 +11144,7 @@ var GenerationSettings = ({
|
|
|
11023
11144
|
}
|
|
11024
11145
|
)
|
|
11025
11146
|
] }, ref.id)),
|
|
11026
|
-
onAddReference && slot.canAdd && /* @__PURE__ */ (0,
|
|
11147
|
+
onAddReference && slot.canAdd && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11027
11148
|
"button",
|
|
11028
11149
|
{
|
|
11029
11150
|
type: "button",
|
|
@@ -11034,21 +11155,21 @@ var GenerationSettings = ({
|
|
|
11034
11155
|
) })
|
|
11035
11156
|
] })
|
|
11036
11157
|
] }, slot.role)),
|
|
11037
|
-
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0,
|
|
11038
|
-
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0,
|
|
11158
|
+
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.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_runtime54.jsx)("li", { "data-adjustment-field": adjustment.field, "data-adjustment-kind": adjustment.kind, children: adjustment.reason }, index)) }),
|
|
11159
|
+
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.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_runtime54.jsx)("li", { "data-error-field": error.field, children: error.message }, index)) })
|
|
11039
11160
|
] });
|
|
11040
11161
|
};
|
|
11041
11162
|
|
|
11042
11163
|
// src/generation/JobProgress.tsx
|
|
11043
|
-
var
|
|
11164
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
11044
11165
|
var JobProgress = ({ title, className = "", ...options }) => {
|
|
11045
11166
|
const progress = useJobProgress(options);
|
|
11046
|
-
return /* @__PURE__ */ (0,
|
|
11047
|
-
/* @__PURE__ */ (0,
|
|
11048
|
-
title && /* @__PURE__ */ (0,
|
|
11049
|
-
/* @__PURE__ */ (0,
|
|
11167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: `flex flex-col gap-1 text-sm ${className}`, "data-job-progress": "", "data-done": options.done ? "" : void 0, children: [
|
|
11168
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex items-center justify-between gap-2 text-muted-foreground", children: [
|
|
11169
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "truncate text-foreground", children: title }),
|
|
11170
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { "data-job-progress-label": "", "aria-live": "polite", children: progress.label })
|
|
11050
11171
|
] }),
|
|
11051
|
-
/* @__PURE__ */ (0,
|
|
11172
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11052
11173
|
"div",
|
|
11053
11174
|
{
|
|
11054
11175
|
role: "progressbar",
|
|
@@ -11058,7 +11179,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
11058
11179
|
"aria-valuenow": progress.percent,
|
|
11059
11180
|
"aria-valuetext": `${progress.percent}%, ${progress.label}`,
|
|
11060
11181
|
className: "h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
11061
|
-
children: /* @__PURE__ */ (0,
|
|
11182
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11062
11183
|
"div",
|
|
11063
11184
|
{
|
|
11064
11185
|
className: "h-full rounded-full bg-primary transition-[width] duration-500",
|
|
@@ -11071,9 +11192,9 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
11071
11192
|
};
|
|
11072
11193
|
|
|
11073
11194
|
// src/generation/AssetMentionChips.tsx
|
|
11074
|
-
var
|
|
11195
|
+
var import_react78 = require("react");
|
|
11075
11196
|
var import_generation3 = require("@pixerate/editor/generation");
|
|
11076
|
-
var
|
|
11197
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
11077
11198
|
var AssetMentionChips = ({
|
|
11078
11199
|
content,
|
|
11079
11200
|
onChange,
|
|
@@ -11083,14 +11204,14 @@ var AssetMentionChips = ({
|
|
|
11083
11204
|
renderAsset,
|
|
11084
11205
|
className = ""
|
|
11085
11206
|
}) => {
|
|
11086
|
-
const [open, setOpen] = (0,
|
|
11087
|
-
const rootRef = (0,
|
|
11088
|
-
const chips = (0,
|
|
11207
|
+
const [open, setOpen] = (0, import_react78.useState)(null);
|
|
11208
|
+
const rootRef = (0, import_react78.useRef)(null);
|
|
11209
|
+
const chips = (0, import_react78.useMemo)(
|
|
11089
11210
|
() => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
|
|
11090
11211
|
[content, assets, capabilities]
|
|
11091
11212
|
);
|
|
11092
11213
|
const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
|
|
11093
|
-
(0,
|
|
11214
|
+
(0, import_react78.useEffect)(() => {
|
|
11094
11215
|
if (open === null) return;
|
|
11095
11216
|
const onPointer = (event) => {
|
|
11096
11217
|
if (!rootRef.current?.contains(event.target)) setOpen(null);
|
|
@@ -11104,13 +11225,13 @@ var AssetMentionChips = ({
|
|
|
11104
11225
|
onChange((0, import_generation3.setMentionRoleInText)(content, chip2.start, role));
|
|
11105
11226
|
};
|
|
11106
11227
|
if (chips.length === 0) return null;
|
|
11107
|
-
return /* @__PURE__ */ (0,
|
|
11228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { ref: rootRef, className: `flex flex-wrap gap-1.5 ${className}`, "data-asset-mention-chips": "", children: chips.map((chip2) => {
|
|
11108
11229
|
const error = chip2.issues.find((issue) => issue.severity === "error");
|
|
11109
11230
|
const warning = chip2.issues.find((issue) => issue.severity === "warning");
|
|
11110
11231
|
const problem = error ?? warning;
|
|
11111
11232
|
const isOpen = open === chip2.index;
|
|
11112
|
-
return /* @__PURE__ */ (0,
|
|
11113
|
-
/* @__PURE__ */ (0,
|
|
11233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "relative inline-flex", "data-asset-chip": chip2.asset.id, children: [
|
|
11234
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
11114
11235
|
"button",
|
|
11115
11236
|
{
|
|
11116
11237
|
type: "button",
|
|
@@ -11124,8 +11245,8 @@ var AssetMentionChips = ({
|
|
|
11124
11245
|
},
|
|
11125
11246
|
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`,
|
|
11126
11247
|
children: [
|
|
11127
|
-
/* @__PURE__ */ (0,
|
|
11128
|
-
/* @__PURE__ */ (0,
|
|
11248
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: renderAsset ? renderAsset(chip2) : `@${chip2.asset.label ?? chip2.handle}` }),
|
|
11249
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
11129
11250
|
"span",
|
|
11130
11251
|
{
|
|
11131
11252
|
className: `rounded px-1 text-[10px] uppercase tracking-wide ${chip2.role ? "bg-primary/15" : "opacity-60"}`,
|
|
@@ -11136,7 +11257,7 @@ var AssetMentionChips = ({
|
|
|
11136
11257
|
]
|
|
11137
11258
|
}
|
|
11138
11259
|
),
|
|
11139
|
-
isOpen && /* @__PURE__ */ (0,
|
|
11260
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
11140
11261
|
"div",
|
|
11141
11262
|
{
|
|
11142
11263
|
role: "listbox",
|
|
@@ -11147,7 +11268,7 @@ var AssetMentionChips = ({
|
|
|
11147
11268
|
if (e.key === "Escape") setOpen(null);
|
|
11148
11269
|
},
|
|
11149
11270
|
children: [
|
|
11150
|
-
options.map((option) => /* @__PURE__ */ (0,
|
|
11271
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
11151
11272
|
"button",
|
|
11152
11273
|
{
|
|
11153
11274
|
type: "button",
|
|
@@ -11158,13 +11279,13 @@ var AssetMentionChips = ({
|
|
|
11158
11279
|
onClick: () => pick(chip2, option.role),
|
|
11159
11280
|
className: "flex items-center justify-between gap-2 rounded px-2 py-1 text-left hover:bg-muted",
|
|
11160
11281
|
children: [
|
|
11161
|
-
/* @__PURE__ */ (0,
|
|
11162
|
-
option.accepts?.length ? /* @__PURE__ */ (0,
|
|
11282
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: option.label }),
|
|
11283
|
+
option.accepts?.length ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "text-[10px] opacity-60", children: option.accepts.join(", ") }) : null
|
|
11163
11284
|
]
|
|
11164
11285
|
},
|
|
11165
11286
|
option.role
|
|
11166
11287
|
)),
|
|
11167
|
-
/* @__PURE__ */ (0,
|
|
11288
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
11168
11289
|
"button",
|
|
11169
11290
|
{
|
|
11170
11291
|
type: "button",
|
|
@@ -11176,7 +11297,7 @@ var AssetMentionChips = ({
|
|
|
11176
11297
|
children: "No role"
|
|
11177
11298
|
}
|
|
11178
11299
|
),
|
|
11179
|
-
chip2.issues.length > 0 && /* @__PURE__ */ (0,
|
|
11300
|
+
chip2.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime56.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_runtime56.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : "text-amber-500", children: issue.message }, i)) })
|
|
11180
11301
|
]
|
|
11181
11302
|
}
|
|
11182
11303
|
)
|
|
@@ -11185,15 +11306,15 @@ var AssetMentionChips = ({
|
|
|
11185
11306
|
};
|
|
11186
11307
|
|
|
11187
11308
|
// src/generation/GenerationHistory.tsx
|
|
11188
|
-
var
|
|
11309
|
+
var import_react79 = require("react");
|
|
11189
11310
|
var import_generation4 = require("@pixerate/editor/generation");
|
|
11190
|
-
var
|
|
11311
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
11191
11312
|
function useGenerationRecords(store, filter) {
|
|
11192
|
-
const [records, setRecords] = (0,
|
|
11193
|
-
const [loading, setLoading] = (0,
|
|
11194
|
-
const [error, setError] = (0,
|
|
11313
|
+
const [records, setRecords] = (0, import_react79.useState)([]);
|
|
11314
|
+
const [loading, setLoading] = (0, import_react79.useState)(!!store);
|
|
11315
|
+
const [error, setError] = (0, import_react79.useState)(null);
|
|
11195
11316
|
const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
|
|
11196
|
-
const refresh = (0,
|
|
11317
|
+
const refresh = (0, import_react79.useCallback)(async () => {
|
|
11197
11318
|
if (!store) {
|
|
11198
11319
|
setRecords([]);
|
|
11199
11320
|
setLoading(false);
|
|
@@ -11210,7 +11331,7 @@ function useGenerationRecords(store, filter) {
|
|
|
11210
11331
|
setLoading(false);
|
|
11211
11332
|
}
|
|
11212
11333
|
}, [store, filterKey]);
|
|
11213
|
-
(0,
|
|
11334
|
+
(0, import_react79.useEffect)(() => {
|
|
11214
11335
|
void refresh();
|
|
11215
11336
|
if (!store) return;
|
|
11216
11337
|
return store.subscribe(() => void refresh());
|
|
@@ -11236,21 +11357,21 @@ var GenerationHistory = ({
|
|
|
11236
11357
|
emptyText = "No generations yet.",
|
|
11237
11358
|
className = ""
|
|
11238
11359
|
}) => {
|
|
11239
|
-
const [innerMode, setInnerMode] = (0,
|
|
11360
|
+
const [innerMode, setInnerMode] = (0, import_react79.useState)("exact");
|
|
11240
11361
|
const mode = modeProp ?? innerMode;
|
|
11241
11362
|
const setMode = (next) => {
|
|
11242
11363
|
if (modeProp === void 0) setInnerMode(next);
|
|
11243
11364
|
onModeChange?.(next);
|
|
11244
11365
|
};
|
|
11245
|
-
const options = (0,
|
|
11246
|
-
const results = (0,
|
|
11247
|
-
const models = (0,
|
|
11366
|
+
const options = (0, import_react79.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
|
|
11367
|
+
const results = (0, import_react79.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
|
|
11368
|
+
const models = (0, import_react79.useMemo)(
|
|
11248
11369
|
() => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
|
|
11249
11370
|
[capabilities]
|
|
11250
11371
|
);
|
|
11251
|
-
return /* @__PURE__ */ (0,
|
|
11252
|
-
/* @__PURE__ */ (0,
|
|
11253
|
-
/* @__PURE__ */ (0,
|
|
11372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: `flex flex-col gap-2 text-sm ${className}`, "data-generation-history": "", children: [
|
|
11373
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.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_runtime57.jsxs)("label", { className: "inline-flex items-center gap-1", children: [
|
|
11374
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11254
11375
|
"input",
|
|
11255
11376
|
{
|
|
11256
11377
|
type: "radio",
|
|
@@ -11263,34 +11384,34 @@ var GenerationHistory = ({
|
|
|
11263
11384
|
),
|
|
11264
11385
|
value === "exact" ? "Exact (recorded versions)" : "Latest templates & settings"
|
|
11265
11386
|
] }, value)) }),
|
|
11266
|
-
records.length === 0 && /* @__PURE__ */ (0,
|
|
11267
|
-
/* @__PURE__ */ (0,
|
|
11387
|
+
records.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyText }),
|
|
11388
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className: "flex flex-col gap-2", children: records.map((record, i) => {
|
|
11268
11389
|
const result = results[i];
|
|
11269
11390
|
const model = models.find((m) => m.id === record.provenance.modelId);
|
|
11270
11391
|
const blocked = !result.ok;
|
|
11271
|
-
return /* @__PURE__ */ (0,
|
|
11392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11272
11393
|
"li",
|
|
11273
11394
|
{
|
|
11274
11395
|
className: "rounded-md border border-border p-2",
|
|
11275
11396
|
"data-record": record.id,
|
|
11276
11397
|
"data-drift": result.drift.length,
|
|
11277
11398
|
children: [
|
|
11278
|
-
/* @__PURE__ */ (0,
|
|
11279
|
-
/* @__PURE__ */ (0,
|
|
11280
|
-
/* @__PURE__ */ (0,
|
|
11281
|
-
record.kind !== "generate" && /* @__PURE__ */ (0,
|
|
11399
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs", children: [
|
|
11400
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "font-medium", children: model?.name ?? record.provenance.modelId }),
|
|
11401
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
11402
|
+
record.kind !== "generate" && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { "data-kind": "", children: [
|
|
11282
11403
|
record.kind,
|
|
11283
11404
|
" \xB7 "
|
|
11284
11405
|
] }),
|
|
11285
|
-
/* @__PURE__ */ (0,
|
|
11286
|
-
record.seed !== void 0 && /* @__PURE__ */ (0,
|
|
11406
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("time", { dateTime: record.createdAt, children: record.createdAt.replace("T", " ").slice(0, 16) }),
|
|
11407
|
+
record.seed !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
|
|
11287
11408
|
" \xB7 seed ",
|
|
11288
11409
|
record.seed
|
|
11289
11410
|
] })
|
|
11290
11411
|
] })
|
|
11291
11412
|
] }),
|
|
11292
|
-
/* @__PURE__ */ (0,
|
|
11293
|
-
record.assets.length > 0 && /* @__PURE__ */ (0,
|
|
11413
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "mt-1 line-clamp-3 break-words text-xs", "data-record-prompt": "", children: record.provenance.resolvedPrompt }),
|
|
11414
|
+
record.assets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children: record.assets.map((asset) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11294
11415
|
"span",
|
|
11295
11416
|
{
|
|
11296
11417
|
className: "rounded-full bg-muted px-2 py-0.5 text-[10px]",
|
|
@@ -11304,16 +11425,16 @@ var GenerationHistory = ({
|
|
|
11304
11425
|
`${asset.role}:${asset.id}`
|
|
11305
11426
|
)) }),
|
|
11306
11427
|
renderPreview?.(record),
|
|
11307
|
-
result.drift.length > 0 && /* @__PURE__ */ (0,
|
|
11308
|
-
/* @__PURE__ */ (0,
|
|
11428
|
+
result.drift.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.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_runtime57.jsxs)("li", { className: severityClass[item.severity], "data-drift-type": item.type, children: [
|
|
11429
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("strong", { children: [
|
|
11309
11430
|
import_generation4.DRIFT_TYPE_LABELS[item.type],
|
|
11310
11431
|
":"
|
|
11311
11432
|
] }),
|
|
11312
11433
|
" ",
|
|
11313
11434
|
item.message
|
|
11314
11435
|
] }, j)) }),
|
|
11315
|
-
/* @__PURE__ */ (0,
|
|
11316
|
-
onRecreate && /* @__PURE__ */ (0,
|
|
11436
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "mt-2 flex gap-2", children: [
|
|
11437
|
+
onRecreate && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11317
11438
|
"button",
|
|
11318
11439
|
{
|
|
11319
11440
|
type: "button",
|
|
@@ -11325,7 +11446,7 @@ var GenerationHistory = ({
|
|
|
11325
11446
|
children: "Recreate"
|
|
11326
11447
|
}
|
|
11327
11448
|
),
|
|
11328
|
-
onVariation && /* @__PURE__ */ (0,
|
|
11449
|
+
onVariation && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11329
11450
|
"button",
|
|
11330
11451
|
{
|
|
11331
11452
|
type: "button",
|
|
@@ -11335,7 +11456,7 @@ var GenerationHistory = ({
|
|
|
11335
11456
|
children: "Variation"
|
|
11336
11457
|
}
|
|
11337
11458
|
),
|
|
11338
|
-
onRemove && /* @__PURE__ */ (0,
|
|
11459
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11339
11460
|
"button",
|
|
11340
11461
|
{
|
|
11341
11462
|
type: "button",
|
|
@@ -11355,19 +11476,19 @@ var GenerationHistory = ({
|
|
|
11355
11476
|
};
|
|
11356
11477
|
|
|
11357
11478
|
// src/find-replace/useFindReplace.ts
|
|
11358
|
-
var
|
|
11479
|
+
var import_react80 = require("react");
|
|
11359
11480
|
var import_editor17 = require("@pixerate/editor");
|
|
11360
11481
|
var noopUnsubscribe2 = () => {
|
|
11361
11482
|
};
|
|
11362
11483
|
function useFindReplace(editor) {
|
|
11363
11484
|
const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
|
|
11364
|
-
const subscribe = (0,
|
|
11485
|
+
const subscribe = (0, import_react80.useCallback)(
|
|
11365
11486
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
11366
11487
|
[store]
|
|
11367
11488
|
);
|
|
11368
11489
|
const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
11369
|
-
const snapshot = (0,
|
|
11370
|
-
return (0,
|
|
11490
|
+
const snapshot = (0, import_react80.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11491
|
+
return (0, import_react80.useMemo)(() => {
|
|
11371
11492
|
const run = (fn) => {
|
|
11372
11493
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
11373
11494
|
};
|
|
@@ -11391,9 +11512,9 @@ function useFindReplace(editor) {
|
|
|
11391
11512
|
}
|
|
11392
11513
|
|
|
11393
11514
|
// src/find-replace/FindReplaceBar.tsx
|
|
11394
|
-
var
|
|
11515
|
+
var import_react81 = require("react");
|
|
11395
11516
|
var import_editor18 = require("@pixerate/editor");
|
|
11396
|
-
var
|
|
11517
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
11397
11518
|
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";
|
|
11398
11519
|
var buttonClass5 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
11399
11520
|
var toggleClass = (on) => `${buttonClass5} font-mono ${on ? "bg-primary/10 text-primary" : "text-muted-foreground"}`;
|
|
@@ -11406,10 +11527,10 @@ var FindReplaceBar = ({
|
|
|
11406
11527
|
onClose
|
|
11407
11528
|
}) => {
|
|
11408
11529
|
const find = useFindReplace(editor);
|
|
11409
|
-
const findInput = (0,
|
|
11410
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
11530
|
+
const findInput = (0, import_react81.useRef)(null);
|
|
11531
|
+
const [moreOpen, setMoreOpen] = (0, import_react81.useState)(false);
|
|
11411
11532
|
const visible = find.available && (alwaysOpen || find.open);
|
|
11412
|
-
(0,
|
|
11533
|
+
(0, import_react81.useEffect)(() => {
|
|
11413
11534
|
if (!visible || find.focusRequest === 0) return;
|
|
11414
11535
|
findInput.current?.focus();
|
|
11415
11536
|
findInput.current?.select();
|
|
@@ -11447,9 +11568,9 @@ var FindReplaceBar = ({
|
|
|
11447
11568
|
if (isMod(e)) find.replaceAll();
|
|
11448
11569
|
else find.replace();
|
|
11449
11570
|
};
|
|
11450
|
-
return /* @__PURE__ */ (0,
|
|
11451
|
-
/* @__PURE__ */ (0,
|
|
11452
|
-
/* @__PURE__ */ (0,
|
|
11571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className, role: "search", "aria-label": "Find and replace", onKeyDown: onBarKeyDown, children: [
|
|
11572
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
11573
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11453
11574
|
"button",
|
|
11454
11575
|
{
|
|
11455
11576
|
type: "button",
|
|
@@ -11460,7 +11581,7 @@ var FindReplaceBar = ({
|
|
|
11460
11581
|
children: showReplace ? "\u25BE" : "\u25B8"
|
|
11461
11582
|
}
|
|
11462
11583
|
),
|
|
11463
|
-
/* @__PURE__ */ (0,
|
|
11584
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11464
11585
|
"input",
|
|
11465
11586
|
{
|
|
11466
11587
|
ref: findInput,
|
|
@@ -11474,7 +11595,7 @@ var FindReplaceBar = ({
|
|
|
11474
11595
|
onKeyDown: onFindKeyDown
|
|
11475
11596
|
}
|
|
11476
11597
|
),
|
|
11477
|
-
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0,
|
|
11598
|
+
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11478
11599
|
"button",
|
|
11479
11600
|
{
|
|
11480
11601
|
type: "button",
|
|
@@ -11487,7 +11608,7 @@ var FindReplaceBar = ({
|
|
|
11487
11608
|
},
|
|
11488
11609
|
t.key
|
|
11489
11610
|
)),
|
|
11490
|
-
/* @__PURE__ */ (0,
|
|
11611
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11491
11612
|
"span",
|
|
11492
11613
|
{
|
|
11493
11614
|
className: `min-w-[5rem] px-1 text-center text-xs ${find.error ? "text-destructive" : "text-muted-foreground"}`,
|
|
@@ -11497,9 +11618,9 @@ var FindReplaceBar = ({
|
|
|
11497
11618
|
children: status
|
|
11498
11619
|
}
|
|
11499
11620
|
),
|
|
11500
|
-
/* @__PURE__ */ (0,
|
|
11501
|
-
/* @__PURE__ */ (0,
|
|
11502
|
-
showMoreOptions && /* @__PURE__ */ (0,
|
|
11621
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Previous match", disabled: !hasMatches, onClick: find.previous, children: "\u2191" }),
|
|
11622
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Next match", disabled: !hasMatches, onClick: find.next, children: "\u2193" }),
|
|
11623
|
+
showMoreOptions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11503
11624
|
"button",
|
|
11504
11625
|
{
|
|
11505
11626
|
type: "button",
|
|
@@ -11510,10 +11631,10 @@ var FindReplaceBar = ({
|
|
|
11510
11631
|
children: "\u2026"
|
|
11511
11632
|
}
|
|
11512
11633
|
),
|
|
11513
|
-
/* @__PURE__ */ (0,
|
|
11634
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Close find", onClick: close, children: "\xD7" })
|
|
11514
11635
|
] }),
|
|
11515
|
-
showReplace && /* @__PURE__ */ (0,
|
|
11516
|
-
/* @__PURE__ */ (0,
|
|
11636
|
+
showReplace && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-1 pl-7", children: [
|
|
11637
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11517
11638
|
"input",
|
|
11518
11639
|
{
|
|
11519
11640
|
type: "text",
|
|
@@ -11525,7 +11646,7 @@ var FindReplaceBar = ({
|
|
|
11525
11646
|
onKeyDown: onReplaceKeyDown
|
|
11526
11647
|
}
|
|
11527
11648
|
),
|
|
11528
|
-
/* @__PURE__ */ (0,
|
|
11649
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11529
11650
|
"button",
|
|
11530
11651
|
{
|
|
11531
11652
|
type: "button",
|
|
@@ -11535,11 +11656,11 @@ var FindReplaceBar = ({
|
|
|
11535
11656
|
children: "Replace"
|
|
11536
11657
|
}
|
|
11537
11658
|
),
|
|
11538
|
-
/* @__PURE__ */ (0,
|
|
11539
|
-
find.lastReplaceCount !== null && /* @__PURE__ */ (0,
|
|
11659
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, disabled: !hasMatches, onClick: find.replaceAll, children: "Replace all" }),
|
|
11660
|
+
find.lastReplaceCount !== null && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "px-1 text-xs text-muted-foreground", "aria-live": "polite", children: find.lastReplaceCount === 1 ? "1 replaced" : `${find.lastReplaceCount} replaced` })
|
|
11540
11661
|
] }),
|
|
11541
|
-
showMoreOptions && moreOpen && /* @__PURE__ */ (0,
|
|
11542
|
-
/* @__PURE__ */ (0,
|
|
11662
|
+
showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime58.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_runtime58.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
11663
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11543
11664
|
"input",
|
|
11544
11665
|
{
|
|
11545
11666
|
type: "checkbox",
|
|
@@ -11553,12 +11674,12 @@ var FindReplaceBar = ({
|
|
|
11553
11674
|
};
|
|
11554
11675
|
|
|
11555
11676
|
// src/tables/useTableMenu.ts
|
|
11556
|
-
var
|
|
11677
|
+
var import_react82 = require("react");
|
|
11557
11678
|
var import_editor19 = require("@pixerate/editor");
|
|
11558
11679
|
function useTableMenu(editor) {
|
|
11559
|
-
const store = (0,
|
|
11560
|
-
const snapshot = (0,
|
|
11561
|
-
return (0,
|
|
11680
|
+
const store = (0, import_react82.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
|
|
11681
|
+
const snapshot = (0, import_react82.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
11682
|
+
return (0, import_react82.useMemo)(
|
|
11562
11683
|
() => ({
|
|
11563
11684
|
...snapshot,
|
|
11564
11685
|
run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
|
|
@@ -11569,9 +11690,9 @@ function useTableMenu(editor) {
|
|
|
11569
11690
|
}
|
|
11570
11691
|
|
|
11571
11692
|
// src/tables/TableToolbar.tsx
|
|
11572
|
-
var
|
|
11693
|
+
var import_react83 = __toESM(require("react"), 1);
|
|
11573
11694
|
var import_editor20 = require("@pixerate/editor");
|
|
11574
|
-
var
|
|
11695
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
11575
11696
|
var keepSelection2 = (event) => event.preventDefault();
|
|
11576
11697
|
var TableToolbar = ({
|
|
11577
11698
|
editor,
|
|
@@ -11585,14 +11706,14 @@ var TableToolbar = ({
|
|
|
11585
11706
|
}) => {
|
|
11586
11707
|
const table = useTableMenu(editor);
|
|
11587
11708
|
if (!editor || !table.inTable && !showWhenOutside) return null;
|
|
11588
|
-
return /* @__PURE__ */ (0,
|
|
11709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, role: "toolbar", "aria-label": "Table", "data-table-toolbar": "", children: items.map((item, index) => {
|
|
11589
11710
|
const status = table.check(item.action, item.params);
|
|
11590
11711
|
const enabled = status === true;
|
|
11591
11712
|
const active = item.active?.(table);
|
|
11592
11713
|
const separator = index > 0 && items[index - 1].group !== item.group;
|
|
11593
|
-
return /* @__PURE__ */ (0,
|
|
11594
|
-
separator && /* @__PURE__ */ (0,
|
|
11595
|
-
/* @__PURE__ */ (0,
|
|
11714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react83.default.Fragment, { children: [
|
|
11715
|
+
separator && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
|
|
11716
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
11596
11717
|
"button",
|
|
11597
11718
|
{
|
|
11598
11719
|
type: "button",
|
|
@@ -11614,8 +11735,8 @@ var TableToolbar = ({
|
|
|
11614
11735
|
};
|
|
11615
11736
|
|
|
11616
11737
|
// src/tables/InsertTableGrid.tsx
|
|
11617
|
-
var
|
|
11618
|
-
var
|
|
11738
|
+
var import_react84 = require("react");
|
|
11739
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
11619
11740
|
var keepSelection3 = (event) => event.preventDefault();
|
|
11620
11741
|
var InsertTableGrid = ({
|
|
11621
11742
|
editor,
|
|
@@ -11628,14 +11749,14 @@ var InsertTableGrid = ({
|
|
|
11628
11749
|
onInsert
|
|
11629
11750
|
}) => {
|
|
11630
11751
|
const table = useTableMenu(editor);
|
|
11631
|
-
const [hover, setHover] = (0,
|
|
11752
|
+
const [hover, setHover] = (0, import_react84.useState)(null);
|
|
11632
11753
|
const status = table.actions.insertTable;
|
|
11633
11754
|
const disabled = !editor || !status.enabled;
|
|
11634
11755
|
const insert = (size) => {
|
|
11635
11756
|
if (table.run("insertTable", { ...size, withHeaderRow })) onInsert?.(size);
|
|
11636
11757
|
setHover(null);
|
|
11637
11758
|
};
|
|
11638
|
-
return /* @__PURE__ */ (0,
|
|
11759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
11639
11760
|
"div",
|
|
11640
11761
|
{
|
|
11641
11762
|
className,
|
|
@@ -11645,7 +11766,7 @@ var InsertTableGrid = ({
|
|
|
11645
11766
|
"data-insert-table-grid": "",
|
|
11646
11767
|
onMouseLeave: () => setHover(null),
|
|
11647
11768
|
children: [
|
|
11648
|
-
/* @__PURE__ */ (0,
|
|
11769
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
11649
11770
|
"div",
|
|
11650
11771
|
{
|
|
11651
11772
|
role: "grid",
|
|
@@ -11654,7 +11775,7 @@ var InsertTableGrid = ({
|
|
|
11654
11775
|
children: Array.from({ length: rows * cols }, (_, i) => {
|
|
11655
11776
|
const size = { rows: Math.floor(i / cols) + 1, cols: i % cols + 1 };
|
|
11656
11777
|
const active = !!hover && size.rows <= hover.rows && size.cols <= hover.cols;
|
|
11657
|
-
return /* @__PURE__ */ (0,
|
|
11778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
11658
11779
|
"button",
|
|
11659
11780
|
{
|
|
11660
11781
|
type: "button",
|
|
@@ -11674,7 +11795,7 @@ var InsertTableGrid = ({
|
|
|
11674
11795
|
})
|
|
11675
11796
|
}
|
|
11676
11797
|
),
|
|
11677
|
-
/* @__PURE__ */ (0,
|
|
11798
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { "aria-live": "polite", "data-testid": "insert-table-size", children: disabled ? status.reason : hover ? `${hover.rows} \xD7 ${hover.cols}` : "Insert table" })
|
|
11678
11799
|
]
|
|
11679
11800
|
}
|
|
11680
11801
|
);
|
|
@@ -11682,31 +11803,31 @@ var InsertTableGrid = ({
|
|
|
11682
11803
|
|
|
11683
11804
|
// src/tables/TableBubbleMenu.tsx
|
|
11684
11805
|
var import_editor21 = require("@pixerate/editor");
|
|
11685
|
-
var
|
|
11806
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
11686
11807
|
var TableBubbleMenu = ({
|
|
11687
11808
|
editor,
|
|
11688
11809
|
children,
|
|
11689
11810
|
toolbarProps,
|
|
11690
11811
|
pluginKey = "tableBubbleMenu",
|
|
11691
11812
|
...rest
|
|
11692
|
-
}) => /* @__PURE__ */ (0,
|
|
11813
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor21.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TableToolbar, { editor, ...toolbarProps }) });
|
|
11693
11814
|
|
|
11694
11815
|
// src/chart-node/ChartNodeView.tsx
|
|
11695
11816
|
var import_client = require("react-dom/client");
|
|
11696
11817
|
|
|
11697
11818
|
// src/chart/ChartCanvas.tsx
|
|
11698
|
-
var
|
|
11819
|
+
var import_react86 = require("react");
|
|
11699
11820
|
var import_chart2 = require("@pixerate/editor/chart");
|
|
11700
11821
|
|
|
11701
11822
|
// src/chart/useChartEditor.ts
|
|
11702
|
-
var
|
|
11823
|
+
var import_react85 = require("react");
|
|
11703
11824
|
var import_chart = require("@pixerate/editor/chart");
|
|
11704
11825
|
function useChartState(controller) {
|
|
11705
|
-
return (0,
|
|
11826
|
+
return (0, import_react85.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
11706
11827
|
}
|
|
11707
11828
|
|
|
11708
11829
|
// src/chart/ChartCanvas.tsx
|
|
11709
|
-
var
|
|
11830
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
11710
11831
|
function renderChartMark(mark, fontFamily, interactive) {
|
|
11711
11832
|
const common = {
|
|
11712
11833
|
"data-role": mark.role,
|
|
@@ -11718,9 +11839,9 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11718
11839
|
};
|
|
11719
11840
|
switch (mark.kind) {
|
|
11720
11841
|
case "rect":
|
|
11721
|
-
return /* @__PURE__ */ (0,
|
|
11842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.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);
|
|
11722
11843
|
case "path":
|
|
11723
|
-
return /* @__PURE__ */ (0,
|
|
11844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11724
11845
|
"path",
|
|
11725
11846
|
{
|
|
11726
11847
|
...common,
|
|
@@ -11733,11 +11854,11 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11733
11854
|
mark.key
|
|
11734
11855
|
);
|
|
11735
11856
|
case "circle":
|
|
11736
|
-
return /* @__PURE__ */ (0,
|
|
11857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
11737
11858
|
case "line":
|
|
11738
|
-
return /* @__PURE__ */ (0,
|
|
11859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.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);
|
|
11739
11860
|
case "text":
|
|
11740
|
-
return /* @__PURE__ */ (0,
|
|
11861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11741
11862
|
"text",
|
|
11742
11863
|
{
|
|
11743
11864
|
...common,
|
|
@@ -11754,36 +11875,36 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11754
11875
|
}
|
|
11755
11876
|
}
|
|
11756
11877
|
function ChartPresenceLayer({ presence }) {
|
|
11757
|
-
const { actors } = (0,
|
|
11758
|
-
return /* @__PURE__ */ (0,
|
|
11759
|
-
/* @__PURE__ */ (0,
|
|
11760
|
-
/* @__PURE__ */ (0,
|
|
11761
|
-
/* @__PURE__ */ (0,
|
|
11762
|
-
/* @__PURE__ */ (0,
|
|
11878
|
+
const { actors } = (0, import_react86.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
11879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
|
|
11880
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.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 }),
|
|
11881
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("g", { transform: "translate(13 16)", children: [
|
|
11882
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.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 } }),
|
|
11883
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("text", { x: 6, y: 9, dominantBaseline: "central", style: { fill: "#ffffff", fontSize: 11, fontWeight: 600, fontFamily: "inherit" }, children: a.message ?? a.name })
|
|
11763
11884
|
] })
|
|
11764
11885
|
] }, a.id)) });
|
|
11765
11886
|
}
|
|
11766
11887
|
function ChartTooltipContent({ tooltip }) {
|
|
11767
|
-
return /* @__PURE__ */ (0,
|
|
11768
|
-
tooltip.title && /* @__PURE__ */ (0,
|
|
11769
|
-
tooltip.items.map((item) => /* @__PURE__ */ (0,
|
|
11770
|
-
/* @__PURE__ */ (0,
|
|
11771
|
-
/* @__PURE__ */ (0,
|
|
11772
|
-
/* @__PURE__ */ (0,
|
|
11888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
|
|
11889
|
+
tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
|
|
11890
|
+
tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11891
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
|
|
11892
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
|
|
11893
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
|
|
11773
11894
|
] }, item.seriesId))
|
|
11774
11895
|
] });
|
|
11775
11896
|
}
|
|
11776
11897
|
function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
|
|
11777
11898
|
const state = useChartState(controller);
|
|
11778
|
-
const wrapper = (0,
|
|
11779
|
-
const svg = (0,
|
|
11780
|
-
const drag = (0,
|
|
11781
|
-
const [measured, setMeasured] = (0,
|
|
11782
|
-
const [frozen, setFrozen] = (0,
|
|
11899
|
+
const wrapper = (0, import_react86.useRef)(null);
|
|
11900
|
+
const svg = (0, import_react86.useRef)(null);
|
|
11901
|
+
const drag = (0, import_react86.useRef)(null);
|
|
11902
|
+
const [measured, setMeasured] = (0, import_react86.useState)(null);
|
|
11903
|
+
const [frozen, setFrozen] = (0, import_react86.useState)(null);
|
|
11783
11904
|
const tooltipMode = tooltip === true ? "point" : tooltip || null;
|
|
11784
|
-
const [tip, setTip] = (0,
|
|
11785
|
-
const [tipAt, setTipAt] = (0,
|
|
11786
|
-
(0,
|
|
11905
|
+
const [tip, setTip] = (0, import_react86.useState)(null);
|
|
11906
|
+
const [tipAt, setTipAt] = (0, import_react86.useState)({ left: 0, top: 0, flip: false });
|
|
11907
|
+
(0, import_react86.useEffect)(() => {
|
|
11787
11908
|
const el = wrapper.current;
|
|
11788
11909
|
if (!responsive || !el || typeof ResizeObserver === "undefined") return;
|
|
11789
11910
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -11794,8 +11915,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11794
11915
|
return () => observer.disconnect();
|
|
11795
11916
|
}, [responsive]);
|
|
11796
11917
|
const sceneWidth = responsive && measured || width;
|
|
11797
|
-
const fullTheme = (0,
|
|
11798
|
-
const scene = (0,
|
|
11918
|
+
const fullTheme = (0, import_react86.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
|
|
11919
|
+
const scene = (0, import_react86.useMemo)(
|
|
11799
11920
|
() => (0, import_chart2.layoutChart)(state.spec, {
|
|
11800
11921
|
width: sceneWidth,
|
|
11801
11922
|
height,
|
|
@@ -11812,8 +11933,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11812
11933
|
[state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
|
|
11813
11934
|
);
|
|
11814
11935
|
if (sceneRef) sceneRef.current = scene;
|
|
11815
|
-
const byKey = (0,
|
|
11816
|
-
(0,
|
|
11936
|
+
const byKey = (0, import_react86.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
|
|
11937
|
+
(0, import_react86.useEffect)(() => () => drag.current?.end(), []);
|
|
11817
11938
|
const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
|
|
11818
11939
|
const onPointerDown = (e) => {
|
|
11819
11940
|
if (!editable || e.button !== 0) return;
|
|
@@ -11860,8 +11981,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11860
11981
|
if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
|
|
11861
11982
|
};
|
|
11862
11983
|
const label = state.spec.title || "Chart";
|
|
11863
|
-
return /* @__PURE__ */ (0,
|
|
11864
|
-
/* @__PURE__ */ (0,
|
|
11984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
|
|
11985
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
|
|
11865
11986
|
"svg",
|
|
11866
11987
|
{
|
|
11867
11988
|
ref: svg,
|
|
@@ -11880,11 +12001,11 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11880
12001
|
onKeyDown,
|
|
11881
12002
|
children: [
|
|
11882
12003
|
scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
|
|
11883
|
-
presence && /* @__PURE__ */ (0,
|
|
12004
|
+
presence && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ChartPresenceLayer, { presence })
|
|
11884
12005
|
]
|
|
11885
12006
|
}
|
|
11886
12007
|
),
|
|
11887
|
-
tip && /* @__PURE__ */ (0,
|
|
12008
|
+
tip && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11888
12009
|
"div",
|
|
11889
12010
|
{
|
|
11890
12011
|
role: "tooltip",
|
|
@@ -11899,14 +12020,14 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11899
12020
|
borderColor: "var(--border, #e2e8f0)",
|
|
11900
12021
|
fontFamily: scene.theme.fontFamily
|
|
11901
12022
|
},
|
|
11902
|
-
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0,
|
|
12023
|
+
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ChartTooltipContent, { tooltip: tip })
|
|
11903
12024
|
}
|
|
11904
12025
|
)
|
|
11905
12026
|
] });
|
|
11906
12027
|
}
|
|
11907
12028
|
|
|
11908
12029
|
// src/chart/ChartDataGrid.tsx
|
|
11909
|
-
var
|
|
12030
|
+
var import_react87 = require("react");
|
|
11910
12031
|
var import_chart3 = require("@pixerate/editor/chart");
|
|
11911
12032
|
|
|
11912
12033
|
// src/chart/styles.ts
|
|
@@ -11919,11 +12040,11 @@ var chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
|
|
|
11919
12040
|
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";
|
|
11920
12041
|
|
|
11921
12042
|
// src/chart/ChartDataGrid.tsx
|
|
11922
|
-
var
|
|
12043
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
11923
12044
|
function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
11924
|
-
const [draft, setDraft] = (0,
|
|
11925
|
-
const typing = (0,
|
|
11926
|
-
(0,
|
|
12045
|
+
const [draft, setDraft] = (0, import_react87.useState)(value);
|
|
12046
|
+
const typing = (0, import_react87.useRef)(false);
|
|
12047
|
+
(0, import_react87.useEffect)(() => {
|
|
11927
12048
|
if (!typing.current) setDraft(value);
|
|
11928
12049
|
}, [value]);
|
|
11929
12050
|
const commit = () => {
|
|
@@ -11932,7 +12053,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
11932
12053
|
if (draft === value) return;
|
|
11933
12054
|
if (onCommit(draft) === false) setDraft(value);
|
|
11934
12055
|
};
|
|
11935
|
-
return /* @__PURE__ */ (0,
|
|
12056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11936
12057
|
"input",
|
|
11937
12058
|
{
|
|
11938
12059
|
...rest,
|
|
@@ -11961,20 +12082,20 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
11961
12082
|
}
|
|
11962
12083
|
function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
11963
12084
|
const { spec } = useChartState(controller);
|
|
11964
|
-
const [columns, setColumns] = (0,
|
|
12085
|
+
const [columns, setColumns] = (0, import_react87.useState)(1);
|
|
11965
12086
|
const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
|
|
11966
12087
|
const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
|
|
11967
12088
|
const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
|
|
11968
12089
|
const commit = (next) => controller.setTreeRows(next).ok;
|
|
11969
|
-
return /* @__PURE__ */ (0,
|
|
11970
|
-
/* @__PURE__ */ (0,
|
|
11971
|
-
/* @__PURE__ */ (0,
|
|
11972
|
-
labels.map((label) => /* @__PURE__ */ (0,
|
|
11973
|
-
/* @__PURE__ */ (0,
|
|
11974
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
|
|
12091
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12092
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12093
|
+
labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
12094
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
12095
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border" })
|
|
11975
12096
|
] }) }),
|
|
11976
|
-
/* @__PURE__ */ (0,
|
|
11977
|
-
labels.map((_, k) => /* @__PURE__ */ (0,
|
|
12097
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-tree-row": r, children: [
|
|
12098
|
+
labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11978
12099
|
ChartCommitInput,
|
|
11979
12100
|
{
|
|
11980
12101
|
value: row.path[k] ?? "",
|
|
@@ -11985,7 +12106,7 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
11985
12106
|
className: `${chartCellClass} text-left`
|
|
11986
12107
|
}
|
|
11987
12108
|
) }, k)),
|
|
11988
|
-
/* @__PURE__ */ (0,
|
|
12109
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11989
12110
|
ChartCommitInput,
|
|
11990
12111
|
{
|
|
11991
12112
|
value: String(row.value),
|
|
@@ -11998,14 +12119,14 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
11998
12119
|
className: chartCellClass
|
|
11999
12120
|
}
|
|
12000
12121
|
) }),
|
|
12001
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12122
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.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" }) })
|
|
12002
12123
|
] }, r)) })
|
|
12003
12124
|
] }),
|
|
12004
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12005
|
-
/* @__PURE__ */ (0,
|
|
12006
|
-
/* @__PURE__ */ (0,
|
|
12007
|
-
/* @__PURE__ */ (0,
|
|
12008
|
-
/* @__PURE__ */ (0,
|
|
12125
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
12126
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.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" }),
|
|
12127
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
|
|
12128
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "flex-1" }),
|
|
12129
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.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" })
|
|
12009
12130
|
] })
|
|
12010
12131
|
] });
|
|
12011
12132
|
}
|
|
@@ -12013,30 +12134,30 @@ function ChartLinksGrid({ controller, readOnly = false, className }) {
|
|
|
12013
12134
|
const { spec } = useChartState(controller);
|
|
12014
12135
|
const links = spec.links;
|
|
12015
12136
|
const commit = (next) => controller.setLinks(next).ok;
|
|
12016
|
-
return /* @__PURE__ */ (0,
|
|
12017
|
-
/* @__PURE__ */ (0,
|
|
12018
|
-
/* @__PURE__ */ (0,
|
|
12019
|
-
["Source", "Target"].map((label) => /* @__PURE__ */ (0,
|
|
12020
|
-
/* @__PURE__ */ (0,
|
|
12021
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-links-grid": "", children: [
|
|
12138
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12139
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12140
|
+
["Source", "Target"].map((label) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
12141
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
12142
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border" })
|
|
12022
12143
|
] }) }),
|
|
12023
|
-
/* @__PURE__ */ (0,
|
|
12024
|
-
["source", "target"].map((field) => /* @__PURE__ */ (0,
|
|
12025
|
-
/* @__PURE__ */ (0,
|
|
12026
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12144
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: links.map((link, i) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-link-row": i, children: [
|
|
12145
|
+
["source", "target"].map((field) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.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)),
|
|
12146
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.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 }) }),
|
|
12147
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.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" }) })
|
|
12027
12148
|
] }, i)) })
|
|
12028
12149
|
] }),
|
|
12029
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12030
|
-
/* @__PURE__ */ (0,
|
|
12031
|
-
/* @__PURE__ */ (0,
|
|
12032
|
-
links.length > 0 && /* @__PURE__ */ (0,
|
|
12150
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
12151
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "link-add", onClick: () => commit((0, import_chart3.addChartLink)(links)), children: "+ Add flow" }),
|
|
12152
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "flex-1" }),
|
|
12153
|
+
links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.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" })
|
|
12033
12154
|
] })
|
|
12034
12155
|
] });
|
|
12035
12156
|
}
|
|
12036
12157
|
function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
|
|
12037
12158
|
const { spec, selection } = useChartState(controller);
|
|
12038
|
-
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0,
|
|
12039
|
-
if (spec.tree.length) return /* @__PURE__ */ (0,
|
|
12159
|
+
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartLinksGrid, { controller, readOnly, className });
|
|
12160
|
+
if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartTreeGrid, { controller, readOnly, className });
|
|
12040
12161
|
const canGroup = spec.type === "treemap" || spec.type === "sunburst";
|
|
12041
12162
|
const paste = (row, column) => (e) => {
|
|
12042
12163
|
const text = e.clipboardData?.getData("text/plain") ?? "";
|
|
@@ -12044,15 +12165,15 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12044
12165
|
e.preventDefault();
|
|
12045
12166
|
controller.pasteCells(row, column, text);
|
|
12046
12167
|
};
|
|
12047
|
-
return /* @__PURE__ */ (0,
|
|
12048
|
-
/* @__PURE__ */ (0,
|
|
12049
|
-
/* @__PURE__ */ (0,
|
|
12050
|
-
/* @__PURE__ */ (0,
|
|
12168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", children: [
|
|
12169
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12170
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12171
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: categoryHeader }),
|
|
12051
12172
|
spec.series.map((s, si) => {
|
|
12052
12173
|
const color = (0, import_chart3.chartSeriesColor)(spec, si);
|
|
12053
12174
|
const selected = selection?.kind === "series" && selection.seriesId === s.id;
|
|
12054
|
-
return /* @__PURE__ */ (0,
|
|
12055
|
-
/* @__PURE__ */ (0,
|
|
12175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.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_runtime63.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12176
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12056
12177
|
"input",
|
|
12057
12178
|
{
|
|
12058
12179
|
type: "color",
|
|
@@ -12065,7 +12186,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12065
12186
|
className: "h-5 w-5 shrink-0 cursor-pointer rounded border-0 bg-transparent p-0"
|
|
12066
12187
|
}
|
|
12067
12188
|
),
|
|
12068
|
-
/* @__PURE__ */ (0,
|
|
12189
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12069
12190
|
ChartCommitInput,
|
|
12070
12191
|
{
|
|
12071
12192
|
value: s.name,
|
|
@@ -12075,8 +12196,8 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12075
12196
|
className: `${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? "text-muted-foreground line-through" : ""}`
|
|
12076
12197
|
}
|
|
12077
12198
|
),
|
|
12078
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12079
|
-
/* @__PURE__ */ (0,
|
|
12199
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
|
|
12200
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12080
12201
|
"button",
|
|
12081
12202
|
{
|
|
12082
12203
|
type: "button",
|
|
@@ -12089,16 +12210,16 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12089
12210
|
children: s.hidden ? "\u25CB" : "\u25CF"
|
|
12090
12211
|
}
|
|
12091
12212
|
),
|
|
12092
|
-
/* @__PURE__ */ (0,
|
|
12213
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.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" })
|
|
12093
12214
|
] })
|
|
12094
12215
|
] }) }, s.id);
|
|
12095
12216
|
}),
|
|
12096
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12217
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Add series", "aria-label": "Add series", "data-action": "add-series", onClick: () => controller.addSeries(), children: "+" }) })
|
|
12097
12218
|
] }) }),
|
|
12098
|
-
/* @__PURE__ */ (0,
|
|
12219
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: spec.categories.map((category, i) => {
|
|
12099
12220
|
const rowSelected = selection?.kind === "category" && selection.index === i;
|
|
12100
|
-
return /* @__PURE__ */ (0,
|
|
12101
|
-
/* @__PURE__ */ (0,
|
|
12221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-category-index": i, className: rowSelected ? "bg-primary/10" : void 0, children: [
|
|
12222
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border p-0 text-left font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12102
12223
|
ChartCommitInput,
|
|
12103
12224
|
{
|
|
12104
12225
|
value: category,
|
|
@@ -12112,7 +12233,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12112
12233
|
spec.series.map((s) => {
|
|
12113
12234
|
const value = s.values[i];
|
|
12114
12235
|
const selected = selection?.kind === "point" && selection.seriesId === s.id && selection.index === i;
|
|
12115
|
-
return /* @__PURE__ */ (0,
|
|
12236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: `border-b border-r border-border p-0 ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12116
12237
|
ChartCommitInput,
|
|
12117
12238
|
{
|
|
12118
12239
|
value: value === null || value === void 0 ? "" : String(value),
|
|
@@ -12127,13 +12248,13 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12127
12248
|
}
|
|
12128
12249
|
) }, s.id);
|
|
12129
12250
|
}),
|
|
12130
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12251
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete category", "aria-label": `Delete ${category}`, "data-action": "remove-category", onClick: () => controller.removeCategory(i), children: "\xD7" }) })
|
|
12131
12252
|
] }, i);
|
|
12132
12253
|
}) })
|
|
12133
12254
|
] }),
|
|
12134
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12135
|
-
/* @__PURE__ */ (0,
|
|
12136
|
-
canGroup && /* @__PURE__ */ (0,
|
|
12255
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "p-1", children: [
|
|
12256
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
|
|
12257
|
+
canGroup && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12137
12258
|
"button",
|
|
12138
12259
|
{
|
|
12139
12260
|
type: "button",
|
|
@@ -12149,29 +12270,29 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
12149
12270
|
}
|
|
12150
12271
|
|
|
12151
12272
|
// src/chart/ChartInspector.tsx
|
|
12152
|
-
var
|
|
12273
|
+
var import_react88 = require("react");
|
|
12153
12274
|
var import_chart4 = require("@pixerate/editor/chart");
|
|
12154
|
-
var
|
|
12275
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
12155
12276
|
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
12156
12277
|
function Field({ label, htmlFor, children }) {
|
|
12157
|
-
return /* @__PURE__ */ (0,
|
|
12158
|
-
/* @__PURE__ */ (0,
|
|
12159
|
-
/* @__PURE__ */ (0,
|
|
12278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12279
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("label", { htmlFor, className: `${chartLabelClass} w-20 shrink-0`, children: label }),
|
|
12280
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "min-w-0 flex-1", children })
|
|
12160
12281
|
] });
|
|
12161
12282
|
}
|
|
12162
12283
|
function Toggle({ label, checked, onChange, name }) {
|
|
12163
|
-
return /* @__PURE__ */ (0,
|
|
12164
|
-
/* @__PURE__ */ (0,
|
|
12284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("label", { className: "flex cursor-pointer items-center gap-2 text-xs text-foreground", children: [
|
|
12285
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("input", { type: "checkbox", className: "h-3.5 w-3.5 accent-primary", checked, "data-option": name, onChange: (e) => onChange(e.currentTarget.checked) }),
|
|
12165
12286
|
label
|
|
12166
12287
|
] });
|
|
12167
12288
|
}
|
|
12168
12289
|
function Select({ id, value, options, onChange, name, labels }) {
|
|
12169
|
-
return /* @__PURE__ */ (0,
|
|
12290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { id, className: chartInputClass, value, "data-option": name, onChange: (e) => onChange(e.currentTarget.value), children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: o, children: labels?.[o] ?? cap(o) }, o)) });
|
|
12170
12291
|
}
|
|
12171
12292
|
function AxisSection({ controller, axis, value, idBase, horizontal, numeric = false, scales = false }) {
|
|
12172
12293
|
const set = (patch) => controller.setAxis(axis, patch);
|
|
12173
12294
|
const setFormat = (patch) => set({ format: { ...value.format, ...patch } });
|
|
12174
|
-
const bound = (key2) => /* @__PURE__ */ (0,
|
|
12295
|
+
const bound = (key2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12175
12296
|
ChartCommitInput,
|
|
12176
12297
|
{
|
|
12177
12298
|
id: `${idBase}-${axis}-${key2}`,
|
|
@@ -12186,26 +12307,26 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12186
12307
|
const name = axis === "x" ? numeric ? "X axis" : "Category axis" : axis === "y" ? "Value axis" : "Secondary axis";
|
|
12187
12308
|
const valueAxis = axis !== "x" || numeric;
|
|
12188
12309
|
const key = axis === "y2" ? "yAxis2" : `${axis}Axis`;
|
|
12189
|
-
return /* @__PURE__ */ (0,
|
|
12190
|
-
/* @__PURE__ */ (0,
|
|
12191
|
-
/* @__PURE__ */ (0,
|
|
12310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": `axis-${axis}`, children: [
|
|
12311
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
12312
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("h4", { className: "text-xs font-semibold text-foreground", children: [
|
|
12192
12313
|
name,
|
|
12193
|
-
/* @__PURE__ */ (0,
|
|
12314
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
12194
12315
|
"(",
|
|
12195
12316
|
axis === "x" ? horizontal ? "left" : "bottom" : axis === "y2" ? horizontal ? "top" : "right" : horizontal ? "bottom" : "left",
|
|
12196
12317
|
")"
|
|
12197
12318
|
] })
|
|
12198
12319
|
] }),
|
|
12199
|
-
/* @__PURE__ */ (0,
|
|
12320
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Show", name: `${axis}Axis.show`, checked: value.show, onChange: (show) => set({ show }) })
|
|
12200
12321
|
] }),
|
|
12201
|
-
/* @__PURE__ */ (0,
|
|
12202
|
-
/* @__PURE__ */ (0,
|
|
12203
|
-
/* @__PURE__ */ (0,
|
|
12204
|
-
axis === "x" && !numeric && /* @__PURE__ */ (0,
|
|
12205
|
-
scales && /* @__PURE__ */ (0,
|
|
12206
|
-
scales && valueAxis && /* @__PURE__ */ (0,
|
|
12322
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Title", htmlFor: `${idBase}-${axis}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-title`, value: value.title, "data-option": `${axis}Axis.title`, className: chartInputClass, onCommit: (title) => void set({ title }) }) }),
|
|
12323
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
12324
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Grid lines", name: `${key}.gridlines`, checked: value.gridlines, onChange: (gridlines) => set({ gridlines }) }),
|
|
12325
|
+
axis === "x" && !numeric && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Dates", name: "xAxis.kind", checked: value.kind === "date", onChange: (dates) => set({ kind: dates ? "date" : void 0 }) }),
|
|
12326
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Reverse", name: `${key}.reverse`, checked: !!value.reverse, onChange: (reverse) => set({ reverse }) }),
|
|
12327
|
+
scales && valueAxis && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Log scale", name: `${key}.scale`, checked: value.scale === "log", onChange: (log) => set({ scale: log ? "log" : "linear" }) })
|
|
12207
12328
|
] }),
|
|
12208
|
-
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0,
|
|
12329
|
+
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Log base", htmlFor: `${idBase}-${axis}-log-base`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12209
12330
|
ChartCommitInput,
|
|
12210
12331
|
{
|
|
12211
12332
|
id: `${idBase}-${axis}-log-base`,
|
|
@@ -12216,7 +12337,7 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12216
12337
|
onCommit: (text) => set({ logBase: text.trim() === "" ? void 0 : Number(text) }).ok
|
|
12217
12338
|
}
|
|
12218
12339
|
) }),
|
|
12219
|
-
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0,
|
|
12340
|
+
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Step", htmlFor: `${idBase}-${axis}-step`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12220
12341
|
ChartCommitInput,
|
|
12221
12342
|
{
|
|
12222
12343
|
id: `${idBase}-${axis}-step`,
|
|
@@ -12228,14 +12349,14 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12228
12349
|
onCommit: (text) => set({ step: text.trim() === "" ? null : Number(text) }).ok
|
|
12229
12350
|
}
|
|
12230
12351
|
) }),
|
|
12231
|
-
valueAxis && /* @__PURE__ */ (0,
|
|
12232
|
-
/* @__PURE__ */ (0,
|
|
12352
|
+
valueAxis && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12353
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Min / max", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12233
12354
|
bound("min"),
|
|
12234
12355
|
bound("max")
|
|
12235
12356
|
] }) }),
|
|
12236
|
-
/* @__PURE__ */ (0,
|
|
12237
|
-
/* @__PURE__ */ (0,
|
|
12238
|
-
/* @__PURE__ */ (0,
|
|
12357
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Format", htmlFor: `${idBase}-${axis}-format`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12358
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12359
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12239
12360
|
ChartCommitInput,
|
|
12240
12361
|
{
|
|
12241
12362
|
value: value.format.decimals === void 0 ? "" : String(value.format.decimals),
|
|
@@ -12254,8 +12375,8 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12254
12375
|
}
|
|
12255
12376
|
)
|
|
12256
12377
|
] }) }),
|
|
12257
|
-
value.format.style === "currency" && /* @__PURE__ */ (0,
|
|
12258
|
-
/* @__PURE__ */ (0,
|
|
12378
|
+
value.format.style === "currency" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Currency", htmlFor: `${idBase}-${axis}-currency`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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() }) }) }),
|
|
12379
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Code", htmlFor: `${idBase}-${axis}-code`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12259
12380
|
ChartCommitInput,
|
|
12260
12381
|
{
|
|
12261
12382
|
id: `${idBase}-${axis}-code`,
|
|
@@ -12281,15 +12402,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
12281
12402
|
const values = which === "xErrorBars" ? series.x ?? [] : series.values;
|
|
12282
12403
|
const set = (next) => controller.updateSeries(series.id, { [which]: next });
|
|
12283
12404
|
const patch = (p) => bars && set({ ...bars, ...p });
|
|
12284
|
-
return /* @__PURE__ */ (0,
|
|
12285
|
-
/* @__PURE__ */ (0,
|
|
12286
|
-
/* @__PURE__ */ (0,
|
|
12287
|
-
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "space-y-1.5", "data-section": which === "errorBars" ? "error-bars" : "x-error-bars", children: [
|
|
12406
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: which === "errorBars" ? "Error bars" : "X error bars", htmlFor: `${id}-type`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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: [
|
|
12407
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "None" }),
|
|
12408
|
+
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: import_chart4.CHART_ERROR_BAR_LABELS[t] }, t))
|
|
12288
12409
|
] }) }),
|
|
12289
|
-
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0,
|
|
12290
|
-
bars?.type === "custom" && /* @__PURE__ */ (0,
|
|
12291
|
-
/* @__PURE__ */ (0,
|
|
12292
|
-
/* @__PURE__ */ (0,
|
|
12410
|
+
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: bars.type === "percent" ? "Percent" : bars.type === "stddev" ? "Deviations" : "Amount", htmlFor: `${id}-value`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12411
|
+
bars?.type === "custom" && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12412
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Plus", htmlFor: `${id}-plus`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12413
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Minus", htmlFor: `${id}-minus`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12293
12414
|
ChartCommitInput,
|
|
12294
12415
|
{
|
|
12295
12416
|
id: `${id}-minus`,
|
|
@@ -12306,15 +12427,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
12306
12427
|
}
|
|
12307
12428
|
) })
|
|
12308
12429
|
] }),
|
|
12309
|
-
bars && /* @__PURE__ */ (0,
|
|
12310
|
-
/* @__PURE__ */ (0,
|
|
12311
|
-
/* @__PURE__ */ (0,
|
|
12430
|
+
bars && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12431
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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_runtime64.jsx)("option", { value: d, children: d === "both" ? "Both ways" : d === "plus" ? "Plus only" : "Minus only" }, d)) }),
|
|
12432
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Caps", name: `${key}.cap`, checked: bars.cap !== false, onChange: (cap2) => patch({ cap: cap2 }) })
|
|
12312
12433
|
] })
|
|
12313
12434
|
] });
|
|
12314
12435
|
}
|
|
12315
12436
|
function ChartInspector({ controller, sections, className }) {
|
|
12316
12437
|
const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
|
|
12317
|
-
const idBase = (0,
|
|
12438
|
+
const idBase = (0, import_react88.useId)();
|
|
12318
12439
|
const show = (section) => !sections || sections.includes(section);
|
|
12319
12440
|
const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
|
|
12320
12441
|
const family = (0, import_chart4.chartFamily)(spec);
|
|
@@ -12329,30 +12450,30 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12329
12450
|
const annotated = scales;
|
|
12330
12451
|
const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
|
|
12331
12452
|
const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
|
|
12332
|
-
return /* @__PURE__ */ (0,
|
|
12333
|
-
show("type") && /* @__PURE__ */ (0,
|
|
12334
|
-
show("style") && /* @__PURE__ */ (0,
|
|
12335
|
-
/* @__PURE__ */ (0,
|
|
12336
|
-
/* @__PURE__ */ (0,
|
|
12337
|
-
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0,
|
|
12453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
|
|
12454
|
+
show("type") && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime64.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_runtime64.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)) }) }),
|
|
12455
|
+
show("style") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
|
|
12456
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Layout", htmlFor: `${idBase}-layout`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("select", { id: `${idBase}-layout`, className: chartInputClass, value: "", "data-option": "preset.layout", onChange: (e) => e.currentTarget.value && controller.applyPreset({ layout: e.currentTarget.value }), children: [
|
|
12457
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Quick layout\u2026" }),
|
|
12458
|
+
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: p.id, title: p.description, children: p.label }, p.id))
|
|
12338
12459
|
] }) }),
|
|
12339
|
-
/* @__PURE__ */ (0,
|
|
12340
|
-
/* @__PURE__ */ (0,
|
|
12341
|
-
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0,
|
|
12460
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Colours", htmlFor: `${idBase}-colors`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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: [
|
|
12461
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Custom" }),
|
|
12462
|
+
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: c.id, title: c.description, children: c.label }, c.id))
|
|
12342
12463
|
] }) }),
|
|
12343
|
-
!colorCheck.ok && /* @__PURE__ */ (0,
|
|
12344
|
-
/* @__PURE__ */ (0,
|
|
12464
|
+
!colorCheck.ok && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-[11px] leading-snug text-amber-600 dark:text-amber-400", "data-chart-color-warning": "", children: colorCheck.issues[0] }),
|
|
12465
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "transpose", onClick: () => controller.transpose(), children: "Switch rows and columns" })
|
|
12345
12466
|
] }),
|
|
12346
|
-
show("titles") && /* @__PURE__ */ (0,
|
|
12347
|
-
/* @__PURE__ */ (0,
|
|
12348
|
-
/* @__PURE__ */ (0,
|
|
12349
|
-
/* @__PURE__ */ (0,
|
|
12467
|
+
show("titles") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
|
|
12468
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
|
|
12469
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
|
|
12470
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
|
|
12350
12471
|
] }),
|
|
12351
|
-
show("options") && /* @__PURE__ */ (0,
|
|
12352
|
-
cartesian && /* @__PURE__ */ (0,
|
|
12353
|
-
hasBars && /* @__PURE__ */ (0,
|
|
12354
|
-
hasLines && /* @__PURE__ */ (0,
|
|
12355
|
-
spec.type === "donut" && /* @__PURE__ */ (0,
|
|
12472
|
+
show("options") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
|
|
12473
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }) }),
|
|
12474
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bars", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: ["vertical", "horizontal"].map((o) => /* @__PURE__ */ (0, import_jsx_runtime64.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)) }) }),
|
|
12475
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Lines", htmlFor: `${idBase}-curve`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-curve`, name: "curve", value: spec.curve, options: import_chart4.CHART_CURVES, onChange: (curve) => controller.update({ curve }) }) }),
|
|
12476
|
+
spec.type === "donut" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Hole", htmlFor: `${idBase}-hole`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12356
12477
|
"input",
|
|
12357
12478
|
{
|
|
12358
12479
|
id: `${idBase}-hole`,
|
|
@@ -12368,7 +12489,7 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12368
12489
|
onChange: (e) => controller.update({ innerRadius: Number(e.currentTarget.value) })
|
|
12369
12490
|
}
|
|
12370
12491
|
) }),
|
|
12371
|
-
hasBars && /* @__PURE__ */ (0,
|
|
12492
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Spacing", htmlFor: `${idBase}-gap`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12372
12493
|
"input",
|
|
12373
12494
|
{
|
|
12374
12495
|
id: `${idBase}-gap`,
|
|
@@ -12384,9 +12505,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12384
12505
|
onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
|
|
12385
12506
|
}
|
|
12386
12507
|
) }),
|
|
12387
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12388
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12389
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12508
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Map", htmlFor: `${idBase}-map`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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_runtime64.jsx)("option", { value: id, children: (0, import_chart4.listChartMaps)().find((m) => m.id === id)?.name ?? `${id} (not loaded)` }, id)) }) }),
|
|
12509
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Classes", htmlFor: `${idBase}-map-steps`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12510
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Breaks", htmlFor: `${idBase}-map-breaks`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12390
12511
|
ChartCommitInput,
|
|
12391
12512
|
{
|
|
12392
12513
|
id: `${idBase}-map-breaks`,
|
|
@@ -12397,10 +12518,10 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12397
12518
|
onCommit: (text) => controller.update({ mapThresholds: text.trim() ? text.split(",").map((t) => Number(t.trim())) : [] }).ok
|
|
12398
12519
|
}
|
|
12399
12520
|
) }),
|
|
12400
|
-
spec.type === "barrace" && /* @__PURE__ */ (0,
|
|
12401
|
-
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0,
|
|
12402
|
-
/* @__PURE__ */ (0,
|
|
12403
|
-
/* @__PURE__ */ (0,
|
|
12521
|
+
spec.type === "barrace" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bars", htmlFor: `${idBase}-race-top`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12522
|
+
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Time", htmlFor: `${idBase}-race-frame`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12523
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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" }),
|
|
12524
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12404
12525
|
"input",
|
|
12405
12526
|
{
|
|
12406
12527
|
id: `${idBase}-race-frame`,
|
|
@@ -12415,13 +12536,13 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12415
12536
|
onChange: (e) => controller.setRaceFrame(Number(e.currentTarget.value))
|
|
12416
12537
|
}
|
|
12417
12538
|
),
|
|
12418
|
-
/* @__PURE__ */ (0,
|
|
12539
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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)] })
|
|
12419
12540
|
] }) }),
|
|
12420
|
-
spec.type === "sankey" && /* @__PURE__ */ (0,
|
|
12421
|
-
spec.type === "sunburst" && /* @__PURE__ */ (0,
|
|
12422
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
12423
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
12424
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12541
|
+
spec.type === "sankey" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Flows", htmlFor: `${idBase}-sankey-color`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }) }),
|
|
12542
|
+
spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
|
|
12543
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }) }),
|
|
12544
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }) }),
|
|
12545
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12425
12546
|
"input",
|
|
12426
12547
|
{
|
|
12427
12548
|
id: `${idBase}-parliament-arc`,
|
|
@@ -12437,34 +12558,34 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12437
12558
|
onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
|
|
12438
12559
|
}
|
|
12439
12560
|
) }),
|
|
12440
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12441
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12442
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
12443
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
12444
|
-
spec.dataLabels && hasBars && /* @__PURE__ */ (0,
|
|
12445
|
-
spec.type === "histogram" && /* @__PURE__ */ (0,
|
|
12446
|
-
/* @__PURE__ */ (0,
|
|
12447
|
-
spec.type === "waterfall" && /* @__PURE__ */ (0,
|
|
12448
|
-
hasLines && /* @__PURE__ */ (0,
|
|
12449
|
-
oneSeries && /* @__PURE__ */ (0,
|
|
12450
|
-
/* @__PURE__ */ (0,
|
|
12561
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12562
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
|
|
12563
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12564
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }) }),
|
|
12565
|
+
spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
|
|
12566
|
+
spec.type === "histogram" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bins", htmlFor: `${idBase}-bins`, children: /* @__PURE__ */ (0, import_jsx_runtime64.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 }) }),
|
|
12567
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
12568
|
+
spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
|
|
12569
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
|
|
12570
|
+
oneSeries && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
|
|
12571
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
|
|
12451
12572
|
] })
|
|
12452
12573
|
] }),
|
|
12453
|
-
show("legend") && /* @__PURE__ */ (0,
|
|
12454
|
-
/* @__PURE__ */ (0,
|
|
12455
|
-
/* @__PURE__ */ (0,
|
|
12456
|
-
/* @__PURE__ */ (0,
|
|
12574
|
+
show("legend") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "legend", children: [
|
|
12575
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
12576
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Legend" }),
|
|
12577
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Show", name: "legend.show", checked: spec.legend.show, onChange: (v) => controller.setLegend({ show: v }) })
|
|
12457
12578
|
] }),
|
|
12458
|
-
spec.legend.show && /* @__PURE__ */ (0,
|
|
12579
|
+
spec.legend.show && /* @__PURE__ */ (0, import_jsx_runtime64.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_runtime64.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)) })
|
|
12459
12580
|
] }),
|
|
12460
|
-
show("axes") && hasAxes && /* @__PURE__ */ (0,
|
|
12461
|
-
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0,
|
|
12462
|
-
/* @__PURE__ */ (0,
|
|
12463
|
-
usesSecondary && /* @__PURE__ */ (0,
|
|
12581
|
+
show("axes") && hasAxes && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12582
|
+
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "x", value: spec.xAxis, idBase, horizontal: spec.orientation === "horizontal", numeric: family === "xy", scales }),
|
|
12583
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
|
|
12584
|
+
usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
|
|
12464
12585
|
] }),
|
|
12465
|
-
show("annotations") && annotated && /* @__PURE__ */ (0,
|
|
12466
|
-
/* @__PURE__ */ (0,
|
|
12467
|
-
/* @__PURE__ */ (0,
|
|
12586
|
+
show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
|
|
12587
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
|
|
12588
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12468
12589
|
ChartCommitInput,
|
|
12469
12590
|
{
|
|
12470
12591
|
id: `${idBase}-highlight`,
|
|
@@ -12475,27 +12596,27 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12475
12596
|
onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
|
|
12476
12597
|
}
|
|
12477
12598
|
) }),
|
|
12478
|
-
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0,
|
|
12479
|
-
/* @__PURE__ */ (0,
|
|
12480
|
-
/* @__PURE__ */ (0,
|
|
12481
|
-
/* @__PURE__ */ (0,
|
|
12599
|
+
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
|
|
12600
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }),
|
|
12601
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }),
|
|
12602
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
|
|
12482
12603
|
] }, `line-${i}`)),
|
|
12483
|
-
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0,
|
|
12484
|
-
/* @__PURE__ */ (0,
|
|
12485
|
-
/* @__PURE__ */ (0,
|
|
12486
|
-
/* @__PURE__ */ (0,
|
|
12487
|
-
/* @__PURE__ */ (0,
|
|
12604
|
+
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
|
|
12605
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }),
|
|
12606
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }),
|
|
12607
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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 }),
|
|
12608
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
|
|
12488
12609
|
] }, `band-${i}`)),
|
|
12489
|
-
/* @__PURE__ */ (0,
|
|
12490
|
-
/* @__PURE__ */ (0,
|
|
12491
|
-
/* @__PURE__ */ (0,
|
|
12610
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12611
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
|
|
12612
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
|
|
12492
12613
|
] })
|
|
12493
12614
|
] }),
|
|
12494
|
-
show("series") && selectedSeries && /* @__PURE__ */ (0,
|
|
12495
|
-
/* @__PURE__ */ (0,
|
|
12496
|
-
/* @__PURE__ */ (0,
|
|
12497
|
-
/* @__PURE__ */ (0,
|
|
12498
|
-
/* @__PURE__ */ (0,
|
|
12615
|
+
show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
|
|
12616
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
|
|
12617
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
|
|
12618
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12619
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12499
12620
|
"input",
|
|
12500
12621
|
{
|
|
12501
12622
|
id: `${idBase}-series-color`,
|
|
@@ -12508,9 +12629,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12508
12629
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
|
|
12509
12630
|
}
|
|
12510
12631
|
),
|
|
12511
|
-
selectedSeries.color && /* @__PURE__ */ (0,
|
|
12632
|
+
selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
|
|
12512
12633
|
] }) }),
|
|
12513
|
-
cartesian && /* @__PURE__ */ (0,
|
|
12634
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12514
12635
|
"select",
|
|
12515
12636
|
{
|
|
12516
12637
|
id: `${idBase}-series-type`,
|
|
@@ -12519,12 +12640,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12519
12640
|
"data-option": "series.type",
|
|
12520
12641
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { type: e.currentTarget.value || null }),
|
|
12521
12642
|
children: [
|
|
12522
|
-
/* @__PURE__ */ (0,
|
|
12523
|
-
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12643
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Chart type" }),
|
|
12644
|
+
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: import_chart4.CHART_TYPE_LABELS[t] }, t))
|
|
12524
12645
|
]
|
|
12525
12646
|
}
|
|
12526
12647
|
) }),
|
|
12527
|
-
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0,
|
|
12648
|
+
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Marker", htmlFor: `${idBase}-series-marker`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12528
12649
|
"select",
|
|
12529
12650
|
{
|
|
12530
12651
|
id: `${idBase}-series-marker`,
|
|
@@ -12533,12 +12654,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12533
12654
|
"data-option": "series.marker",
|
|
12534
12655
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { marker: e.currentTarget.value || null }),
|
|
12535
12656
|
children: [
|
|
12536
|
-
/* @__PURE__ */ (0,
|
|
12537
|
-
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0,
|
|
12657
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Default" }),
|
|
12658
|
+
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: m, children: cap(m) }, m))
|
|
12538
12659
|
]
|
|
12539
12660
|
}
|
|
12540
12661
|
) }),
|
|
12541
|
-
annotated && calloutIndex !== null && /* @__PURE__ */ (0,
|
|
12662
|
+
annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12542
12663
|
ChartCommitInput,
|
|
12543
12664
|
{
|
|
12544
12665
|
id: `${idBase}-series-callout`,
|
|
@@ -12549,15 +12670,15 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12549
12670
|
onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
|
|
12550
12671
|
}
|
|
12551
12672
|
) }),
|
|
12552
|
-
scales && /* @__PURE__ */ (0,
|
|
12553
|
-
family === "xy" && /* @__PURE__ */ (0,
|
|
12554
|
-
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0,
|
|
12555
|
-
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0,
|
|
12556
|
-
/* @__PURE__ */ (0,
|
|
12557
|
-
/* @__PURE__ */ (0,
|
|
12558
|
-
/* @__PURE__ */ (0,
|
|
12673
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
|
|
12674
|
+
family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
|
|
12675
|
+
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
|
|
12676
|
+
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-trendline": i, children: [
|
|
12677
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "flex-1 truncate text-muted-foreground", children: (0, import_chart4.chartTrendlineName)(t, selectedSeries.name) }),
|
|
12678
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "R\xB2", name: `trendline.${i}.showR2`, checked: !!t.showR2, onChange: (showR2) => controller.updateTrendline(selectedSeries.id, i, { showR2 }) }),
|
|
12679
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete trendline", "data-action": "trendline-delete", onClick: () => controller.removeTrendline(selectedSeries.id, i), children: "\xD7" })
|
|
12559
12680
|
] }, i)),
|
|
12560
|
-
/* @__PURE__ */ (0,
|
|
12681
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12561
12682
|
"select",
|
|
12562
12683
|
{
|
|
12563
12684
|
className: chartInputClass,
|
|
@@ -12566,32 +12687,32 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12566
12687
|
"data-option": "trendline.add",
|
|
12567
12688
|
onChange: (e) => e.currentTarget.value && controller.addTrendline(selectedSeries.id, { type: e.currentTarget.value }),
|
|
12568
12689
|
children: [
|
|
12569
|
-
/* @__PURE__ */ (0,
|
|
12570
|
-
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12690
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Add trendline\u2026" }),
|
|
12691
|
+
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: cap(t.replace("-", " ")) }, t))
|
|
12571
12692
|
]
|
|
12572
12693
|
}
|
|
12573
12694
|
)
|
|
12574
12695
|
] }),
|
|
12575
|
-
/* @__PURE__ */ (0,
|
|
12576
|
-
/* @__PURE__ */ (0,
|
|
12577
|
-
family === "cartesian" && /* @__PURE__ */ (0,
|
|
12578
|
-
/* @__PURE__ */ (0,
|
|
12579
|
-
/* @__PURE__ */ (0,
|
|
12580
|
-
/* @__PURE__ */ (0,
|
|
12581
|
-
/* @__PURE__ */ (0,
|
|
12696
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
12697
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Hidden", name: "series.hidden", checked: !!selectedSeries.hidden, onChange: (hidden) => controller.updateSeries(selectedSeries.id, { hidden }) }),
|
|
12698
|
+
family === "cartesian" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Secondary axis", name: "series.axis", checked: selectedSeries.axis === "secondary", onChange: (secondary) => controller.updateSeries(selectedSeries.id, { axis: secondary ? "secondary" : null }) }),
|
|
12699
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "flex-1" }),
|
|
12700
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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" }),
|
|
12701
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.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" }),
|
|
12702
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: `${chartButtonClass} text-destructive`, "data-action": "series-delete", onClick: () => controller.removeSeries(selectedSeries.id), children: "Delete" })
|
|
12582
12703
|
] })
|
|
12583
12704
|
] })
|
|
12584
12705
|
] });
|
|
12585
12706
|
}
|
|
12586
12707
|
|
|
12587
12708
|
// src/chart-node/ChartNodeView.tsx
|
|
12588
|
-
var
|
|
12709
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
12589
12710
|
function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
12590
12711
|
const { controller, editing, editable, selected, width, height, setEditing } = state;
|
|
12591
12712
|
const open = () => {
|
|
12592
12713
|
if (editable && !editing) setEditing(true);
|
|
12593
12714
|
};
|
|
12594
|
-
return /* @__PURE__ */ (0,
|
|
12715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
12595
12716
|
"div",
|
|
12596
12717
|
{
|
|
12597
12718
|
className: `not-prose my-2 rounded-md border bg-background p-1 ${selected ? "border-primary ring-1 ring-primary" : "border-border"}`,
|
|
@@ -12604,24 +12725,24 @@ function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
|
12604
12725
|
}
|
|
12605
12726
|
},
|
|
12606
12727
|
children: [
|
|
12607
|
-
editing && /* @__PURE__ */ (0,
|
|
12608
|
-
/* @__PURE__ */ (0,
|
|
12609
|
-
/* @__PURE__ */ (0,
|
|
12728
|
+
editing && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "mb-1 flex items-center justify-between gap-2 px-1", "data-chart-node-toolbar": "", children: [
|
|
12729
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-xs text-muted-foreground", children: "Editing chart" }),
|
|
12730
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "done", onClick: () => setEditing(false), children: "Done" })
|
|
12610
12731
|
] }),
|
|
12611
|
-
/* @__PURE__ */ (0,
|
|
12732
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12612
12733
|
"div",
|
|
12613
12734
|
{
|
|
12614
12735
|
className: editable && !editing ? "cursor-pointer" : void 0,
|
|
12615
12736
|
onClick: open,
|
|
12616
12737
|
title: editable && !editing ? "Click to edit the chart" : void 0,
|
|
12617
12738
|
"data-chart-node-canvas": "",
|
|
12618
|
-
children: /* @__PURE__ */ (0,
|
|
12739
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartCanvas, { controller, width: width ?? 640, height, responsive: width === null, editable: editing, theme })
|
|
12619
12740
|
}
|
|
12620
12741
|
),
|
|
12621
12742
|
editing && // Wraps by the document's width, not the viewport's: side by side when there is room.
|
|
12622
|
-
/* @__PURE__ */ (0,
|
|
12623
|
-
showDataGrid && /* @__PURE__ */ (0,
|
|
12624
|
-
/* @__PURE__ */ (0,
|
|
12743
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "mt-2 flex flex-wrap items-start gap-2", "data-chart-node-panel": "", children: [
|
|
12744
|
+
showDataGrid && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "min-w-0 flex-[1_1_20rem] overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartDataGrid, { controller }) }),
|
|
12745
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartInspector, { controller, className: "max-h-96 min-w-0 flex-[1_1_16rem] overflow-y-auto rounded-md border border-border p-3" })
|
|
12625
12746
|
] })
|
|
12626
12747
|
]
|
|
12627
12748
|
}
|
|
@@ -12639,7 +12760,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
12639
12760
|
scheduled = true;
|
|
12640
12761
|
queueMicrotask(() => {
|
|
12641
12762
|
scheduled = false;
|
|
12642
|
-
if (!destroyed) root.render(/* @__PURE__ */ (0,
|
|
12763
|
+
if (!destroyed) root.render(/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Component, { ...props, state: latest }));
|
|
12643
12764
|
});
|
|
12644
12765
|
};
|
|
12645
12766
|
schedule();
|
|
@@ -12657,10 +12778,10 @@ function createReactChartNodeView(options = {}) {
|
|
|
12657
12778
|
}
|
|
12658
12779
|
|
|
12659
12780
|
// src/style/useStyle.ts
|
|
12660
|
-
var
|
|
12781
|
+
var import_react89 = require("react");
|
|
12661
12782
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
12662
12783
|
function useResolverTask(styles, run, deliver, deps) {
|
|
12663
|
-
(0,
|
|
12784
|
+
(0, import_react89.useEffect)(() => {
|
|
12664
12785
|
if (!styles || !run) {
|
|
12665
12786
|
deliver({ value: null, error: null });
|
|
12666
12787
|
return;
|
|
@@ -12687,7 +12808,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
12687
12808
|
}, [styles, ...deps]);
|
|
12688
12809
|
}
|
|
12689
12810
|
function useStyle(styles, domain) {
|
|
12690
|
-
const [result, setResult] = (0,
|
|
12811
|
+
const [result, setResult] = (0, import_react89.useState)({ style: null, error: null });
|
|
12691
12812
|
useResolverTask(
|
|
12692
12813
|
styles,
|
|
12693
12814
|
(s) => s.resolve(domain),
|
|
@@ -12697,7 +12818,7 @@ function useStyle(styles, domain) {
|
|
|
12697
12818
|
return result;
|
|
12698
12819
|
}
|
|
12699
12820
|
function useStyleFindings(styles, domain, state) {
|
|
12700
|
-
const [result, setResult] = (0,
|
|
12821
|
+
const [result, setResult] = (0, import_react89.useState)({ report: null, style: null, error: null });
|
|
12701
12822
|
useResolverTask(
|
|
12702
12823
|
styles,
|
|
12703
12824
|
(s) => s.check(domain, state),
|
|
@@ -12714,7 +12835,7 @@ function useStyleFindings(styles, domain, state) {
|
|
|
12714
12835
|
}
|
|
12715
12836
|
|
|
12716
12837
|
// src/style/StyleFindings.tsx
|
|
12717
|
-
var
|
|
12838
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
12718
12839
|
var SEVERITY_CLASS = {
|
|
12719
12840
|
error: "text-destructive",
|
|
12720
12841
|
warning: "text-amber-600",
|
|
@@ -12723,24 +12844,24 @@ var SEVERITY_CLASS = {
|
|
|
12723
12844
|
function StyleFindings({ report, onSelect, title = "House style", className = "" }) {
|
|
12724
12845
|
if (!report) return null;
|
|
12725
12846
|
const { findings, ran, skipped } = report;
|
|
12726
|
-
return /* @__PURE__ */ (0,
|
|
12727
|
-
/* @__PURE__ */ (0,
|
|
12728
|
-
findings.length > 0 && /* @__PURE__ */ (0,
|
|
12847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("section", { "data-style-findings": "", "aria-label": title, className: `flex flex-col gap-1.5 text-xs text-foreground ${className}`, children: [
|
|
12848
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("h3", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
|
|
12849
|
+
findings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("ul", { className: "flex flex-col gap-1", children: findings.map((finding, i) => {
|
|
12729
12850
|
const selectable = finding.target !== void 0 && !!onSelect;
|
|
12730
|
-
const body = /* @__PURE__ */ (0,
|
|
12731
|
-
/* @__PURE__ */ (0,
|
|
12732
|
-
/* @__PURE__ */ (0,
|
|
12733
|
-
/* @__PURE__ */ (0,
|
|
12734
|
-
/* @__PURE__ */ (0,
|
|
12735
|
-
/* @__PURE__ */ (0,
|
|
12736
|
-
finding.layer && /* @__PURE__ */ (0,
|
|
12851
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
12852
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { "data-style-severity": finding.severity, className: `shrink-0 font-semibold uppercase text-[10px] ${SEVERITY_CLASS[finding.severity]}`, children: finding.severity }),
|
|
12853
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "flex min-w-0 flex-col", children: [
|
|
12854
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { "data-style-message": "", children: finding.message }),
|
|
12855
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
12856
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("code", { children: finding.check }),
|
|
12857
|
+
finding.layer && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
12737
12858
|
" \xB7 ",
|
|
12738
12859
|
finding.layer
|
|
12739
12860
|
] })
|
|
12740
12861
|
] })
|
|
12741
12862
|
] })
|
|
12742
12863
|
] });
|
|
12743
|
-
return /* @__PURE__ */ (0,
|
|
12864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("li", { "data-style-finding": finding.check, children: selectable ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12744
12865
|
"button",
|
|
12745
12866
|
{
|
|
12746
12867
|
type: "button",
|
|
@@ -12748,19 +12869,19 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
12748
12869
|
onClick: () => onSelect(finding),
|
|
12749
12870
|
children: body
|
|
12750
12871
|
}
|
|
12751
|
-
) : /* @__PURE__ */ (0,
|
|
12872
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex items-start gap-2 rounded border border-border px-2 py-1", children: body }) }, `${finding.check}-${i}`);
|
|
12752
12873
|
}) }),
|
|
12753
|
-
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0,
|
|
12874
|
+
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("p", { "data-style-clear": "", className: "text-emerald-600", children: [
|
|
12754
12875
|
"All clear: ",
|
|
12755
12876
|
ran.length,
|
|
12756
12877
|
" ",
|
|
12757
12878
|
ran.length === 1 ? "check" : "checks",
|
|
12758
12879
|
" passed."
|
|
12759
12880
|
] }),
|
|
12760
|
-
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0,
|
|
12761
|
-
skipped.length > 0 && /* @__PURE__ */ (0,
|
|
12881
|
+
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "text-muted-foreground", children: "No house-style checks apply." }),
|
|
12882
|
+
skipped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.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_runtime66.jsxs)("li", { "data-style-skipped-check": s.check, children: [
|
|
12762
12883
|
"Skipped ",
|
|
12763
|
-
/* @__PURE__ */ (0,
|
|
12884
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("code", { children: s.check }),
|
|
12764
12885
|
": ",
|
|
12765
12886
|
s.reason
|
|
12766
12887
|
] }, s.check)) })
|
|
@@ -12773,6 +12894,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
12773
12894
|
AssetMentionChips,
|
|
12774
12895
|
BrushOptionsBar,
|
|
12775
12896
|
BubbleMenu,
|
|
12897
|
+
ChannelsPanel,
|
|
12776
12898
|
ChartNodeView,
|
|
12777
12899
|
ColorProfilePanel,
|
|
12778
12900
|
CommandPalette,
|