@pixerate/editor-react 0.146.0 → 0.147.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-3E32BAYS.js → chunk-FL5RL6NO.js} +448 -406
- package/dist/image-editor/SelectionChangeCheck.d.cts +14 -0
- package/dist/image-editor/SelectionChangeCheck.d.ts +14 -0
- package/dist/image-editor/index.cjs +465 -422
- 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 +990 -947
- package/dist/index.js +3 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ __export(src_exports, {
|
|
|
81
81
|
RefineEdgePanel: () => RefineEdgePanel,
|
|
82
82
|
ReviewToolbar: () => ReviewToolbar,
|
|
83
83
|
SelectAndMaskWorkspace: () => SelectAndMaskWorkspace,
|
|
84
|
+
SelectionChangeCheck: () => SelectionChangeCheck,
|
|
84
85
|
SelectionOptionsBar: () => SelectionOptionsBar,
|
|
85
86
|
ShapeOptionsBar: () => ShapeOptionsBar,
|
|
86
87
|
SheetTabs: () => SheetTabs,
|
|
@@ -2212,17 +2213,17 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
|
|
|
2212
2213
|
style === "warning" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mt-2", children: "Continue?" })
|
|
2213
2214
|
] })
|
|
2214
2215
|
] }),
|
|
2215
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-4 flex justify-end gap-2", children: buttons.map((
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-4 flex justify-end gap-2", children: buttons.map((button7, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2216
2217
|
"button",
|
|
2217
2218
|
{
|
|
2218
2219
|
ref: i === 0 ? firstButton : void 0,
|
|
2219
2220
|
type: "button",
|
|
2220
|
-
"data-action":
|
|
2221
|
+
"data-action": button7.action,
|
|
2221
2222
|
className: `rounded border border-border px-3 py-1 ${i === 0 ? "bg-primary text-primary-foreground" : "hover:bg-muted"}`,
|
|
2222
|
-
onClick: () => onResolve(
|
|
2223
|
-
children:
|
|
2223
|
+
onClick: () => onResolve(button7.action),
|
|
2224
|
+
children: button7.label
|
|
2224
2225
|
},
|
|
2225
|
-
|
|
2226
|
+
button7.action
|
|
2226
2227
|
)) })
|
|
2227
2228
|
]
|
|
2228
2229
|
}
|
|
@@ -4045,7 +4046,7 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
4045
4046
|
}
|
|
4046
4047
|
|
|
4047
4048
|
// src/image-editor/ImageEditor.tsx
|
|
4048
|
-
var
|
|
4049
|
+
var import_react73 = __toESM(require("react"), 1);
|
|
4049
4050
|
var import_image_editor24 = require("@pixerate/editor/image-editor");
|
|
4050
4051
|
|
|
4051
4052
|
// src/image-editor/ImageEditorCanvas.tsx
|
|
@@ -9465,7 +9466,7 @@ var SelectionOptionsBar = ({
|
|
|
9465
9466
|
};
|
|
9466
9467
|
|
|
9467
9468
|
// src/image-editor/RefineEdgePanel.tsx
|
|
9468
|
-
var
|
|
9469
|
+
var import_react67 = require("react");
|
|
9469
9470
|
var import_image_editor18 = require("@pixerate/editor/image-editor");
|
|
9470
9471
|
|
|
9471
9472
|
// src/image-editor/MaskEdgeCheck.tsx
|
|
@@ -9515,20 +9516,60 @@ var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, cla
|
|
|
9515
9516
|
] });
|
|
9516
9517
|
};
|
|
9517
9518
|
|
|
9518
|
-
// src/image-editor/
|
|
9519
|
+
// src/image-editor/SelectionChangeCheck.tsx
|
|
9520
|
+
var import_react66 = require("react");
|
|
9519
9521
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9520
|
-
var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
|
|
9521
9522
|
var button5 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
|
|
9522
|
-
var
|
|
9523
|
-
const
|
|
9524
|
-
const [
|
|
9523
|
+
var SelectionChangeCheck = ({ controller, selection, className = "" }) => {
|
|
9524
|
+
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
9525
|
+
const [result, setResult] = (0, import_react66.useState)(null);
|
|
9525
9526
|
const [error, setError] = (0, import_react66.useState)(null);
|
|
9526
|
-
const
|
|
9527
|
-
const
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9527
|
+
const diff = result && result.for === sel ? result.diff : null;
|
|
9528
|
+
const show = () => {
|
|
9529
|
+
setError(null);
|
|
9530
|
+
try {
|
|
9531
|
+
setResult({ diff: controller.compareSelections(), for: sel });
|
|
9532
|
+
} catch (err) {
|
|
9533
|
+
setResult(null);
|
|
9534
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
9535
|
+
}
|
|
9536
|
+
};
|
|
9537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { "data-testid": "selection-change-check", className: `flex flex-col gap-1 text-xs ${className}`, children: [
|
|
9538
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", className: `${button5} self-start`, onClick: show, children: "Show Last Change" }),
|
|
9539
|
+
diff && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { "data-testid": "selection-change-summary", className: "text-foreground", children: diff.identical ? "The last step did not change the selection." : /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
9540
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: "text-green-600", children: [
|
|
9541
|
+
"+",
|
|
9542
|
+
diff.added.area,
|
|
9543
|
+
" px"
|
|
9544
|
+
] }),
|
|
9545
|
+
" ",
|
|
9546
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: "text-destructive", children: [
|
|
9547
|
+
"\u2212",
|
|
9548
|
+
diff.removed.area,
|
|
9549
|
+
" px"
|
|
9550
|
+
] }),
|
|
9551
|
+
", overlap ",
|
|
9552
|
+
Math.round(diff.iou * 100),
|
|
9553
|
+
"%"
|
|
9554
|
+
] }) }),
|
|
9555
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9556
|
+
] });
|
|
9557
|
+
};
|
|
9558
|
+
|
|
9559
|
+
// src/image-editor/RefineEdgePanel.tsx
|
|
9560
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
9561
|
+
var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
|
|
9562
|
+
var button6 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
|
|
9563
|
+
var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
9564
|
+
const [params, setParams] = (0, import_react67.useState)(DEFAULT_PARAMS);
|
|
9565
|
+
const [busy, setBusy] = (0, import_react67.useState)(false);
|
|
9566
|
+
const [error, setError] = (0, import_react67.useState)(null);
|
|
9567
|
+
const [layerId, setLayerId] = (0, import_react67.useState)("");
|
|
9568
|
+
const [newKind, setNewKind] = (0, import_react67.useState)("hueSaturation");
|
|
9569
|
+
const [output, setOutput] = (0, import_react67.useState)("selection");
|
|
9570
|
+
const [decontaminate, setDecontaminate] = (0, import_react67.useState)(0);
|
|
9571
|
+
const [objectAware, setObjectAware] = (0, import_react67.useState)(false);
|
|
9572
|
+
const [onlyUncertain, setOnlyUncertain] = (0, import_react67.useState)(false);
|
|
9532
9573
|
const canObject = Boolean(controller.segmentationProvider);
|
|
9533
9574
|
const toLayer = output !== "selection" && output !== "layer-mask";
|
|
9534
9575
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
@@ -9551,17 +9592,17 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9551
9592
|
setBusy(false);
|
|
9552
9593
|
}
|
|
9553
9594
|
};
|
|
9554
|
-
return /* @__PURE__ */ (0,
|
|
9555
|
-
/* @__PURE__ */ (0,
|
|
9556
|
-
import_image_editor18.REFINE_EDGE_CONTROLS.map((c) => /* @__PURE__ */ (0,
|
|
9557
|
-
/* @__PURE__ */ (0,
|
|
9558
|
-
/* @__PURE__ */ (0,
|
|
9559
|
-
/* @__PURE__ */ (0,
|
|
9595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { "data-testid": "refine-edge-panel", className: `flex flex-col gap-3 text-xs ${className}`, children: [
|
|
9596
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Refine Edge" }),
|
|
9597
|
+
import_image_editor18.REFINE_EDGE_CONTROLS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
9598
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
9599
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: c.label }),
|
|
9600
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9560
9601
|
params[c.id],
|
|
9561
9602
|
c.unit
|
|
9562
9603
|
] })
|
|
9563
9604
|
] }),
|
|
9564
|
-
/* @__PURE__ */ (0,
|
|
9605
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9565
9606
|
"input",
|
|
9566
9607
|
{
|
|
9567
9608
|
type: "range",
|
|
@@ -9575,43 +9616,43 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9575
9616
|
}
|
|
9576
9617
|
)
|
|
9577
9618
|
] }, c.id)),
|
|
9578
|
-
/* @__PURE__ */ (0,
|
|
9579
|
-
/* @__PURE__ */ (0,
|
|
9619
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
9620
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { type: "checkbox", checked: params.smartRadius, onChange: (e) => setParams({ ...params, smartRadius: e.target.checked }) }),
|
|
9580
9621
|
"Smart Radius"
|
|
9581
9622
|
] }),
|
|
9582
|
-
/* @__PURE__ */ (0,
|
|
9583
|
-
/* @__PURE__ */ (0,
|
|
9623
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-foreground", title: "Refine only where the edge has no image edge under it", children: [
|
|
9624
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { type: "checkbox", "aria-label": "Only uncertain areas", checked: onlyUncertain, onChange: (e) => setOnlyUncertain(e.target.checked) }),
|
|
9584
9625
|
"Only uncertain areas"
|
|
9585
9626
|
] }),
|
|
9586
|
-
canObject && /* @__PURE__ */ (0,
|
|
9587
|
-
/* @__PURE__ */ (0,
|
|
9627
|
+
canObject && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
9628
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { type: "checkbox", "aria-label": "Object aware", checked: objectAware, onChange: (e) => setObjectAware(e.target.checked) }),
|
|
9588
9629
|
"Object aware (segmentation model)"
|
|
9589
9630
|
] }),
|
|
9590
|
-
/* @__PURE__ */ (0,
|
|
9631
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 text-muted-foreground", children: [
|
|
9591
9632
|
"Output to",
|
|
9592
|
-
/* @__PURE__ */ (0,
|
|
9633
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9593
9634
|
"select",
|
|
9594
9635
|
{
|
|
9595
9636
|
"aria-label": "Refine output",
|
|
9596
9637
|
value: output,
|
|
9597
9638
|
onChange: (e) => setOutput(e.target.value),
|
|
9598
9639
|
className: "flex-1 bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
9599
|
-
children: import_image_editor18.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => /* @__PURE__ */ (0,
|
|
9640
|
+
children: import_image_editor18.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
9600
9641
|
}
|
|
9601
9642
|
)
|
|
9602
9643
|
] }),
|
|
9603
|
-
/* @__PURE__ */ (0,
|
|
9604
|
-
/* @__PURE__ */ (0,
|
|
9605
|
-
/* @__PURE__ */ (0,
|
|
9644
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
9645
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
9646
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { children: [
|
|
9606
9647
|
"Decontaminate colors",
|
|
9607
9648
|
toLayer ? "" : " (new layer or document outputs)"
|
|
9608
9649
|
] }),
|
|
9609
|
-
/* @__PURE__ */ (0,
|
|
9650
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9610
9651
|
decontaminate,
|
|
9611
9652
|
"%"
|
|
9612
9653
|
] })
|
|
9613
9654
|
] }),
|
|
9614
|
-
/* @__PURE__ */ (0,
|
|
9655
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9615
9656
|
"input",
|
|
9616
9657
|
{
|
|
9617
9658
|
type: "range",
|
|
@@ -9626,64 +9667,65 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9626
9667
|
}
|
|
9627
9668
|
)
|
|
9628
9669
|
] }),
|
|
9629
|
-
/* @__PURE__ */ (0,
|
|
9630
|
-
/* @__PURE__ */ (0,
|
|
9631
|
-
/* @__PURE__ */ (0,
|
|
9670
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-1", children: [
|
|
9671
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", className: button6, disabled: !sel || busy, onClick: refine, children: "Refine Edge" }),
|
|
9672
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", className: button6, onClick: () => setParams(DEFAULT_PARAMS), children: "Reset" })
|
|
9632
9673
|
] }),
|
|
9633
|
-
error && /* @__PURE__ */ (0,
|
|
9634
|
-
/* @__PURE__ */ (0,
|
|
9635
|
-
/* @__PURE__ */ (0,
|
|
9636
|
-
/* @__PURE__ */ (0,
|
|
9637
|
-
|
|
9674
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", children: error }),
|
|
9675
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(MaskEdgeCheck, { controller, selection: sel }),
|
|
9676
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SelectionChangeCheck, { controller, selection: sel }),
|
|
9677
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] mt-2", children: "Layer Mask" }),
|
|
9678
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-1 items-center", children: [
|
|
9679
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9638
9680
|
"select",
|
|
9639
9681
|
{
|
|
9640
9682
|
"aria-label": "New masked layer kind",
|
|
9641
9683
|
value: newKind,
|
|
9642
9684
|
onChange: (e) => setNewKind(e.target.value),
|
|
9643
9685
|
className: "flex-1 bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
9644
|
-
children: import_image_editor18.ADJUSTMENT_KINDS.map((k) => /* @__PURE__ */ (0,
|
|
9686
|
+
children: import_image_editor18.ADJUSTMENT_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: k.kind, children: k.label }, k.kind))
|
|
9645
9687
|
}
|
|
9646
9688
|
),
|
|
9647
|
-
/* @__PURE__ */ (0,
|
|
9689
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9648
9690
|
"button",
|
|
9649
9691
|
{
|
|
9650
9692
|
type: "button",
|
|
9651
|
-
className:
|
|
9693
|
+
className: button6,
|
|
9652
9694
|
disabled: !sel,
|
|
9653
9695
|
onClick: () => sel && setLayerId(controller.addAdjustmentLayer({ kind: newKind, mask: (0, import_image_editor18.layerMaskFromSelection)(sel) })),
|
|
9654
9696
|
children: "New Masked Layer"
|
|
9655
9697
|
}
|
|
9656
9698
|
)
|
|
9657
9699
|
] }),
|
|
9658
|
-
list.length > 0 && target && /* @__PURE__ */ (0,
|
|
9659
|
-
/* @__PURE__ */ (0,
|
|
9700
|
+
list.length > 0 && target && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
9701
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9660
9702
|
"select",
|
|
9661
9703
|
{
|
|
9662
9704
|
"aria-label": "Mask layer",
|
|
9663
9705
|
value: target.id,
|
|
9664
9706
|
onChange: (e) => setLayerId(e.target.value),
|
|
9665
9707
|
className: "bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
9666
|
-
children: list.map((l) => /* @__PURE__ */ (0,
|
|
9708
|
+
children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("option", { value: l.id, children: [
|
|
9667
9709
|
l.name || (0, import_image_editor18.adjustmentKindLabel)(l.kind),
|
|
9668
9710
|
l.mask ? " (masked)" : ""
|
|
9669
9711
|
] }, l.id))
|
|
9670
9712
|
}
|
|
9671
9713
|
),
|
|
9672
|
-
/* @__PURE__ */ (0,
|
|
9673
|
-
/* @__PURE__ */ (0,
|
|
9674
|
-
/* @__PURE__ */ (0,
|
|
9675
|
-
/* @__PURE__ */ (0,
|
|
9714
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
9715
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", className: button6, disabled: !sel, onClick: () => controller.applySelectionAsLayerMask(target.id), children: "Mask with Selection" }),
|
|
9716
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", className: button6, disabled: !target.mask, onClick: () => controller.selectionFromLayerMask(target.id), children: "Load as Selection" }),
|
|
9717
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", className: button6, disabled: !target.mask, onClick: () => controller.setAdjustmentLayerMask(target.id, null), children: "Remove Mask" })
|
|
9676
9718
|
] }),
|
|
9677
|
-
target.mask && /* @__PURE__ */ (0,
|
|
9678
|
-
/* @__PURE__ */ (0,
|
|
9679
|
-
/* @__PURE__ */ (0,
|
|
9680
|
-
/* @__PURE__ */ (0,
|
|
9681
|
-
/* @__PURE__ */ (0,
|
|
9719
|
+
target.mask && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
9720
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
9722
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Density" }),
|
|
9723
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9682
9724
|
Math.round((target.mask.density ?? 1) * 100),
|
|
9683
9725
|
"%"
|
|
9684
9726
|
] })
|
|
9685
9727
|
] }),
|
|
9686
|
-
/* @__PURE__ */ (0,
|
|
9728
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9687
9729
|
"input",
|
|
9688
9730
|
{
|
|
9689
9731
|
type: "range",
|
|
@@ -9697,15 +9739,15 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9697
9739
|
}
|
|
9698
9740
|
)
|
|
9699
9741
|
] }),
|
|
9700
|
-
/* @__PURE__ */ (0,
|
|
9701
|
-
/* @__PURE__ */ (0,
|
|
9702
|
-
/* @__PURE__ */ (0,
|
|
9703
|
-
/* @__PURE__ */ (0,
|
|
9742
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
9743
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
9744
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Mask Feather" }),
|
|
9745
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9704
9746
|
target.mask.feather ?? 0,
|
|
9705
9747
|
"px"
|
|
9706
9748
|
] })
|
|
9707
9749
|
] }),
|
|
9708
|
-
/* @__PURE__ */ (0,
|
|
9750
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9709
9751
|
"input",
|
|
9710
9752
|
{
|
|
9711
9753
|
type: "range",
|
|
@@ -9725,13 +9767,13 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9725
9767
|
};
|
|
9726
9768
|
|
|
9727
9769
|
// src/image-editor/ChannelsPanel.tsx
|
|
9728
|
-
var
|
|
9770
|
+
var import_react68 = require("react");
|
|
9729
9771
|
var import_image_editor19 = require("@pixerate/editor/image-editor");
|
|
9730
|
-
var
|
|
9772
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9731
9773
|
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"}`;
|
|
9732
9774
|
var ChannelThumb = ({ channel, size }) => {
|
|
9733
|
-
const ref = (0,
|
|
9734
|
-
(0,
|
|
9775
|
+
const ref = (0, import_react68.useRef)(null);
|
|
9776
|
+
(0, import_react68.useEffect)(() => {
|
|
9735
9777
|
const canvas = ref.current;
|
|
9736
9778
|
const ctx = canvas?.getContext("2d");
|
|
9737
9779
|
if (!canvas || !ctx || typeof ctx.createImageData !== "function") return;
|
|
@@ -9742,15 +9784,15 @@ var ChannelThumb = ({ channel, size }) => {
|
|
|
9742
9784
|
img.data.set(px.data);
|
|
9743
9785
|
ctx.putImageData(img, 0, 0);
|
|
9744
9786
|
}, [channel.mask]);
|
|
9745
|
-
return /* @__PURE__ */ (0,
|
|
9787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("canvas", { ref, "aria-hidden": "true", style: { width: size, height: size }, className: "shrink-0 rounded object-contain ring-1 ring-border bg-black" });
|
|
9746
9788
|
};
|
|
9747
9789
|
var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
9748
|
-
const [, setTick] = (0,
|
|
9749
|
-
(0,
|
|
9750
|
-
const [activeId, setActiveId] = (0,
|
|
9751
|
-
const [renaming, setRenaming] = (0,
|
|
9752
|
-
const [error, setError] = (0,
|
|
9753
|
-
const fileInput = (0,
|
|
9790
|
+
const [, setTick] = (0, import_react68.useState)(0);
|
|
9791
|
+
(0, import_react68.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9792
|
+
const [activeId, setActiveId] = (0, import_react68.useState)(null);
|
|
9793
|
+
const [renaming, setRenaming] = (0, import_react68.useState)(null);
|
|
9794
|
+
const [error, setError] = (0, import_react68.useState)(null);
|
|
9795
|
+
const fileInput = (0, import_react68.useRef)(null);
|
|
9754
9796
|
const channels = controller.getChannels();
|
|
9755
9797
|
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
9756
9798
|
const hasSelection = Boolean(controller.getSelection());
|
|
@@ -9772,13 +9814,13 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9772
9814
|
setError(err instanceof Error ? err.message : String(err));
|
|
9773
9815
|
}
|
|
9774
9816
|
};
|
|
9775
|
-
return /* @__PURE__ */ (0,
|
|
9776
|
-
/* @__PURE__ */ (0,
|
|
9777
|
-
/* @__PURE__ */ (0,
|
|
9778
|
-
/* @__PURE__ */ (0,
|
|
9817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
9818
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9819
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
9820
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.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" })
|
|
9779
9821
|
] }),
|
|
9780
|
-
channels.length === 0 && /* @__PURE__ */ (0,
|
|
9781
|
-
/* @__PURE__ */ (0,
|
|
9822
|
+
channels.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-muted-foreground", children: "No channels. Save a selection to keep it." }),
|
|
9823
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: channels.map((c) => /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
9782
9824
|
"li",
|
|
9783
9825
|
{
|
|
9784
9826
|
"data-testid": "channel-row",
|
|
@@ -9790,7 +9832,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9790
9832
|
},
|
|
9791
9833
|
onDoubleClick: () => setRenaming(c.id),
|
|
9792
9834
|
children: [
|
|
9793
|
-
/* @__PURE__ */ (0,
|
|
9835
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9794
9836
|
"button",
|
|
9795
9837
|
{
|
|
9796
9838
|
type: "button",
|
|
@@ -9804,8 +9846,8 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9804
9846
|
children: c.visible ? "\u25CF" : "\u25CB"
|
|
9805
9847
|
}
|
|
9806
9848
|
),
|
|
9807
|
-
/* @__PURE__ */ (0,
|
|
9808
|
-
renaming === c.id ? /* @__PURE__ */ (0,
|
|
9849
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ChannelThumb, { channel: c, size: thumbnailSize }),
|
|
9850
|
+
renaming === c.id ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9809
9851
|
"input",
|
|
9810
9852
|
{
|
|
9811
9853
|
autoFocus: true,
|
|
@@ -9822,16 +9864,16 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9822
9864
|
if (e.key === "Escape") setRenaming(null);
|
|
9823
9865
|
}
|
|
9824
9866
|
}
|
|
9825
|
-
) : /* @__PURE__ */ (0,
|
|
9867
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "min-w-0 flex-1 truncate", children: c.name })
|
|
9826
9868
|
]
|
|
9827
9869
|
},
|
|
9828
9870
|
c.id
|
|
9829
9871
|
)) }),
|
|
9830
|
-
/* @__PURE__ */ (0,
|
|
9831
|
-
/* @__PURE__ */ (0,
|
|
9832
|
-
/* @__PURE__ */ (0,
|
|
9833
|
-
/* @__PURE__ */ (0,
|
|
9834
|
-
/* @__PURE__ */ (0,
|
|
9872
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
9873
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: btn2(), disabled: !hasSelection, onClick: () => attempt(() => setActiveId(controller.saveSelection().id)), children: "Save Selection" }),
|
|
9874
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.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" }),
|
|
9875
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: btn2(), disabled: !active, onClick: () => attempt(() => setActiveId(controller.duplicateChannel(active.id).id)), children: "Duplicate" }),
|
|
9876
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9835
9877
|
"button",
|
|
9836
9878
|
{
|
|
9837
9879
|
type: "button",
|
|
@@ -9844,8 +9886,8 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9844
9886
|
children: "Delete"
|
|
9845
9887
|
}
|
|
9846
9888
|
),
|
|
9847
|
-
/* @__PURE__ */ (0,
|
|
9848
|
-
/* @__PURE__ */ (0,
|
|
9889
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: btn2(), title: "Load a mask image (white = selected) into a new channel", onClick: () => fileInput.current?.click(), children: "Import\u2026" }),
|
|
9890
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9849
9891
|
"button",
|
|
9850
9892
|
{
|
|
9851
9893
|
type: "button",
|
|
@@ -9856,7 +9898,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9856
9898
|
children: "Export PNG"
|
|
9857
9899
|
}
|
|
9858
9900
|
),
|
|
9859
|
-
/* @__PURE__ */ (0,
|
|
9901
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9860
9902
|
"input",
|
|
9861
9903
|
{
|
|
9862
9904
|
ref: fileInput,
|
|
@@ -9871,22 +9913,22 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9871
9913
|
}
|
|
9872
9914
|
)
|
|
9873
9915
|
] }),
|
|
9874
|
-
error && /* @__PURE__ */ (0,
|
|
9916
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9875
9917
|
] });
|
|
9876
9918
|
};
|
|
9877
9919
|
|
|
9878
9920
|
// src/image-editor/PathsPanel.tsx
|
|
9879
|
-
var
|
|
9921
|
+
var import_react69 = require("react");
|
|
9880
9922
|
var import_image_editor20 = require("@pixerate/editor/image-editor");
|
|
9881
|
-
var
|
|
9923
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
9882
9924
|
var btn3 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
9883
9925
|
var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
9884
|
-
const [, setTick] = (0,
|
|
9885
|
-
(0,
|
|
9886
|
-
const [renaming, setRenaming] = (0,
|
|
9887
|
-
const [color, setColor] = (0,
|
|
9888
|
-
const [width, setWidth] = (0,
|
|
9889
|
-
const [error, setError] = (0,
|
|
9926
|
+
const [, setTick] = (0, import_react69.useState)(0);
|
|
9927
|
+
(0, import_react69.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9928
|
+
const [renaming, setRenaming] = (0, import_react69.useState)(null);
|
|
9929
|
+
const [color, setColor] = (0, import_react69.useState)("#000000");
|
|
9930
|
+
const [width, setWidth] = (0, import_react69.useState)(2);
|
|
9931
|
+
const [error, setError] = (0, import_react69.useState)(null);
|
|
9890
9932
|
const paths = controller.getPaths();
|
|
9891
9933
|
const activeId = controller.getState().activePathId ?? null;
|
|
9892
9934
|
const active = paths.find((p) => p.id === activeId) ?? null;
|
|
@@ -9902,10 +9944,10 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9902
9944
|
};
|
|
9903
9945
|
return (
|
|
9904
9946
|
// Clicking the panel's empty space deselects the path (the path tools then edit the active layer).
|
|
9905
|
-
/* @__PURE__ */ (0,
|
|
9906
|
-
/* @__PURE__ */ (0,
|
|
9907
|
-
paths.length === 0 && /* @__PURE__ */ (0,
|
|
9908
|
-
/* @__PURE__ */ (0,
|
|
9947
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { "data-testid": "paths-panel", className: `flex flex-col gap-2 text-xs ${className}`, onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: [
|
|
9948
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: imageSectionTitleClass, children: "Paths" }),
|
|
9949
|
+
paths.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "text-muted-foreground", children: "No paths. Make a work path from a selection." }),
|
|
9950
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5 min-h-4", onClick: (e) => e.target === e.currentTarget && attempt(() => controller.setActivePath(null)), children: paths.map((p) => /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
9909
9951
|
"li",
|
|
9910
9952
|
{
|
|
9911
9953
|
"data-testid": "path-row",
|
|
@@ -9914,8 +9956,8 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9914
9956
|
onClick: () => attempt(() => controller.setActivePath(p.id)),
|
|
9915
9957
|
onDoubleClick: () => setRenaming(p.id),
|
|
9916
9958
|
children: [
|
|
9917
|
-
/* @__PURE__ */ (0,
|
|
9918
|
-
renaming === p.id ? /* @__PURE__ */ (0,
|
|
9959
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("svg", { "aria-hidden": "true", viewBox: `0 0 ${w || 1} ${h || 1}`, style: { width: thumbnailSize, height: thumbnailSize }, className: "shrink-0 rounded ring-1 ring-border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("path", { d: (0, import_image_editor20.pathSvgData)(p), fill: "currentColor", fillOpacity: 0.25, stroke: "currentColor", strokeWidth: Math.max(w, h) / 64, fillRule: p.fillRule ?? "nonzero" }) }),
|
|
9960
|
+
renaming === p.id ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
9919
9961
|
"input",
|
|
9920
9962
|
{
|
|
9921
9963
|
autoFocus: true,
|
|
@@ -9934,13 +9976,13 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9934
9976
|
if (e.key === "Escape") setRenaming(null);
|
|
9935
9977
|
}
|
|
9936
9978
|
}
|
|
9937
|
-
) : /* @__PURE__ */ (0,
|
|
9979
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: `min-w-0 flex-1 truncate ${p.work ? "italic" : ""}`, children: p.name })
|
|
9938
9980
|
]
|
|
9939
9981
|
},
|
|
9940
9982
|
p.id
|
|
9941
9983
|
)) }),
|
|
9942
|
-
/* @__PURE__ */ (0,
|
|
9943
|
-
/* @__PURE__ */ (0,
|
|
9984
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
9985
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
9944
9986
|
"button",
|
|
9945
9987
|
{
|
|
9946
9988
|
type: "button",
|
|
@@ -9951,15 +9993,15 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9951
9993
|
children: "Load as Selection"
|
|
9952
9994
|
}
|
|
9953
9995
|
),
|
|
9954
|
-
/* @__PURE__ */ (0,
|
|
9955
|
-
active?.work && /* @__PURE__ */ (0,
|
|
9956
|
-
/* @__PURE__ */ (0,
|
|
9996
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !hasSelection, onClick: () => attempt(() => controller.makeWorkPath()), children: "Make Work Path" }),
|
|
9997
|
+
active?.work && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), onClick: () => setRenaming(active.id), children: "Save Path" }),
|
|
9998
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.addVectorMaskFromPath(active.id)), children: "Add Vector Mask" })
|
|
9957
9999
|
] }),
|
|
9958
|
-
/* @__PURE__ */ (0,
|
|
9959
|
-
/* @__PURE__ */ (0,
|
|
9960
|
-
/* @__PURE__ */ (0,
|
|
9961
|
-
/* @__PURE__ */ (0,
|
|
9962
|
-
/* @__PURE__ */ (0,
|
|
10000
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
10001
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("input", { type: "color", "aria-label": "Path paint colour", value: color, onChange: (e) => setColor(e.target.value), className: "h-6 w-8 bg-background border border-border rounded" }),
|
|
10002
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.fillPath(active.id, { color })), children: "Fill Path" }),
|
|
10003
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
10004
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
9963
10005
|
"input",
|
|
9964
10006
|
{
|
|
9965
10007
|
type: "number",
|
|
@@ -9974,25 +10016,25 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
9974
10016
|
),
|
|
9975
10017
|
"px"
|
|
9976
10018
|
] }),
|
|
9977
|
-
/* @__PURE__ */ (0,
|
|
10019
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.strokePath(active.id, { width, color })), children: "Stroke Path" })
|
|
9978
10020
|
] }),
|
|
9979
|
-
/* @__PURE__ */ (0,
|
|
9980
|
-
/* @__PURE__ */ (0,
|
|
9981
|
-
/* @__PURE__ */ (0,
|
|
10021
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
10022
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.duplicatePath(active.id)), children: "Duplicate" }),
|
|
10023
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: btn3(), disabled: !active, onClick: () => attempt(() => controller.deletePath(active.id)), children: "Delete" })
|
|
9982
10024
|
] }),
|
|
9983
|
-
error && /* @__PURE__ */ (0,
|
|
10025
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
9984
10026
|
] })
|
|
9985
10027
|
);
|
|
9986
10028
|
};
|
|
9987
10029
|
|
|
9988
10030
|
// src/image-editor/FreeTransformOptionsBar.tsx
|
|
9989
|
-
var
|
|
10031
|
+
var import_react70 = require("react");
|
|
9990
10032
|
var import_image_editor21 = require("@pixerate/editor/image-editor");
|
|
9991
|
-
var
|
|
10033
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
9992
10034
|
var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
|
|
9993
10035
|
var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
9994
|
-
const [, setTick] = (0,
|
|
9995
|
-
(0,
|
|
10036
|
+
const [, setTick] = (0, import_react70.useState)(0);
|
|
10037
|
+
(0, import_react70.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
|
|
9996
10038
|
const bar = tool.bar();
|
|
9997
10039
|
if (!tool.active || !bar) return null;
|
|
9998
10040
|
const warp = tool.warpBar();
|
|
@@ -10004,17 +10046,17 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10004
10046
|
const v = Number(raw);
|
|
10005
10047
|
if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
|
|
10006
10048
|
};
|
|
10007
|
-
return /* @__PURE__ */ (0,
|
|
10008
|
-
/* @__PURE__ */ (0,
|
|
10009
|
-
/* @__PURE__ */ (0,
|
|
10010
|
-
tool.mode === "warp" && /* @__PURE__ */ (0,
|
|
10011
|
-
/* @__PURE__ */ (0,
|
|
10012
|
-
/* @__PURE__ */ (0,
|
|
10013
|
-
/* @__PURE__ */ (0,
|
|
10049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.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: [
|
|
10050
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor21.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime50.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)) }),
|
|
10051
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor21.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime50.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)) }),
|
|
10052
|
+
tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
|
|
10053
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10054
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: "Warp" }),
|
|
10055
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: imageFieldClass, children: import_image_editor21.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: o.id, children: o.label }, o.id)) })
|
|
10014
10056
|
] }),
|
|
10015
|
-
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0,
|
|
10016
|
-
/* @__PURE__ */ (0,
|
|
10017
|
-
/* @__PURE__ */ (0,
|
|
10057
|
+
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10058
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
|
|
10059
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10018
10060
|
"input",
|
|
10019
10061
|
{
|
|
10020
10062
|
type: "number",
|
|
@@ -10035,9 +10077,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10035
10077
|
},
|
|
10036
10078
|
`${k}:${warp[k]}`
|
|
10037
10079
|
),
|
|
10038
|
-
/* @__PURE__ */ (0,
|
|
10080
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: "%" })
|
|
10039
10081
|
] }, k)),
|
|
10040
|
-
/* @__PURE__ */ (0,
|
|
10082
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10041
10083
|
"button",
|
|
10042
10084
|
{
|
|
10043
10085
|
type: "button",
|
|
@@ -10049,9 +10091,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10049
10091
|
children: "Vertical"
|
|
10050
10092
|
}
|
|
10051
10093
|
),
|
|
10052
|
-
/* @__PURE__ */ (0,
|
|
10053
|
-
/* @__PURE__ */ (0,
|
|
10054
|
-
/* @__PURE__ */ (0,
|
|
10094
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10095
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: "Grid" }),
|
|
10096
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10055
10097
|
"select",
|
|
10056
10098
|
{
|
|
10057
10099
|
"aria-label": "Warp grid",
|
|
@@ -10061,14 +10103,14 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10061
10103
|
tool.setWarp({ columns: g.columns, rows: g.rows });
|
|
10062
10104
|
},
|
|
10063
10105
|
className: imageFieldClass,
|
|
10064
|
-
children: import_image_editor21.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0,
|
|
10106
|
+
children: import_image_editor21.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: g.id, children: g.label }, g.id))
|
|
10065
10107
|
}
|
|
10066
10108
|
)
|
|
10067
10109
|
] })
|
|
10068
10110
|
] }),
|
|
10069
|
-
tool.mode !== "warp" && import_image_editor21.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0,
|
|
10070
|
-
/* @__PURE__ */ (0,
|
|
10071
|
-
/* @__PURE__ */ (0,
|
|
10111
|
+
tool.mode !== "warp" && import_image_editor21.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
|
|
10112
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: f.label }),
|
|
10113
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10072
10114
|
"input",
|
|
10073
10115
|
{
|
|
10074
10116
|
type: "number",
|
|
@@ -10088,8 +10130,8 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10088
10130
|
},
|
|
10089
10131
|
`${f.id}:${round(bar[f.id], f.unit)}`
|
|
10090
10132
|
),
|
|
10091
|
-
/* @__PURE__ */ (0,
|
|
10092
|
-
f.id === "scaleX" && /* @__PURE__ */ (0,
|
|
10133
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: f.unit }),
|
|
10134
|
+
f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10093
10135
|
"button",
|
|
10094
10136
|
{
|
|
10095
10137
|
type: "button",
|
|
@@ -10104,33 +10146,33 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
10104
10146
|
}
|
|
10105
10147
|
)
|
|
10106
10148
|
] }, f.id)),
|
|
10107
|
-
/* @__PURE__ */ (0,
|
|
10108
|
-
/* @__PURE__ */ (0,
|
|
10109
|
-
/* @__PURE__ */ (0,
|
|
10149
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10150
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-muted-foreground", children: "Interpolation" }),
|
|
10151
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10110
10152
|
"select",
|
|
10111
10153
|
{
|
|
10112
10154
|
"aria-label": "Interpolation",
|
|
10113
10155
|
value: tool.interpolation,
|
|
10114
10156
|
onChange: (e) => tool.setInterpolation(e.target.value),
|
|
10115
10157
|
className: imageFieldClass,
|
|
10116
|
-
children: import_image_editor21.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0,
|
|
10158
|
+
children: import_image_editor21.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
|
|
10117
10159
|
}
|
|
10118
10160
|
)
|
|
10119
10161
|
] }),
|
|
10120
|
-
/* @__PURE__ */ (0,
|
|
10121
|
-
/* @__PURE__ */ (0,
|
|
10122
|
-
tool.error && /* @__PURE__ */ (0,
|
|
10162
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.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" }),
|
|
10163
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("button", { type: "button", title: "Cancel (Esc)", className: imageChipClass(false), onClick: () => tool.cancel(), children: "Cancel" }),
|
|
10164
|
+
tool.error && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { role: "alert", className: "text-destructive", children: tool.error })
|
|
10123
10165
|
] });
|
|
10124
10166
|
};
|
|
10125
10167
|
|
|
10126
10168
|
// src/image-editor/ShapeOptionsBar.tsx
|
|
10127
|
-
var
|
|
10169
|
+
var import_react71 = require("react");
|
|
10128
10170
|
var import_image_editor22 = require("@pixerate/editor/image-editor");
|
|
10129
|
-
var
|
|
10171
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
10130
10172
|
var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
10131
|
-
const [, setTick] = (0,
|
|
10132
|
-
(0,
|
|
10133
|
-
const [error, setError] = (0,
|
|
10173
|
+
const [, setTick] = (0, import_react71.useState)(0);
|
|
10174
|
+
(0, import_react71.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
10175
|
+
const [error, setError] = (0, import_react71.useState)(null);
|
|
10134
10176
|
const active = controller.getActiveLayer();
|
|
10135
10177
|
const shapeId = active?.type === "shape" ? active.id : null;
|
|
10136
10178
|
const set = (change) => {
|
|
@@ -10144,22 +10186,22 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
10144
10186
|
}
|
|
10145
10187
|
};
|
|
10146
10188
|
const num = (v, min, max) => Math.max(min, Math.min(max, Number(v) || min));
|
|
10147
|
-
return /* @__PURE__ */ (0,
|
|
10148
|
-
/* @__PURE__ */ (0,
|
|
10149
|
-
/* @__PURE__ */ (0,
|
|
10150
|
-
/* @__PURE__ */ (0,
|
|
10151
|
-
/* @__PURE__ */ (0,
|
|
10189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "shape-options", children: [
|
|
10190
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor22.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: imageChipClass(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor22.SHAPE_KIND_LABELS[k] }, k)) }),
|
|
10191
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
10192
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10193
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
|
|
10152
10194
|
"Fill",
|
|
10153
|
-
/* @__PURE__ */ (0,
|
|
10195
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
|
|
10154
10196
|
] }),
|
|
10155
|
-
/* @__PURE__ */ (0,
|
|
10156
|
-
/* @__PURE__ */ (0,
|
|
10197
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10198
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
|
|
10157
10199
|
"Stroke",
|
|
10158
|
-
/* @__PURE__ */ (0,
|
|
10200
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
|
|
10159
10201
|
] }),
|
|
10160
|
-
/* @__PURE__ */ (0,
|
|
10202
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10161
10203
|
"Width",
|
|
10162
|
-
/* @__PURE__ */ (0,
|
|
10204
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
10163
10205
|
"input",
|
|
10164
10206
|
{
|
|
10165
10207
|
type: "number",
|
|
@@ -10173,52 +10215,52 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
10173
10215
|
)
|
|
10174
10216
|
] })
|
|
10175
10217
|
] }),
|
|
10176
|
-
/* @__PURE__ */ (0,
|
|
10177
|
-
options.kind === "rect" && /* @__PURE__ */ (0,
|
|
10218
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
10219
|
+
options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10178
10220
|
"Radius",
|
|
10179
|
-
/* @__PURE__ */ (0,
|
|
10221
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.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}` })
|
|
10180
10222
|
] }),
|
|
10181
|
-
options.kind === "polygon" && /* @__PURE__ */ (0,
|
|
10223
|
+
options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10182
10224
|
"Sides",
|
|
10183
|
-
/* @__PURE__ */ (0,
|
|
10225
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.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}` })
|
|
10184
10226
|
] }),
|
|
10185
|
-
options.kind === "star" && /* @__PURE__ */ (0,
|
|
10186
|
-
/* @__PURE__ */ (0,
|
|
10227
|
+
options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
|
|
10228
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10187
10229
|
"Points",
|
|
10188
|
-
/* @__PURE__ */ (0,
|
|
10230
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.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}` })
|
|
10189
10231
|
] }),
|
|
10190
|
-
/* @__PURE__ */ (0,
|
|
10232
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10191
10233
|
"Inner",
|
|
10192
|
-
/* @__PURE__ */ (0,
|
|
10234
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageRange, { label: "Inner radius", min: 0.05, max: 1, step: 0.05, value: options.innerRatio, onChange: (v) => set({ innerRatio: v }) })
|
|
10193
10235
|
] })
|
|
10194
10236
|
] }),
|
|
10195
|
-
options.kind === "line" && /* @__PURE__ */ (0,
|
|
10196
|
-
/* @__PURE__ */ (0,
|
|
10237
|
+
options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
|
|
10238
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10197
10239
|
"Weight",
|
|
10198
|
-
/* @__PURE__ */ (0,
|
|
10240
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.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}` })
|
|
10199
10241
|
] }),
|
|
10200
|
-
/* @__PURE__ */ (0,
|
|
10201
|
-
/* @__PURE__ */ (0,
|
|
10242
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10243
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ImageCheckbox, { label: "Arrowhead", checked: options.arrow, onChange: (on) => set({ arrow: on }) }),
|
|
10202
10244
|
"Arrowhead"
|
|
10203
10245
|
] })
|
|
10204
10246
|
] })
|
|
10205
10247
|
] }),
|
|
10206
|
-
/* @__PURE__ */ (0,
|
|
10207
|
-
error && /* @__PURE__ */ (0,
|
|
10248
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.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." }),
|
|
10249
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
10208
10250
|
] });
|
|
10209
10251
|
};
|
|
10210
10252
|
|
|
10211
10253
|
// src/image-editor/TypeOptionsBar.tsx
|
|
10212
|
-
var
|
|
10254
|
+
var import_react72 = require("react");
|
|
10213
10255
|
var import_image_editor23 = require("@pixerate/editor/image-editor");
|
|
10214
|
-
var
|
|
10256
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
10215
10257
|
var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
|
|
10216
10258
|
var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
|
|
10217
10259
|
var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
|
|
10218
|
-
const [, setTick] = (0,
|
|
10219
|
-
(0,
|
|
10220
|
-
(0,
|
|
10221
|
-
const [error, setError] = (0,
|
|
10260
|
+
const [, setTick] = (0, import_react72.useState)(0);
|
|
10261
|
+
(0, import_react72.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
10262
|
+
(0, import_react72.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
|
|
10263
|
+
const [error, setError] = (0, import_react72.useState)(null);
|
|
10222
10264
|
const active = controller.getActiveLayer();
|
|
10223
10265
|
const typeId = !session && active?.type === "type" ? active.id : null;
|
|
10224
10266
|
const here = session?.alive ? session.styleHere() : {};
|
|
@@ -10271,11 +10313,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
10271
10313
|
setError(e instanceof Error ? e.message : String(e));
|
|
10272
10314
|
}
|
|
10273
10315
|
};
|
|
10274
|
-
return /* @__PURE__ */ (0,
|
|
10275
|
-
/* @__PURE__ */ (0,
|
|
10276
|
-
/* @__PURE__ */ (0,
|
|
10316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "type-options", children: [
|
|
10317
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
10318
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10277
10319
|
"Font",
|
|
10278
|
-
/* @__PURE__ */ (0,
|
|
10320
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10279
10321
|
"input",
|
|
10280
10322
|
{
|
|
10281
10323
|
list: "pixerate-type-fonts",
|
|
@@ -10285,11 +10327,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
10285
10327
|
className: "w-32 rounded border border-border bg-background px-1 py-0.5"
|
|
10286
10328
|
}
|
|
10287
10329
|
),
|
|
10288
|
-
/* @__PURE__ */ (0,
|
|
10330
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("option", { value: f }, f)) })
|
|
10289
10331
|
] }),
|
|
10290
|
-
/* @__PURE__ */ (0,
|
|
10332
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
10291
10333
|
"Size",
|
|
10292
|
-
/* @__PURE__ */ (0,
|
|
10334
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10293
10335
|
"input",
|
|
10294
10336
|
{
|
|
10295
10337
|
type: "number",
|
|
@@ -10302,14 +10344,14 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
10302
10344
|
}
|
|
10303
10345
|
)
|
|
10304
10346
|
] }),
|
|
10305
|
-
/* @__PURE__ */ (0,
|
|
10306
|
-
/* @__PURE__ */ (0,
|
|
10307
|
-
/* @__PURE__ */ (0,
|
|
10347
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.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" }),
|
|
10348
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
|
|
10349
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
|
|
10308
10350
|
] }),
|
|
10309
|
-
/* @__PURE__ */ (0,
|
|
10310
|
-
/* @__PURE__ */ (0,
|
|
10311
|
-
import_image_editor23.TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ (0,
|
|
10312
|
-
orientation === "vertical" && editedId && /* @__PURE__ */ (0,
|
|
10351
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor23.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
|
|
10352
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Orientation", children: [
|
|
10353
|
+
import_image_editor23.TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", "aria-pressed": orientation === o, className: imageChipClass(orientation === o), onClick: () => orient(o), children: ORIENTATION_LABELS[o] }, o)),
|
|
10354
|
+
orientation === "vertical" && editedId && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10313
10355
|
"button",
|
|
10314
10356
|
{
|
|
10315
10357
|
type: "button",
|
|
@@ -10321,19 +10363,19 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
10321
10363
|
}
|
|
10322
10364
|
)
|
|
10323
10365
|
] }),
|
|
10324
|
-
/* @__PURE__ */ (0,
|
|
10325
|
-
missing.length > 0 && /* @__PURE__ */ (0,
|
|
10366
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text (vertical: a column down from the click), drag for a paragraph box, click text to edit it. Esc finishes." }),
|
|
10367
|
+
missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
|
|
10326
10368
|
"Missing ",
|
|
10327
10369
|
missing.length === 1 ? "font" : "fonts",
|
|
10328
10370
|
": ",
|
|
10329
10371
|
missing.join(", ")
|
|
10330
10372
|
] }),
|
|
10331
|
-
error && /* @__PURE__ */ (0,
|
|
10373
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
10332
10374
|
] });
|
|
10333
10375
|
};
|
|
10334
10376
|
|
|
10335
10377
|
// src/image-editor/ImageEditor.tsx
|
|
10336
|
-
var
|
|
10378
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
10337
10379
|
var ImageEditor = ({
|
|
10338
10380
|
editor: externalEditor,
|
|
10339
10381
|
src,
|
|
@@ -10358,32 +10400,32 @@ var ImageEditor = ({
|
|
|
10358
10400
|
return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
|
|
10359
10401
|
});
|
|
10360
10402
|
const legacyProcess = (0, import_image_editor24.normalizeProcessVersion)(state.adjustments.process) < import_image_editor24.LATEST_PROCESS_VERSION;
|
|
10361
|
-
const [activeTab, setActiveTab] = (0,
|
|
10362
|
-
const rootRef = (0,
|
|
10403
|
+
const [activeTab, setActiveTab] = (0, import_react73.useState)("crop");
|
|
10404
|
+
const rootRef = (0, import_react73.useRef)(null);
|
|
10363
10405
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
10364
|
-
const activeTabRef = (0,
|
|
10406
|
+
const activeTabRef = (0, import_react73.useRef)(activeTab);
|
|
10365
10407
|
activeTabRef.current = activeTab;
|
|
10366
10408
|
const openPanel = async (ref) => {
|
|
10367
10409
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
10368
10410
|
rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
|
|
10369
10411
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
10370
10412
|
};
|
|
10371
|
-
const [activeCropRatio, setActiveCropRatio] = (0,
|
|
10372
|
-
const [selectionOptions, setSelectionOptions] = (0,
|
|
10373
|
-
const [shapeOptions, setShapeOptions] = (0,
|
|
10374
|
-
const [typeOptions, setTypeOptions] = (0,
|
|
10375
|
-
const [typeSession, setTypeSession] = (0,
|
|
10376
|
-
const [selectionError, setSelectionError] = (0,
|
|
10377
|
-
const [paintError, setPaintError] = (0,
|
|
10378
|
-
const [shapeTypeError, setShapeTypeError] = (0,
|
|
10413
|
+
const [activeCropRatio, setActiveCropRatio] = (0, import_react73.useState)(null);
|
|
10414
|
+
const [selectionOptions, setSelectionOptions] = (0, import_react73.useState)(import_image_editor24.DEFAULT_SELECTION_TOOL_OPTIONS);
|
|
10415
|
+
const [shapeOptions, setShapeOptions] = (0, import_react73.useState)(import_image_editor24.DEFAULT_SHAPE_TOOL_OPTIONS);
|
|
10416
|
+
const [typeOptions, setTypeOptions] = (0, import_react73.useState)(import_image_editor24.DEFAULT_TYPE_TOOL_OPTIONS);
|
|
10417
|
+
const [typeSession, setTypeSession] = (0, import_react73.useState)(null);
|
|
10418
|
+
const [selectionError, setSelectionError] = (0, import_react73.useState)(null);
|
|
10419
|
+
const [paintError, setPaintError] = (0, import_react73.useState)(null);
|
|
10420
|
+
const [shapeTypeError, setShapeTypeError] = (0, import_react73.useState)(null);
|
|
10379
10421
|
const handleCanvasError = (source, message2) => {
|
|
10380
10422
|
if (source === "paint") setPaintError(message2);
|
|
10381
10423
|
else if (source === "select") setSelectionError(message2);
|
|
10382
10424
|
else setShapeTypeError(message2);
|
|
10383
10425
|
};
|
|
10384
10426
|
const finishTyping = () => setTypeSession(null);
|
|
10385
|
-
const transformToolRef = (0,
|
|
10386
|
-
const transformControllerRef = (0,
|
|
10427
|
+
const transformToolRef = (0, import_react73.useRef)(null);
|
|
10428
|
+
const transformControllerRef = (0, import_react73.useRef)(controller);
|
|
10387
10429
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
10388
10430
|
transformToolRef.current?.cancel();
|
|
10389
10431
|
transformToolRef.current = new import_image_editor24.FreeTransformTool(controller, {
|
|
@@ -10392,16 +10434,16 @@ var ImageEditor = ({
|
|
|
10392
10434
|
transformControllerRef.current = controller;
|
|
10393
10435
|
}
|
|
10394
10436
|
const transformTool = transformToolRef.current;
|
|
10395
|
-
const [, setTransformTick] = (0,
|
|
10396
|
-
(0,
|
|
10397
|
-
(0,
|
|
10398
|
-
const [inpaintPrompt, setInpaintPrompt] = (0,
|
|
10399
|
-
const [inpaintMaskMode, setInpaintMaskMode] = (0,
|
|
10400
|
-
const [isRemovingBg, setIsRemovingBg] = (0,
|
|
10401
|
-
const [isInpainting, setIsInpainting] = (0,
|
|
10402
|
-
const [aiError, setAiError] = (0,
|
|
10403
|
-
const [aiSuccess, setAiSuccess] = (0,
|
|
10404
|
-
const [aiTarget, setAiTarget] = (0,
|
|
10437
|
+
const [, setTransformTick] = (0, import_react73.useState)(0);
|
|
10438
|
+
(0, import_react73.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
|
|
10439
|
+
(0, import_react73.useEffect)(() => () => transformToolRef.current?.cancel(), []);
|
|
10440
|
+
const [inpaintPrompt, setInpaintPrompt] = (0, import_react73.useState)("");
|
|
10441
|
+
const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react73.useState)("annotations");
|
|
10442
|
+
const [isRemovingBg, setIsRemovingBg] = (0, import_react73.useState)(false);
|
|
10443
|
+
const [isInpainting, setIsInpainting] = (0, import_react73.useState)(false);
|
|
10444
|
+
const [aiError, setAiError] = (0, import_react73.useState)(null);
|
|
10445
|
+
const [aiSuccess, setAiSuccess] = (0, import_react73.useState)(null);
|
|
10446
|
+
const [aiTarget, setAiTarget] = (0, import_react73.useState)("auto");
|
|
10405
10447
|
const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
|
|
10406
10448
|
const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
|
|
10407
10449
|
const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
|
|
@@ -10464,11 +10506,11 @@ var ImageEditor = ({
|
|
|
10464
10506
|
setIsInpainting(false);
|
|
10465
10507
|
}
|
|
10466
10508
|
};
|
|
10467
|
-
const [activeColor, setActiveColor] = (0,
|
|
10468
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
10469
|
-
const [fontSize, setFontSize] = (0,
|
|
10470
|
-
const [textInput, setTextInput] = (0,
|
|
10471
|
-
(0,
|
|
10509
|
+
const [activeColor, setActiveColor] = (0, import_react73.useState)("#ef4444");
|
|
10510
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react73.useState)(3);
|
|
10511
|
+
const [fontSize, setFontSize] = (0, import_react73.useState)(24);
|
|
10512
|
+
const [textInput, setTextInput] = (0, import_react73.useState)("");
|
|
10513
|
+
(0, import_react73.useEffect)(() => {
|
|
10472
10514
|
if (activeTab === "crop" && editor.state.activeTool !== "crop") {
|
|
10473
10515
|
editor.setTool("crop");
|
|
10474
10516
|
}
|
|
@@ -10496,16 +10538,16 @@ var ImageEditor = ({
|
|
|
10496
10538
|
link.click();
|
|
10497
10539
|
}
|
|
10498
10540
|
};
|
|
10499
|
-
return /* @__PURE__ */ (0,
|
|
10541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
10500
10542
|
"div",
|
|
10501
10543
|
{
|
|
10502
10544
|
ref: rootRef,
|
|
10503
10545
|
className: `${imageEditorFrameClass} ${className}`,
|
|
10504
10546
|
style,
|
|
10505
10547
|
children: [
|
|
10506
|
-
/* @__PURE__ */ (0,
|
|
10507
|
-
/* @__PURE__ */ (0,
|
|
10508
|
-
/* @__PURE__ */ (0,
|
|
10548
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: imageEditorHeaderClass, children: [
|
|
10549
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { role: "tablist", className: imageTabListClass, children: [
|
|
10550
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10509
10551
|
"button",
|
|
10510
10552
|
{
|
|
10511
10553
|
type: "button",
|
|
@@ -10520,7 +10562,7 @@ var ImageEditor = ({
|
|
|
10520
10562
|
children: "Transform & Crop"
|
|
10521
10563
|
}
|
|
10522
10564
|
),
|
|
10523
|
-
/* @__PURE__ */ (0,
|
|
10565
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10524
10566
|
"button",
|
|
10525
10567
|
{
|
|
10526
10568
|
type: "button",
|
|
@@ -10535,7 +10577,7 @@ var ImageEditor = ({
|
|
|
10535
10577
|
children: "Adjustments"
|
|
10536
10578
|
}
|
|
10537
10579
|
),
|
|
10538
|
-
/* @__PURE__ */ (0,
|
|
10580
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10539
10581
|
"button",
|
|
10540
10582
|
{
|
|
10541
10583
|
type: "button",
|
|
@@ -10550,7 +10592,7 @@ var ImageEditor = ({
|
|
|
10550
10592
|
children: "Layers"
|
|
10551
10593
|
}
|
|
10552
10594
|
),
|
|
10553
|
-
/* @__PURE__ */ (0,
|
|
10595
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10554
10596
|
"button",
|
|
10555
10597
|
{
|
|
10556
10598
|
type: "button",
|
|
@@ -10565,7 +10607,7 @@ var ImageEditor = ({
|
|
|
10565
10607
|
children: "Paint"
|
|
10566
10608
|
}
|
|
10567
10609
|
),
|
|
10568
|
-
/* @__PURE__ */ (0,
|
|
10610
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10569
10611
|
"button",
|
|
10570
10612
|
{
|
|
10571
10613
|
type: "button",
|
|
@@ -10580,7 +10622,7 @@ var ImageEditor = ({
|
|
|
10580
10622
|
children: "Select & Mask"
|
|
10581
10623
|
}
|
|
10582
10624
|
),
|
|
10583
|
-
/* @__PURE__ */ (0,
|
|
10625
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10584
10626
|
"button",
|
|
10585
10627
|
{
|
|
10586
10628
|
type: "button",
|
|
@@ -10595,7 +10637,7 @@ var ImageEditor = ({
|
|
|
10595
10637
|
children: "Annotations"
|
|
10596
10638
|
}
|
|
10597
10639
|
),
|
|
10598
|
-
/* @__PURE__ */ (0,
|
|
10640
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10599
10641
|
"button",
|
|
10600
10642
|
{
|
|
10601
10643
|
type: "button",
|
|
@@ -10610,7 +10652,7 @@ var ImageEditor = ({
|
|
|
10610
10652
|
children: "Depth Mask"
|
|
10611
10653
|
}
|
|
10612
10654
|
),
|
|
10613
|
-
/* @__PURE__ */ (0,
|
|
10655
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
10614
10656
|
"button",
|
|
10615
10657
|
{
|
|
10616
10658
|
type: "button",
|
|
@@ -10623,14 +10665,14 @@ var ImageEditor = ({
|
|
|
10623
10665
|
"aria-selected": activeTab === "ai",
|
|
10624
10666
|
className: `${imageTabClass(activeTab === "ai")} flex items-center gap-1.5`,
|
|
10625
10667
|
children: [
|
|
10626
|
-
/* @__PURE__ */ (0,
|
|
10668
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.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_runtime53.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" }) }),
|
|
10627
10669
|
"AI Tools"
|
|
10628
10670
|
]
|
|
10629
10671
|
}
|
|
10630
10672
|
)
|
|
10631
10673
|
] }),
|
|
10632
|
-
/* @__PURE__ */ (0,
|
|
10633
|
-
/* @__PURE__ */ (0,
|
|
10674
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
10675
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10634
10676
|
"button",
|
|
10635
10677
|
{
|
|
10636
10678
|
type: "button",
|
|
@@ -10641,7 +10683,7 @@ var ImageEditor = ({
|
|
|
10641
10683
|
children: "\u21A9"
|
|
10642
10684
|
}
|
|
10643
10685
|
),
|
|
10644
|
-
/* @__PURE__ */ (0,
|
|
10686
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10645
10687
|
"button",
|
|
10646
10688
|
{
|
|
10647
10689
|
type: "button",
|
|
@@ -10652,7 +10694,7 @@ var ImageEditor = ({
|
|
|
10652
10694
|
children: "\u21AA"
|
|
10653
10695
|
}
|
|
10654
10696
|
),
|
|
10655
|
-
/* @__PURE__ */ (0,
|
|
10697
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10656
10698
|
"button",
|
|
10657
10699
|
{
|
|
10658
10700
|
type: "button",
|
|
@@ -10661,8 +10703,8 @@ var ImageEditor = ({
|
|
|
10661
10703
|
children: "Reset"
|
|
10662
10704
|
}
|
|
10663
10705
|
),
|
|
10664
|
-
/* @__PURE__ */ (0,
|
|
10665
|
-
/* @__PURE__ */ (0,
|
|
10706
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
10707
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10666
10708
|
"button",
|
|
10667
10709
|
{
|
|
10668
10710
|
type: "button",
|
|
@@ -10672,11 +10714,11 @@ var ImageEditor = ({
|
|
|
10672
10714
|
children: "-"
|
|
10673
10715
|
}
|
|
10674
10716
|
),
|
|
10675
|
-
/* @__PURE__ */ (0,
|
|
10717
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "font-mono text-muted-foreground w-10 text-center", children: [
|
|
10676
10718
|
Math.round(state.zoom * 100),
|
|
10677
10719
|
"%"
|
|
10678
10720
|
] }),
|
|
10679
|
-
/* @__PURE__ */ (0,
|
|
10721
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10680
10722
|
"button",
|
|
10681
10723
|
{
|
|
10682
10724
|
type: "button",
|
|
@@ -10686,8 +10728,8 @@ var ImageEditor = ({
|
|
|
10686
10728
|
children: "+"
|
|
10687
10729
|
}
|
|
10688
10730
|
),
|
|
10689
|
-
/* @__PURE__ */ (0,
|
|
10690
|
-
/* @__PURE__ */ (0,
|
|
10731
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
10732
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10691
10733
|
"button",
|
|
10692
10734
|
{
|
|
10693
10735
|
type: "button",
|
|
@@ -10698,7 +10740,7 @@ var ImageEditor = ({
|
|
|
10698
10740
|
children: "Hold Compare"
|
|
10699
10741
|
}
|
|
10700
10742
|
),
|
|
10701
|
-
/* @__PURE__ */ (0,
|
|
10743
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10702
10744
|
"button",
|
|
10703
10745
|
{
|
|
10704
10746
|
type: "button",
|
|
@@ -10709,10 +10751,10 @@ var ImageEditor = ({
|
|
|
10709
10751
|
)
|
|
10710
10752
|
] })
|
|
10711
10753
|
] }),
|
|
10712
|
-
transformTool.active && /* @__PURE__ */ (0,
|
|
10713
|
-
!transformTool.active && transformTool.error && /* @__PURE__ */ (0,
|
|
10714
|
-
/* @__PURE__ */ (0,
|
|
10715
|
-
/* @__PURE__ */ (0,
|
|
10754
|
+
transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-border bg-background/95 px-4 py-2" }),
|
|
10755
|
+
!transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { role: "alert", className: imageErrorBannerClass, children: transformTool.error }),
|
|
10756
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
|
|
10757
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10716
10758
|
ImageEditorCanvas,
|
|
10717
10759
|
{
|
|
10718
10760
|
editor,
|
|
@@ -10736,11 +10778,11 @@ var ImageEditor = ({
|
|
|
10736
10778
|
className: "flex-1 h-[360px] md:h-full min-h-[320px] bg-muted"
|
|
10737
10779
|
}
|
|
10738
10780
|
),
|
|
10739
|
-
/* @__PURE__ */ (0,
|
|
10740
|
-
activeTab === "crop" && /* @__PURE__ */ (0,
|
|
10741
|
-
/* @__PURE__ */ (0,
|
|
10742
|
-
/* @__PURE__ */ (0,
|
|
10743
|
-
/* @__PURE__ */ (0,
|
|
10781
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: imageSidebarClass, children: [
|
|
10782
|
+
activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10783
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Aspect Ratio Presets" }),
|
|
10784
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
|
|
10785
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10744
10786
|
"button",
|
|
10745
10787
|
{
|
|
10746
10788
|
type: "button",
|
|
@@ -10752,7 +10794,7 @@ var ImageEditor = ({
|
|
|
10752
10794
|
children: "Freeform"
|
|
10753
10795
|
}
|
|
10754
10796
|
),
|
|
10755
|
-
/* @__PURE__ */ (0,
|
|
10797
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10756
10798
|
"button",
|
|
10757
10799
|
{
|
|
10758
10800
|
type: "button",
|
|
@@ -10764,7 +10806,7 @@ var ImageEditor = ({
|
|
|
10764
10806
|
children: "1:1 Square"
|
|
10765
10807
|
}
|
|
10766
10808
|
),
|
|
10767
|
-
/* @__PURE__ */ (0,
|
|
10809
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10768
10810
|
"button",
|
|
10769
10811
|
{
|
|
10770
10812
|
type: "button",
|
|
@@ -10776,7 +10818,7 @@ var ImageEditor = ({
|
|
|
10776
10818
|
children: "4:3 Standard"
|
|
10777
10819
|
}
|
|
10778
10820
|
),
|
|
10779
|
-
/* @__PURE__ */ (0,
|
|
10821
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10780
10822
|
"button",
|
|
10781
10823
|
{
|
|
10782
10824
|
type: "button",
|
|
@@ -10788,7 +10830,7 @@ var ImageEditor = ({
|
|
|
10788
10830
|
children: "16:9 Wide"
|
|
10789
10831
|
}
|
|
10790
10832
|
),
|
|
10791
|
-
/* @__PURE__ */ (0,
|
|
10833
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10792
10834
|
"button",
|
|
10793
10835
|
{
|
|
10794
10836
|
type: "button",
|
|
@@ -10800,7 +10842,7 @@ var ImageEditor = ({
|
|
|
10800
10842
|
children: "3:2 Photo"
|
|
10801
10843
|
}
|
|
10802
10844
|
),
|
|
10803
|
-
/* @__PURE__ */ (0,
|
|
10845
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10804
10846
|
"button",
|
|
10805
10847
|
{
|
|
10806
10848
|
type: "button",
|
|
@@ -10813,10 +10855,10 @@ var ImageEditor = ({
|
|
|
10813
10855
|
}
|
|
10814
10856
|
)
|
|
10815
10857
|
] }),
|
|
10816
|
-
/* @__PURE__ */ (0,
|
|
10817
|
-
/* @__PURE__ */ (0,
|
|
10818
|
-
/* @__PURE__ */ (0,
|
|
10819
|
-
/* @__PURE__ */ (0,
|
|
10858
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageDividerClass }),
|
|
10859
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Orientation & Flips" }),
|
|
10860
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
10861
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10820
10862
|
"button",
|
|
10821
10863
|
{
|
|
10822
10864
|
type: "button",
|
|
@@ -10825,7 +10867,7 @@ var ImageEditor = ({
|
|
|
10825
10867
|
children: "Rotate -90\xB0"
|
|
10826
10868
|
}
|
|
10827
10869
|
),
|
|
10828
|
-
/* @__PURE__ */ (0,
|
|
10870
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10829
10871
|
"button",
|
|
10830
10872
|
{
|
|
10831
10873
|
type: "button",
|
|
@@ -10834,7 +10876,7 @@ var ImageEditor = ({
|
|
|
10834
10876
|
children: "Rotate +90\xB0"
|
|
10835
10877
|
}
|
|
10836
10878
|
),
|
|
10837
|
-
/* @__PURE__ */ (0,
|
|
10879
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10838
10880
|
"button",
|
|
10839
10881
|
{
|
|
10840
10882
|
type: "button",
|
|
@@ -10843,7 +10885,7 @@ var ImageEditor = ({
|
|
|
10843
10885
|
children: "Flip Horizontal"
|
|
10844
10886
|
}
|
|
10845
10887
|
),
|
|
10846
|
-
/* @__PURE__ */ (0,
|
|
10888
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10847
10889
|
"button",
|
|
10848
10890
|
{
|
|
10849
10891
|
type: "button",
|
|
@@ -10854,10 +10896,10 @@ var ImageEditor = ({
|
|
|
10854
10896
|
)
|
|
10855
10897
|
] })
|
|
10856
10898
|
] }),
|
|
10857
|
-
activeTab === "adjust" && /* @__PURE__ */ (0,
|
|
10858
|
-
/* @__PURE__ */ (0,
|
|
10859
|
-
/* @__PURE__ */ (0,
|
|
10860
|
-
/* @__PURE__ */ (0,
|
|
10899
|
+
activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10900
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10901
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Color Adjustments" }),
|
|
10902
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10861
10903
|
"button",
|
|
10862
10904
|
{
|
|
10863
10905
|
type: "button",
|
|
@@ -10867,9 +10909,9 @@ var ImageEditor = ({
|
|
|
10867
10909
|
}
|
|
10868
10910
|
)
|
|
10869
10911
|
] }),
|
|
10870
|
-
/* @__PURE__ */ (0,
|
|
10871
|
-
import_image_editor24.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0,
|
|
10872
|
-
/* @__PURE__ */ (0,
|
|
10912
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Histogram, { histogram: editor.histogram }),
|
|
10913
|
+
import_image_editor24.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react73.default.Fragment, { children: [
|
|
10914
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10873
10915
|
ControlSlider,
|
|
10874
10916
|
{
|
|
10875
10917
|
spec,
|
|
@@ -10878,14 +10920,14 @@ var ImageEditor = ({
|
|
|
10878
10920
|
onChange: (v) => editor.setAdjustments({ [spec.id]: v })
|
|
10879
10921
|
}
|
|
10880
10922
|
),
|
|
10881
|
-
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0,
|
|
10923
|
+
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
10882
10924
|
"div",
|
|
10883
10925
|
{
|
|
10884
10926
|
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",
|
|
10885
10927
|
"data-testid": "image-editor-process-notice",
|
|
10886
10928
|
children: [
|
|
10887
|
-
/* @__PURE__ */ (0,
|
|
10888
|
-
/* @__PURE__ */ (0,
|
|
10929
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
|
|
10930
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10889
10931
|
"button",
|
|
10890
10932
|
{
|
|
10891
10933
|
type: "button",
|
|
@@ -10898,7 +10940,7 @@ var ImageEditor = ({
|
|
|
10898
10940
|
}
|
|
10899
10941
|
)
|
|
10900
10942
|
] }, spec.id)),
|
|
10901
|
-
/* @__PURE__ */ (0,
|
|
10943
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10902
10944
|
AdjustmentLayersPanel,
|
|
10903
10945
|
{
|
|
10904
10946
|
controller,
|
|
@@ -10907,9 +10949,9 @@ var ImageEditor = ({
|
|
|
10907
10949
|
}
|
|
10908
10950
|
) })
|
|
10909
10951
|
] }),
|
|
10910
|
-
activeTab === "layers" && /* @__PURE__ */ (0,
|
|
10911
|
-
/* @__PURE__ */ (0,
|
|
10912
|
-
/* @__PURE__ */ (0,
|
|
10952
|
+
activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10953
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Layers" }),
|
|
10954
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10913
10955
|
"button",
|
|
10914
10956
|
{
|
|
10915
10957
|
type: "button",
|
|
@@ -10920,15 +10962,15 @@ var ImageEditor = ({
|
|
|
10920
10962
|
children: "Free Transform"
|
|
10921
10963
|
}
|
|
10922
10964
|
),
|
|
10923
|
-
/* @__PURE__ */ (0,
|
|
10924
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
10925
|
-
/* @__PURE__ */ (0,
|
|
10926
|
-
/* @__PURE__ */ (0,
|
|
10965
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(LayersPanel, { controller }),
|
|
10966
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ImageProviderEffectsPanel, { controller, className: imageSectionClass }),
|
|
10967
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Colour" }),
|
|
10968
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ColorProfilePanel, { controller })
|
|
10927
10969
|
] }),
|
|
10928
|
-
activeTab === "paint" && /* @__PURE__ */ (0,
|
|
10929
|
-
/* @__PURE__ */ (0,
|
|
10930
|
-
/* @__PURE__ */ (0,
|
|
10931
|
-
/* @__PURE__ */ (0,
|
|
10970
|
+
activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10971
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Paint" }),
|
|
10972
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(BrushOptionsBar, { controller }),
|
|
10973
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10932
10974
|
"button",
|
|
10933
10975
|
{
|
|
10934
10976
|
type: "button",
|
|
@@ -10939,12 +10981,12 @@ var ImageEditor = ({
|
|
|
10939
10981
|
children: "Free Transform"
|
|
10940
10982
|
}
|
|
10941
10983
|
),
|
|
10942
|
-
paintError && /* @__PURE__ */ (0,
|
|
10943
|
-
/* @__PURE__ */ (0,
|
|
10984
|
+
paintError && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "paint-error", children: paintError }),
|
|
10985
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(LayersPanel, { controller }) })
|
|
10944
10986
|
] }),
|
|
10945
|
-
activeTab === "annotate" && /* @__PURE__ */ (0,
|
|
10946
|
-
/* @__PURE__ */ (0,
|
|
10947
|
-
/* @__PURE__ */ (0,
|
|
10987
|
+
activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
10988
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers, Paths" }),
|
|
10989
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type", "path-pen", "path-select", "direct-select"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10948
10990
|
"button",
|
|
10949
10991
|
{
|
|
10950
10992
|
type: "button",
|
|
@@ -10955,13 +10997,13 @@ var ImageEditor = ({
|
|
|
10955
10997
|
},
|
|
10956
10998
|
t
|
|
10957
10999
|
)) }),
|
|
10958
|
-
state.activeTool === "shape" && /* @__PURE__ */ (0,
|
|
10959
|
-
state.activeTool === "type" && /* @__PURE__ */ (0,
|
|
10960
|
-
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0,
|
|
10961
|
-
shapeTypeError && /* @__PURE__ */ (0,
|
|
10962
|
-
/* @__PURE__ */ (0,
|
|
10963
|
-
/* @__PURE__ */ (0,
|
|
10964
|
-
/* @__PURE__ */ (0,
|
|
11000
|
+
state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
|
|
11001
|
+
state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
|
|
11002
|
+
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime53.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" }),
|
|
11003
|
+
shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "shape-type-error", children: shapeTypeError }),
|
|
11004
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageDividerClass }),
|
|
11005
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Draw & Annotate" }),
|
|
11006
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10965
11007
|
"button",
|
|
10966
11008
|
{
|
|
10967
11009
|
type: "button",
|
|
@@ -10971,18 +11013,18 @@ var ImageEditor = ({
|
|
|
10971
11013
|
},
|
|
10972
11014
|
t
|
|
10973
11015
|
)) }),
|
|
10974
|
-
/* @__PURE__ */ (0,
|
|
10975
|
-
/* @__PURE__ */ (0,
|
|
10976
|
-
/* @__PURE__ */ (0,
|
|
10977
|
-
/* @__PURE__ */ (0,
|
|
10978
|
-
/* @__PURE__ */ (0,
|
|
10979
|
-
/* @__PURE__ */ (0,
|
|
10980
|
-
/* @__PURE__ */ (0,
|
|
11016
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
|
|
11017
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
|
|
11018
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
|
|
11019
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex-1 ml-2", children: [
|
|
11020
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
|
|
11021
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Width:" }),
|
|
11022
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "font-mono", children: [
|
|
10981
11023
|
strokeWidth,
|
|
10982
11024
|
"px"
|
|
10983
11025
|
] })
|
|
10984
11026
|
] }),
|
|
10985
|
-
/* @__PURE__ */ (0,
|
|
11027
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10986
11028
|
"input",
|
|
10987
11029
|
{
|
|
10988
11030
|
type: "range",
|
|
@@ -10995,10 +11037,10 @@ var ImageEditor = ({
|
|
|
10995
11037
|
)
|
|
10996
11038
|
] })
|
|
10997
11039
|
] }),
|
|
10998
|
-
/* @__PURE__ */ (0,
|
|
10999
|
-
/* @__PURE__ */ (0,
|
|
11000
|
-
/* @__PURE__ */ (0,
|
|
11001
|
-
/* @__PURE__ */ (0,
|
|
11040
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageDividerClass }),
|
|
11041
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Add Text" }),
|
|
11042
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex gap-2", children: [
|
|
11043
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11002
11044
|
"input",
|
|
11003
11045
|
{
|
|
11004
11046
|
type: "text",
|
|
@@ -11009,7 +11051,7 @@ var ImageEditor = ({
|
|
|
11009
11051
|
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"
|
|
11010
11052
|
}
|
|
11011
11053
|
),
|
|
11012
|
-
/* @__PURE__ */ (0,
|
|
11054
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11013
11055
|
"button",
|
|
11014
11056
|
{
|
|
11015
11057
|
type: "button",
|
|
@@ -11019,14 +11061,14 @@ var ImageEditor = ({
|
|
|
11019
11061
|
}
|
|
11020
11062
|
)
|
|
11021
11063
|
] }),
|
|
11022
|
-
/* @__PURE__ */ (0,
|
|
11023
|
-
/* @__PURE__ */ (0,
|
|
11024
|
-
/* @__PURE__ */ (0,
|
|
11064
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between text-muted-foreground", children: [
|
|
11065
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Font Size:" }),
|
|
11066
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "font-mono", children: [
|
|
11025
11067
|
fontSize,
|
|
11026
11068
|
"px"
|
|
11027
11069
|
] })
|
|
11028
11070
|
] }),
|
|
11029
|
-
/* @__PURE__ */ (0,
|
|
11071
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11030
11072
|
"input",
|
|
11031
11073
|
{
|
|
11032
11074
|
type: "range",
|
|
@@ -11037,14 +11079,14 @@ var ImageEditor = ({
|
|
|
11037
11079
|
className: imageRangeClass
|
|
11038
11080
|
}
|
|
11039
11081
|
),
|
|
11040
|
-
/* @__PURE__ */ (0,
|
|
11041
|
-
/* @__PURE__ */ (0,
|
|
11042
|
-
/* @__PURE__ */ (0,
|
|
11082
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageDividerClass }),
|
|
11083
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11084
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
11043
11085
|
"Layers (",
|
|
11044
11086
|
state.annotations.length,
|
|
11045
11087
|
")"
|
|
11046
11088
|
] }),
|
|
11047
|
-
state.selectedAnnotationId && /* @__PURE__ */ (0,
|
|
11089
|
+
state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11048
11090
|
"button",
|
|
11049
11091
|
{
|
|
11050
11092
|
type: "button",
|
|
@@ -11053,7 +11095,7 @@ var ImageEditor = ({
|
|
|
11053
11095
|
children: "Delete Selected"
|
|
11054
11096
|
}
|
|
11055
11097
|
),
|
|
11056
|
-
state.annotations.length > 0 && /* @__PURE__ */ (0,
|
|
11098
|
+
state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11057
11099
|
"button",
|
|
11058
11100
|
{
|
|
11059
11101
|
type: "button",
|
|
@@ -11064,10 +11106,10 @@ var ImageEditor = ({
|
|
|
11064
11106
|
)
|
|
11065
11107
|
] })
|
|
11066
11108
|
] }),
|
|
11067
|
-
activeTab === "depth" && /* @__PURE__ */ (0,
|
|
11068
|
-
/* @__PURE__ */ (0,
|
|
11069
|
-
/* @__PURE__ */ (0,
|
|
11070
|
-
/* @__PURE__ */ (0,
|
|
11109
|
+
activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
11110
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11111
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: imageSectionTitleClass, children: "Depth Masking" }),
|
|
11112
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11071
11113
|
"button",
|
|
11072
11114
|
{
|
|
11073
11115
|
type: "button",
|
|
@@ -11077,8 +11119,8 @@ var ImageEditor = ({
|
|
|
11077
11119
|
}
|
|
11078
11120
|
)
|
|
11079
11121
|
] }),
|
|
11080
|
-
/* @__PURE__ */ (0,
|
|
11081
|
-
/* @__PURE__ */ (0,
|
|
11122
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground", children: [
|
|
11123
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11082
11124
|
"input",
|
|
11083
11125
|
{
|
|
11084
11126
|
type: "checkbox",
|
|
@@ -11087,12 +11129,12 @@ var ImageEditor = ({
|
|
|
11087
11129
|
className: "rounded accent-primary"
|
|
11088
11130
|
}
|
|
11089
11131
|
),
|
|
11090
|
-
/* @__PURE__ */ (0,
|
|
11132
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Enable Depth / Alpha Mask" })
|
|
11091
11133
|
] }),
|
|
11092
|
-
state.depthMask.enabled && /* @__PURE__ */ (0,
|
|
11093
|
-
/* @__PURE__ */ (0,
|
|
11094
|
-
/* @__PURE__ */ (0,
|
|
11095
|
-
/* @__PURE__ */ (0,
|
|
11134
|
+
state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
11135
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
11136
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { className: "text-muted-foreground block mb-1", children: "Mask Image URL:" }),
|
|
11137
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11096
11138
|
"input",
|
|
11097
11139
|
{
|
|
11098
11140
|
type: "text",
|
|
@@ -11103,8 +11145,8 @@ var ImageEditor = ({
|
|
|
11103
11145
|
}
|
|
11104
11146
|
)
|
|
11105
11147
|
] }),
|
|
11106
|
-
/* @__PURE__ */ (0,
|
|
11107
|
-
/* @__PURE__ */ (0,
|
|
11148
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex gap-2", children: [
|
|
11149
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11108
11150
|
"button",
|
|
11109
11151
|
{
|
|
11110
11152
|
type: "button",
|
|
@@ -11113,7 +11155,7 @@ var ImageEditor = ({
|
|
|
11113
11155
|
children: "Threshold Mode"
|
|
11114
11156
|
}
|
|
11115
11157
|
),
|
|
11116
|
-
/* @__PURE__ */ (0,
|
|
11158
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11117
11159
|
"button",
|
|
11118
11160
|
{
|
|
11119
11161
|
type: "button",
|
|
@@ -11123,12 +11165,12 @@ var ImageEditor = ({
|
|
|
11123
11165
|
}
|
|
11124
11166
|
)
|
|
11125
11167
|
] }),
|
|
11126
|
-
/* @__PURE__ */ (0,
|
|
11127
|
-
/* @__PURE__ */ (0,
|
|
11128
|
-
/* @__PURE__ */ (0,
|
|
11129
|
-
/* @__PURE__ */ (0,
|
|
11168
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
11169
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
11170
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Depth Start (Lower):" }),
|
|
11171
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
|
|
11130
11172
|
] }),
|
|
11131
|
-
/* @__PURE__ */ (0,
|
|
11173
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11132
11174
|
"input",
|
|
11133
11175
|
{
|
|
11134
11176
|
type: "range",
|
|
@@ -11142,12 +11184,12 @@ var ImageEditor = ({
|
|
|
11142
11184
|
}
|
|
11143
11185
|
)
|
|
11144
11186
|
] }),
|
|
11145
|
-
/* @__PURE__ */ (0,
|
|
11146
|
-
/* @__PURE__ */ (0,
|
|
11147
|
-
/* @__PURE__ */ (0,
|
|
11148
|
-
/* @__PURE__ */ (0,
|
|
11187
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
11188
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
11189
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Depth Stop (Upper):" }),
|
|
11190
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
|
|
11149
11191
|
] }),
|
|
11150
|
-
/* @__PURE__ */ (0,
|
|
11192
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11151
11193
|
"input",
|
|
11152
11194
|
{
|
|
11153
11195
|
type: "range",
|
|
@@ -11161,12 +11203,12 @@ var ImageEditor = ({
|
|
|
11161
11203
|
}
|
|
11162
11204
|
)
|
|
11163
11205
|
] }),
|
|
11164
|
-
/* @__PURE__ */ (0,
|
|
11165
|
-
/* @__PURE__ */ (0,
|
|
11166
|
-
/* @__PURE__ */ (0,
|
|
11167
|
-
/* @__PURE__ */ (0,
|
|
11206
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
11207
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
11208
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Softness:" }),
|
|
11209
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
|
|
11168
11210
|
] }),
|
|
11169
|
-
/* @__PURE__ */ (0,
|
|
11211
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11170
11212
|
"input",
|
|
11171
11213
|
{
|
|
11172
11214
|
type: "range",
|
|
@@ -11178,8 +11220,8 @@ var ImageEditor = ({
|
|
|
11178
11220
|
}
|
|
11179
11221
|
)
|
|
11180
11222
|
] }),
|
|
11181
|
-
/* @__PURE__ */ (0,
|
|
11182
|
-
/* @__PURE__ */ (0,
|
|
11223
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground mt-1", children: [
|
|
11224
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11183
11225
|
"input",
|
|
11184
11226
|
{
|
|
11185
11227
|
type: "checkbox",
|
|
@@ -11188,12 +11230,12 @@ var ImageEditor = ({
|
|
|
11188
11230
|
className: "rounded accent-primary"
|
|
11189
11231
|
}
|
|
11190
11232
|
),
|
|
11191
|
-
/* @__PURE__ */ (0,
|
|
11233
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Invert Mask" })
|
|
11192
11234
|
] })
|
|
11193
11235
|
] })
|
|
11194
11236
|
] }),
|
|
11195
|
-
activeTab === "select" && /* @__PURE__ */ (0,
|
|
11196
|
-
/* @__PURE__ */ (0,
|
|
11237
|
+
activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
11238
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11197
11239
|
SelectionOptionsBar,
|
|
11198
11240
|
{
|
|
11199
11241
|
controller,
|
|
@@ -11204,9 +11246,9 @@ var ImageEditor = ({
|
|
|
11204
11246
|
selectionDisplay: state.selectionDisplay
|
|
11205
11247
|
}
|
|
11206
11248
|
),
|
|
11207
|
-
selectionError && /* @__PURE__ */ (0,
|
|
11208
|
-
/* @__PURE__ */ (0,
|
|
11209
|
-
/* @__PURE__ */ (0,
|
|
11249
|
+
selectionError && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
|
|
11250
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex gap-1", children: [
|
|
11251
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11210
11252
|
"button",
|
|
11211
11253
|
{
|
|
11212
11254
|
type: "button",
|
|
@@ -11217,7 +11259,7 @@ var ImageEditor = ({
|
|
|
11217
11259
|
children: "Transform Selection"
|
|
11218
11260
|
}
|
|
11219
11261
|
),
|
|
11220
|
-
/* @__PURE__ */ (0,
|
|
11262
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11221
11263
|
"button",
|
|
11222
11264
|
{
|
|
11223
11265
|
type: "button",
|
|
@@ -11229,14 +11271,14 @@ var ImageEditor = ({
|
|
|
11229
11271
|
}
|
|
11230
11272
|
)
|
|
11231
11273
|
] }),
|
|
11232
|
-
/* @__PURE__ */ (0,
|
|
11233
|
-
/* @__PURE__ */ (0,
|
|
11234
|
-
/* @__PURE__ */ (0,
|
|
11274
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers }),
|
|
11275
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ChannelsPanel, { controller }),
|
|
11276
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(PathsPanel, { controller })
|
|
11235
11277
|
] }),
|
|
11236
|
-
activeTab === "ai" && /* @__PURE__ */ (0,
|
|
11237
|
-
/* @__PURE__ */ (0,
|
|
11238
|
-
/* @__PURE__ */ (0,
|
|
11239
|
-
/* @__PURE__ */ (0,
|
|
11278
|
+
activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
11279
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("label", { className: "flex items-center justify-between gap-2 text-foreground", children: [
|
|
11280
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { children: "Results go to" }),
|
|
11281
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
11240
11282
|
"select",
|
|
11241
11283
|
{
|
|
11242
11284
|
"aria-label": "AI result target",
|
|
@@ -11244,54 +11286,54 @@ var ImageEditor = ({
|
|
|
11244
11286
|
onChange: (e) => setAiTarget(e.target.value),
|
|
11245
11287
|
className: imageSelectClass,
|
|
11246
11288
|
children: [
|
|
11247
|
-
/* @__PURE__ */ (0,
|
|
11248
|
-
/* @__PURE__ */ (0,
|
|
11249
|
-
/* @__PURE__ */ (0,
|
|
11289
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
|
|
11290
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
|
|
11291
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: "replace", children: "Replace image" })
|
|
11250
11292
|
]
|
|
11251
11293
|
}
|
|
11252
11294
|
)
|
|
11253
11295
|
] }),
|
|
11254
|
-
/* @__PURE__ */ (0,
|
|
11255
|
-
/* @__PURE__ */ (0,
|
|
11256
|
-
/* @__PURE__ */ (0,
|
|
11257
|
-
/* @__PURE__ */ (0,
|
|
11296
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
11297
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11298
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
11299
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.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_runtime53.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" }) }),
|
|
11258
11300
|
"Background Removal"
|
|
11259
11301
|
] }),
|
|
11260
|
-
isRemovingBg && /* @__PURE__ */ (0,
|
|
11302
|
+
isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime53.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..." })
|
|
11261
11303
|
] }),
|
|
11262
|
-
/* @__PURE__ */ (0,
|
|
11263
|
-
/* @__PURE__ */ (0,
|
|
11304
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
|
|
11305
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11264
11306
|
"button",
|
|
11265
11307
|
{
|
|
11266
11308
|
type: "button",
|
|
11267
11309
|
onClick: handleRemoveBackground,
|
|
11268
11310
|
disabled: isRemovingBg || isInpainting,
|
|
11269
11311
|
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",
|
|
11270
|
-
children: isRemovingBg ? /* @__PURE__ */ (0,
|
|
11271
|
-
/* @__PURE__ */ (0,
|
|
11312
|
+
children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
11313
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageSpinnerClass }),
|
|
11272
11314
|
"Removing Background..."
|
|
11273
|
-
] }) : /* @__PURE__ */ (0,
|
|
11274
|
-
/* @__PURE__ */ (0,
|
|
11315
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
11316
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.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_runtime53.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" }) }),
|
|
11275
11317
|
"Remove Background"
|
|
11276
11318
|
] })
|
|
11277
11319
|
}
|
|
11278
11320
|
)
|
|
11279
11321
|
] }),
|
|
11280
|
-
/* @__PURE__ */ (0,
|
|
11281
|
-
/* @__PURE__ */ (0,
|
|
11282
|
-
/* @__PURE__ */ (0,
|
|
11283
|
-
/* @__PURE__ */ (0,
|
|
11284
|
-
/* @__PURE__ */ (0,
|
|
11285
|
-
/* @__PURE__ */ (0,
|
|
11322
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
11323
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
11324
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
11325
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
11326
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.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" }),
|
|
11327
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "m14 7 3 3" })
|
|
11286
11328
|
] }),
|
|
11287
11329
|
"Generative Inpainting"
|
|
11288
11330
|
] }),
|
|
11289
|
-
isInpainting && /* @__PURE__ */ (0,
|
|
11331
|
+
isInpainting && /* @__PURE__ */ (0, import_jsx_runtime53.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..." })
|
|
11290
11332
|
] }),
|
|
11291
|
-
/* @__PURE__ */ (0,
|
|
11292
|
-
/* @__PURE__ */ (0,
|
|
11293
|
-
/* @__PURE__ */ (0,
|
|
11294
|
-
/* @__PURE__ */ (0,
|
|
11333
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
|
|
11334
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
11335
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-foreground text-[11px] font-medium", children: "Prompt" }),
|
|
11336
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11295
11337
|
"textarea",
|
|
11296
11338
|
{
|
|
11297
11339
|
id: "ai-inpaint-prompt-react",
|
|
@@ -11303,10 +11345,10 @@ var ImageEditor = ({
|
|
|
11303
11345
|
}
|
|
11304
11346
|
)
|
|
11305
11347
|
] }),
|
|
11306
|
-
/* @__PURE__ */ (0,
|
|
11307
|
-
/* @__PURE__ */ (0,
|
|
11308
|
-
/* @__PURE__ */ (0,
|
|
11309
|
-
/* @__PURE__ */ (0,
|
|
11348
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
11349
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-foreground text-[11px] font-medium", children: "Target Mask Region" }),
|
|
11350
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
|
|
11351
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
11310
11352
|
"button",
|
|
11311
11353
|
{
|
|
11312
11354
|
type: "button",
|
|
@@ -11319,7 +11361,7 @@ var ImageEditor = ({
|
|
|
11319
11361
|
]
|
|
11320
11362
|
}
|
|
11321
11363
|
),
|
|
11322
|
-
/* @__PURE__ */ (0,
|
|
11364
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
11323
11365
|
"button",
|
|
11324
11366
|
{
|
|
11325
11367
|
type: "button",
|
|
@@ -11334,25 +11376,25 @@ var ImageEditor = ({
|
|
|
11334
11376
|
)
|
|
11335
11377
|
] })
|
|
11336
11378
|
] }),
|
|
11337
|
-
/* @__PURE__ */ (0,
|
|
11379
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11338
11380
|
"button",
|
|
11339
11381
|
{
|
|
11340
11382
|
type: "button",
|
|
11341
11383
|
onClick: handleInpaint,
|
|
11342
11384
|
disabled: isInpainting || isRemovingBg || !inpaintPrompt.trim(),
|
|
11343
11385
|
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",
|
|
11344
|
-
children: isInpainting ? /* @__PURE__ */ (0,
|
|
11345
|
-
/* @__PURE__ */ (0,
|
|
11386
|
+
children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
11387
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: imageSpinnerClass }),
|
|
11346
11388
|
"Generating Inpaint..."
|
|
11347
|
-
] }) : /* @__PURE__ */ (0,
|
|
11348
|
-
/* @__PURE__ */ (0,
|
|
11389
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
11390
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.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_runtime53.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" }) }),
|
|
11349
11391
|
"Apply Inpainting"
|
|
11350
11392
|
] })
|
|
11351
11393
|
}
|
|
11352
11394
|
)
|
|
11353
11395
|
] }),
|
|
11354
|
-
aiError && /* @__PURE__ */ (0,
|
|
11355
|
-
aiSuccess && /* @__PURE__ */ (0,
|
|
11396
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "p-2.5 rounded-lg bg-destructive/10 border border-destructive/40 text-destructive text-[11px]", children: aiError }),
|
|
11397
|
+
aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-600 text-[11px]", children: aiSuccess })
|
|
11356
11398
|
] })
|
|
11357
11399
|
] })
|
|
11358
11400
|
] })
|
|
@@ -11362,7 +11404,7 @@ var ImageEditor = ({
|
|
|
11362
11404
|
};
|
|
11363
11405
|
|
|
11364
11406
|
// src/review/useReview.ts
|
|
11365
|
-
var
|
|
11407
|
+
var import_react74 = require("react");
|
|
11366
11408
|
var import_editor13 = require("@pixerate/editor");
|
|
11367
11409
|
var EMPTY_COMMENTS = Object.freeze({
|
|
11368
11410
|
threads: [],
|
|
@@ -11381,23 +11423,23 @@ function isCommentStore(value) {
|
|
|
11381
11423
|
}
|
|
11382
11424
|
function useComments(source) {
|
|
11383
11425
|
const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
|
|
11384
|
-
const subscribe = (0,
|
|
11426
|
+
const subscribe = (0, import_react74.useCallback)(
|
|
11385
11427
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
11386
11428
|
[store]
|
|
11387
11429
|
);
|
|
11388
11430
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
11389
|
-
const snapshot = (0,
|
|
11390
|
-
return (0,
|
|
11431
|
+
const snapshot = (0, import_react74.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11432
|
+
return (0, import_react74.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
11391
11433
|
}
|
|
11392
11434
|
function useTrackChanges(editor) {
|
|
11393
11435
|
const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
|
|
11394
|
-
const subscribe = (0,
|
|
11436
|
+
const subscribe = (0, import_react74.useCallback)(
|
|
11395
11437
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
11396
11438
|
[store]
|
|
11397
11439
|
);
|
|
11398
11440
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
11399
|
-
const snapshot = (0,
|
|
11400
|
-
return (0,
|
|
11441
|
+
const snapshot = (0, import_react74.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11442
|
+
return (0, import_react74.useMemo)(() => {
|
|
11401
11443
|
const run = (fn) => () => {
|
|
11402
11444
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
11403
11445
|
};
|
|
@@ -11420,9 +11462,9 @@ function useTrackChanges(editor) {
|
|
|
11420
11462
|
}
|
|
11421
11463
|
|
|
11422
11464
|
// src/review/CommentsPanel.tsx
|
|
11423
|
-
var
|
|
11465
|
+
var import_react75 = require("react");
|
|
11424
11466
|
var import_editor14 = require("@pixerate/editor");
|
|
11425
|
-
var
|
|
11467
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
11426
11468
|
var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
|
|
11427
11469
|
var primaryButtonClass = "rounded px-2 py-1 text-xs bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50";
|
|
11428
11470
|
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";
|
|
@@ -11436,18 +11478,18 @@ var CommentsPanel = ({
|
|
|
11436
11478
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
11437
11479
|
}) => {
|
|
11438
11480
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
11439
|
-
const [showResolved, setShowResolved] = (0,
|
|
11481
|
+
const [showResolved, setShowResolved] = (0, import_react75.useState)(showResolvedInitial);
|
|
11440
11482
|
const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
11441
11483
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
11442
11484
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
11443
|
-
return /* @__PURE__ */ (0,
|
|
11444
|
-
/* @__PURE__ */ (0,
|
|
11445
|
-
/* @__PURE__ */ (0,
|
|
11485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("aside", { className, "aria-label": "Comments", children: [
|
|
11486
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
11487
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
11446
11488
|
threads.length - resolvedCount,
|
|
11447
11489
|
" open",
|
|
11448
11490
|
resolvedCount > 0 ? ` \xB7 ${resolvedCount} resolved` : ""
|
|
11449
11491
|
] }),
|
|
11450
|
-
resolvedCount > 0 && /* @__PURE__ */ (0,
|
|
11492
|
+
resolvedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11451
11493
|
"button",
|
|
11452
11494
|
{
|
|
11453
11495
|
type: "button",
|
|
@@ -11458,7 +11500,7 @@ var CommentsPanel = ({
|
|
|
11458
11500
|
}
|
|
11459
11501
|
)
|
|
11460
11502
|
] }),
|
|
11461
|
-
visible.length === 0 ? /* @__PURE__ */ (0,
|
|
11503
|
+
visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { className: "flex flex-col gap-2", role: "list", children: visible.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11462
11504
|
CommentThreadCard,
|
|
11463
11505
|
{
|
|
11464
11506
|
thread,
|
|
@@ -11480,7 +11522,7 @@ var CommentThreadCard = ({
|
|
|
11480
11522
|
author,
|
|
11481
11523
|
formatTime
|
|
11482
11524
|
}) => {
|
|
11483
|
-
const [draft, setDraft] = (0,
|
|
11525
|
+
const [draft, setDraft] = (0, import_react75.useState)("");
|
|
11484
11526
|
const isDraft = thread.body === "";
|
|
11485
11527
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
11486
11528
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -11506,7 +11548,7 @@ var CommentThreadCard = ({
|
|
|
11506
11548
|
setDraft("");
|
|
11507
11549
|
};
|
|
11508
11550
|
const stop = (e) => e.stopPropagation();
|
|
11509
|
-
return /* @__PURE__ */ (0,
|
|
11551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
11510
11552
|
"li",
|
|
11511
11553
|
{
|
|
11512
11554
|
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" : ""}`,
|
|
@@ -11522,24 +11564,24 @@ var CommentThreadCard = ({
|
|
|
11522
11564
|
}
|
|
11523
11565
|
},
|
|
11524
11566
|
children: [
|
|
11525
|
-
/* @__PURE__ */ (0,
|
|
11526
|
-
/* @__PURE__ */ (0,
|
|
11527
|
-
/* @__PURE__ */ (0,
|
|
11567
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
11568
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "font-medium", children: thread.author.name }),
|
|
11569
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-xs text-muted-foreground", children: formatTime(thread.createdAt) })
|
|
11528
11570
|
] }),
|
|
11529
|
-
quote && /* @__PURE__ */ (0,
|
|
11530
|
-
thread.orphaned && /* @__PURE__ */ (0,
|
|
11531
|
-
thread.resolved && /* @__PURE__ */ (0,
|
|
11532
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
11533
|
-
thread.replies.length > 0 && /* @__PURE__ */ (0,
|
|
11534
|
-
/* @__PURE__ */ (0,
|
|
11535
|
-
/* @__PURE__ */ (0,
|
|
11571
|
+
quote && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("blockquote", { className: "border-l-2 border-border pl-2 text-xs text-muted-foreground line-clamp-2", children: quote }),
|
|
11572
|
+
thread.orphaned && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-xs text-destructive", children: "The commented text was deleted." }),
|
|
11573
|
+
thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-xs text-muted-foreground", children: "Resolved" }),
|
|
11574
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "whitespace-pre-wrap break-words", children: thread.body }),
|
|
11575
|
+
thread.replies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.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_runtime54.jsxs)("li", { className: "flex flex-col gap-0.5", "data-reply-id": reply.id, children: [
|
|
11576
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "text-xs", children: [
|
|
11577
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "font-medium", children: reply.author.name }),
|
|
11536
11578
|
" ",
|
|
11537
|
-
/* @__PURE__ */ (0,
|
|
11579
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-muted-foreground", children: formatTime(reply.createdAt) })
|
|
11538
11580
|
] }),
|
|
11539
|
-
/* @__PURE__ */ (0,
|
|
11581
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "whitespace-pre-wrap break-words", children: reply.body })
|
|
11540
11582
|
] }, reply.id)) }),
|
|
11541
|
-
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0,
|
|
11542
|
-
/* @__PURE__ */ (0,
|
|
11583
|
+
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex flex-col gap-1", onClick: stop, children: [
|
|
11584
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11543
11585
|
"textarea",
|
|
11544
11586
|
{
|
|
11545
11587
|
className: textareaClass,
|
|
@@ -11557,9 +11599,9 @@ var CommentThreadCard = ({
|
|
|
11557
11599
|
}
|
|
11558
11600
|
}
|
|
11559
11601
|
),
|
|
11560
|
-
/* @__PURE__ */ (0,
|
|
11561
|
-
isDraft && /* @__PURE__ */ (0,
|
|
11562
|
-
/* @__PURE__ */ (0,
|
|
11602
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex justify-end gap-1", children: [
|
|
11603
|
+
isDraft && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("button", { type: "button", className: buttonClass2, onClick: remove, children: "Cancel" }),
|
|
11604
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11563
11605
|
"button",
|
|
11564
11606
|
{
|
|
11565
11607
|
type: "button",
|
|
@@ -11571,9 +11613,9 @@ var CommentThreadCard = ({
|
|
|
11571
11613
|
)
|
|
11572
11614
|
] })
|
|
11573
11615
|
] }),
|
|
11574
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
11575
|
-
/* @__PURE__ */ (0,
|
|
11576
|
-
/* @__PURE__ */ (0,
|
|
11616
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex justify-end gap-1", onClick: stop, children: [
|
|
11617
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("button", { type: "button", className: buttonClass2, onClick: () => setResolved(!thread.resolved), children: thread.resolved ? "Reopen" : "Resolve" }),
|
|
11618
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
11577
11619
|
"button",
|
|
11578
11620
|
{
|
|
11579
11621
|
type: "button",
|
|
@@ -11589,7 +11631,7 @@ var CommentThreadCard = ({
|
|
|
11589
11631
|
};
|
|
11590
11632
|
|
|
11591
11633
|
// src/review/ReviewToolbar.tsx
|
|
11592
|
-
var
|
|
11634
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
11593
11635
|
var defaultDescriptionClass = "max-w-[16rem] truncate px-1 text-xs text-muted-foreground";
|
|
11594
11636
|
var buttonClass3 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
11595
11637
|
var ReviewToolbar = ({
|
|
@@ -11602,8 +11644,8 @@ var ReviewToolbar = ({
|
|
|
11602
11644
|
const count = review.changes.length;
|
|
11603
11645
|
const current = review.currentChange;
|
|
11604
11646
|
const index = current ? review.changes.findIndex((c) => c.id === current.id) + 1 : 0;
|
|
11605
|
-
return /* @__PURE__ */ (0,
|
|
11606
|
-
/* @__PURE__ */ (0,
|
|
11647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className, role: "toolbar", "aria-label": "Review", children: [
|
|
11648
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11607
11649
|
"button",
|
|
11608
11650
|
{
|
|
11609
11651
|
type: "button",
|
|
@@ -11614,8 +11656,8 @@ var ReviewToolbar = ({
|
|
|
11614
11656
|
children: review.enabled ? "Tracking on" : "Track changes"
|
|
11615
11657
|
}
|
|
11616
11658
|
),
|
|
11617
|
-
/* @__PURE__ */ (0,
|
|
11618
|
-
/* @__PURE__ */ (0,
|
|
11659
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
11660
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11619
11661
|
"button",
|
|
11620
11662
|
{
|
|
11621
11663
|
type: "button",
|
|
@@ -11626,8 +11668,8 @@ var ReviewToolbar = ({
|
|
|
11626
11668
|
children: "\u2039"
|
|
11627
11669
|
}
|
|
11628
11670
|
),
|
|
11629
|
-
/* @__PURE__ */ (0,
|
|
11630
|
-
/* @__PURE__ */ (0,
|
|
11671
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.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` }),
|
|
11672
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11631
11673
|
"button",
|
|
11632
11674
|
{
|
|
11633
11675
|
type: "button",
|
|
@@ -11638,7 +11680,7 @@ var ReviewToolbar = ({
|
|
|
11638
11680
|
children: "\u203A"
|
|
11639
11681
|
}
|
|
11640
11682
|
),
|
|
11641
|
-
showDescription && current && /* @__PURE__ */ (0,
|
|
11683
|
+
showDescription && current && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
11642
11684
|
"span",
|
|
11643
11685
|
{
|
|
11644
11686
|
className: descriptionClassName,
|
|
@@ -11650,8 +11692,8 @@ var ReviewToolbar = ({
|
|
|
11650
11692
|
]
|
|
11651
11693
|
}
|
|
11652
11694
|
),
|
|
11653
|
-
/* @__PURE__ */ (0,
|
|
11654
|
-
/* @__PURE__ */ (0,
|
|
11695
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
11696
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11655
11697
|
"button",
|
|
11656
11698
|
{
|
|
11657
11699
|
type: "button",
|
|
@@ -11661,7 +11703,7 @@ var ReviewToolbar = ({
|
|
|
11661
11703
|
children: "Accept"
|
|
11662
11704
|
}
|
|
11663
11705
|
),
|
|
11664
|
-
/* @__PURE__ */ (0,
|
|
11706
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
11665
11707
|
"button",
|
|
11666
11708
|
{
|
|
11667
11709
|
type: "button",
|
|
@@ -11671,18 +11713,18 @@ var ReviewToolbar = ({
|
|
|
11671
11713
|
children: "Reject"
|
|
11672
11714
|
}
|
|
11673
11715
|
),
|
|
11674
|
-
/* @__PURE__ */ (0,
|
|
11675
|
-
/* @__PURE__ */ (0,
|
|
11716
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.acceptAll, children: "Accept all" }),
|
|
11717
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.rejectAll, children: "Reject all" })
|
|
11676
11718
|
] });
|
|
11677
11719
|
};
|
|
11678
11720
|
|
|
11679
11721
|
// src/review/CommentButton.tsx
|
|
11680
|
-
var
|
|
11722
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
11681
11723
|
var CommentButton = ({
|
|
11682
11724
|
editor,
|
|
11683
11725
|
className = "rounded px-2 py-1 text-xs text-popover-foreground hover:bg-muted",
|
|
11684
11726
|
children = "Comment"
|
|
11685
|
-
}) => /* @__PURE__ */ (0,
|
|
11727
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
11686
11728
|
"button",
|
|
11687
11729
|
{
|
|
11688
11730
|
type: "button",
|
|
@@ -11694,13 +11736,13 @@ var CommentButton = ({
|
|
|
11694
11736
|
);
|
|
11695
11737
|
|
|
11696
11738
|
// src/review/useDocumentCompare.ts
|
|
11697
|
-
var
|
|
11739
|
+
var import_react76 = require("react");
|
|
11698
11740
|
var import_editor15 = require("@pixerate/editor");
|
|
11699
11741
|
function useDocumentCompare(editor, options) {
|
|
11700
|
-
const [summary, setSummary] = (0,
|
|
11701
|
-
const defaults = (0,
|
|
11742
|
+
const [summary, setSummary] = (0, import_react76.useState)(null);
|
|
11743
|
+
const defaults = (0, import_react76.useRef)(options);
|
|
11702
11744
|
defaults.current = options;
|
|
11703
|
-
const compare = (0,
|
|
11745
|
+
const compare = (0, import_react76.useCallback)(
|
|
11704
11746
|
(original, revised, overrides) => {
|
|
11705
11747
|
if (!editor || editor.isDestroyed) return null;
|
|
11706
11748
|
const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
|
|
@@ -11712,13 +11754,13 @@ function useDocumentCompare(editor, options) {
|
|
|
11712
11754
|
},
|
|
11713
11755
|
[editor]
|
|
11714
11756
|
);
|
|
11715
|
-
const clear = (0,
|
|
11716
|
-
return (0,
|
|
11757
|
+
const clear = (0, import_react76.useCallback)(() => setSummary(null), []);
|
|
11758
|
+
return (0, import_react76.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
11717
11759
|
}
|
|
11718
11760
|
|
|
11719
11761
|
// src/review/TrackedChangesList.tsx
|
|
11720
11762
|
var import_editor16 = require("@pixerate/editor");
|
|
11721
|
-
var
|
|
11763
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
11722
11764
|
var buttonClass4 = "rounded px-1.5 py-0.5 text-xs text-foreground hover:bg-muted disabled:opacity-40";
|
|
11723
11765
|
var TrackedChangesList = ({
|
|
11724
11766
|
editor,
|
|
@@ -11729,18 +11771,18 @@ var TrackedChangesList = ({
|
|
|
11729
11771
|
}) => {
|
|
11730
11772
|
const review = useTrackChanges(editor);
|
|
11731
11773
|
if (review.changes.length === 0) {
|
|
11732
|
-
return /* @__PURE__ */ (0,
|
|
11774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className, "data-tracked-changes-list": "", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "pixerate-changes-empty text-xs text-muted-foreground", children: emptyState }) });
|
|
11733
11775
|
}
|
|
11734
|
-
return /* @__PURE__ */ (0,
|
|
11776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className, role: "list", "aria-label": "Tracked changes", "data-tracked-changes-list": "", children: review.changes.map((change) => {
|
|
11735
11777
|
const active = change.id === review.currentChangeId;
|
|
11736
|
-
return /* @__PURE__ */ (0,
|
|
11778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11737
11779
|
"li",
|
|
11738
11780
|
{
|
|
11739
11781
|
className: active ? `${itemClassName} ${activeItemClassName}` : itemClassName,
|
|
11740
11782
|
"data-change-type": change.type,
|
|
11741
11783
|
"data-change-id": change.id,
|
|
11742
11784
|
children: [
|
|
11743
|
-
/* @__PURE__ */ (0,
|
|
11785
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11744
11786
|
"button",
|
|
11745
11787
|
{
|
|
11746
11788
|
type: "button",
|
|
@@ -11748,14 +11790,14 @@ var TrackedChangesList = ({
|
|
|
11748
11790
|
title: `${change.author.name}: ${change.description}`,
|
|
11749
11791
|
onClick: () => review.select(change.id),
|
|
11750
11792
|
children: [
|
|
11751
|
-
/* @__PURE__ */ (0,
|
|
11793
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "font-medium", children: (0, import_editor16.trackedChangeLabel)(change) }),
|
|
11752
11794
|
change.author.name ? ` \xB7 ${change.author.name}` : "",
|
|
11753
|
-
/* @__PURE__ */ (0,
|
|
11795
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "block truncate text-muted-foreground", children: change.description })
|
|
11754
11796
|
]
|
|
11755
11797
|
}
|
|
11756
11798
|
),
|
|
11757
|
-
/* @__PURE__ */ (0,
|
|
11758
|
-
/* @__PURE__ */ (0,
|
|
11799
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.accept(change.id), children: "Accept" }),
|
|
11800
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.reject(change.id), children: "Reject" })
|
|
11759
11801
|
]
|
|
11760
11802
|
},
|
|
11761
11803
|
`${change.type}:${change.id}`
|
|
@@ -11764,12 +11806,12 @@ var TrackedChangesList = ({
|
|
|
11764
11806
|
};
|
|
11765
11807
|
|
|
11766
11808
|
// src/commands/useCommandPalette.ts
|
|
11767
|
-
var
|
|
11809
|
+
var import_react77 = require("react");
|
|
11768
11810
|
var import_commands2 = require("@pixerate/editor/commands");
|
|
11769
11811
|
function useCommandPalette(registry, options = {}) {
|
|
11770
|
-
const optionsRef = (0,
|
|
11812
|
+
const optionsRef = (0, import_react77.useRef)(options);
|
|
11771
11813
|
optionsRef.current = options;
|
|
11772
|
-
const controller = (0,
|
|
11814
|
+
const controller = (0, import_react77.useMemo)(
|
|
11773
11815
|
() => (0, import_commands2.createCommandPaletteController)(registry, {
|
|
11774
11816
|
context: () => {
|
|
11775
11817
|
const c = optionsRef.current.context;
|
|
@@ -11790,9 +11832,9 @@ function useCommandPalette(registry, options = {}) {
|
|
|
11790
11832
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11791
11833
|
[registry]
|
|
11792
11834
|
);
|
|
11793
|
-
const state = (0,
|
|
11835
|
+
const state = (0, import_react77.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
11794
11836
|
const { hotkey, hotkeyTarget } = options;
|
|
11795
|
-
(0,
|
|
11837
|
+
(0, import_react77.useEffect)(() => {
|
|
11796
11838
|
if (!hotkey) return;
|
|
11797
11839
|
const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
|
|
11798
11840
|
if (!target) return;
|
|
@@ -11820,13 +11862,13 @@ function useCommandPalette(registry, options = {}) {
|
|
|
11820
11862
|
}
|
|
11821
11863
|
|
|
11822
11864
|
// src/commands/CommandPalette.tsx
|
|
11823
|
-
var
|
|
11824
|
-
var
|
|
11865
|
+
var import_react78 = __toESM(require("react"), 1);
|
|
11866
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
11825
11867
|
function HighlightedLabel({ item }) {
|
|
11826
|
-
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0,
|
|
11868
|
+
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: item.label });
|
|
11827
11869
|
const marked = new Set(item.labelIndices);
|
|
11828
|
-
return /* @__PURE__ */ (0,
|
|
11829
|
-
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0,
|
|
11870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, { children: Array.from(item.label).map(
|
|
11871
|
+
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_react78.default.Fragment, { children: ch }, i)
|
|
11830
11872
|
) });
|
|
11831
11873
|
}
|
|
11832
11874
|
var CommandPalette = ({
|
|
@@ -11835,22 +11877,22 @@ var CommandPalette = ({
|
|
|
11835
11877
|
emptyMessage = "No matching commands",
|
|
11836
11878
|
className = ""
|
|
11837
11879
|
}) => {
|
|
11838
|
-
const inputRef = (0,
|
|
11839
|
-
const listRef = (0,
|
|
11840
|
-
const baseId = (0,
|
|
11880
|
+
const inputRef = (0, import_react78.useRef)(null);
|
|
11881
|
+
const listRef = (0, import_react78.useRef)(null);
|
|
11882
|
+
const baseId = (0, import_react78.useId)();
|
|
11841
11883
|
const listId = `${baseId}-list`;
|
|
11842
11884
|
const optionId = (index) => `${baseId}-option-${index}`;
|
|
11843
11885
|
const { open, query, items, activeIndex } = palette;
|
|
11844
|
-
(0,
|
|
11886
|
+
(0, import_react78.useEffect)(() => {
|
|
11845
11887
|
if (open) inputRef.current?.focus();
|
|
11846
11888
|
}, [open]);
|
|
11847
|
-
(0,
|
|
11889
|
+
(0, import_react78.useEffect)(() => {
|
|
11848
11890
|
if (!open) return;
|
|
11849
11891
|
const active = listRef.current?.querySelector('[aria-selected="true"]');
|
|
11850
11892
|
active?.scrollIntoView?.({ block: "nearest" });
|
|
11851
11893
|
}, [open, activeIndex]);
|
|
11852
11894
|
if (!open) return null;
|
|
11853
|
-
return /* @__PURE__ */ (0,
|
|
11895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11854
11896
|
"div",
|
|
11855
11897
|
{
|
|
11856
11898
|
className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 px-4 pt-[15vh]",
|
|
@@ -11858,7 +11900,7 @@ var CommandPalette = ({
|
|
|
11858
11900
|
onMouseDown: (e) => {
|
|
11859
11901
|
if (e.target === e.currentTarget) palette.setOpen(false);
|
|
11860
11902
|
},
|
|
11861
|
-
children: /* @__PURE__ */ (0,
|
|
11903
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
|
|
11862
11904
|
"div",
|
|
11863
11905
|
{
|
|
11864
11906
|
role: "dialog",
|
|
@@ -11867,7 +11909,7 @@ var CommandPalette = ({
|
|
|
11867
11909
|
className: `w-full max-w-lg overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl ${className}`,
|
|
11868
11910
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
11869
11911
|
children: [
|
|
11870
|
-
/* @__PURE__ */ (0,
|
|
11912
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11871
11913
|
"input",
|
|
11872
11914
|
{
|
|
11873
11915
|
ref: inputRef,
|
|
@@ -11887,7 +11929,7 @@ var CommandPalette = ({
|
|
|
11887
11929
|
className: "w-full border-b border-border bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground"
|
|
11888
11930
|
}
|
|
11889
11931
|
),
|
|
11890
|
-
items.length === 0 ? /* @__PURE__ */ (0,
|
|
11932
|
+
items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime58.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_runtime58.jsxs)(
|
|
11891
11933
|
"li",
|
|
11892
11934
|
{
|
|
11893
11935
|
id: optionId(index),
|
|
@@ -11902,12 +11944,12 @@ var CommandPalette = ({
|
|
|
11902
11944
|
onClick: () => palette.run(item.id),
|
|
11903
11945
|
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"}`,
|
|
11904
11946
|
children: [
|
|
11905
|
-
/* @__PURE__ */ (0,
|
|
11906
|
-
/* @__PURE__ */ (0,
|
|
11907
|
-
item.disabledReason && /* @__PURE__ */ (0,
|
|
11947
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
11948
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(HighlightedLabel, { item }),
|
|
11949
|
+
item.disabledReason && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "ml-2 text-xs text-muted-foreground", "data-disabled-reason": "", children: item.disabledReason })
|
|
11908
11950
|
] }),
|
|
11909
|
-
item.group && /* @__PURE__ */ (0,
|
|
11910
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
11951
|
+
item.group && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "shrink-0 text-xs text-muted-foreground", children: item.group }),
|
|
11952
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("kbd", { className: "shrink-0 rounded border border-border px-1.5 font-mono text-[10px] text-muted-foreground", children: item.shortcut })
|
|
11911
11953
|
]
|
|
11912
11954
|
},
|
|
11913
11955
|
item.id
|
|
@@ -11920,12 +11962,12 @@ var CommandPalette = ({
|
|
|
11920
11962
|
};
|
|
11921
11963
|
|
|
11922
11964
|
// src/commands/useCommandShortcuts.ts
|
|
11923
|
-
var
|
|
11965
|
+
var import_react79 = require("react");
|
|
11924
11966
|
function useCommandShortcuts(registry, options = {}) {
|
|
11925
|
-
const optionsRef = (0,
|
|
11967
|
+
const optionsRef = (0, import_react79.useRef)(options);
|
|
11926
11968
|
optionsRef.current = options;
|
|
11927
11969
|
const { enabled = true, target } = options;
|
|
11928
|
-
(0,
|
|
11970
|
+
(0, import_react79.useEffect)(() => {
|
|
11929
11971
|
if (!registry || !enabled) return;
|
|
11930
11972
|
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
11931
11973
|
if (!eventTarget) return;
|
|
@@ -11943,14 +11985,14 @@ function useCommandShortcuts(registry, options = {}) {
|
|
|
11943
11985
|
}, [registry, enabled, target]);
|
|
11944
11986
|
}
|
|
11945
11987
|
function useRegisterCommands(registry, specs) {
|
|
11946
|
-
(0,
|
|
11988
|
+
(0, import_react79.useEffect)(() => {
|
|
11947
11989
|
if (!registry || !specs || specs.length === 0) return;
|
|
11948
11990
|
return registry.register(specs);
|
|
11949
11991
|
}, [registry, specs]);
|
|
11950
11992
|
}
|
|
11951
11993
|
|
|
11952
11994
|
// src/persistence/useAutosave.ts
|
|
11953
|
-
var
|
|
11995
|
+
var import_react80 = require("react");
|
|
11954
11996
|
var import_persistence = require("@pixerate/editor/persistence");
|
|
11955
11997
|
var IDLE = {
|
|
11956
11998
|
status: "idle",
|
|
@@ -11961,18 +12003,18 @@ var IDLE = {
|
|
|
11961
12003
|
ready: false
|
|
11962
12004
|
};
|
|
11963
12005
|
function useAutosave(options) {
|
|
11964
|
-
const optionsRef = (0,
|
|
12006
|
+
const optionsRef = (0, import_react80.useRef)(options);
|
|
11965
12007
|
optionsRef.current = options;
|
|
11966
12008
|
const { storage, key, history, dirty } = options;
|
|
11967
12009
|
const recover = options.recover !== false;
|
|
11968
12010
|
const flushOnHide = options.flushOnHide !== false;
|
|
11969
12011
|
const ready = options.ready !== false;
|
|
11970
|
-
const [controller, setController] = (0,
|
|
11971
|
-
const [status, setStatus] = (0,
|
|
11972
|
-
const [recovery, setRecovery] = (0,
|
|
11973
|
-
const [pendingRecovery, setPendingRecovery] = (0,
|
|
11974
|
-
const revisionsRef = (0,
|
|
11975
|
-
(0,
|
|
12012
|
+
const [controller, setController] = (0, import_react80.useState)(null);
|
|
12013
|
+
const [status, setStatus] = (0, import_react80.useState)(IDLE);
|
|
12014
|
+
const [recovery, setRecovery] = (0, import_react80.useState)(null);
|
|
12015
|
+
const [pendingRecovery, setPendingRecovery] = (0, import_react80.useState)(recover);
|
|
12016
|
+
const revisionsRef = (0, import_react80.useRef)(null);
|
|
12017
|
+
(0, import_react80.useEffect)(() => {
|
|
11976
12018
|
const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
|
|
11977
12019
|
const o = optionsRef.current;
|
|
11978
12020
|
const instance = (0, import_persistence.createAutosaveController)({
|
|
@@ -12015,10 +12057,10 @@ function useAutosave(options) {
|
|
|
12015
12057
|
if (revisionsRef.current === revisions) revisionsRef.current = null;
|
|
12016
12058
|
};
|
|
12017
12059
|
}, [storage, key, history, dirty, recover]);
|
|
12018
|
-
(0,
|
|
12060
|
+
(0, import_react80.useEffect)(() => {
|
|
12019
12061
|
if (controller && ready && !pendingRecovery) controller.ready();
|
|
12020
12062
|
}, [controller, ready, pendingRecovery]);
|
|
12021
|
-
(0,
|
|
12063
|
+
(0, import_react80.useEffect)(() => {
|
|
12022
12064
|
if (!controller || !flushOnHide || typeof window === "undefined") return;
|
|
12023
12065
|
const flush = () => void controller.flushNow();
|
|
12024
12066
|
const onVisibility = () => {
|
|
@@ -12031,33 +12073,33 @@ function useAutosave(options) {
|
|
|
12031
12073
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
12032
12074
|
};
|
|
12033
12075
|
}, [controller, flushOnHide]);
|
|
12034
|
-
const restore = (0,
|
|
12076
|
+
const restore = (0, import_react80.useCallback)(() => {
|
|
12035
12077
|
const snapshot = recovery?.snapshot;
|
|
12036
12078
|
setRecovery(null);
|
|
12037
12079
|
setPendingRecovery(false);
|
|
12038
12080
|
return snapshot;
|
|
12039
12081
|
}, [recovery]);
|
|
12040
|
-
const discard = (0,
|
|
12082
|
+
const discard = (0, import_react80.useCallback)(async () => {
|
|
12041
12083
|
if (controller) await controller.discardRecovery();
|
|
12042
12084
|
setRecovery(null);
|
|
12043
12085
|
setPendingRecovery(false);
|
|
12044
12086
|
}, [controller]);
|
|
12045
|
-
const flushNow = (0,
|
|
12087
|
+
const flushNow = (0, import_react80.useCallback)(async () => {
|
|
12046
12088
|
await controller?.flushNow();
|
|
12047
12089
|
}, [controller]);
|
|
12048
|
-
const markClean = (0,
|
|
12090
|
+
const markClean = (0, import_react80.useCallback)(async () => {
|
|
12049
12091
|
revisionsRef.current?.markSaved();
|
|
12050
12092
|
await controller?.markClean();
|
|
12051
12093
|
}, [controller]);
|
|
12052
|
-
const notifyChange = (0,
|
|
12094
|
+
const notifyChange = (0, import_react80.useCallback)(() => revisionsRef.current?.bump(), []);
|
|
12053
12095
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
12054
12096
|
}
|
|
12055
12097
|
|
|
12056
12098
|
// src/persistence/useEditorAutosave.ts
|
|
12057
|
-
var
|
|
12099
|
+
var import_react81 = require("react");
|
|
12058
12100
|
var import_persistence2 = require("@pixerate/editor/persistence");
|
|
12059
12101
|
function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
12060
|
-
const storage = (0,
|
|
12102
|
+
const storage = (0, import_react81.useMemo)(
|
|
12061
12103
|
() => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
|
|
12062
12104
|
[options.storage, doc.assets]
|
|
12063
12105
|
);
|
|
@@ -12070,19 +12112,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
12070
12112
|
history: doc
|
|
12071
12113
|
});
|
|
12072
12114
|
const take = autosave.restore;
|
|
12073
|
-
const restore = (0,
|
|
12115
|
+
const restore = (0, import_react81.useCallback)(() => {
|
|
12074
12116
|
const snapshot = take();
|
|
12075
12117
|
return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
|
|
12076
12118
|
}, [take, doc]);
|
|
12077
12119
|
const { markClean: clean, discard: drop } = autosave;
|
|
12078
12120
|
const rawStorage = options.storage;
|
|
12079
|
-
const gcRef = (0,
|
|
12121
|
+
const gcRef = (0, import_react81.useRef)(collectAssetGarbage);
|
|
12080
12122
|
gcRef.current = collectAssetGarbage;
|
|
12081
|
-
const markClean = (0,
|
|
12123
|
+
const markClean = (0, import_react81.useCallback)(async () => {
|
|
12082
12124
|
await clean();
|
|
12083
12125
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
12084
12126
|
}, [clean, rawStorage, doc]);
|
|
12085
|
-
const discard = (0,
|
|
12127
|
+
const discard = (0, import_react81.useCallback)(async () => {
|
|
12086
12128
|
await drop();
|
|
12087
12129
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
12088
12130
|
}, [drop, rawStorage, doc]);
|
|
@@ -12091,7 +12133,7 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
12091
12133
|
|
|
12092
12134
|
// src/persistence/RecoveryPrompt.tsx
|
|
12093
12135
|
var import_persistence3 = require("@pixerate/editor/persistence");
|
|
12094
|
-
var
|
|
12136
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
12095
12137
|
var RecoveryPrompt = ({
|
|
12096
12138
|
recovery,
|
|
12097
12139
|
onRestore,
|
|
@@ -12103,7 +12145,7 @@ var RecoveryPrompt = ({
|
|
|
12103
12145
|
}) => {
|
|
12104
12146
|
if (!recovery) return null;
|
|
12105
12147
|
const { name } = recovery.meta;
|
|
12106
|
-
return /* @__PURE__ */ (0,
|
|
12148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
12107
12149
|
"div",
|
|
12108
12150
|
{
|
|
12109
12151
|
role: "alertdialog",
|
|
@@ -12111,15 +12153,15 @@ var RecoveryPrompt = ({
|
|
|
12111
12153
|
"data-recovery-prompt": "",
|
|
12112
12154
|
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}`,
|
|
12113
12155
|
children: [
|
|
12114
|
-
/* @__PURE__ */ (0,
|
|
12156
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
12115
12157
|
(0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
|
|
12116
|
-
name ? /* @__PURE__ */ (0,
|
|
12158
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
|
|
12117
12159
|
"(",
|
|
12118
12160
|
name,
|
|
12119
12161
|
")"
|
|
12120
12162
|
] }) : null
|
|
12121
12163
|
] }),
|
|
12122
|
-
/* @__PURE__ */ (0,
|
|
12164
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
12123
12165
|
"button",
|
|
12124
12166
|
{
|
|
12125
12167
|
type: "button",
|
|
@@ -12129,7 +12171,7 @@ var RecoveryPrompt = ({
|
|
|
12129
12171
|
children: restoreLabel
|
|
12130
12172
|
}
|
|
12131
12173
|
),
|
|
12132
|
-
/* @__PURE__ */ (0,
|
|
12174
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
12133
12175
|
"button",
|
|
12134
12176
|
{
|
|
12135
12177
|
type: "button",
|
|
@@ -12145,17 +12187,17 @@ var RecoveryPrompt = ({
|
|
|
12145
12187
|
};
|
|
12146
12188
|
|
|
12147
12189
|
// src/generation/useGenerationPlan.ts
|
|
12148
|
-
var
|
|
12190
|
+
var import_react82 = require("react");
|
|
12149
12191
|
var import_generation = require("@pixerate/editor/generation");
|
|
12150
12192
|
function useGenerationPlan(request, capabilities, options = {}) {
|
|
12151
12193
|
const key = JSON.stringify([request, capabilities, options]);
|
|
12152
|
-
return (0,
|
|
12194
|
+
return (0, import_react82.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
|
|
12153
12195
|
}
|
|
12154
12196
|
function useJobProgress(options) {
|
|
12155
12197
|
const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
|
|
12156
|
-
const [tick, setTick] = (0,
|
|
12198
|
+
const [tick, setTick] = (0, import_react82.useState)(() => Date.now());
|
|
12157
12199
|
const ticking = !done && now === void 0;
|
|
12158
|
-
(0,
|
|
12200
|
+
(0, import_react82.useEffect)(() => {
|
|
12159
12201
|
if (!ticking) return;
|
|
12160
12202
|
setTick(Date.now());
|
|
12161
12203
|
const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
|
|
@@ -12165,9 +12207,9 @@ function useJobProgress(options) {
|
|
|
12165
12207
|
}
|
|
12166
12208
|
|
|
12167
12209
|
// src/generation/GenerationSettings.tsx
|
|
12168
|
-
var
|
|
12210
|
+
var import_react83 = require("react");
|
|
12169
12211
|
var import_generation2 = require("@pixerate/editor/generation");
|
|
12170
|
-
var
|
|
12212
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
12171
12213
|
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";
|
|
12172
12214
|
function Control({
|
|
12173
12215
|
control,
|
|
@@ -12177,7 +12219,7 @@ function Control({
|
|
|
12177
12219
|
}) {
|
|
12178
12220
|
const shown = value ?? control.defaultValue;
|
|
12179
12221
|
if (control.kind === "checkbox") {
|
|
12180
|
-
return /* @__PURE__ */ (0,
|
|
12222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12181
12223
|
"input",
|
|
12182
12224
|
{
|
|
12183
12225
|
id,
|
|
@@ -12189,7 +12231,7 @@ function Control({
|
|
|
12189
12231
|
);
|
|
12190
12232
|
}
|
|
12191
12233
|
if (control.kind === "select") {
|
|
12192
|
-
return /* @__PURE__ */ (0,
|
|
12234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
12193
12235
|
"select",
|
|
12194
12236
|
{
|
|
12195
12237
|
id,
|
|
@@ -12198,14 +12240,14 @@ function Control({
|
|
|
12198
12240
|
value: shown === void 0 ? "" : String(shown),
|
|
12199
12241
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value)),
|
|
12200
12242
|
children: [
|
|
12201
|
-
shown === void 0 && /* @__PURE__ */ (0,
|
|
12202
|
-
control.options.map((option) => /* @__PURE__ */ (0,
|
|
12243
|
+
shown === void 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("option", { value: "", children: "Default" }),
|
|
12244
|
+
control.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("option", { value: String(option.value), children: option.label }, String(option.value)))
|
|
12203
12245
|
]
|
|
12204
12246
|
}
|
|
12205
12247
|
);
|
|
12206
12248
|
}
|
|
12207
12249
|
if (control.kind === "textarea") {
|
|
12208
|
-
return /* @__PURE__ */ (0,
|
|
12250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12209
12251
|
"textarea",
|
|
12210
12252
|
{
|
|
12211
12253
|
id,
|
|
@@ -12219,8 +12261,8 @@ function Control({
|
|
|
12219
12261
|
);
|
|
12220
12262
|
}
|
|
12221
12263
|
const numeric = typeof shown === "number" ? shown : void 0;
|
|
12222
|
-
return /* @__PURE__ */ (0,
|
|
12223
|
-
/* @__PURE__ */ (0,
|
|
12264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12265
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12224
12266
|
"input",
|
|
12225
12267
|
{
|
|
12226
12268
|
id,
|
|
@@ -12234,7 +12276,7 @@ function Control({
|
|
|
12234
12276
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
|
|
12235
12277
|
}
|
|
12236
12278
|
),
|
|
12237
|
-
control.kind === "range" && /* @__PURE__ */ (0,
|
|
12279
|
+
control.kind === "range" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "w-10 text-right tabular-nums text-muted-foreground", "data-field-value": "", children: numeric ?? "\u2013" })
|
|
12238
12280
|
] });
|
|
12239
12281
|
}
|
|
12240
12282
|
var GenerationSettings = ({
|
|
@@ -12248,17 +12290,17 @@ var GenerationSettings = ({
|
|
|
12248
12290
|
renderReference,
|
|
12249
12291
|
className = ""
|
|
12250
12292
|
}) => {
|
|
12251
|
-
const baseId = (0,
|
|
12252
|
-
const controls = (0,
|
|
12293
|
+
const baseId = (0, import_react83.useId)();
|
|
12294
|
+
const controls = (0, import_react83.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
|
|
12253
12295
|
const computed = useGenerationPlan(value, capabilities, { strategy });
|
|
12254
12296
|
const plan = planProp ?? computed;
|
|
12255
12297
|
const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
|
|
12256
|
-
return /* @__PURE__ */ (0,
|
|
12298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: `flex flex-col gap-3 text-sm ${className}`, "data-generation-settings": "", "data-model": capabilities.id, children: [
|
|
12257
12299
|
controls.map((control) => {
|
|
12258
12300
|
const id = `${baseId}-${control.key}`;
|
|
12259
|
-
return /* @__PURE__ */ (0,
|
|
12260
|
-
/* @__PURE__ */ (0,
|
|
12261
|
-
/* @__PURE__ */ (0,
|
|
12301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "flex flex-col gap-1", "data-control": control.key, children: [
|
|
12302
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("label", { htmlFor: id, className: "text-xs font-medium text-muted-foreground", title: control.description, children: control.label }),
|
|
12303
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12262
12304
|
Control,
|
|
12263
12305
|
{
|
|
12264
12306
|
control,
|
|
@@ -12269,23 +12311,23 @@ var GenerationSettings = ({
|
|
|
12269
12311
|
)
|
|
12270
12312
|
] }, control.key);
|
|
12271
12313
|
}),
|
|
12272
|
-
slots.map((slot) => /* @__PURE__ */ (0,
|
|
12273
|
-
/* @__PURE__ */ (0,
|
|
12314
|
+
slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("fieldset", { className: "flex flex-col gap-1", "data-reference-role": slot.role, children: [
|
|
12315
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("legend", { className: "text-xs font-medium text-muted-foreground", title: slot.description, children: [
|
|
12274
12316
|
slot.label,
|
|
12275
12317
|
" ",
|
|
12276
|
-
/* @__PURE__ */ (0,
|
|
12318
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("span", { className: "tabular-nums", "data-reference-count": "", children: [
|
|
12277
12319
|
"(",
|
|
12278
12320
|
slot.references.length,
|
|
12279
12321
|
"/",
|
|
12280
12322
|
slot.max,
|
|
12281
12323
|
")"
|
|
12282
12324
|
] }),
|
|
12283
|
-
slot.min > 0 && /* @__PURE__ */ (0,
|
|
12325
|
+
slot.min > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "text-destructive", children: " *" })
|
|
12284
12326
|
] }),
|
|
12285
|
-
/* @__PURE__ */ (0,
|
|
12286
|
-
slot.references.map((ref) => /* @__PURE__ */ (0,
|
|
12287
|
-
renderReference ? renderReference(ref) : /* @__PURE__ */ (0,
|
|
12288
|
-
/* @__PURE__ */ (0,
|
|
12327
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("ul", { className: "flex flex-wrap gap-1", children: [
|
|
12328
|
+
slot.references.map((ref) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("li", { className: "flex items-center gap-1 rounded border border-border px-1.5 py-0.5", "data-reference-id": ref.id, children: [
|
|
12329
|
+
renderReference ? renderReference(ref) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "max-w-[10rem] truncate", children: ref.id }),
|
|
12330
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12289
12331
|
"button",
|
|
12290
12332
|
{
|
|
12291
12333
|
type: "button",
|
|
@@ -12296,7 +12338,7 @@ var GenerationSettings = ({
|
|
|
12296
12338
|
}
|
|
12297
12339
|
)
|
|
12298
12340
|
] }, ref.id)),
|
|
12299
|
-
onAddReference && slot.canAdd && /* @__PURE__ */ (0,
|
|
12341
|
+
onAddReference && slot.canAdd && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12300
12342
|
"button",
|
|
12301
12343
|
{
|
|
12302
12344
|
type: "button",
|
|
@@ -12307,21 +12349,21 @@ var GenerationSettings = ({
|
|
|
12307
12349
|
) })
|
|
12308
12350
|
] })
|
|
12309
12351
|
] }, slot.role)),
|
|
12310
|
-
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0,
|
|
12311
|
-
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0,
|
|
12352
|
+
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.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_runtime60.jsx)("li", { "data-adjustment-field": adjustment.field, "data-adjustment-kind": adjustment.kind, children: adjustment.reason }, index)) }),
|
|
12353
|
+
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.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_runtime60.jsx)("li", { "data-error-field": error.field, children: error.message }, index)) })
|
|
12312
12354
|
] });
|
|
12313
12355
|
};
|
|
12314
12356
|
|
|
12315
12357
|
// src/generation/JobProgress.tsx
|
|
12316
|
-
var
|
|
12358
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
12317
12359
|
var JobProgress = ({ title, className = "", ...options }) => {
|
|
12318
12360
|
const progress = useJobProgress(options);
|
|
12319
|
-
return /* @__PURE__ */ (0,
|
|
12320
|
-
/* @__PURE__ */ (0,
|
|
12321
|
-
title && /* @__PURE__ */ (0,
|
|
12322
|
-
/* @__PURE__ */ (0,
|
|
12361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: `flex flex-col gap-1 text-sm ${className}`, "data-job-progress": "", "data-done": options.done ? "" : void 0, children: [
|
|
12362
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "flex items-center justify-between gap-2 text-muted-foreground", children: [
|
|
12363
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "truncate text-foreground", children: title }),
|
|
12364
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { "data-job-progress-label": "", "aria-live": "polite", children: progress.label })
|
|
12323
12365
|
] }),
|
|
12324
|
-
/* @__PURE__ */ (0,
|
|
12366
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12325
12367
|
"div",
|
|
12326
12368
|
{
|
|
12327
12369
|
role: "progressbar",
|
|
@@ -12331,7 +12373,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
12331
12373
|
"aria-valuenow": progress.percent,
|
|
12332
12374
|
"aria-valuetext": `${progress.percent}%, ${progress.label}`,
|
|
12333
12375
|
className: "h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
12334
|
-
children: /* @__PURE__ */ (0,
|
|
12376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
12335
12377
|
"div",
|
|
12336
12378
|
{
|
|
12337
12379
|
className: "h-full rounded-full bg-primary transition-[width] duration-500",
|
|
@@ -12344,9 +12386,9 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
12344
12386
|
};
|
|
12345
12387
|
|
|
12346
12388
|
// src/generation/AssetMentionChips.tsx
|
|
12347
|
-
var
|
|
12389
|
+
var import_react84 = require("react");
|
|
12348
12390
|
var import_generation3 = require("@pixerate/editor/generation");
|
|
12349
|
-
var
|
|
12391
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
12350
12392
|
var AssetMentionChips = ({
|
|
12351
12393
|
content,
|
|
12352
12394
|
onChange,
|
|
@@ -12356,14 +12398,14 @@ var AssetMentionChips = ({
|
|
|
12356
12398
|
renderAsset,
|
|
12357
12399
|
className = ""
|
|
12358
12400
|
}) => {
|
|
12359
|
-
const [open, setOpen] = (0,
|
|
12360
|
-
const rootRef = (0,
|
|
12361
|
-
const chips = (0,
|
|
12401
|
+
const [open, setOpen] = (0, import_react84.useState)(null);
|
|
12402
|
+
const rootRef = (0, import_react84.useRef)(null);
|
|
12403
|
+
const chips = (0, import_react84.useMemo)(
|
|
12362
12404
|
() => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
|
|
12363
12405
|
[content, assets, capabilities]
|
|
12364
12406
|
);
|
|
12365
12407
|
const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
|
|
12366
|
-
(0,
|
|
12408
|
+
(0, import_react84.useEffect)(() => {
|
|
12367
12409
|
if (open === null) return;
|
|
12368
12410
|
const onPointer = (event) => {
|
|
12369
12411
|
if (!rootRef.current?.contains(event.target)) setOpen(null);
|
|
@@ -12377,13 +12419,13 @@ var AssetMentionChips = ({
|
|
|
12377
12419
|
onChange((0, import_generation3.setMentionRoleInText)(content, chip2.start, role));
|
|
12378
12420
|
};
|
|
12379
12421
|
if (chips.length === 0) return null;
|
|
12380
|
-
return /* @__PURE__ */ (0,
|
|
12422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { ref: rootRef, className: `flex flex-wrap gap-1.5 ${className}`, "data-asset-mention-chips": "", children: chips.map((chip2) => {
|
|
12381
12423
|
const error = chip2.issues.find((issue) => issue.severity === "error");
|
|
12382
12424
|
const warning = chip2.issues.find((issue) => issue.severity === "warning");
|
|
12383
12425
|
const problem = error ?? warning;
|
|
12384
12426
|
const isOpen = open === chip2.index;
|
|
12385
|
-
return /* @__PURE__ */ (0,
|
|
12386
|
-
/* @__PURE__ */ (0,
|
|
12427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "relative inline-flex", "data-asset-chip": chip2.asset.id, children: [
|
|
12428
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
|
|
12387
12429
|
"button",
|
|
12388
12430
|
{
|
|
12389
12431
|
type: "button",
|
|
@@ -12397,8 +12439,8 @@ var AssetMentionChips = ({
|
|
|
12397
12439
|
},
|
|
12398
12440
|
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`,
|
|
12399
12441
|
children: [
|
|
12400
|
-
/* @__PURE__ */ (0,
|
|
12401
|
-
/* @__PURE__ */ (0,
|
|
12442
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: renderAsset ? renderAsset(chip2) : `@${chip2.asset.label ?? chip2.handle}` }),
|
|
12443
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
12402
12444
|
"span",
|
|
12403
12445
|
{
|
|
12404
12446
|
className: `rounded px-1 text-[10px] uppercase tracking-wide ${chip2.role ? "bg-primary/15" : "opacity-60"}`,
|
|
@@ -12409,7 +12451,7 @@ var AssetMentionChips = ({
|
|
|
12409
12451
|
]
|
|
12410
12452
|
}
|
|
12411
12453
|
),
|
|
12412
|
-
isOpen && /* @__PURE__ */ (0,
|
|
12454
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
|
|
12413
12455
|
"div",
|
|
12414
12456
|
{
|
|
12415
12457
|
role: "listbox",
|
|
@@ -12420,7 +12462,7 @@ var AssetMentionChips = ({
|
|
|
12420
12462
|
if (e.key === "Escape") setOpen(null);
|
|
12421
12463
|
},
|
|
12422
12464
|
children: [
|
|
12423
|
-
options.map((option) => /* @__PURE__ */ (0,
|
|
12465
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
|
|
12424
12466
|
"button",
|
|
12425
12467
|
{
|
|
12426
12468
|
type: "button",
|
|
@@ -12431,13 +12473,13 @@ var AssetMentionChips = ({
|
|
|
12431
12473
|
onClick: () => pick(chip2, option.role),
|
|
12432
12474
|
className: "flex items-center justify-between gap-2 rounded px-2 py-1 text-left hover:bg-muted",
|
|
12433
12475
|
children: [
|
|
12434
|
-
/* @__PURE__ */ (0,
|
|
12435
|
-
option.accepts?.length ? /* @__PURE__ */ (0,
|
|
12476
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: option.label }),
|
|
12477
|
+
option.accepts?.length ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "text-[10px] opacity-60", children: option.accepts.join(", ") }) : null
|
|
12436
12478
|
]
|
|
12437
12479
|
},
|
|
12438
12480
|
option.role
|
|
12439
12481
|
)),
|
|
12440
|
-
/* @__PURE__ */ (0,
|
|
12482
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
12441
12483
|
"button",
|
|
12442
12484
|
{
|
|
12443
12485
|
type: "button",
|
|
@@ -12449,7 +12491,7 @@ var AssetMentionChips = ({
|
|
|
12449
12491
|
children: "No role"
|
|
12450
12492
|
}
|
|
12451
12493
|
),
|
|
12452
|
-
chip2.issues.length > 0 && /* @__PURE__ */ (0,
|
|
12494
|
+
chip2.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime62.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_runtime62.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : "text-amber-500", children: issue.message }, i)) })
|
|
12453
12495
|
]
|
|
12454
12496
|
}
|
|
12455
12497
|
)
|
|
@@ -12458,15 +12500,15 @@ var AssetMentionChips = ({
|
|
|
12458
12500
|
};
|
|
12459
12501
|
|
|
12460
12502
|
// src/generation/GenerationHistory.tsx
|
|
12461
|
-
var
|
|
12503
|
+
var import_react85 = require("react");
|
|
12462
12504
|
var import_generation4 = require("@pixerate/editor/generation");
|
|
12463
|
-
var
|
|
12505
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
12464
12506
|
function useGenerationRecords(store, filter) {
|
|
12465
|
-
const [records, setRecords] = (0,
|
|
12466
|
-
const [loading, setLoading] = (0,
|
|
12467
|
-
const [error, setError] = (0,
|
|
12507
|
+
const [records, setRecords] = (0, import_react85.useState)([]);
|
|
12508
|
+
const [loading, setLoading] = (0, import_react85.useState)(!!store);
|
|
12509
|
+
const [error, setError] = (0, import_react85.useState)(null);
|
|
12468
12510
|
const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
|
|
12469
|
-
const refresh = (0,
|
|
12511
|
+
const refresh = (0, import_react85.useCallback)(async () => {
|
|
12470
12512
|
if (!store) {
|
|
12471
12513
|
setRecords([]);
|
|
12472
12514
|
setLoading(false);
|
|
@@ -12483,7 +12525,7 @@ function useGenerationRecords(store, filter) {
|
|
|
12483
12525
|
setLoading(false);
|
|
12484
12526
|
}
|
|
12485
12527
|
}, [store, filterKey]);
|
|
12486
|
-
(0,
|
|
12528
|
+
(0, import_react85.useEffect)(() => {
|
|
12487
12529
|
void refresh();
|
|
12488
12530
|
if (!store) return;
|
|
12489
12531
|
return store.subscribe(() => void refresh());
|
|
@@ -12509,21 +12551,21 @@ var GenerationHistory = ({
|
|
|
12509
12551
|
emptyText = "No generations yet.",
|
|
12510
12552
|
className = ""
|
|
12511
12553
|
}) => {
|
|
12512
|
-
const [innerMode, setInnerMode] = (0,
|
|
12554
|
+
const [innerMode, setInnerMode] = (0, import_react85.useState)("exact");
|
|
12513
12555
|
const mode = modeProp ?? innerMode;
|
|
12514
12556
|
const setMode = (next) => {
|
|
12515
12557
|
if (modeProp === void 0) setInnerMode(next);
|
|
12516
12558
|
onModeChange?.(next);
|
|
12517
12559
|
};
|
|
12518
|
-
const options = (0,
|
|
12519
|
-
const results = (0,
|
|
12520
|
-
const models = (0,
|
|
12560
|
+
const options = (0, import_react85.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
|
|
12561
|
+
const results = (0, import_react85.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
|
|
12562
|
+
const models = (0, import_react85.useMemo)(
|
|
12521
12563
|
() => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
|
|
12522
12564
|
[capabilities]
|
|
12523
12565
|
);
|
|
12524
|
-
return /* @__PURE__ */ (0,
|
|
12525
|
-
/* @__PURE__ */ (0,
|
|
12526
|
-
/* @__PURE__ */ (0,
|
|
12566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `flex flex-col gap-2 text-sm ${className}`, "data-generation-history": "", children: [
|
|
12567
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.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_runtime63.jsxs)("label", { className: "inline-flex items-center gap-1", children: [
|
|
12568
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12527
12569
|
"input",
|
|
12528
12570
|
{
|
|
12529
12571
|
type: "radio",
|
|
@@ -12536,34 +12578,34 @@ var GenerationHistory = ({
|
|
|
12536
12578
|
),
|
|
12537
12579
|
value === "exact" ? "Exact (recorded versions)" : "Latest templates & settings"
|
|
12538
12580
|
] }, value)) }),
|
|
12539
|
-
records.length === 0 && /* @__PURE__ */ (0,
|
|
12540
|
-
/* @__PURE__ */ (0,
|
|
12581
|
+
records.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyText }),
|
|
12582
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("ul", { className: "flex flex-col gap-2", children: records.map((record, i) => {
|
|
12541
12583
|
const result = results[i];
|
|
12542
12584
|
const model = models.find((m) => m.id === record.provenance.modelId);
|
|
12543
12585
|
const blocked = !result.ok;
|
|
12544
|
-
return /* @__PURE__ */ (0,
|
|
12586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
|
|
12545
12587
|
"li",
|
|
12546
12588
|
{
|
|
12547
12589
|
className: "rounded-md border border-border p-2",
|
|
12548
12590
|
"data-record": record.id,
|
|
12549
12591
|
"data-drift": result.drift.length,
|
|
12550
12592
|
children: [
|
|
12551
|
-
/* @__PURE__ */ (0,
|
|
12552
|
-
/* @__PURE__ */ (0,
|
|
12553
|
-
/* @__PURE__ */ (0,
|
|
12554
|
-
record.kind !== "generate" && /* @__PURE__ */ (0,
|
|
12593
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs", children: [
|
|
12594
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "font-medium", children: model?.name ?? record.provenance.modelId }),
|
|
12595
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
12596
|
+
record.kind !== "generate" && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("span", { "data-kind": "", children: [
|
|
12555
12597
|
record.kind,
|
|
12556
12598
|
" \xB7 "
|
|
12557
12599
|
] }),
|
|
12558
|
-
/* @__PURE__ */ (0,
|
|
12559
|
-
record.seed !== void 0 && /* @__PURE__ */ (0,
|
|
12600
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("time", { dateTime: record.createdAt, children: record.createdAt.replace("T", " ").slice(0, 16) }),
|
|
12601
|
+
record.seed !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
|
|
12560
12602
|
" \xB7 seed ",
|
|
12561
12603
|
record.seed
|
|
12562
12604
|
] })
|
|
12563
12605
|
] })
|
|
12564
12606
|
] }),
|
|
12565
|
-
/* @__PURE__ */ (0,
|
|
12566
|
-
record.assets.length > 0 && /* @__PURE__ */ (0,
|
|
12607
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "mt-1 line-clamp-3 break-words text-xs", "data-record-prompt": "", children: record.provenance.resolvedPrompt }),
|
|
12608
|
+
record.assets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children: record.assets.map((asset) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
|
|
12567
12609
|
"span",
|
|
12568
12610
|
{
|
|
12569
12611
|
className: "rounded-full bg-muted px-2 py-0.5 text-[10px]",
|
|
@@ -12577,16 +12619,16 @@ var GenerationHistory = ({
|
|
|
12577
12619
|
`${asset.role}:${asset.id}`
|
|
12578
12620
|
)) }),
|
|
12579
12621
|
renderPreview?.(record),
|
|
12580
|
-
result.drift.length > 0 && /* @__PURE__ */ (0,
|
|
12581
|
-
/* @__PURE__ */ (0,
|
|
12622
|
+
result.drift.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.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_runtime63.jsxs)("li", { className: severityClass[item.severity], "data-drift-type": item.type, children: [
|
|
12623
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("strong", { children: [
|
|
12582
12624
|
import_generation4.DRIFT_TYPE_LABELS[item.type],
|
|
12583
12625
|
":"
|
|
12584
12626
|
] }),
|
|
12585
12627
|
" ",
|
|
12586
12628
|
item.message
|
|
12587
12629
|
] }, j)) }),
|
|
12588
|
-
/* @__PURE__ */ (0,
|
|
12589
|
-
onRecreate && /* @__PURE__ */ (0,
|
|
12630
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "mt-2 flex gap-2", children: [
|
|
12631
|
+
onRecreate && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12590
12632
|
"button",
|
|
12591
12633
|
{
|
|
12592
12634
|
type: "button",
|
|
@@ -12598,7 +12640,7 @@ var GenerationHistory = ({
|
|
|
12598
12640
|
children: "Recreate"
|
|
12599
12641
|
}
|
|
12600
12642
|
),
|
|
12601
|
-
onVariation && /* @__PURE__ */ (0,
|
|
12643
|
+
onVariation && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12602
12644
|
"button",
|
|
12603
12645
|
{
|
|
12604
12646
|
type: "button",
|
|
@@ -12608,7 +12650,7 @@ var GenerationHistory = ({
|
|
|
12608
12650
|
children: "Variation"
|
|
12609
12651
|
}
|
|
12610
12652
|
),
|
|
12611
|
-
onRemove && /* @__PURE__ */ (0,
|
|
12653
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
12612
12654
|
"button",
|
|
12613
12655
|
{
|
|
12614
12656
|
type: "button",
|
|
@@ -12628,19 +12670,19 @@ var GenerationHistory = ({
|
|
|
12628
12670
|
};
|
|
12629
12671
|
|
|
12630
12672
|
// src/find-replace/useFindReplace.ts
|
|
12631
|
-
var
|
|
12673
|
+
var import_react86 = require("react");
|
|
12632
12674
|
var import_editor17 = require("@pixerate/editor");
|
|
12633
12675
|
var noopUnsubscribe2 = () => {
|
|
12634
12676
|
};
|
|
12635
12677
|
function useFindReplace(editor) {
|
|
12636
12678
|
const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
|
|
12637
|
-
const subscribe = (0,
|
|
12679
|
+
const subscribe = (0, import_react86.useCallback)(
|
|
12638
12680
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
12639
12681
|
[store]
|
|
12640
12682
|
);
|
|
12641
12683
|
const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
12642
|
-
const snapshot = (0,
|
|
12643
|
-
return (0,
|
|
12684
|
+
const snapshot = (0, import_react86.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
12685
|
+
return (0, import_react86.useMemo)(() => {
|
|
12644
12686
|
const run = (fn) => {
|
|
12645
12687
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
12646
12688
|
};
|
|
@@ -12664,9 +12706,9 @@ function useFindReplace(editor) {
|
|
|
12664
12706
|
}
|
|
12665
12707
|
|
|
12666
12708
|
// src/find-replace/FindReplaceBar.tsx
|
|
12667
|
-
var
|
|
12709
|
+
var import_react87 = require("react");
|
|
12668
12710
|
var import_editor18 = require("@pixerate/editor");
|
|
12669
|
-
var
|
|
12711
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
12670
12712
|
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";
|
|
12671
12713
|
var buttonClass5 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
12672
12714
|
var toggleClass = (on) => `${buttonClass5} font-mono ${on ? "bg-primary/10 text-primary" : "text-muted-foreground"}`;
|
|
@@ -12679,10 +12721,10 @@ var FindReplaceBar = ({
|
|
|
12679
12721
|
onClose
|
|
12680
12722
|
}) => {
|
|
12681
12723
|
const find = useFindReplace(editor);
|
|
12682
|
-
const findInput = (0,
|
|
12683
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
12724
|
+
const findInput = (0, import_react87.useRef)(null);
|
|
12725
|
+
const [moreOpen, setMoreOpen] = (0, import_react87.useState)(false);
|
|
12684
12726
|
const visible = find.available && (alwaysOpen || find.open);
|
|
12685
|
-
(0,
|
|
12727
|
+
(0, import_react87.useEffect)(() => {
|
|
12686
12728
|
if (!visible || find.focusRequest === 0) return;
|
|
12687
12729
|
findInput.current?.focus();
|
|
12688
12730
|
findInput.current?.select();
|
|
@@ -12720,9 +12762,9 @@ var FindReplaceBar = ({
|
|
|
12720
12762
|
if (isMod(e)) find.replaceAll();
|
|
12721
12763
|
else find.replace();
|
|
12722
12764
|
};
|
|
12723
|
-
return /* @__PURE__ */ (0,
|
|
12724
|
-
/* @__PURE__ */ (0,
|
|
12725
|
-
/* @__PURE__ */ (0,
|
|
12765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className, role: "search", "aria-label": "Find and replace", onKeyDown: onBarKeyDown, children: [
|
|
12766
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12767
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12726
12768
|
"button",
|
|
12727
12769
|
{
|
|
12728
12770
|
type: "button",
|
|
@@ -12733,7 +12775,7 @@ var FindReplaceBar = ({
|
|
|
12733
12775
|
children: showReplace ? "\u25BE" : "\u25B8"
|
|
12734
12776
|
}
|
|
12735
12777
|
),
|
|
12736
|
-
/* @__PURE__ */ (0,
|
|
12778
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12737
12779
|
"input",
|
|
12738
12780
|
{
|
|
12739
12781
|
ref: findInput,
|
|
@@ -12747,7 +12789,7 @@ var FindReplaceBar = ({
|
|
|
12747
12789
|
onKeyDown: onFindKeyDown
|
|
12748
12790
|
}
|
|
12749
12791
|
),
|
|
12750
|
-
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0,
|
|
12792
|
+
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12751
12793
|
"button",
|
|
12752
12794
|
{
|
|
12753
12795
|
type: "button",
|
|
@@ -12760,7 +12802,7 @@ var FindReplaceBar = ({
|
|
|
12760
12802
|
},
|
|
12761
12803
|
t.key
|
|
12762
12804
|
)),
|
|
12763
|
-
/* @__PURE__ */ (0,
|
|
12805
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12764
12806
|
"span",
|
|
12765
12807
|
{
|
|
12766
12808
|
className: `min-w-[5rem] px-1 text-center text-xs ${find.error ? "text-destructive" : "text-muted-foreground"}`,
|
|
@@ -12770,9 +12812,9 @@ var FindReplaceBar = ({
|
|
|
12770
12812
|
children: status
|
|
12771
12813
|
}
|
|
12772
12814
|
),
|
|
12773
|
-
/* @__PURE__ */ (0,
|
|
12774
|
-
/* @__PURE__ */ (0,
|
|
12775
|
-
showMoreOptions && /* @__PURE__ */ (0,
|
|
12815
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Previous match", disabled: !hasMatches, onClick: find.previous, children: "\u2191" }),
|
|
12816
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Next match", disabled: !hasMatches, onClick: find.next, children: "\u2193" }),
|
|
12817
|
+
showMoreOptions && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12776
12818
|
"button",
|
|
12777
12819
|
{
|
|
12778
12820
|
type: "button",
|
|
@@ -12783,10 +12825,10 @@ var FindReplaceBar = ({
|
|
|
12783
12825
|
children: "\u2026"
|
|
12784
12826
|
}
|
|
12785
12827
|
),
|
|
12786
|
-
/* @__PURE__ */ (0,
|
|
12828
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Close find", onClick: close, children: "\xD7" })
|
|
12787
12829
|
] }),
|
|
12788
|
-
showReplace && /* @__PURE__ */ (0,
|
|
12789
|
-
/* @__PURE__ */ (0,
|
|
12830
|
+
showReplace && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1 pl-7", children: [
|
|
12831
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12790
12832
|
"input",
|
|
12791
12833
|
{
|
|
12792
12834
|
type: "text",
|
|
@@ -12798,7 +12840,7 @@ var FindReplaceBar = ({
|
|
|
12798
12840
|
onKeyDown: onReplaceKeyDown
|
|
12799
12841
|
}
|
|
12800
12842
|
),
|
|
12801
|
-
/* @__PURE__ */ (0,
|
|
12843
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12802
12844
|
"button",
|
|
12803
12845
|
{
|
|
12804
12846
|
type: "button",
|
|
@@ -12808,11 +12850,11 @@ var FindReplaceBar = ({
|
|
|
12808
12850
|
children: "Replace"
|
|
12809
12851
|
}
|
|
12810
12852
|
),
|
|
12811
|
-
/* @__PURE__ */ (0,
|
|
12812
|
-
find.lastReplaceCount !== null && /* @__PURE__ */ (0,
|
|
12853
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: buttonClass5, disabled: !hasMatches, onClick: find.replaceAll, children: "Replace all" }),
|
|
12854
|
+
find.lastReplaceCount !== null && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "px-1 text-xs text-muted-foreground", "aria-live": "polite", children: find.lastReplaceCount === 1 ? "1 replaced" : `${find.lastReplaceCount} replaced` })
|
|
12813
12855
|
] }),
|
|
12814
|
-
showMoreOptions && moreOpen && /* @__PURE__ */ (0,
|
|
12815
|
-
/* @__PURE__ */ (0,
|
|
12856
|
+
showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime64.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_runtime64.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
12857
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12816
12858
|
"input",
|
|
12817
12859
|
{
|
|
12818
12860
|
type: "checkbox",
|
|
@@ -12826,12 +12868,12 @@ var FindReplaceBar = ({
|
|
|
12826
12868
|
};
|
|
12827
12869
|
|
|
12828
12870
|
// src/tables/useTableMenu.ts
|
|
12829
|
-
var
|
|
12871
|
+
var import_react88 = require("react");
|
|
12830
12872
|
var import_editor19 = require("@pixerate/editor");
|
|
12831
12873
|
function useTableMenu(editor) {
|
|
12832
|
-
const store = (0,
|
|
12833
|
-
const snapshot = (0,
|
|
12834
|
-
return (0,
|
|
12874
|
+
const store = (0, import_react88.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
|
|
12875
|
+
const snapshot = (0, import_react88.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
12876
|
+
return (0, import_react88.useMemo)(
|
|
12835
12877
|
() => ({
|
|
12836
12878
|
...snapshot,
|
|
12837
12879
|
run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
|
|
@@ -12842,9 +12884,9 @@ function useTableMenu(editor) {
|
|
|
12842
12884
|
}
|
|
12843
12885
|
|
|
12844
12886
|
// src/tables/TableToolbar.tsx
|
|
12845
|
-
var
|
|
12887
|
+
var import_react89 = __toESM(require("react"), 1);
|
|
12846
12888
|
var import_editor20 = require("@pixerate/editor");
|
|
12847
|
-
var
|
|
12889
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
12848
12890
|
var keepSelection2 = (event) => event.preventDefault();
|
|
12849
12891
|
var TableToolbar = ({
|
|
12850
12892
|
editor,
|
|
@@ -12858,14 +12900,14 @@ var TableToolbar = ({
|
|
|
12858
12900
|
}) => {
|
|
12859
12901
|
const table = useTableMenu(editor);
|
|
12860
12902
|
if (!editor || !table.inTable && !showWhenOutside) return null;
|
|
12861
|
-
return /* @__PURE__ */ (0,
|
|
12903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className, role: "toolbar", "aria-label": "Table", "data-table-toolbar": "", children: items.map((item, index) => {
|
|
12862
12904
|
const status = table.check(item.action, item.params);
|
|
12863
12905
|
const enabled = status === true;
|
|
12864
12906
|
const active = item.active?.(table);
|
|
12865
12907
|
const separator = index > 0 && items[index - 1].group !== item.group;
|
|
12866
|
-
return /* @__PURE__ */ (0,
|
|
12867
|
-
separator && /* @__PURE__ */ (0,
|
|
12868
|
-
/* @__PURE__ */ (0,
|
|
12908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_react89.default.Fragment, { children: [
|
|
12909
|
+
separator && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
|
|
12910
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12869
12911
|
"button",
|
|
12870
12912
|
{
|
|
12871
12913
|
type: "button",
|
|
@@ -12887,8 +12929,8 @@ var TableToolbar = ({
|
|
|
12887
12929
|
};
|
|
12888
12930
|
|
|
12889
12931
|
// src/tables/InsertTableGrid.tsx
|
|
12890
|
-
var
|
|
12891
|
-
var
|
|
12932
|
+
var import_react90 = require("react");
|
|
12933
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
12892
12934
|
var keepSelection3 = (event) => event.preventDefault();
|
|
12893
12935
|
var InsertTableGrid = ({
|
|
12894
12936
|
editor,
|
|
@@ -12901,14 +12943,14 @@ var InsertTableGrid = ({
|
|
|
12901
12943
|
onInsert
|
|
12902
12944
|
}) => {
|
|
12903
12945
|
const table = useTableMenu(editor);
|
|
12904
|
-
const [hover, setHover] = (0,
|
|
12946
|
+
const [hover, setHover] = (0, import_react90.useState)(null);
|
|
12905
12947
|
const status = table.actions.insertTable;
|
|
12906
12948
|
const disabled = !editor || !status.enabled;
|
|
12907
12949
|
const insert = (size) => {
|
|
12908
12950
|
if (table.run("insertTable", { ...size, withHeaderRow })) onInsert?.(size);
|
|
12909
12951
|
setHover(null);
|
|
12910
12952
|
};
|
|
12911
|
-
return /* @__PURE__ */ (0,
|
|
12953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
12912
12954
|
"div",
|
|
12913
12955
|
{
|
|
12914
12956
|
className,
|
|
@@ -12918,7 +12960,7 @@ var InsertTableGrid = ({
|
|
|
12918
12960
|
"data-insert-table-grid": "",
|
|
12919
12961
|
onMouseLeave: () => setHover(null),
|
|
12920
12962
|
children: [
|
|
12921
|
-
/* @__PURE__ */ (0,
|
|
12963
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12922
12964
|
"div",
|
|
12923
12965
|
{
|
|
12924
12966
|
role: "grid",
|
|
@@ -12927,7 +12969,7 @@ var InsertTableGrid = ({
|
|
|
12927
12969
|
children: Array.from({ length: rows * cols }, (_, i) => {
|
|
12928
12970
|
const size = { rows: Math.floor(i / cols) + 1, cols: i % cols + 1 };
|
|
12929
12971
|
const active = !!hover && size.rows <= hover.rows && size.cols <= hover.cols;
|
|
12930
|
-
return /* @__PURE__ */ (0,
|
|
12972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12931
12973
|
"button",
|
|
12932
12974
|
{
|
|
12933
12975
|
type: "button",
|
|
@@ -12947,7 +12989,7 @@ var InsertTableGrid = ({
|
|
|
12947
12989
|
})
|
|
12948
12990
|
}
|
|
12949
12991
|
),
|
|
12950
|
-
/* @__PURE__ */ (0,
|
|
12992
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { "aria-live": "polite", "data-testid": "insert-table-size", children: disabled ? status.reason : hover ? `${hover.rows} \xD7 ${hover.cols}` : "Insert table" })
|
|
12951
12993
|
]
|
|
12952
12994
|
}
|
|
12953
12995
|
);
|
|
@@ -12955,31 +12997,31 @@ var InsertTableGrid = ({
|
|
|
12955
12997
|
|
|
12956
12998
|
// src/tables/TableBubbleMenu.tsx
|
|
12957
12999
|
var import_editor21 = require("@pixerate/editor");
|
|
12958
|
-
var
|
|
13000
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
12959
13001
|
var TableBubbleMenu = ({
|
|
12960
13002
|
editor,
|
|
12961
13003
|
children,
|
|
12962
13004
|
toolbarProps,
|
|
12963
13005
|
pluginKey = "tableBubbleMenu",
|
|
12964
13006
|
...rest
|
|
12965
|
-
}) => /* @__PURE__ */ (0,
|
|
13007
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor21.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(TableToolbar, { editor, ...toolbarProps }) });
|
|
12966
13008
|
|
|
12967
13009
|
// src/chart-node/ChartNodeView.tsx
|
|
12968
13010
|
var import_client = require("react-dom/client");
|
|
12969
13011
|
|
|
12970
13012
|
// src/chart/ChartCanvas.tsx
|
|
12971
|
-
var
|
|
13013
|
+
var import_react92 = require("react");
|
|
12972
13014
|
var import_chart2 = require("@pixerate/editor/chart");
|
|
12973
13015
|
|
|
12974
13016
|
// src/chart/useChartEditor.ts
|
|
12975
|
-
var
|
|
13017
|
+
var import_react91 = require("react");
|
|
12976
13018
|
var import_chart = require("@pixerate/editor/chart");
|
|
12977
13019
|
function useChartState(controller) {
|
|
12978
|
-
return (0,
|
|
13020
|
+
return (0, import_react91.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
12979
13021
|
}
|
|
12980
13022
|
|
|
12981
13023
|
// src/chart/ChartCanvas.tsx
|
|
12982
|
-
var
|
|
13024
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
12983
13025
|
function renderChartMark(mark, fontFamily, interactive) {
|
|
12984
13026
|
const common = {
|
|
12985
13027
|
"data-role": mark.role,
|
|
@@ -12991,9 +13033,9 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
12991
13033
|
};
|
|
12992
13034
|
switch (mark.kind) {
|
|
12993
13035
|
case "rect":
|
|
12994
|
-
return /* @__PURE__ */ (0,
|
|
13036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.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);
|
|
12995
13037
|
case "path":
|
|
12996
|
-
return /* @__PURE__ */ (0,
|
|
13038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
12997
13039
|
"path",
|
|
12998
13040
|
{
|
|
12999
13041
|
...common,
|
|
@@ -13006,11 +13048,11 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
13006
13048
|
mark.key
|
|
13007
13049
|
);
|
|
13008
13050
|
case "circle":
|
|
13009
|
-
return /* @__PURE__ */ (0,
|
|
13051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
13010
13052
|
case "line":
|
|
13011
|
-
return /* @__PURE__ */ (0,
|
|
13053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.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);
|
|
13012
13054
|
case "text":
|
|
13013
|
-
return /* @__PURE__ */ (0,
|
|
13055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
13014
13056
|
"text",
|
|
13015
13057
|
{
|
|
13016
13058
|
...common,
|
|
@@ -13027,36 +13069,36 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
13027
13069
|
}
|
|
13028
13070
|
}
|
|
13029
13071
|
function ChartPresenceLayer({ presence }) {
|
|
13030
|
-
const { actors } = (0,
|
|
13031
|
-
return /* @__PURE__ */ (0,
|
|
13032
|
-
/* @__PURE__ */ (0,
|
|
13033
|
-
/* @__PURE__ */ (0,
|
|
13034
|
-
/* @__PURE__ */ (0,
|
|
13035
|
-
/* @__PURE__ */ (0,
|
|
13072
|
+
const { actors } = (0, import_react92.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
13073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
|
|
13074
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.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 }),
|
|
13075
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("g", { transform: "translate(13 16)", children: [
|
|
13076
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.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 } }),
|
|
13077
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("text", { x: 6, y: 9, dominantBaseline: "central", style: { fill: "#ffffff", fontSize: 11, fontWeight: 600, fontFamily: "inherit" }, children: a.message ?? a.name })
|
|
13036
13078
|
] })
|
|
13037
13079
|
] }, a.id)) });
|
|
13038
13080
|
}
|
|
13039
13081
|
function ChartTooltipContent({ tooltip }) {
|
|
13040
|
-
return /* @__PURE__ */ (0,
|
|
13041
|
-
tooltip.title && /* @__PURE__ */ (0,
|
|
13042
|
-
tooltip.items.map((item) => /* @__PURE__ */ (0,
|
|
13043
|
-
/* @__PURE__ */ (0,
|
|
13044
|
-
/* @__PURE__ */ (0,
|
|
13045
|
-
/* @__PURE__ */ (0,
|
|
13082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
|
|
13083
|
+
tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
|
|
13084
|
+
tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
13085
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
|
|
13086
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
|
|
13087
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
|
|
13046
13088
|
] }, item.seriesId))
|
|
13047
13089
|
] });
|
|
13048
13090
|
}
|
|
13049
13091
|
function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
|
|
13050
13092
|
const state = useChartState(controller);
|
|
13051
|
-
const wrapper = (0,
|
|
13052
|
-
const svg = (0,
|
|
13053
|
-
const drag = (0,
|
|
13054
|
-
const [measured, setMeasured] = (0,
|
|
13055
|
-
const [frozen, setFrozen] = (0,
|
|
13093
|
+
const wrapper = (0, import_react92.useRef)(null);
|
|
13094
|
+
const svg = (0, import_react92.useRef)(null);
|
|
13095
|
+
const drag = (0, import_react92.useRef)(null);
|
|
13096
|
+
const [measured, setMeasured] = (0, import_react92.useState)(null);
|
|
13097
|
+
const [frozen, setFrozen] = (0, import_react92.useState)(null);
|
|
13056
13098
|
const tooltipMode = tooltip === true ? "point" : tooltip || null;
|
|
13057
|
-
const [tip, setTip] = (0,
|
|
13058
|
-
const [tipAt, setTipAt] = (0,
|
|
13059
|
-
(0,
|
|
13099
|
+
const [tip, setTip] = (0, import_react92.useState)(null);
|
|
13100
|
+
const [tipAt, setTipAt] = (0, import_react92.useState)({ left: 0, top: 0, flip: false });
|
|
13101
|
+
(0, import_react92.useEffect)(() => {
|
|
13060
13102
|
const el = wrapper.current;
|
|
13061
13103
|
if (!responsive || !el || typeof ResizeObserver === "undefined") return;
|
|
13062
13104
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -13067,8 +13109,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
13067
13109
|
return () => observer.disconnect();
|
|
13068
13110
|
}, [responsive]);
|
|
13069
13111
|
const sceneWidth = responsive && measured || width;
|
|
13070
|
-
const fullTheme = (0,
|
|
13071
|
-
const scene = (0,
|
|
13112
|
+
const fullTheme = (0, import_react92.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
|
|
13113
|
+
const scene = (0, import_react92.useMemo)(
|
|
13072
13114
|
() => (0, import_chart2.layoutChart)(state.spec, {
|
|
13073
13115
|
width: sceneWidth,
|
|
13074
13116
|
height,
|
|
@@ -13085,8 +13127,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
13085
13127
|
[state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
|
|
13086
13128
|
);
|
|
13087
13129
|
if (sceneRef) sceneRef.current = scene;
|
|
13088
|
-
const byKey = (0,
|
|
13089
|
-
(0,
|
|
13130
|
+
const byKey = (0, import_react92.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
|
|
13131
|
+
(0, import_react92.useEffect)(() => () => drag.current?.end(), []);
|
|
13090
13132
|
const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
|
|
13091
13133
|
const onPointerDown = (e) => {
|
|
13092
13134
|
if (!editable || e.button !== 0) return;
|
|
@@ -13133,8 +13175,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
13133
13175
|
if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
|
|
13134
13176
|
};
|
|
13135
13177
|
const label = state.spec.title || "Chart";
|
|
13136
|
-
return /* @__PURE__ */ (0,
|
|
13137
|
-
/* @__PURE__ */ (0,
|
|
13178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
|
|
13179
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
|
|
13138
13180
|
"svg",
|
|
13139
13181
|
{
|
|
13140
13182
|
ref: svg,
|
|
@@ -13153,11 +13195,11 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
13153
13195
|
onKeyDown,
|
|
13154
13196
|
children: [
|
|
13155
13197
|
scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
|
|
13156
|
-
presence && /* @__PURE__ */ (0,
|
|
13198
|
+
presence && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChartPresenceLayer, { presence })
|
|
13157
13199
|
]
|
|
13158
13200
|
}
|
|
13159
13201
|
),
|
|
13160
|
-
tip && /* @__PURE__ */ (0,
|
|
13202
|
+
tip && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
13161
13203
|
"div",
|
|
13162
13204
|
{
|
|
13163
13205
|
role: "tooltip",
|
|
@@ -13172,14 +13214,14 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
13172
13214
|
borderColor: "var(--border, #e2e8f0)",
|
|
13173
13215
|
fontFamily: scene.theme.fontFamily
|
|
13174
13216
|
},
|
|
13175
|
-
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0,
|
|
13217
|
+
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChartTooltipContent, { tooltip: tip })
|
|
13176
13218
|
}
|
|
13177
13219
|
)
|
|
13178
13220
|
] });
|
|
13179
13221
|
}
|
|
13180
13222
|
|
|
13181
13223
|
// src/chart/ChartDataGrid.tsx
|
|
13182
|
-
var
|
|
13224
|
+
var import_react93 = require("react");
|
|
13183
13225
|
var import_chart3 = require("@pixerate/editor/chart");
|
|
13184
13226
|
|
|
13185
13227
|
// src/chart/styles.ts
|
|
@@ -13192,11 +13234,11 @@ var chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
|
|
|
13192
13234
|
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";
|
|
13193
13235
|
|
|
13194
13236
|
// src/chart/ChartDataGrid.tsx
|
|
13195
|
-
var
|
|
13237
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
13196
13238
|
function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
13197
|
-
const [draft, setDraft] = (0,
|
|
13198
|
-
const typing = (0,
|
|
13199
|
-
(0,
|
|
13239
|
+
const [draft, setDraft] = (0, import_react93.useState)(value);
|
|
13240
|
+
const typing = (0, import_react93.useRef)(false);
|
|
13241
|
+
(0, import_react93.useEffect)(() => {
|
|
13200
13242
|
if (!typing.current) setDraft(value);
|
|
13201
13243
|
}, [value]);
|
|
13202
13244
|
const commit = () => {
|
|
@@ -13205,7 +13247,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
13205
13247
|
if (draft === value) return;
|
|
13206
13248
|
if (onCommit(draft) === false) setDraft(value);
|
|
13207
13249
|
};
|
|
13208
|
-
return /* @__PURE__ */ (0,
|
|
13250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13209
13251
|
"input",
|
|
13210
13252
|
{
|
|
13211
13253
|
...rest,
|
|
@@ -13234,20 +13276,20 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
13234
13276
|
}
|
|
13235
13277
|
function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
13236
13278
|
const { spec } = useChartState(controller);
|
|
13237
|
-
const [columns, setColumns] = (0,
|
|
13279
|
+
const [columns, setColumns] = (0, import_react93.useState)(1);
|
|
13238
13280
|
const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
|
|
13239
13281
|
const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
|
|
13240
13282
|
const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
|
|
13241
13283
|
const commit = (next) => controller.setTreeRows(next).ok;
|
|
13242
|
-
return /* @__PURE__ */ (0,
|
|
13243
|
-
/* @__PURE__ */ (0,
|
|
13244
|
-
/* @__PURE__ */ (0,
|
|
13245
|
-
labels.map((label) => /* @__PURE__ */ (0,
|
|
13246
|
-
/* @__PURE__ */ (0,
|
|
13247
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
|
|
13285
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13286
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { children: [
|
|
13287
|
+
labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
13288
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
13289
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "w-8 border-b border-border" })
|
|
13248
13290
|
] }) }),
|
|
13249
|
-
/* @__PURE__ */ (0,
|
|
13250
|
-
labels.map((_, k) => /* @__PURE__ */ (0,
|
|
13291
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { "data-tree-row": r, children: [
|
|
13292
|
+
labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13251
13293
|
ChartCommitInput,
|
|
13252
13294
|
{
|
|
13253
13295
|
value: row.path[k] ?? "",
|
|
@@ -13258,7 +13300,7 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
13258
13300
|
className: `${chartCellClass} text-left`
|
|
13259
13301
|
}
|
|
13260
13302
|
) }, k)),
|
|
13261
|
-
/* @__PURE__ */ (0,
|
|
13303
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13262
13304
|
ChartCommitInput,
|
|
13263
13305
|
{
|
|
13264
13306
|
value: String(row.value),
|
|
@@ -13271,14 +13313,14 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
13271
13313
|
className: chartCellClass
|
|
13272
13314
|
}
|
|
13273
13315
|
) }),
|
|
13274
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13316
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime69.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" }) })
|
|
13275
13317
|
] }, r)) })
|
|
13276
13318
|
] }),
|
|
13277
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13278
|
-
/* @__PURE__ */ (0,
|
|
13279
|
-
/* @__PURE__ */ (0,
|
|
13280
|
-
/* @__PURE__ */ (0,
|
|
13281
|
-
/* @__PURE__ */ (0,
|
|
13319
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
13320
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.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" }),
|
|
13321
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
|
|
13322
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "flex-1" }),
|
|
13323
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.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" })
|
|
13282
13324
|
] })
|
|
13283
13325
|
] });
|
|
13284
13326
|
}
|
|
@@ -13286,30 +13328,30 @@ function ChartLinksGrid({ controller, readOnly = false, className }) {
|
|
|
13286
13328
|
const { spec } = useChartState(controller);
|
|
13287
13329
|
const links = spec.links;
|
|
13288
13330
|
const commit = (next) => controller.setLinks(next).ok;
|
|
13289
|
-
return /* @__PURE__ */ (0,
|
|
13290
|
-
/* @__PURE__ */ (0,
|
|
13291
|
-
/* @__PURE__ */ (0,
|
|
13292
|
-
["Source", "Target"].map((label) => /* @__PURE__ */ (0,
|
|
13293
|
-
/* @__PURE__ */ (0,
|
|
13294
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-links-grid": "", children: [
|
|
13332
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13333
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { children: [
|
|
13334
|
+
["Source", "Target"].map((label) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
13335
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
13336
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "w-8 border-b border-border" })
|
|
13295
13337
|
] }) }),
|
|
13296
|
-
/* @__PURE__ */ (0,
|
|
13297
|
-
["source", "target"].map((field) => /* @__PURE__ */ (0,
|
|
13298
|
-
/* @__PURE__ */ (0,
|
|
13299
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13338
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("tbody", { children: links.map((link, i) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { "data-link-row": i, children: [
|
|
13339
|
+
["source", "target"].map((field) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime69.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)),
|
|
13340
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime69.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 }) }),
|
|
13341
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime69.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" }) })
|
|
13300
13342
|
] }, i)) })
|
|
13301
13343
|
] }),
|
|
13302
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13303
|
-
/* @__PURE__ */ (0,
|
|
13304
|
-
/* @__PURE__ */ (0,
|
|
13305
|
-
links.length > 0 && /* @__PURE__ */ (0,
|
|
13344
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
13345
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "link-add", onClick: () => commit((0, import_chart3.addChartLink)(links)), children: "+ Add flow" }),
|
|
13346
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "flex-1" }),
|
|
13347
|
+
links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.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" })
|
|
13306
13348
|
] })
|
|
13307
13349
|
] });
|
|
13308
13350
|
}
|
|
13309
13351
|
function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
|
|
13310
13352
|
const { spec, selection } = useChartState(controller);
|
|
13311
|
-
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0,
|
|
13312
|
-
if (spec.tree.length) return /* @__PURE__ */ (0,
|
|
13353
|
+
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ChartLinksGrid, { controller, readOnly, className });
|
|
13354
|
+
if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ChartTreeGrid, { controller, readOnly, className });
|
|
13313
13355
|
const canGroup = spec.type === "treemap" || spec.type === "sunburst";
|
|
13314
13356
|
const paste = (row, column) => (e) => {
|
|
13315
13357
|
const text = e.clipboardData?.getData("text/plain") ?? "";
|
|
@@ -13317,15 +13359,15 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13317
13359
|
e.preventDefault();
|
|
13318
13360
|
controller.pasteCells(row, column, text);
|
|
13319
13361
|
};
|
|
13320
|
-
return /* @__PURE__ */ (0,
|
|
13321
|
-
/* @__PURE__ */ (0,
|
|
13322
|
-
/* @__PURE__ */ (0,
|
|
13323
|
-
/* @__PURE__ */ (0,
|
|
13362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", children: [
|
|
13363
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
13364
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { children: [
|
|
13365
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: categoryHeader }),
|
|
13324
13366
|
spec.series.map((s, si) => {
|
|
13325
13367
|
const color = (0, import_chart3.chartSeriesColor)(spec, si);
|
|
13326
13368
|
const selected = selection?.kind === "series" && selection.seriesId === s.id;
|
|
13327
|
-
return /* @__PURE__ */ (0,
|
|
13328
|
-
/* @__PURE__ */ (0,
|
|
13369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.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_runtime69.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13370
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13329
13371
|
"input",
|
|
13330
13372
|
{
|
|
13331
13373
|
type: "color",
|
|
@@ -13338,7 +13380,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13338
13380
|
className: "h-5 w-5 shrink-0 cursor-pointer rounded border-0 bg-transparent p-0"
|
|
13339
13381
|
}
|
|
13340
13382
|
),
|
|
13341
|
-
/* @__PURE__ */ (0,
|
|
13383
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13342
13384
|
ChartCommitInput,
|
|
13343
13385
|
{
|
|
13344
13386
|
value: s.name,
|
|
@@ -13348,8 +13390,8 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13348
13390
|
className: `${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? "text-muted-foreground line-through" : ""}`
|
|
13349
13391
|
}
|
|
13350
13392
|
),
|
|
13351
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13352
|
-
/* @__PURE__ */ (0,
|
|
13393
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
13394
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13353
13395
|
"button",
|
|
13354
13396
|
{
|
|
13355
13397
|
type: "button",
|
|
@@ -13362,16 +13404,16 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13362
13404
|
children: s.hidden ? "\u25CB" : "\u25CF"
|
|
13363
13405
|
}
|
|
13364
13406
|
),
|
|
13365
|
-
/* @__PURE__ */ (0,
|
|
13407
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.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" })
|
|
13366
13408
|
] })
|
|
13367
13409
|
] }) }, s.id);
|
|
13368
13410
|
}),
|
|
13369
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13411
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "w-8 border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Add series", "aria-label": "Add series", "data-action": "add-series", onClick: () => controller.addSeries(), children: "+" }) })
|
|
13370
13412
|
] }) }),
|
|
13371
|
-
/* @__PURE__ */ (0,
|
|
13413
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("tbody", { children: spec.categories.map((category, i) => {
|
|
13372
13414
|
const rowSelected = selection?.kind === "category" && selection.index === i;
|
|
13373
|
-
return /* @__PURE__ */ (0,
|
|
13374
|
-
/* @__PURE__ */ (0,
|
|
13415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("tr", { "data-category-index": i, className: rowSelected ? "bg-primary/10" : void 0, children: [
|
|
13416
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("th", { className: "border-b border-r border-border p-0 text-left font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13375
13417
|
ChartCommitInput,
|
|
13376
13418
|
{
|
|
13377
13419
|
value: category,
|
|
@@ -13385,7 +13427,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13385
13427
|
spec.series.map((s) => {
|
|
13386
13428
|
const value = s.values[i];
|
|
13387
13429
|
const selected = selection?.kind === "point" && selection.seriesId === s.id && selection.index === i;
|
|
13388
|
-
return /* @__PURE__ */ (0,
|
|
13430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: `border-b border-r border-border p-0 ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13389
13431
|
ChartCommitInput,
|
|
13390
13432
|
{
|
|
13391
13433
|
value: value === null || value === void 0 ? "" : String(value),
|
|
@@ -13400,13 +13442,13 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13400
13442
|
}
|
|
13401
13443
|
) }, s.id);
|
|
13402
13444
|
}),
|
|
13403
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13445
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete category", "aria-label": `Delete ${category}`, "data-action": "remove-category", onClick: () => controller.removeCategory(i), children: "\xD7" }) })
|
|
13404
13446
|
] }, i);
|
|
13405
13447
|
}) })
|
|
13406
13448
|
] }),
|
|
13407
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
13408
|
-
/* @__PURE__ */ (0,
|
|
13409
|
-
canGroup && /* @__PURE__ */ (0,
|
|
13449
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "p-1", children: [
|
|
13450
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
|
|
13451
|
+
canGroup && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
13410
13452
|
"button",
|
|
13411
13453
|
{
|
|
13412
13454
|
type: "button",
|
|
@@ -13422,29 +13464,29 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
13422
13464
|
}
|
|
13423
13465
|
|
|
13424
13466
|
// src/chart/ChartInspector.tsx
|
|
13425
|
-
var
|
|
13467
|
+
var import_react94 = require("react");
|
|
13426
13468
|
var import_chart4 = require("@pixerate/editor/chart");
|
|
13427
|
-
var
|
|
13469
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
13428
13470
|
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
13429
13471
|
function Field({ label, htmlFor, children }) {
|
|
13430
|
-
return /* @__PURE__ */ (0,
|
|
13431
|
-
/* @__PURE__ */ (0,
|
|
13432
|
-
/* @__PURE__ */ (0,
|
|
13472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
13473
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("label", { htmlFor, className: `${chartLabelClass} w-20 shrink-0`, children: label }),
|
|
13474
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "min-w-0 flex-1", children })
|
|
13433
13475
|
] });
|
|
13434
13476
|
}
|
|
13435
13477
|
function Toggle({ label, checked, onChange, name }) {
|
|
13436
|
-
return /* @__PURE__ */ (0,
|
|
13437
|
-
/* @__PURE__ */ (0,
|
|
13478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("label", { className: "flex cursor-pointer items-center gap-2 text-xs text-foreground", children: [
|
|
13479
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("input", { type: "checkbox", className: "h-3.5 w-3.5 accent-primary", checked, "data-option": name, onChange: (e) => onChange(e.currentTarget.checked) }),
|
|
13438
13480
|
label
|
|
13439
13481
|
] });
|
|
13440
13482
|
}
|
|
13441
13483
|
function Select({ id, value, options, onChange, name, labels }) {
|
|
13442
|
-
return /* @__PURE__ */ (0,
|
|
13484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("select", { id, className: chartInputClass, value, "data-option": name, onChange: (e) => onChange(e.currentTarget.value), children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: o, children: labels?.[o] ?? cap(o) }, o)) });
|
|
13443
13485
|
}
|
|
13444
13486
|
function AxisSection({ controller, axis, value, idBase, horizontal, numeric = false, scales = false }) {
|
|
13445
13487
|
const set = (patch) => controller.setAxis(axis, patch);
|
|
13446
13488
|
const setFormat = (patch) => set({ format: { ...value.format, ...patch } });
|
|
13447
|
-
const bound = (key2) => /* @__PURE__ */ (0,
|
|
13489
|
+
const bound = (key2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13448
13490
|
ChartCommitInput,
|
|
13449
13491
|
{
|
|
13450
13492
|
id: `${idBase}-${axis}-${key2}`,
|
|
@@ -13459,26 +13501,26 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13459
13501
|
const name = axis === "x" ? numeric ? "X axis" : "Category axis" : axis === "y" ? "Value axis" : "Secondary axis";
|
|
13460
13502
|
const valueAxis = axis !== "x" || numeric;
|
|
13461
13503
|
const key = axis === "y2" ? "yAxis2" : `${axis}Axis`;
|
|
13462
|
-
return /* @__PURE__ */ (0,
|
|
13463
|
-
/* @__PURE__ */ (0,
|
|
13464
|
-
/* @__PURE__ */ (0,
|
|
13504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": `axis-${axis}`, children: [
|
|
13505
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
13506
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("h4", { className: "text-xs font-semibold text-foreground", children: [
|
|
13465
13507
|
name,
|
|
13466
|
-
/* @__PURE__ */ (0,
|
|
13508
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
13467
13509
|
"(",
|
|
13468
13510
|
axis === "x" ? horizontal ? "left" : "bottom" : axis === "y2" ? horizontal ? "top" : "right" : horizontal ? "bottom" : "left",
|
|
13469
13511
|
")"
|
|
13470
13512
|
] })
|
|
13471
13513
|
] }),
|
|
13472
|
-
/* @__PURE__ */ (0,
|
|
13514
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Show", name: `${axis}Axis.show`, checked: value.show, onChange: (show) => set({ show }) })
|
|
13473
13515
|
] }),
|
|
13474
|
-
/* @__PURE__ */ (0,
|
|
13475
|
-
/* @__PURE__ */ (0,
|
|
13476
|
-
/* @__PURE__ */ (0,
|
|
13477
|
-
axis === "x" && !numeric && /* @__PURE__ */ (0,
|
|
13478
|
-
scales && /* @__PURE__ */ (0,
|
|
13479
|
-
scales && valueAxis && /* @__PURE__ */ (0,
|
|
13516
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Title", htmlFor: `${idBase}-${axis}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-title`, value: value.title, "data-option": `${axis}Axis.title`, className: chartInputClass, onCommit: (title) => void set({ title }) }) }),
|
|
13517
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
13518
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Grid lines", name: `${key}.gridlines`, checked: value.gridlines, onChange: (gridlines) => set({ gridlines }) }),
|
|
13519
|
+
axis === "x" && !numeric && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Dates", name: "xAxis.kind", checked: value.kind === "date", onChange: (dates) => set({ kind: dates ? "date" : void 0 }) }),
|
|
13520
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Reverse", name: `${key}.reverse`, checked: !!value.reverse, onChange: (reverse) => set({ reverse }) }),
|
|
13521
|
+
scales && valueAxis && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Log scale", name: `${key}.scale`, checked: value.scale === "log", onChange: (log) => set({ scale: log ? "log" : "linear" }) })
|
|
13480
13522
|
] }),
|
|
13481
|
-
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0,
|
|
13523
|
+
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Log base", htmlFor: `${idBase}-${axis}-log-base`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13482
13524
|
ChartCommitInput,
|
|
13483
13525
|
{
|
|
13484
13526
|
id: `${idBase}-${axis}-log-base`,
|
|
@@ -13489,7 +13531,7 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13489
13531
|
onCommit: (text) => set({ logBase: text.trim() === "" ? void 0 : Number(text) }).ok
|
|
13490
13532
|
}
|
|
13491
13533
|
) }),
|
|
13492
|
-
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0,
|
|
13534
|
+
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Step", htmlFor: `${idBase}-${axis}-step`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13493
13535
|
ChartCommitInput,
|
|
13494
13536
|
{
|
|
13495
13537
|
id: `${idBase}-${axis}-step`,
|
|
@@ -13501,14 +13543,14 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13501
13543
|
onCommit: (text) => set({ step: text.trim() === "" ? null : Number(text) }).ok
|
|
13502
13544
|
}
|
|
13503
13545
|
) }),
|
|
13504
|
-
valueAxis && /* @__PURE__ */ (0,
|
|
13505
|
-
/* @__PURE__ */ (0,
|
|
13546
|
+
valueAxis && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
13547
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Min / max", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex gap-1", children: [
|
|
13506
13548
|
bound("min"),
|
|
13507
13549
|
bound("max")
|
|
13508
13550
|
] }) }),
|
|
13509
|
-
/* @__PURE__ */ (0,
|
|
13510
|
-
/* @__PURE__ */ (0,
|
|
13511
|
-
/* @__PURE__ */ (0,
|
|
13551
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Format", htmlFor: `${idBase}-${axis}-format`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex gap-1", children: [
|
|
13552
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13553
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13512
13554
|
ChartCommitInput,
|
|
13513
13555
|
{
|
|
13514
13556
|
value: value.format.decimals === void 0 ? "" : String(value.format.decimals),
|
|
@@ -13527,8 +13569,8 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
13527
13569
|
}
|
|
13528
13570
|
)
|
|
13529
13571
|
] }) }),
|
|
13530
|
-
value.format.style === "currency" && /* @__PURE__ */ (0,
|
|
13531
|
-
/* @__PURE__ */ (0,
|
|
13572
|
+
value.format.style === "currency" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Currency", htmlFor: `${idBase}-${axis}-currency`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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() }) }) }),
|
|
13573
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Code", htmlFor: `${idBase}-${axis}-code`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13532
13574
|
ChartCommitInput,
|
|
13533
13575
|
{
|
|
13534
13576
|
id: `${idBase}-${axis}-code`,
|
|
@@ -13554,15 +13596,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
13554
13596
|
const values = which === "xErrorBars" ? series.x ?? [] : series.values;
|
|
13555
13597
|
const set = (next) => controller.updateSeries(series.id, { [which]: next });
|
|
13556
13598
|
const patch = (p) => bars && set({ ...bars, ...p });
|
|
13557
|
-
return /* @__PURE__ */ (0,
|
|
13558
|
-
/* @__PURE__ */ (0,
|
|
13559
|
-
/* @__PURE__ */ (0,
|
|
13560
|
-
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "space-y-1.5", "data-section": which === "errorBars" ? "error-bars" : "x-error-bars", children: [
|
|
13600
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: which === "errorBars" ? "Error bars" : "X error bars", htmlFor: `${id}-type`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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: [
|
|
13601
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "None" }),
|
|
13602
|
+
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: t, children: import_chart4.CHART_ERROR_BAR_LABELS[t] }, t))
|
|
13561
13603
|
] }) }),
|
|
13562
|
-
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0,
|
|
13563
|
-
bars?.type === "custom" && /* @__PURE__ */ (0,
|
|
13564
|
-
/* @__PURE__ */ (0,
|
|
13565
|
-
/* @__PURE__ */ (0,
|
|
13604
|
+
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: bars.type === "percent" ? "Percent" : bars.type === "stddev" ? "Deviations" : "Amount", htmlFor: `${id}-value`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13605
|
+
bars?.type === "custom" && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
13606
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Plus", htmlFor: `${id}-plus`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13607
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Minus", htmlFor: `${id}-minus`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13566
13608
|
ChartCommitInput,
|
|
13567
13609
|
{
|
|
13568
13610
|
id: `${id}-minus`,
|
|
@@ -13579,15 +13621,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
13579
13621
|
}
|
|
13580
13622
|
) })
|
|
13581
13623
|
] }),
|
|
13582
|
-
bars && /* @__PURE__ */ (0,
|
|
13583
|
-
/* @__PURE__ */ (0,
|
|
13584
|
-
/* @__PURE__ */ (0,
|
|
13624
|
+
bars && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
13625
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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_runtime70.jsx)("option", { value: d, children: d === "both" ? "Both ways" : d === "plus" ? "Plus only" : "Minus only" }, d)) }),
|
|
13626
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Caps", name: `${key}.cap`, checked: bars.cap !== false, onChange: (cap2) => patch({ cap: cap2 }) })
|
|
13585
13627
|
] })
|
|
13586
13628
|
] });
|
|
13587
13629
|
}
|
|
13588
13630
|
function ChartInspector({ controller, sections, className }) {
|
|
13589
13631
|
const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
|
|
13590
|
-
const idBase = (0,
|
|
13632
|
+
const idBase = (0, import_react94.useId)();
|
|
13591
13633
|
const show = (section) => !sections || sections.includes(section);
|
|
13592
13634
|
const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
|
|
13593
13635
|
const family = (0, import_chart4.chartFamily)(spec);
|
|
@@ -13602,30 +13644,30 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13602
13644
|
const annotated = scales;
|
|
13603
13645
|
const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
|
|
13604
13646
|
const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
|
|
13605
|
-
return /* @__PURE__ */ (0,
|
|
13606
|
-
show("type") && /* @__PURE__ */ (0,
|
|
13607
|
-
show("style") && /* @__PURE__ */ (0,
|
|
13608
|
-
/* @__PURE__ */ (0,
|
|
13609
|
-
/* @__PURE__ */ (0,
|
|
13610
|
-
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0,
|
|
13647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
|
|
13648
|
+
show("type") && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime70.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_runtime70.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)) }) }),
|
|
13649
|
+
show("style") && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
|
|
13650
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Layout", htmlFor: `${idBase}-layout`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("select", { id: `${idBase}-layout`, className: chartInputClass, value: "", "data-option": "preset.layout", onChange: (e) => e.currentTarget.value && controller.applyPreset({ layout: e.currentTarget.value }), children: [
|
|
13651
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "Quick layout\u2026" }),
|
|
13652
|
+
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: p.id, title: p.description, children: p.label }, p.id))
|
|
13611
13653
|
] }) }),
|
|
13612
|
-
/* @__PURE__ */ (0,
|
|
13613
|
-
/* @__PURE__ */ (0,
|
|
13614
|
-
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0,
|
|
13654
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Colours", htmlFor: `${idBase}-colors`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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: [
|
|
13655
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "Custom" }),
|
|
13656
|
+
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: c.id, title: c.description, children: c.label }, c.id))
|
|
13615
13657
|
] }) }),
|
|
13616
|
-
!colorCheck.ok && /* @__PURE__ */ (0,
|
|
13617
|
-
/* @__PURE__ */ (0,
|
|
13658
|
+
!colorCheck.ok && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("p", { className: "text-[11px] leading-snug text-amber-600 dark:text-amber-400", "data-chart-color-warning": "", children: colorCheck.issues[0] }),
|
|
13659
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "transpose", onClick: () => controller.transpose(), children: "Switch rows and columns" })
|
|
13618
13660
|
] }),
|
|
13619
|
-
show("titles") && /* @__PURE__ */ (0,
|
|
13620
|
-
/* @__PURE__ */ (0,
|
|
13621
|
-
/* @__PURE__ */ (0,
|
|
13622
|
-
/* @__PURE__ */ (0,
|
|
13661
|
+
show("titles") && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
|
|
13662
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
|
|
13663
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
|
|
13664
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
|
|
13623
13665
|
] }),
|
|
13624
|
-
show("options") && /* @__PURE__ */ (0,
|
|
13625
|
-
cartesian && /* @__PURE__ */ (0,
|
|
13626
|
-
hasBars && /* @__PURE__ */ (0,
|
|
13627
|
-
hasLines && /* @__PURE__ */ (0,
|
|
13628
|
-
spec.type === "donut" && /* @__PURE__ */ (0,
|
|
13666
|
+
show("options") && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
|
|
13667
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }) }),
|
|
13668
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Bars", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: ["vertical", "horizontal"].map((o) => /* @__PURE__ */ (0, import_jsx_runtime70.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)) }) }),
|
|
13669
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Lines", htmlFor: `${idBase}-curve`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Select, { id: `${idBase}-curve`, name: "curve", value: spec.curve, options: import_chart4.CHART_CURVES, onChange: (curve) => controller.update({ curve }) }) }),
|
|
13670
|
+
spec.type === "donut" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Hole", htmlFor: `${idBase}-hole`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13629
13671
|
"input",
|
|
13630
13672
|
{
|
|
13631
13673
|
id: `${idBase}-hole`,
|
|
@@ -13641,7 +13683,7 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13641
13683
|
onChange: (e) => controller.update({ innerRadius: Number(e.currentTarget.value) })
|
|
13642
13684
|
}
|
|
13643
13685
|
) }),
|
|
13644
|
-
hasBars && /* @__PURE__ */ (0,
|
|
13686
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Spacing", htmlFor: `${idBase}-gap`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13645
13687
|
"input",
|
|
13646
13688
|
{
|
|
13647
13689
|
id: `${idBase}-gap`,
|
|
@@ -13657,9 +13699,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13657
13699
|
onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
|
|
13658
13700
|
}
|
|
13659
13701
|
) }),
|
|
13660
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13661
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13662
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
13702
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Map", htmlFor: `${idBase}-map`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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_runtime70.jsx)("option", { value: id, children: (0, import_chart4.listChartMaps)().find((m) => m.id === id)?.name ?? `${id} (not loaded)` }, id)) }) }),
|
|
13703
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Classes", htmlFor: `${idBase}-map-steps`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13704
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Breaks", htmlFor: `${idBase}-map-breaks`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13663
13705
|
ChartCommitInput,
|
|
13664
13706
|
{
|
|
13665
13707
|
id: `${idBase}-map-breaks`,
|
|
@@ -13670,10 +13712,10 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13670
13712
|
onCommit: (text) => controller.update({ mapThresholds: text.trim() ? text.split(",").map((t) => Number(t.trim())) : [] }).ok
|
|
13671
13713
|
}
|
|
13672
13714
|
) }),
|
|
13673
|
-
spec.type === "barrace" && /* @__PURE__ */ (0,
|
|
13674
|
-
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0,
|
|
13675
|
-
/* @__PURE__ */ (0,
|
|
13676
|
-
/* @__PURE__ */ (0,
|
|
13715
|
+
spec.type === "barrace" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Bars", htmlFor: `${idBase}-race-top`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13716
|
+
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Time", htmlFor: `${idBase}-race-frame`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13717
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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" }),
|
|
13718
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13677
13719
|
"input",
|
|
13678
13720
|
{
|
|
13679
13721
|
id: `${idBase}-race-frame`,
|
|
@@ -13688,13 +13730,13 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13688
13730
|
onChange: (e) => controller.setRaceFrame(Number(e.currentTarget.value))
|
|
13689
13731
|
}
|
|
13690
13732
|
),
|
|
13691
|
-
/* @__PURE__ */ (0,
|
|
13733
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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)] })
|
|
13692
13734
|
] }) }),
|
|
13693
|
-
spec.type === "sankey" && /* @__PURE__ */ (0,
|
|
13694
|
-
spec.type === "sunburst" && /* @__PURE__ */ (0,
|
|
13695
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
13696
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
13697
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13735
|
+
spec.type === "sankey" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Flows", htmlFor: `${idBase}-sankey-color`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }) }),
|
|
13736
|
+
spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
|
|
13737
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }) }),
|
|
13738
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }) }),
|
|
13739
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13698
13740
|
"input",
|
|
13699
13741
|
{
|
|
13700
13742
|
id: `${idBase}-parliament-arc`,
|
|
@@ -13710,34 +13752,34 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13710
13752
|
onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
|
|
13711
13753
|
}
|
|
13712
13754
|
) }),
|
|
13713
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13714
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
13715
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
13716
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
13717
|
-
spec.dataLabels && hasBars && /* @__PURE__ */ (0,
|
|
13718
|
-
spec.type === "histogram" && /* @__PURE__ */ (0,
|
|
13719
|
-
/* @__PURE__ */ (0,
|
|
13720
|
-
spec.type === "waterfall" && /* @__PURE__ */ (0,
|
|
13721
|
-
hasLines && /* @__PURE__ */ (0,
|
|
13722
|
-
oneSeries && /* @__PURE__ */ (0,
|
|
13723
|
-
/* @__PURE__ */ (0,
|
|
13755
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13756
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
|
|
13757
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13758
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }) }),
|
|
13759
|
+
spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
|
|
13760
|
+
spec.type === "histogram" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Bins", htmlFor: `${idBase}-bins`, children: /* @__PURE__ */ (0, import_jsx_runtime70.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 }) }),
|
|
13761
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
13762
|
+
spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
|
|
13763
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
|
|
13764
|
+
oneSeries && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
|
|
13765
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
|
|
13724
13766
|
] })
|
|
13725
13767
|
] }),
|
|
13726
|
-
show("legend") && /* @__PURE__ */ (0,
|
|
13727
|
-
/* @__PURE__ */ (0,
|
|
13728
|
-
/* @__PURE__ */ (0,
|
|
13729
|
-
/* @__PURE__ */ (0,
|
|
13768
|
+
show("legend") && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "legend", children: [
|
|
13769
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
13770
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Legend" }),
|
|
13771
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Show", name: "legend.show", checked: spec.legend.show, onChange: (v) => controller.setLegend({ show: v }) })
|
|
13730
13772
|
] }),
|
|
13731
|
-
spec.legend.show && /* @__PURE__ */ (0,
|
|
13773
|
+
spec.legend.show && /* @__PURE__ */ (0, import_jsx_runtime70.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_runtime70.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)) })
|
|
13732
13774
|
] }),
|
|
13733
|
-
show("axes") && hasAxes && /* @__PURE__ */ (0,
|
|
13734
|
-
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0,
|
|
13735
|
-
/* @__PURE__ */ (0,
|
|
13736
|
-
usesSecondary && /* @__PURE__ */ (0,
|
|
13775
|
+
show("axes") && hasAxes && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
13776
|
+
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(AxisSection, { controller, axis: "x", value: spec.xAxis, idBase, horizontal: spec.orientation === "horizontal", numeric: family === "xy", scales }),
|
|
13777
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
|
|
13778
|
+
usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
|
|
13737
13779
|
] }),
|
|
13738
|
-
show("annotations") && annotated && /* @__PURE__ */ (0,
|
|
13739
|
-
/* @__PURE__ */ (0,
|
|
13740
|
-
/* @__PURE__ */ (0,
|
|
13780
|
+
show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
|
|
13781
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
|
|
13782
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13741
13783
|
ChartCommitInput,
|
|
13742
13784
|
{
|
|
13743
13785
|
id: `${idBase}-highlight`,
|
|
@@ -13748,27 +13790,27 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13748
13790
|
onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
|
|
13749
13791
|
}
|
|
13750
13792
|
) }),
|
|
13751
|
-
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0,
|
|
13752
|
-
/* @__PURE__ */ (0,
|
|
13753
|
-
/* @__PURE__ */ (0,
|
|
13754
|
-
/* @__PURE__ */ (0,
|
|
13793
|
+
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
|
|
13794
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }),
|
|
13795
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }),
|
|
13796
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
|
|
13755
13797
|
] }, `line-${i}`)),
|
|
13756
|
-
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0,
|
|
13757
|
-
/* @__PURE__ */ (0,
|
|
13758
|
-
/* @__PURE__ */ (0,
|
|
13759
|
-
/* @__PURE__ */ (0,
|
|
13760
|
-
/* @__PURE__ */ (0,
|
|
13798
|
+
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
|
|
13799
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }),
|
|
13800
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }),
|
|
13801
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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 }),
|
|
13802
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
|
|
13761
13803
|
] }, `band-${i}`)),
|
|
13762
|
-
/* @__PURE__ */ (0,
|
|
13763
|
-
/* @__PURE__ */ (0,
|
|
13764
|
-
/* @__PURE__ */ (0,
|
|
13804
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex gap-1", children: [
|
|
13805
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
|
|
13806
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
|
|
13765
13807
|
] })
|
|
13766
13808
|
] }),
|
|
13767
|
-
show("series") && selectedSeries && /* @__PURE__ */ (0,
|
|
13768
|
-
/* @__PURE__ */ (0,
|
|
13769
|
-
/* @__PURE__ */ (0,
|
|
13770
|
-
/* @__PURE__ */ (0,
|
|
13771
|
-
/* @__PURE__ */ (0,
|
|
13809
|
+
show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
|
|
13810
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
|
|
13811
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
|
|
13812
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
13813
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13772
13814
|
"input",
|
|
13773
13815
|
{
|
|
13774
13816
|
id: `${idBase}-series-color`,
|
|
@@ -13781,9 +13823,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13781
13823
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
|
|
13782
13824
|
}
|
|
13783
13825
|
),
|
|
13784
|
-
selectedSeries.color && /* @__PURE__ */ (0,
|
|
13826
|
+
selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
|
|
13785
13827
|
] }) }),
|
|
13786
|
-
cartesian && /* @__PURE__ */ (0,
|
|
13828
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
13787
13829
|
"select",
|
|
13788
13830
|
{
|
|
13789
13831
|
id: `${idBase}-series-type`,
|
|
@@ -13792,12 +13834,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13792
13834
|
"data-option": "series.type",
|
|
13793
13835
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { type: e.currentTarget.value || null }),
|
|
13794
13836
|
children: [
|
|
13795
|
-
/* @__PURE__ */ (0,
|
|
13796
|
-
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13837
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "Chart type" }),
|
|
13838
|
+
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: t, children: import_chart4.CHART_TYPE_LABELS[t] }, t))
|
|
13797
13839
|
]
|
|
13798
13840
|
}
|
|
13799
13841
|
) }),
|
|
13800
|
-
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0,
|
|
13842
|
+
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Marker", htmlFor: `${idBase}-series-marker`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
13801
13843
|
"select",
|
|
13802
13844
|
{
|
|
13803
13845
|
id: `${idBase}-series-marker`,
|
|
@@ -13806,12 +13848,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13806
13848
|
"data-option": "series.marker",
|
|
13807
13849
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { marker: e.currentTarget.value || null }),
|
|
13808
13850
|
children: [
|
|
13809
|
-
/* @__PURE__ */ (0,
|
|
13810
|
-
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0,
|
|
13851
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "Default" }),
|
|
13852
|
+
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: m, children: cap(m) }, m))
|
|
13811
13853
|
]
|
|
13812
13854
|
}
|
|
13813
13855
|
) }),
|
|
13814
|
-
annotated && calloutIndex !== null && /* @__PURE__ */ (0,
|
|
13856
|
+
annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
13815
13857
|
ChartCommitInput,
|
|
13816
13858
|
{
|
|
13817
13859
|
id: `${idBase}-series-callout`,
|
|
@@ -13822,15 +13864,15 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13822
13864
|
onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
|
|
13823
13865
|
}
|
|
13824
13866
|
) }),
|
|
13825
|
-
scales && /* @__PURE__ */ (0,
|
|
13826
|
-
family === "xy" && /* @__PURE__ */ (0,
|
|
13827
|
-
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0,
|
|
13828
|
-
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0,
|
|
13829
|
-
/* @__PURE__ */ (0,
|
|
13830
|
-
/* @__PURE__ */ (0,
|
|
13831
|
-
/* @__PURE__ */ (0,
|
|
13867
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
|
|
13868
|
+
family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
|
|
13869
|
+
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
|
|
13870
|
+
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex items-center gap-1", "data-trendline": i, children: [
|
|
13871
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "flex-1 truncate text-muted-foreground", children: (0, import_chart4.chartTrendlineName)(t, selectedSeries.name) }),
|
|
13872
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "R\xB2", name: `trendline.${i}.showR2`, checked: !!t.showR2, onChange: (showR2) => controller.updateTrendline(selectedSeries.id, i, { showR2 }) }),
|
|
13873
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete trendline", "data-action": "trendline-delete", onClick: () => controller.removeTrendline(selectedSeries.id, i), children: "\xD7" })
|
|
13832
13874
|
] }, i)),
|
|
13833
|
-
/* @__PURE__ */ (0,
|
|
13875
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
13834
13876
|
"select",
|
|
13835
13877
|
{
|
|
13836
13878
|
className: chartInputClass,
|
|
@@ -13839,32 +13881,32 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
13839
13881
|
"data-option": "trendline.add",
|
|
13840
13882
|
onChange: (e) => e.currentTarget.value && controller.addTrendline(selectedSeries.id, { type: e.currentTarget.value }),
|
|
13841
13883
|
children: [
|
|
13842
|
-
/* @__PURE__ */ (0,
|
|
13843
|
-
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
13884
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: "", children: "Add trendline\u2026" }),
|
|
13885
|
+
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("option", { value: t, children: cap(t.replace("-", " ")) }, t))
|
|
13844
13886
|
]
|
|
13845
13887
|
}
|
|
13846
13888
|
)
|
|
13847
13889
|
] }),
|
|
13848
|
-
/* @__PURE__ */ (0,
|
|
13849
|
-
/* @__PURE__ */ (0,
|
|
13850
|
-
family === "cartesian" && /* @__PURE__ */ (0,
|
|
13851
|
-
/* @__PURE__ */ (0,
|
|
13852
|
-
/* @__PURE__ */ (0,
|
|
13853
|
-
/* @__PURE__ */ (0,
|
|
13854
|
-
/* @__PURE__ */ (0,
|
|
13890
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
13891
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Hidden", name: "series.hidden", checked: !!selectedSeries.hidden, onChange: (hidden) => controller.updateSeries(selectedSeries.id, { hidden }) }),
|
|
13892
|
+
family === "cartesian" && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Toggle, { label: "Secondary axis", name: "series.axis", checked: selectedSeries.axis === "secondary", onChange: (secondary) => controller.updateSeries(selectedSeries.id, { axis: secondary ? "secondary" : null }) }),
|
|
13893
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "flex-1" }),
|
|
13894
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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" }),
|
|
13895
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.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" }),
|
|
13896
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("button", { type: "button", className: `${chartButtonClass} text-destructive`, "data-action": "series-delete", onClick: () => controller.removeSeries(selectedSeries.id), children: "Delete" })
|
|
13855
13897
|
] })
|
|
13856
13898
|
] })
|
|
13857
13899
|
] });
|
|
13858
13900
|
}
|
|
13859
13901
|
|
|
13860
13902
|
// src/chart-node/ChartNodeView.tsx
|
|
13861
|
-
var
|
|
13903
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
13862
13904
|
function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
13863
13905
|
const { controller, editing, editable, selected, width, height, setEditing } = state;
|
|
13864
13906
|
const open = () => {
|
|
13865
13907
|
if (editable && !editing) setEditing(true);
|
|
13866
13908
|
};
|
|
13867
|
-
return /* @__PURE__ */ (0,
|
|
13909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
13868
13910
|
"div",
|
|
13869
13911
|
{
|
|
13870
13912
|
className: `not-prose my-2 rounded-md border bg-background p-1 ${selected ? "border-primary ring-1 ring-primary" : "border-border"}`,
|
|
@@ -13877,24 +13919,24 @@ function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
|
13877
13919
|
}
|
|
13878
13920
|
},
|
|
13879
13921
|
children: [
|
|
13880
|
-
editing && /* @__PURE__ */ (0,
|
|
13881
|
-
/* @__PURE__ */ (0,
|
|
13882
|
-
/* @__PURE__ */ (0,
|
|
13922
|
+
editing && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "mb-1 flex items-center justify-between gap-2 px-1", "data-chart-node-toolbar": "", children: [
|
|
13923
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "text-xs text-muted-foreground", children: "Editing chart" }),
|
|
13924
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "done", onClick: () => setEditing(false), children: "Done" })
|
|
13883
13925
|
] }),
|
|
13884
|
-
/* @__PURE__ */ (0,
|
|
13926
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
13885
13927
|
"div",
|
|
13886
13928
|
{
|
|
13887
13929
|
className: editable && !editing ? "cursor-pointer" : void 0,
|
|
13888
13930
|
onClick: open,
|
|
13889
13931
|
title: editable && !editing ? "Click to edit the chart" : void 0,
|
|
13890
13932
|
"data-chart-node-canvas": "",
|
|
13891
|
-
children: /* @__PURE__ */ (0,
|
|
13933
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChartCanvas, { controller, width: width ?? 640, height, responsive: width === null, editable: editing, theme })
|
|
13892
13934
|
}
|
|
13893
13935
|
),
|
|
13894
13936
|
editing && // Wraps by the document's width, not the viewport's: side by side when there is room.
|
|
13895
|
-
/* @__PURE__ */ (0,
|
|
13896
|
-
showDataGrid && /* @__PURE__ */ (0,
|
|
13897
|
-
/* @__PURE__ */ (0,
|
|
13937
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "mt-2 flex flex-wrap items-start gap-2", "data-chart-node-panel": "", children: [
|
|
13938
|
+
showDataGrid && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "min-w-0 flex-[1_1_20rem] overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChartDataGrid, { controller }) }),
|
|
13939
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChartInspector, { controller, className: "max-h-96 min-w-0 flex-[1_1_16rem] overflow-y-auto rounded-md border border-border p-3" })
|
|
13898
13940
|
] })
|
|
13899
13941
|
]
|
|
13900
13942
|
}
|
|
@@ -13912,7 +13954,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
13912
13954
|
scheduled = true;
|
|
13913
13955
|
queueMicrotask(() => {
|
|
13914
13956
|
scheduled = false;
|
|
13915
|
-
if (!destroyed) root.render(/* @__PURE__ */ (0,
|
|
13957
|
+
if (!destroyed) root.render(/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Component, { ...props, state: latest }));
|
|
13916
13958
|
});
|
|
13917
13959
|
};
|
|
13918
13960
|
schedule();
|
|
@@ -13930,10 +13972,10 @@ function createReactChartNodeView(options = {}) {
|
|
|
13930
13972
|
}
|
|
13931
13973
|
|
|
13932
13974
|
// src/style/useStyle.ts
|
|
13933
|
-
var
|
|
13975
|
+
var import_react95 = require("react");
|
|
13934
13976
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
13935
13977
|
function useResolverTask(styles, run, deliver, deps) {
|
|
13936
|
-
(0,
|
|
13978
|
+
(0, import_react95.useEffect)(() => {
|
|
13937
13979
|
if (!styles || !run) {
|
|
13938
13980
|
deliver({ value: null, error: null });
|
|
13939
13981
|
return;
|
|
@@ -13960,7 +14002,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
13960
14002
|
}, [styles, ...deps]);
|
|
13961
14003
|
}
|
|
13962
14004
|
function useStyle(styles, domain) {
|
|
13963
|
-
const [result, setResult] = (0,
|
|
14005
|
+
const [result, setResult] = (0, import_react95.useState)({ style: null, error: null });
|
|
13964
14006
|
useResolverTask(
|
|
13965
14007
|
styles,
|
|
13966
14008
|
(s) => s.resolve(domain),
|
|
@@ -13970,7 +14012,7 @@ function useStyle(styles, domain) {
|
|
|
13970
14012
|
return result;
|
|
13971
14013
|
}
|
|
13972
14014
|
function useStyleFindings(styles, domain, state) {
|
|
13973
|
-
const [result, setResult] = (0,
|
|
14015
|
+
const [result, setResult] = (0, import_react95.useState)({ report: null, style: null, error: null });
|
|
13974
14016
|
useResolverTask(
|
|
13975
14017
|
styles,
|
|
13976
14018
|
(s) => s.check(domain, state),
|
|
@@ -13987,7 +14029,7 @@ function useStyleFindings(styles, domain, state) {
|
|
|
13987
14029
|
}
|
|
13988
14030
|
|
|
13989
14031
|
// src/style/StyleFindings.tsx
|
|
13990
|
-
var
|
|
14032
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
13991
14033
|
var SEVERITY_CLASS = {
|
|
13992
14034
|
error: "text-destructive",
|
|
13993
14035
|
warning: "text-amber-600",
|
|
@@ -13996,24 +14038,24 @@ var SEVERITY_CLASS = {
|
|
|
13996
14038
|
function StyleFindings({ report, onSelect, title = "House style", className = "" }) {
|
|
13997
14039
|
if (!report) return null;
|
|
13998
14040
|
const { findings, ran, skipped } = report;
|
|
13999
|
-
return /* @__PURE__ */ (0,
|
|
14000
|
-
/* @__PURE__ */ (0,
|
|
14001
|
-
findings.length > 0 && /* @__PURE__ */ (0,
|
|
14041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("section", { "data-style-findings": "", "aria-label": title, className: `flex flex-col gap-1.5 text-xs text-foreground ${className}`, children: [
|
|
14042
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("h3", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
|
|
14043
|
+
findings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("ul", { className: "flex flex-col gap-1", children: findings.map((finding, i) => {
|
|
14002
14044
|
const selectable = finding.target !== void 0 && !!onSelect;
|
|
14003
|
-
const body = /* @__PURE__ */ (0,
|
|
14004
|
-
/* @__PURE__ */ (0,
|
|
14005
|
-
/* @__PURE__ */ (0,
|
|
14006
|
-
/* @__PURE__ */ (0,
|
|
14007
|
-
/* @__PURE__ */ (0,
|
|
14008
|
-
/* @__PURE__ */ (0,
|
|
14009
|
-
finding.layer && /* @__PURE__ */ (0,
|
|
14045
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
14046
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { "data-style-severity": finding.severity, className: `shrink-0 font-semibold uppercase text-[10px] ${SEVERITY_CLASS[finding.severity]}`, children: finding.severity }),
|
|
14047
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: "flex min-w-0 flex-col", children: [
|
|
14048
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { "data-style-message": "", children: finding.message }),
|
|
14049
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
14050
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("code", { children: finding.check }),
|
|
14051
|
+
finding.layer && /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
14010
14052
|
" \xB7 ",
|
|
14011
14053
|
finding.layer
|
|
14012
14054
|
] })
|
|
14013
14055
|
] })
|
|
14014
14056
|
] })
|
|
14015
14057
|
] });
|
|
14016
|
-
return /* @__PURE__ */ (0,
|
|
14058
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("li", { "data-style-finding": finding.check, children: selectable ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
14017
14059
|
"button",
|
|
14018
14060
|
{
|
|
14019
14061
|
type: "button",
|
|
@@ -14021,19 +14063,19 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
14021
14063
|
onClick: () => onSelect(finding),
|
|
14022
14064
|
children: body
|
|
14023
14065
|
}
|
|
14024
|
-
) : /* @__PURE__ */ (0,
|
|
14066
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "flex items-start gap-2 rounded border border-border px-2 py-1", children: body }) }, `${finding.check}-${i}`);
|
|
14025
14067
|
}) }),
|
|
14026
|
-
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0,
|
|
14068
|
+
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("p", { "data-style-clear": "", className: "text-emerald-600", children: [
|
|
14027
14069
|
"All clear: ",
|
|
14028
14070
|
ran.length,
|
|
14029
14071
|
" ",
|
|
14030
14072
|
ran.length === 1 ? "check" : "checks",
|
|
14031
14073
|
" passed."
|
|
14032
14074
|
] }),
|
|
14033
|
-
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0,
|
|
14034
|
-
skipped.length > 0 && /* @__PURE__ */ (0,
|
|
14075
|
+
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "text-muted-foreground", children: "No house-style checks apply." }),
|
|
14076
|
+
skipped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime72.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_runtime72.jsxs)("li", { "data-style-skipped-check": s.check, children: [
|
|
14035
14077
|
"Skipped ",
|
|
14036
|
-
/* @__PURE__ */ (0,
|
|
14078
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("code", { children: s.check }),
|
|
14037
14079
|
": ",
|
|
14038
14080
|
s.reason
|
|
14039
14081
|
] }, s.check)) })
|
|
@@ -14091,6 +14133,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
14091
14133
|
RefineEdgePanel,
|
|
14092
14134
|
ReviewToolbar,
|
|
14093
14135
|
SelectAndMaskWorkspace,
|
|
14136
|
+
SelectionChangeCheck,
|
|
14094
14137
|
SelectionOptionsBar,
|
|
14095
14138
|
ShapeOptionsBar,
|
|
14096
14139
|
SheetTabs,
|