@pixerate/editor-react 0.119.0 → 0.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-H2EO7O3J.js → chunk-VR3JON4V.js} +638 -309
- package/dist/image-editor/ChannelsPanel.d.cts +15 -0
- package/dist/image-editor/ChannelsPanel.d.ts +15 -0
- package/dist/image-editor/LayersPanel.d.cts +2 -1
- package/dist/image-editor/LayersPanel.d.ts +2 -1
- package/dist/image-editor/SelectionOptionsBar.d.cts +8 -4
- package/dist/image-editor/SelectionOptionsBar.d.ts +8 -4
- package/dist/image-editor/index.cjs +641 -317
- 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 +1161 -837
- package/dist/index.js +3 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
AssetMentionChips: () => AssetMentionChips,
|
|
37
37
|
BrushOptionsBar: () => BrushOptionsBar,
|
|
38
38
|
BubbleMenu: () => BubbleMenu,
|
|
39
|
+
ChannelsPanel: () => ChannelsPanel,
|
|
39
40
|
ChartNodeView: () => ChartNodeView,
|
|
40
41
|
ColorProfilePanel: () => ColorProfilePanel,
|
|
41
42
|
CommandPalette: () => CommandPalette,
|
|
@@ -4039,8 +4040,8 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
4039
4040
|
}
|
|
4040
4041
|
|
|
4041
4042
|
// src/image-editor/ImageEditor.tsx
|
|
4042
|
-
var
|
|
4043
|
-
var
|
|
4043
|
+
var import_react67 = __toESM(require("react"), 1);
|
|
4044
|
+
var import_image_editor20 = require("@pixerate/editor/image-editor");
|
|
4044
4045
|
|
|
4045
4046
|
// src/image-editor/ImageEditorCanvas.tsx
|
|
4046
4047
|
var import_react41 = require("react");
|
|
@@ -4410,6 +4411,30 @@ var ImageEditorCanvas = ({
|
|
|
4410
4411
|
if (g.error) report("paint", g.error);
|
|
4411
4412
|
}
|
|
4412
4413
|
};
|
|
4414
|
+
(0, import_react41.useEffect)(() => {
|
|
4415
|
+
if (mode !== "select" || typeof window === "undefined") return;
|
|
4416
|
+
const onKey = (e) => {
|
|
4417
|
+
const target = e.target;
|
|
4418
|
+
if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
|
|
4419
|
+
if (window.getSelection?.()?.toString()) return;
|
|
4420
|
+
const gesture = selectionGestureRef.current;
|
|
4421
|
+
if ((0, import_image_editor2.handleQuickMaskKey)(controller, e)) {
|
|
4422
|
+
e.preventDefault();
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4425
|
+
if ((0, import_image_editor2.handleSelectionShortcut)(controller, e, (message2) => report("select", message2))) {
|
|
4426
|
+
e.preventDefault();
|
|
4427
|
+
return;
|
|
4428
|
+
}
|
|
4429
|
+
if (gesture?.key(e.key)) {
|
|
4430
|
+
e.preventDefault();
|
|
4431
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
4432
|
+
void renderCanvas();
|
|
4433
|
+
}
|
|
4434
|
+
};
|
|
4435
|
+
window.addEventListener("keydown", onKey);
|
|
4436
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
4437
|
+
});
|
|
4413
4438
|
(0, import_react41.useEffect)(() => {
|
|
4414
4439
|
if (mode !== "paint" || typeof window === "undefined") return;
|
|
4415
4440
|
const onKey = (e) => {
|
|
@@ -4425,7 +4450,11 @@ var ImageEditorCanvas = ({
|
|
|
4425
4450
|
if (mode === "select") {
|
|
4426
4451
|
const gesture = selectionGestureRef.current;
|
|
4427
4452
|
const imgPt = (0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false);
|
|
4428
|
-
void gesture.begin(imgPt, e).then(() =>
|
|
4453
|
+
void gesture.begin(imgPt, e).then(() => {
|
|
4454
|
+
report("select", gesture.error);
|
|
4455
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
4456
|
+
void renderCanvas();
|
|
4457
|
+
});
|
|
4429
4458
|
return;
|
|
4430
4459
|
}
|
|
4431
4460
|
if (mode === "crop") {
|
|
@@ -4507,7 +4536,7 @@ var ImageEditorCanvas = ({
|
|
|
4507
4536
|
const canvasPt = getCanvasEventPoint(e);
|
|
4508
4537
|
if (mode === "select") {
|
|
4509
4538
|
const gesture = selectionGestureRef.current;
|
|
4510
|
-
if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false))) {
|
|
4539
|
+
if (gesture.active && gesture.move((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e)) {
|
|
4511
4540
|
selectionDraftRef.current = gesture.draftPath;
|
|
4512
4541
|
renderCanvas();
|
|
4513
4542
|
}
|
|
@@ -4650,7 +4679,7 @@ var ImageEditorCanvas = ({
|
|
|
4650
4679
|
const gesture = selectionGestureRef.current;
|
|
4651
4680
|
if (gesture.active) {
|
|
4652
4681
|
gesture.end((0, import_image_editor2.canvasToImagePoint)(canvasPt, state, viewRef.current.width, viewRef.current.height, false), e);
|
|
4653
|
-
selectionDraftRef.current =
|
|
4682
|
+
selectionDraftRef.current = gesture.draftPath;
|
|
4654
4683
|
renderCanvas();
|
|
4655
4684
|
}
|
|
4656
4685
|
return;
|
|
@@ -5159,7 +5188,7 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
|
|
|
5159
5188
|
type: "button",
|
|
5160
5189
|
className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",
|
|
5161
5190
|
onClick: () => {
|
|
5162
|
-
setSelectedId(controller.addAdjustmentLayer(newKind));
|
|
5191
|
+
setSelectedId(controller.addAdjustmentLayer({ kind: newKind, useSelection: true }));
|
|
5163
5192
|
setChannel("master");
|
|
5164
5193
|
setRange(-1);
|
|
5165
5194
|
},
|
|
@@ -5712,7 +5741,14 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
5712
5741
|
pixels: thumb(layer),
|
|
5713
5742
|
size: thumbnailSize,
|
|
5714
5743
|
label: `${row.label} pixels`,
|
|
5715
|
-
|
|
5744
|
+
testId: "layer-thumbnail",
|
|
5745
|
+
selected: row.active && state.activeTarget === "pixels" && Boolean(layer.mask),
|
|
5746
|
+
onClick: (e) => {
|
|
5747
|
+
if (e.ctrlKey || e.metaKey) {
|
|
5748
|
+
e.stopPropagation();
|
|
5749
|
+
attempt(() => (0, import_image_editor8.layerThumbnailClick)(controller, layer, e));
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5716
5752
|
}
|
|
5717
5753
|
),
|
|
5718
5754
|
layer.type !== "pixel" && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -5757,8 +5793,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
5757
5793
|
selected: row.active && state.activeTarget === "mask",
|
|
5758
5794
|
onClick: (e) => {
|
|
5759
5795
|
e.stopPropagation();
|
|
5760
|
-
|
|
5761
|
-
else attempt(() => controller.setActiveLayer(layer.id, "mask"));
|
|
5796
|
+
attempt(() => (0, import_image_editor8.maskThumbnailClick)(controller, layer, e));
|
|
5762
5797
|
}
|
|
5763
5798
|
}
|
|
5764
5799
|
),
|
|
@@ -7830,7 +7865,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
7830
7865
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: "Filters" }),
|
|
7831
7866
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: imageOutlineButtonClass, "aria-pressed": browse === "filter", onClick: () => setBrowse(browse === "filter" ? null : "filter"), children: "Add filter\u2026" })
|
|
7832
7867
|
] }),
|
|
7833
|
-
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
7868
|
+
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id, { useSelection: true }))) }),
|
|
7834
7869
|
filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
7835
7870
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
7836
7871
|
const all = layer.smartFilters.filters;
|
|
@@ -8265,12 +8300,18 @@ var import_react61 = require("react");
|
|
|
8265
8300
|
var import_image_editor14 = require("@pixerate/editor/image-editor");
|
|
8266
8301
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8267
8302
|
var MODIFY_OPS = [
|
|
8268
|
-
{ op: "
|
|
8269
|
-
{ op: "
|
|
8303
|
+
{ op: "expand", label: "Expand" },
|
|
8304
|
+
{ op: "contract", label: "Contract" },
|
|
8270
8305
|
{ op: "feather", label: "Feather" },
|
|
8271
8306
|
{ op: "border", label: "Border" },
|
|
8272
8307
|
{ op: "smooth", label: "Smooth" }
|
|
8273
8308
|
];
|
|
8309
|
+
var DISPLAYS = [
|
|
8310
|
+
{ id: "ants", label: "Ants" },
|
|
8311
|
+
{ id: "quickMask", label: "Quick Mask" },
|
|
8312
|
+
{ id: "none", label: "Hidden" }
|
|
8313
|
+
];
|
|
8314
|
+
var numberInput = "w-14 bg-background border border-border rounded px-1 py-0.5 text-foreground";
|
|
8274
8315
|
var btn = (on) => `px-2 py-1 rounded-md border text-[11px] transition-colors ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
8275
8316
|
var SelectionOptionsBar = ({
|
|
8276
8317
|
controller,
|
|
@@ -8278,12 +8319,50 @@ var SelectionOptionsBar = ({
|
|
|
8278
8319
|
onOptionsChange,
|
|
8279
8320
|
selection,
|
|
8280
8321
|
quickMask,
|
|
8322
|
+
selectionDisplay,
|
|
8281
8323
|
className = ""
|
|
8282
8324
|
}) => {
|
|
8283
8325
|
const [radius, setRadius] = (0, import_react61.useState)(2);
|
|
8284
8326
|
const set = (patch) => onOptionsChange({ ...options, ...patch });
|
|
8285
8327
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
8286
|
-
const
|
|
8328
|
+
const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
|
|
8329
|
+
const [preset, setPreset] = (0, import_react61.useState)("reds");
|
|
8330
|
+
const [rangeStatus, setRangeStatus] = (0, import_react61.useState)(null);
|
|
8331
|
+
const [colorStatus, setColorStatus] = (0, import_react61.useState)(null);
|
|
8332
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react61.useState)(4);
|
|
8333
|
+
const [strokeLocation, setStrokeLocation] = (0, import_react61.useState)("outside");
|
|
8334
|
+
const edit = (fn) => {
|
|
8335
|
+
setColorStatus(null);
|
|
8336
|
+
try {
|
|
8337
|
+
fn();
|
|
8338
|
+
} catch (err) {
|
|
8339
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
8340
|
+
}
|
|
8341
|
+
};
|
|
8342
|
+
const runColor = async (op) => {
|
|
8343
|
+
setColorStatus(null);
|
|
8344
|
+
const opts = { tolerance: options.tolerance, sampleMerged: options.sampleMerged, sample: options.sample };
|
|
8345
|
+
try {
|
|
8346
|
+
await (op === "grow" ? controller.growSelection(opts) : controller.selectSimilar(opts));
|
|
8347
|
+
} catch (err) {
|
|
8348
|
+
setColorStatus(err instanceof Error ? err.message : String(err));
|
|
8349
|
+
}
|
|
8350
|
+
};
|
|
8351
|
+
const applyPreset = async () => {
|
|
8352
|
+
setRangeStatus(null);
|
|
8353
|
+
try {
|
|
8354
|
+
await controller.selectColorRangePreset(preset, {
|
|
8355
|
+
mode: options.mode,
|
|
8356
|
+
feather: options.feather ?? 0,
|
|
8357
|
+
invert: options.rangeInvert ?? false,
|
|
8358
|
+
falloff: options.fuzziness ?? 20,
|
|
8359
|
+
sampleMerged: options.sampleMerged,
|
|
8360
|
+
sample: options.sample
|
|
8361
|
+
});
|
|
8362
|
+
} catch (err) {
|
|
8363
|
+
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
8364
|
+
}
|
|
8365
|
+
};
|
|
8287
8366
|
const [subject, setSubject] = (0, import_react61.useState)("");
|
|
8288
8367
|
const [segmenting, setSegmenting] = (0, import_react61.useState)(false);
|
|
8289
8368
|
const [subjectStatus, setSubjectStatus] = (0, import_react61.useState)(null);
|
|
@@ -8316,6 +8395,21 @@ var SelectionOptionsBar = ({
|
|
|
8316
8395
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Contiguous", checked: options.contiguous, onChange: (on) => set({ contiguous: on }) }),
|
|
8317
8396
|
"Contiguous"
|
|
8318
8397
|
] }),
|
|
8398
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
8399
|
+
"Distance",
|
|
8400
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8401
|
+
ImageSelect,
|
|
8402
|
+
{
|
|
8403
|
+
label: "Colour distance",
|
|
8404
|
+
value: options.distance,
|
|
8405
|
+
options: [
|
|
8406
|
+
{ value: "rgb", label: "RGB" },
|
|
8407
|
+
{ value: "perceptual", label: "Perceptual" }
|
|
8408
|
+
],
|
|
8409
|
+
onChange: (v) => set({ distance: v })
|
|
8410
|
+
}
|
|
8411
|
+
)
|
|
8412
|
+
] }),
|
|
8319
8413
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
8320
8414
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Sample adjusted image", checked: options.sampleMerged, onChange: (on) => set({ sampleMerged: on }) }),
|
|
8321
8415
|
"Sample adjusted image"
|
|
@@ -8336,6 +8430,67 @@ var SelectionOptionsBar = ({
|
|
|
8336
8430
|
)
|
|
8337
8431
|
] })
|
|
8338
8432
|
] }),
|
|
8433
|
+
options.tool === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click to add corners (Shift for 45\xB0), drag for a free-hand stretch; double-click, Enter or a click on the first corner closes it, Backspace removes a corner, Escape cancels." }),
|
|
8434
|
+
options.tool === "range" && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { "data-testid": "color-range-options", className: "flex flex-col gap-2", children: [
|
|
8435
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click a colour to select it; Shift-click adds a colour, Alt-click removes one." }),
|
|
8436
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
8437
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
8438
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Fuzziness" }),
|
|
8439
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "font-mono", children: options.fuzziness ?? 40 })
|
|
8440
|
+
] }),
|
|
8441
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageRange, { label: "Fuzziness", min: 0, max: 200, step: 1, value: options.fuzziness ?? 40, onChange: (v) => set({ fuzziness: v }) })
|
|
8442
|
+
] }),
|
|
8443
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
8444
|
+
"Localized radius",
|
|
8445
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8446
|
+
"input",
|
|
8447
|
+
{
|
|
8448
|
+
type: "number",
|
|
8449
|
+
min: 0,
|
|
8450
|
+
step: 1,
|
|
8451
|
+
"aria-label": "Localized radius",
|
|
8452
|
+
value: options.localized ?? 0,
|
|
8453
|
+
onChange: (e) => set({ localized: Math.max(0, Number(e.target.value) || 0) }),
|
|
8454
|
+
className: numberInput
|
|
8455
|
+
}
|
|
8456
|
+
),
|
|
8457
|
+
"px"
|
|
8458
|
+
] }),
|
|
8459
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
|
|
8460
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageCheckbox, { label: "Invert", checked: options.rangeInvert ?? false, onChange: (on) => set({ rangeInvert: on }) }),
|
|
8461
|
+
"Invert"
|
|
8462
|
+
] }),
|
|
8463
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
8464
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8465
|
+
ImageSelect,
|
|
8466
|
+
{
|
|
8467
|
+
label: "Color Range preset",
|
|
8468
|
+
value: preset,
|
|
8469
|
+
options: import_image_editor14.COLOR_RANGE_PRESETS.map((p) => ({ value: p, label: import_image_editor14.COLOR_RANGE_PRESET_LABELS[p] })),
|
|
8470
|
+
onChange: (v) => setPreset(v)
|
|
8471
|
+
}
|
|
8472
|
+
),
|
|
8473
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => void applyPreset(), children: "Select" })
|
|
8474
|
+
] }),
|
|
8475
|
+
rangeStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: rangeStatus })
|
|
8476
|
+
] }),
|
|
8477
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
8478
|
+
"Feather",
|
|
8479
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8480
|
+
"input",
|
|
8481
|
+
{
|
|
8482
|
+
type: "number",
|
|
8483
|
+
min: 0,
|
|
8484
|
+
max: 1e3,
|
|
8485
|
+
step: 0.5,
|
|
8486
|
+
"aria-label": "Feather",
|
|
8487
|
+
value: options.feather ?? 0,
|
|
8488
|
+
onChange: (e) => set({ feather: Math.max(0, Number(e.target.value) || 0) }),
|
|
8489
|
+
className: numberInput
|
|
8490
|
+
}
|
|
8491
|
+
),
|
|
8492
|
+
"px"
|
|
8493
|
+
] }),
|
|
8339
8494
|
controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8340
8495
|
"form",
|
|
8341
8496
|
{
|
|
@@ -8373,7 +8528,13 @@ var SelectionOptionsBar = ({
|
|
|
8373
8528
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.selectAll(), children: "Select All" }),
|
|
8374
8529
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.deselect(), children: "Deselect" }),
|
|
8375
8530
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => controller.invertSelection(), children: "Inverse" }),
|
|
8376
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button",
|
|
8531
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !controller.canReselect(), onClick: () => controller.reselect(), children: "Reselect" }),
|
|
8532
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, title: "Add connected pixels of a selected colour (wand tolerance)", onClick: () => void runColor("grow"), children: "Grow" }),
|
|
8533
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, title: "Add every pixel of a selected colour (wand tolerance)", onClick: () => void runColor("similar"), children: "Similar" })
|
|
8534
|
+
] }),
|
|
8535
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Show selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
8536
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "text-muted-foreground", children: "Show" }),
|
|
8537
|
+
DISPLAYS.map((d) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", "aria-pressed": display === d.id, className: btn(display === d.id), onClick: () => controller.setSelectionDisplay(d.id), children: d.label }, d.id))
|
|
8377
8538
|
] }),
|
|
8378
8539
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
8379
8540
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
@@ -8388,12 +8549,57 @@ var SelectionOptionsBar = ({
|
|
|
8388
8549
|
"aria-label": "Modify radius",
|
|
8389
8550
|
value: radius,
|
|
8390
8551
|
onChange: (e) => setRadius(Math.max(0, Number(e.target.value) || 0)),
|
|
8391
|
-
className:
|
|
8552
|
+
className: numberInput
|
|
8392
8553
|
}
|
|
8393
8554
|
)
|
|
8394
8555
|
] }),
|
|
8395
8556
|
MODIFY_OPS.map(({ op, label }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => controller.modifySelection(op, radius), children: label }, op))
|
|
8396
8557
|
] }),
|
|
8558
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Edit selection", className: "flex flex-wrap items-center gap-1", children: [
|
|
8559
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex items-center gap-1 text-muted-foreground", children: [
|
|
8560
|
+
"Stroke",
|
|
8561
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8562
|
+
"input",
|
|
8563
|
+
{
|
|
8564
|
+
type: "number",
|
|
8565
|
+
min: 1,
|
|
8566
|
+
max: 250,
|
|
8567
|
+
step: 1,
|
|
8568
|
+
"aria-label": "Stroke width",
|
|
8569
|
+
value: strokeWidth,
|
|
8570
|
+
onChange: (e) => setStrokeWidth(Math.min(250, Math.max(1, Number(e.target.value) || 1))),
|
|
8571
|
+
className: numberInput
|
|
8572
|
+
}
|
|
8573
|
+
),
|
|
8574
|
+
"px"
|
|
8575
|
+
] }),
|
|
8576
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8577
|
+
ImageSelect,
|
|
8578
|
+
{
|
|
8579
|
+
label: "Stroke location",
|
|
8580
|
+
value: strokeLocation,
|
|
8581
|
+
options: [
|
|
8582
|
+
{ value: "outside", label: "Outside" },
|
|
8583
|
+
{ value: "center", label: "Center" },
|
|
8584
|
+
{ value: "inside", label: "Inside" }
|
|
8585
|
+
],
|
|
8586
|
+
onChange: (v) => setStrokeLocation(v)
|
|
8587
|
+
}
|
|
8588
|
+
),
|
|
8589
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.strokeSelection({ width: strokeWidth, location: strokeLocation })), children: "Stroke" }),
|
|
8590
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cropToSelection()), children: "Crop to Selection" }),
|
|
8591
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.contentAwareFill({ output: "new-layer" })), children: "Content-Aware Fill" })
|
|
8592
|
+
] }),
|
|
8593
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "group", "aria-label": "Clipboard", className: "flex flex-wrap gap-1", children: [
|
|
8594
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels()), children: "Copy" }),
|
|
8595
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.copyPixels({ merged: true })), children: "Copy Merged" }),
|
|
8596
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.cutPixels()), children: "Cut" }),
|
|
8597
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("new-layer")), children: "Paste" }),
|
|
8598
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), onClick: () => edit(() => controller.pastePixels("in-place")), children: "Paste in Place" }),
|
|
8599
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("into")), children: "Paste Into" }),
|
|
8600
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "button", className: btn(false), disabled: !sel, onClick: () => edit(() => controller.pastePixels("outside")), children: "Paste Outside" })
|
|
8601
|
+
] }),
|
|
8602
|
+
colorStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: colorStatus }),
|
|
8397
8603
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { "data-testid": "selection-status", className: "text-muted-foreground", children: (0, import_image_editor14.describeSelection)(sel) })
|
|
8398
8604
|
] });
|
|
8399
8605
|
};
|
|
@@ -8549,14 +8755,129 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
8549
8755
|
] });
|
|
8550
8756
|
};
|
|
8551
8757
|
|
|
8552
|
-
// src/image-editor/
|
|
8758
|
+
// src/image-editor/ChannelsPanel.tsx
|
|
8553
8759
|
var import_react63 = require("react");
|
|
8554
8760
|
var import_image_editor16 = require("@pixerate/editor/image-editor");
|
|
8555
8761
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8762
|
+
var btn2 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
8763
|
+
var ChannelThumb = ({ channel, size }) => {
|
|
8764
|
+
const ref = (0, import_react63.useRef)(null);
|
|
8765
|
+
(0, import_react63.useEffect)(() => {
|
|
8766
|
+
const canvas = ref.current;
|
|
8767
|
+
const ctx = canvas?.getContext("2d");
|
|
8768
|
+
if (!canvas || !ctx || typeof ctx.createImageData !== "function") return;
|
|
8769
|
+
const px = (0, import_image_editor16.channelThumbnail)(channel, 64);
|
|
8770
|
+
canvas.width = px.width;
|
|
8771
|
+
canvas.height = px.height;
|
|
8772
|
+
const img = ctx.createImageData(px.width, px.height);
|
|
8773
|
+
img.data.set(px.data);
|
|
8774
|
+
ctx.putImageData(img, 0, 0);
|
|
8775
|
+
}, [channel.mask]);
|
|
8776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("canvas", { ref, "aria-hidden": "true", style: { width: size, height: size }, className: "shrink-0 rounded object-contain ring-1 ring-border bg-black" });
|
|
8777
|
+
};
|
|
8778
|
+
var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
8779
|
+
const [, setTick] = (0, import_react63.useState)(0);
|
|
8780
|
+
(0, import_react63.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
8781
|
+
const [activeId, setActiveId] = (0, import_react63.useState)(null);
|
|
8782
|
+
const [renaming, setRenaming] = (0, import_react63.useState)(null);
|
|
8783
|
+
const [error, setError] = (0, import_react63.useState)(null);
|
|
8784
|
+
const channels = controller.getChannels();
|
|
8785
|
+
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
8786
|
+
const hasSelection = Boolean(controller.getSelection());
|
|
8787
|
+
const quickMask = controller.quickMaskEditing;
|
|
8788
|
+
const attempt = (fn) => {
|
|
8789
|
+
setError(null);
|
|
8790
|
+
try {
|
|
8791
|
+
fn();
|
|
8792
|
+
} catch (err) {
|
|
8793
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
8794
|
+
}
|
|
8795
|
+
};
|
|
8796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { "data-testid": "channels-panel", className: `flex flex-col gap-2 text-xs ${className}`, children: [
|
|
8797
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
8798
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: imageSectionTitleClass, children: "Channels" }),
|
|
8799
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-pressed": quickMask, className: btn2(quickMask), title: "Paint the selection: white selects, black deselects (Q)", onClick: () => controller.setQuickMaskMode(!quickMask), children: "Quick Mask" })
|
|
8800
|
+
] }),
|
|
8801
|
+
channels.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "text-muted-foreground", children: "No channels. Save a selection to keep it." }),
|
|
8802
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("ul", { role: "list", className: "flex flex-col gap-0.5", children: channels.map((c) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
8803
|
+
"li",
|
|
8804
|
+
{
|
|
8805
|
+
"data-testid": "channel-row",
|
|
8806
|
+
"aria-current": c.id === activeId ? "true" : void 0,
|
|
8807
|
+
className: `flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer select-none ${c.id === activeId ? "bg-primary/30 ring-1 ring-primary" : "hover:bg-muted"}`,
|
|
8808
|
+
onClick: (e) => {
|
|
8809
|
+
setActiveId(c.id);
|
|
8810
|
+
attempt(() => controller.loadSelectionFromChannel(c.id, { mode: (0, import_image_editor16.selectionModeFromModifiers)(e, "replace") }));
|
|
8811
|
+
},
|
|
8812
|
+
onDoubleClick: () => setRenaming(c.id),
|
|
8813
|
+
children: [
|
|
8814
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8815
|
+
"button",
|
|
8816
|
+
{
|
|
8817
|
+
type: "button",
|
|
8818
|
+
"aria-label": `${c.visible ? "Hide" : "Show"} ${c.name}`,
|
|
8819
|
+
"aria-pressed": c.visible,
|
|
8820
|
+
className: "w-4 text-muted-foreground",
|
|
8821
|
+
onClick: (e) => {
|
|
8822
|
+
e.stopPropagation();
|
|
8823
|
+
attempt(() => controller.setChannelProperties(c.id, { visible: !c.visible }));
|
|
8824
|
+
},
|
|
8825
|
+
children: c.visible ? "\u25CF" : "\u25CB"
|
|
8826
|
+
}
|
|
8827
|
+
),
|
|
8828
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ChannelThumb, { channel: c, size: thumbnailSize }),
|
|
8829
|
+
renaming === c.id ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8830
|
+
"input",
|
|
8831
|
+
{
|
|
8832
|
+
autoFocus: true,
|
|
8833
|
+
"aria-label": "Channel name",
|
|
8834
|
+
defaultValue: c.name,
|
|
8835
|
+
className: "min-w-0 flex-1 bg-background border border-border rounded px-1 py-0.5 text-foreground",
|
|
8836
|
+
onClick: (e) => e.stopPropagation(),
|
|
8837
|
+
onBlur: (e) => {
|
|
8838
|
+
setRenaming(null);
|
|
8839
|
+
if (e.currentTarget.value.trim() && e.currentTarget.value !== c.name) attempt(() => controller.setChannelProperties(c.id, { name: e.currentTarget.value }));
|
|
8840
|
+
},
|
|
8841
|
+
onKeyDown: (e) => {
|
|
8842
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
8843
|
+
if (e.key === "Escape") setRenaming(null);
|
|
8844
|
+
}
|
|
8845
|
+
}
|
|
8846
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "min-w-0 flex-1 truncate", children: c.name })
|
|
8847
|
+
]
|
|
8848
|
+
},
|
|
8849
|
+
c.id
|
|
8850
|
+
)) }),
|
|
8851
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
8852
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !hasSelection, onClick: () => attempt(() => setActiveId(controller.saveSelection().id)), children: "Save Selection" }),
|
|
8853
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !active || !hasSelection, title: "Add the selection to the channel", onClick: () => attempt(() => controller.saveSelection({ channelId: active.id, mode: "add" })), children: "Add to Channel" }),
|
|
8854
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: btn2(), disabled: !active, onClick: () => attempt(() => setActiveId(controller.duplicateChannel(active.id).id)), children: "Duplicate" }),
|
|
8855
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8856
|
+
"button",
|
|
8857
|
+
{
|
|
8858
|
+
type: "button",
|
|
8859
|
+
className: btn2(),
|
|
8860
|
+
disabled: !active,
|
|
8861
|
+
onClick: () => attempt(() => {
|
|
8862
|
+
controller.deleteChannel(active.id);
|
|
8863
|
+
setActiveId(null);
|
|
8864
|
+
}),
|
|
8865
|
+
children: "Delete"
|
|
8866
|
+
}
|
|
8867
|
+
)
|
|
8868
|
+
] }),
|
|
8869
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
8870
|
+
] });
|
|
8871
|
+
};
|
|
8872
|
+
|
|
8873
|
+
// src/image-editor/FreeTransformOptionsBar.tsx
|
|
8874
|
+
var import_react64 = require("react");
|
|
8875
|
+
var import_image_editor17 = require("@pixerate/editor/image-editor");
|
|
8876
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8556
8877
|
var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
|
|
8557
8878
|
var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
8558
|
-
const [, setTick] = (0,
|
|
8559
|
-
(0,
|
|
8879
|
+
const [, setTick] = (0, import_react64.useState)(0);
|
|
8880
|
+
(0, import_react64.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
|
|
8560
8881
|
const bar = tool.bar();
|
|
8561
8882
|
if (!tool.active || !bar) return null;
|
|
8562
8883
|
const warp = tool.warpBar();
|
|
@@ -8568,17 +8889,17 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8568
8889
|
const v = Number(raw);
|
|
8569
8890
|
if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
|
|
8570
8891
|
};
|
|
8571
|
-
return /* @__PURE__ */ (0,
|
|
8572
|
-
/* @__PURE__ */ (0,
|
|
8573
|
-
/* @__PURE__ */ (0,
|
|
8574
|
-
tool.mode === "warp" && /* @__PURE__ */ (0,
|
|
8575
|
-
/* @__PURE__ */ (0,
|
|
8576
|
-
/* @__PURE__ */ (0,
|
|
8577
|
-
/* @__PURE__ */ (0,
|
|
8892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `flex flex-wrap items-center gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "free-transform-options", role: "toolbar", "aria-label": "Free Transform options", children: [
|
|
8893
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor17.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", title: m.title, "aria-pressed": tool.mode === m.id, className: imageChipClass(tool.mode === m.id), onClick: () => tool.setMode(m.id), children: m.label }, m.id)) }),
|
|
8894
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor17.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", "aria-label": `Reference point ${a}`, title: `Reference point: ${a}`, className: "h-2.5 w-2.5 rounded-sm bg-accent hover:bg-primary/90", onClick: () => tool.setReference(a) }, a)) }),
|
|
8895
|
+
tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
|
|
8896
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8897
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Warp" }),
|
|
8898
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: imageFieldClass, children: import_image_editor17.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: o.id, children: o.label }, o.id)) })
|
|
8578
8899
|
] }),
|
|
8579
|
-
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0,
|
|
8580
|
-
/* @__PURE__ */ (0,
|
|
8581
|
-
/* @__PURE__ */ (0,
|
|
8900
|
+
["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8901
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
|
|
8902
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8582
8903
|
"input",
|
|
8583
8904
|
{
|
|
8584
8905
|
type: "number",
|
|
@@ -8599,9 +8920,9 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8599
8920
|
},
|
|
8600
8921
|
`${k}:${warp[k]}`
|
|
8601
8922
|
),
|
|
8602
|
-
/* @__PURE__ */ (0,
|
|
8923
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "%" })
|
|
8603
8924
|
] }, k)),
|
|
8604
|
-
/* @__PURE__ */ (0,
|
|
8925
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8605
8926
|
"button",
|
|
8606
8927
|
{
|
|
8607
8928
|
type: "button",
|
|
@@ -8613,26 +8934,26 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8613
8934
|
children: "Vertical"
|
|
8614
8935
|
}
|
|
8615
8936
|
),
|
|
8616
|
-
/* @__PURE__ */ (0,
|
|
8617
|
-
/* @__PURE__ */ (0,
|
|
8618
|
-
/* @__PURE__ */ (0,
|
|
8937
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8938
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Grid" }),
|
|
8939
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8619
8940
|
"select",
|
|
8620
8941
|
{
|
|
8621
8942
|
"aria-label": "Warp grid",
|
|
8622
|
-
value:
|
|
8943
|
+
value: import_image_editor17.WARP_GRID_OPTIONS.find((g) => g.columns === warp.columns && g.rows === warp.rows)?.id ?? "1x1",
|
|
8623
8944
|
onChange: (e) => {
|
|
8624
|
-
const g =
|
|
8945
|
+
const g = import_image_editor17.WARP_GRID_OPTIONS.find((o) => o.id === e.target.value);
|
|
8625
8946
|
tool.setWarp({ columns: g.columns, rows: g.rows });
|
|
8626
8947
|
},
|
|
8627
8948
|
className: imageFieldClass,
|
|
8628
|
-
children:
|
|
8949
|
+
children: import_image_editor17.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: g.id, children: g.label }, g.id))
|
|
8629
8950
|
}
|
|
8630
8951
|
)
|
|
8631
8952
|
] })
|
|
8632
8953
|
] }),
|
|
8633
|
-
tool.mode !== "warp" &&
|
|
8634
|
-
/* @__PURE__ */ (0,
|
|
8635
|
-
/* @__PURE__ */ (0,
|
|
8954
|
+
tool.mode !== "warp" && import_image_editor17.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
|
|
8955
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: f.label }),
|
|
8956
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8636
8957
|
"input",
|
|
8637
8958
|
{
|
|
8638
8959
|
type: "number",
|
|
@@ -8652,8 +8973,8 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8652
8973
|
},
|
|
8653
8974
|
`${f.id}:${round(bar[f.id], f.unit)}`
|
|
8654
8975
|
),
|
|
8655
|
-
/* @__PURE__ */ (0,
|
|
8656
|
-
f.id === "scaleX" && /* @__PURE__ */ (0,
|
|
8976
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: f.unit }),
|
|
8977
|
+
f.id === "scaleX" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8657
8978
|
"button",
|
|
8658
8979
|
{
|
|
8659
8980
|
type: "button",
|
|
@@ -8668,33 +8989,33 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
8668
8989
|
}
|
|
8669
8990
|
)
|
|
8670
8991
|
] }, f.id)),
|
|
8671
|
-
/* @__PURE__ */ (0,
|
|
8672
|
-
/* @__PURE__ */ (0,
|
|
8673
|
-
/* @__PURE__ */ (0,
|
|
8992
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8993
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-muted-foreground", children: "Interpolation" }),
|
|
8994
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8674
8995
|
"select",
|
|
8675
8996
|
{
|
|
8676
8997
|
"aria-label": "Interpolation",
|
|
8677
8998
|
value: tool.interpolation,
|
|
8678
8999
|
onChange: (e) => tool.setInterpolation(e.target.value),
|
|
8679
9000
|
className: imageFieldClass,
|
|
8680
|
-
children:
|
|
9001
|
+
children: import_image_editor17.INTERPOLATIONS.map((i) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("option", { value: i, children: i[0].toUpperCase() + i.slice(1) }, i))
|
|
8681
9002
|
}
|
|
8682
9003
|
)
|
|
8683
9004
|
] }),
|
|
8684
|
-
/* @__PURE__ */ (0,
|
|
8685
|
-
/* @__PURE__ */ (0,
|
|
8686
|
-
tool.error && /* @__PURE__ */ (0,
|
|
9005
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", title: "Commit (Enter)", className: "px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90", onClick: () => tool.commit(), children: "Commit" }),
|
|
9006
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", title: "Cancel (Esc)", className: imageChipClass(false), onClick: () => tool.cancel(), children: "Cancel" }),
|
|
9007
|
+
tool.error && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { role: "alert", className: "text-destructive", children: tool.error })
|
|
8687
9008
|
] });
|
|
8688
9009
|
};
|
|
8689
9010
|
|
|
8690
9011
|
// src/image-editor/ShapeOptionsBar.tsx
|
|
8691
|
-
var
|
|
8692
|
-
var
|
|
8693
|
-
var
|
|
9012
|
+
var import_react65 = require("react");
|
|
9013
|
+
var import_image_editor18 = require("@pixerate/editor/image-editor");
|
|
9014
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8694
9015
|
var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
8695
|
-
const [, setTick] = (0,
|
|
8696
|
-
(0,
|
|
8697
|
-
const [error, setError] = (0,
|
|
9016
|
+
const [, setTick] = (0, import_react65.useState)(0);
|
|
9017
|
+
(0, import_react65.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9018
|
+
const [error, setError] = (0, import_react65.useState)(null);
|
|
8698
9019
|
const active = controller.getActiveLayer();
|
|
8699
9020
|
const shapeId = active?.type === "shape" ? active.id : null;
|
|
8700
9021
|
const set = (change) => {
|
|
@@ -8702,28 +9023,28 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
8702
9023
|
if (!shapeId) return;
|
|
8703
9024
|
try {
|
|
8704
9025
|
setError(null);
|
|
8705
|
-
(0,
|
|
9026
|
+
(0, import_image_editor18.applyShapeOptions)(controller, shapeId, change);
|
|
8706
9027
|
} catch (e) {
|
|
8707
9028
|
setError(e instanceof Error ? e.message : String(e));
|
|
8708
9029
|
}
|
|
8709
9030
|
};
|
|
8710
9031
|
const num = (v, min, max) => Math.max(min, Math.min(max, Number(v) || min));
|
|
8711
|
-
return /* @__PURE__ */ (0,
|
|
8712
|
-
/* @__PURE__ */ (0,
|
|
8713
|
-
/* @__PURE__ */ (0,
|
|
8714
|
-
/* @__PURE__ */ (0,
|
|
8715
|
-
/* @__PURE__ */ (0,
|
|
9032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "shape-options", children: [
|
|
9033
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Shape kind", children: import_image_editor18.LIVE_SHAPE_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-pressed": options.kind === k, className: imageChipClass(options.kind === k), onClick: () => onChange({ ...options, kind: k }), children: import_image_editor18.SHAPE_KIND_LABELS[k] }, k)) }),
|
|
9034
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9035
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9036
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
|
|
8716
9037
|
"Fill",
|
|
8717
|
-
/* @__PURE__ */ (0,
|
|
9038
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
|
|
8718
9039
|
] }),
|
|
8719
|
-
/* @__PURE__ */ (0,
|
|
8720
|
-
/* @__PURE__ */ (0,
|
|
9040
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9041
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
|
|
8721
9042
|
"Stroke",
|
|
8722
|
-
/* @__PURE__ */ (0,
|
|
9043
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
|
|
8723
9044
|
] }),
|
|
8724
|
-
/* @__PURE__ */ (0,
|
|
9045
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8725
9046
|
"Width",
|
|
8726
|
-
/* @__PURE__ */ (0,
|
|
9047
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8727
9048
|
"input",
|
|
8728
9049
|
{
|
|
8729
9050
|
type: "number",
|
|
@@ -8737,51 +9058,51 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
8737
9058
|
)
|
|
8738
9059
|
] })
|
|
8739
9060
|
] }),
|
|
8740
|
-
/* @__PURE__ */ (0,
|
|
8741
|
-
options.kind === "rect" && /* @__PURE__ */ (0,
|
|
9061
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
9062
|
+
options.kind === "rect" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8742
9063
|
"Radius",
|
|
8743
|
-
/* @__PURE__ */ (0,
|
|
9064
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { type: "number", "aria-label": "Corner radius", min: 0, max: 1e3, value: options.radius, onChange: (e) => set({ radius: num(e.target.value, 0, 1e3) }), className: `w-14 ${imageFieldClass}` })
|
|
8744
9065
|
] }),
|
|
8745
|
-
options.kind === "polygon" && /* @__PURE__ */ (0,
|
|
9066
|
+
options.kind === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8746
9067
|
"Sides",
|
|
8747
|
-
/* @__PURE__ */ (0,
|
|
9068
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { type: "number", "aria-label": "Sides", min: 3, max: 100, value: options.sides, onChange: (e) => set({ sides: num(e.target.value, 3, 100) }), className: `w-14 ${imageFieldClass}` })
|
|
8748
9069
|
] }),
|
|
8749
|
-
options.kind === "star" && /* @__PURE__ */ (0,
|
|
8750
|
-
/* @__PURE__ */ (0,
|
|
9070
|
+
options.kind === "star" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
9071
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8751
9072
|
"Points",
|
|
8752
|
-
/* @__PURE__ */ (0,
|
|
9073
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { type: "number", "aria-label": "Points", min: 3, max: 100, value: options.points, onChange: (e) => set({ points: num(e.target.value, 3, 100) }), className: `w-14 ${imageFieldClass}` })
|
|
8753
9074
|
] }),
|
|
8754
|
-
/* @__PURE__ */ (0,
|
|
9075
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8755
9076
|
"Inner",
|
|
8756
|
-
/* @__PURE__ */ (0,
|
|
9077
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageRange, { label: "Inner radius", min: 0.05, max: 1, step: 0.05, value: options.innerRatio, onChange: (v) => set({ innerRatio: v }) })
|
|
8757
9078
|
] })
|
|
8758
9079
|
] }),
|
|
8759
|
-
options.kind === "line" && /* @__PURE__ */ (0,
|
|
8760
|
-
/* @__PURE__ */ (0,
|
|
9080
|
+
options.kind === "line" && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
9081
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8761
9082
|
"Weight",
|
|
8762
|
-
/* @__PURE__ */ (0,
|
|
9083
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { type: "number", "aria-label": "Line weight", min: 1, max: 200, value: options.weight, onChange: (e) => set({ weight: num(e.target.value, 1, 200) }), className: `w-14 ${imageFieldClass}` })
|
|
8763
9084
|
] }),
|
|
8764
|
-
/* @__PURE__ */ (0,
|
|
8765
|
-
/* @__PURE__ */ (0,
|
|
9085
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
9086
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageCheckbox, { label: "Arrowhead", checked: options.arrow, onChange: (on) => set({ arrow: on }) }),
|
|
8766
9087
|
"Arrowhead"
|
|
8767
9088
|
] })
|
|
8768
9089
|
] })
|
|
8769
9090
|
] }),
|
|
8770
|
-
/* @__PURE__ */ (0,
|
|
8771
|
-
error && /* @__PURE__ */ (0,
|
|
9091
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Drag on the image to draw. Shift: square, circle or 45\xB0 line. Alt: from the centre." }),
|
|
9092
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
8772
9093
|
] });
|
|
8773
9094
|
};
|
|
8774
9095
|
|
|
8775
9096
|
// src/image-editor/TypeOptionsBar.tsx
|
|
8776
|
-
var
|
|
8777
|
-
var
|
|
8778
|
-
var
|
|
9097
|
+
var import_react66 = require("react");
|
|
9098
|
+
var import_image_editor19 = require("@pixerate/editor/image-editor");
|
|
9099
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
8779
9100
|
var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
|
|
8780
9101
|
var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
|
|
8781
|
-
const [, setTick] = (0,
|
|
8782
|
-
(0,
|
|
8783
|
-
(0,
|
|
8784
|
-
const [error, setError] = (0,
|
|
9102
|
+
const [, setTick] = (0, import_react66.useState)(0);
|
|
9103
|
+
(0, import_react66.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
9104
|
+
(0, import_react66.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
|
|
9105
|
+
const [error, setError] = (0, import_react66.useState)(null);
|
|
8785
9106
|
const active = controller.getActiveLayer();
|
|
8786
9107
|
const typeId = !session && active?.type === "type" ? active.id : null;
|
|
8787
9108
|
const here = session?.alive ? session.styleHere() : {};
|
|
@@ -8813,11 +9134,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
8813
9134
|
setError(e instanceof Error ? e.message : String(e));
|
|
8814
9135
|
}
|
|
8815
9136
|
};
|
|
8816
|
-
return /* @__PURE__ */ (0,
|
|
8817
|
-
/* @__PURE__ */ (0,
|
|
8818
|
-
/* @__PURE__ */ (0,
|
|
9137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `flex flex-col gap-2 text-xs text-foreground ${className ?? ""}`, "data-testid": "type-options", children: [
|
|
9138
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
9139
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8819
9140
|
"Font",
|
|
8820
|
-
/* @__PURE__ */ (0,
|
|
9141
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
8821
9142
|
"input",
|
|
8822
9143
|
{
|
|
8823
9144
|
list: "pixerate-type-fonts",
|
|
@@ -8827,11 +9148,11 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
8827
9148
|
className: "w-32 rounded border border-border bg-background px-1 py-0.5"
|
|
8828
9149
|
}
|
|
8829
9150
|
),
|
|
8830
|
-
/* @__PURE__ */ (0,
|
|
9151
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("datalist", { id: "pixerate-type-fonts", children: fonts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: f }, f)) })
|
|
8831
9152
|
] }),
|
|
8832
|
-
/* @__PURE__ */ (0,
|
|
9153
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
8833
9154
|
"Size",
|
|
8834
|
-
/* @__PURE__ */ (0,
|
|
9155
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
8835
9156
|
"input",
|
|
8836
9157
|
{
|
|
8837
9158
|
type: "number",
|
|
@@ -8844,24 +9165,24 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
|
|
|
8844
9165
|
}
|
|
8845
9166
|
)
|
|
8846
9167
|
] }),
|
|
8847
|
-
/* @__PURE__ */ (0,
|
|
8848
|
-
/* @__PURE__ */ (0,
|
|
8849
|
-
/* @__PURE__ */ (0,
|
|
9168
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${imageChipClass(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
|
|
9169
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
|
|
9170
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
|
|
8850
9171
|
] }),
|
|
8851
|
-
/* @__PURE__ */ (0,
|
|
8852
|
-
/* @__PURE__ */ (0,
|
|
8853
|
-
missing.length > 0 && /* @__PURE__ */ (0,
|
|
9172
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor19.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
|
|
9173
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
|
|
9174
|
+
missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
|
|
8854
9175
|
"Missing ",
|
|
8855
9176
|
missing.length === 1 ? "font" : "fonts",
|
|
8856
9177
|
": ",
|
|
8857
9178
|
missing.join(", ")
|
|
8858
9179
|
] }),
|
|
8859
|
-
error && /* @__PURE__ */ (0,
|
|
9180
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { role: "alert", className: "text-destructive", children: error })
|
|
8860
9181
|
] });
|
|
8861
9182
|
};
|
|
8862
9183
|
|
|
8863
9184
|
// src/image-editor/ImageEditor.tsx
|
|
8864
|
-
var
|
|
9185
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
8865
9186
|
var ImageEditor = ({
|
|
8866
9187
|
editor: externalEditor,
|
|
8867
9188
|
src,
|
|
@@ -8885,51 +9206,51 @@ var ImageEditor = ({
|
|
|
8885
9206
|
const effectsShown = !!controller.effectsProvider || state.layers.some(function has(l) {
|
|
8886
9207
|
return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
|
|
8887
9208
|
});
|
|
8888
|
-
const legacyProcess = (0,
|
|
8889
|
-
const [activeTab, setActiveTab] = (0,
|
|
8890
|
-
const rootRef = (0,
|
|
9209
|
+
const legacyProcess = (0, import_image_editor20.normalizeProcessVersion)(state.adjustments.process) < import_image_editor20.LATEST_PROCESS_VERSION;
|
|
9210
|
+
const [activeTab, setActiveTab] = (0, import_react67.useState)("crop");
|
|
9211
|
+
const rootRef = (0, import_react67.useRef)(null);
|
|
8891
9212
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
8892
|
-
const activeTabRef = (0,
|
|
9213
|
+
const activeTabRef = (0, import_react67.useRef)(activeTab);
|
|
8893
9214
|
activeTabRef.current = activeTab;
|
|
8894
9215
|
const openPanel = async (ref) => {
|
|
8895
9216
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
8896
9217
|
rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
|
|
8897
9218
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
8898
9219
|
};
|
|
8899
|
-
const [activeCropRatio, setActiveCropRatio] = (0,
|
|
8900
|
-
const [selectionOptions, setSelectionOptions] = (0,
|
|
8901
|
-
const [shapeOptions, setShapeOptions] = (0,
|
|
8902
|
-
const [typeOptions, setTypeOptions] = (0,
|
|
8903
|
-
const [typeSession, setTypeSession] = (0,
|
|
8904
|
-
const [selectionError, setSelectionError] = (0,
|
|
8905
|
-
const [paintError, setPaintError] = (0,
|
|
8906
|
-
const [shapeTypeError, setShapeTypeError] = (0,
|
|
9220
|
+
const [activeCropRatio, setActiveCropRatio] = (0, import_react67.useState)(null);
|
|
9221
|
+
const [selectionOptions, setSelectionOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_SELECTION_TOOL_OPTIONS);
|
|
9222
|
+
const [shapeOptions, setShapeOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_SHAPE_TOOL_OPTIONS);
|
|
9223
|
+
const [typeOptions, setTypeOptions] = (0, import_react67.useState)(import_image_editor20.DEFAULT_TYPE_TOOL_OPTIONS);
|
|
9224
|
+
const [typeSession, setTypeSession] = (0, import_react67.useState)(null);
|
|
9225
|
+
const [selectionError, setSelectionError] = (0, import_react67.useState)(null);
|
|
9226
|
+
const [paintError, setPaintError] = (0, import_react67.useState)(null);
|
|
9227
|
+
const [shapeTypeError, setShapeTypeError] = (0, import_react67.useState)(null);
|
|
8907
9228
|
const handleCanvasError = (source, message2) => {
|
|
8908
9229
|
if (source === "paint") setPaintError(message2);
|
|
8909
9230
|
else if (source === "select") setSelectionError(message2);
|
|
8910
9231
|
else setShapeTypeError(message2);
|
|
8911
9232
|
};
|
|
8912
9233
|
const finishTyping = () => setTypeSession(null);
|
|
8913
|
-
const transformToolRef = (0,
|
|
8914
|
-
const transformControllerRef = (0,
|
|
9234
|
+
const transformToolRef = (0, import_react67.useRef)(null);
|
|
9235
|
+
const transformControllerRef = (0, import_react67.useRef)(controller);
|
|
8915
9236
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
8916
9237
|
transformToolRef.current?.cancel();
|
|
8917
|
-
transformToolRef.current = new
|
|
9238
|
+
transformToolRef.current = new import_image_editor20.FreeTransformTool(controller, {
|
|
8918
9239
|
schedule: (run) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(run) : run()
|
|
8919
9240
|
});
|
|
8920
9241
|
transformControllerRef.current = controller;
|
|
8921
9242
|
}
|
|
8922
9243
|
const transformTool = transformToolRef.current;
|
|
8923
|
-
const [, setTransformTick] = (0,
|
|
8924
|
-
(0,
|
|
8925
|
-
(0,
|
|
8926
|
-
const [inpaintPrompt, setInpaintPrompt] = (0,
|
|
8927
|
-
const [inpaintMaskMode, setInpaintMaskMode] = (0,
|
|
8928
|
-
const [isRemovingBg, setIsRemovingBg] = (0,
|
|
8929
|
-
const [isInpainting, setIsInpainting] = (0,
|
|
8930
|
-
const [aiError, setAiError] = (0,
|
|
8931
|
-
const [aiSuccess, setAiSuccess] = (0,
|
|
8932
|
-
const [aiTarget, setAiTarget] = (0,
|
|
9244
|
+
const [, setTransformTick] = (0, import_react67.useState)(0);
|
|
9245
|
+
(0, import_react67.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
|
|
9246
|
+
(0, import_react67.useEffect)(() => () => transformToolRef.current?.cancel(), []);
|
|
9247
|
+
const [inpaintPrompt, setInpaintPrompt] = (0, import_react67.useState)("");
|
|
9248
|
+
const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react67.useState)("annotations");
|
|
9249
|
+
const [isRemovingBg, setIsRemovingBg] = (0, import_react67.useState)(false);
|
|
9250
|
+
const [isInpainting, setIsInpainting] = (0, import_react67.useState)(false);
|
|
9251
|
+
const [aiError, setAiError] = (0, import_react67.useState)(null);
|
|
9252
|
+
const [aiSuccess, setAiSuccess] = (0, import_react67.useState)(null);
|
|
9253
|
+
const [aiTarget, setAiTarget] = (0, import_react67.useState)("auto");
|
|
8933
9254
|
const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
|
|
8934
9255
|
const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
|
|
8935
9256
|
const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
|
|
@@ -8992,11 +9313,11 @@ var ImageEditor = ({
|
|
|
8992
9313
|
setIsInpainting(false);
|
|
8993
9314
|
}
|
|
8994
9315
|
};
|
|
8995
|
-
const [activeColor, setActiveColor] = (0,
|
|
8996
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
8997
|
-
const [fontSize, setFontSize] = (0,
|
|
8998
|
-
const [textInput, setTextInput] = (0,
|
|
8999
|
-
(0,
|
|
9316
|
+
const [activeColor, setActiveColor] = (0, import_react67.useState)("#ef4444");
|
|
9317
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react67.useState)(3);
|
|
9318
|
+
const [fontSize, setFontSize] = (0, import_react67.useState)(24);
|
|
9319
|
+
const [textInput, setTextInput] = (0, import_react67.useState)("");
|
|
9320
|
+
(0, import_react67.useEffect)(() => {
|
|
9000
9321
|
if (activeTab === "crop" && editor.state.activeTool !== "crop") {
|
|
9001
9322
|
editor.setTool("crop");
|
|
9002
9323
|
}
|
|
@@ -9024,16 +9345,16 @@ var ImageEditor = ({
|
|
|
9024
9345
|
link.click();
|
|
9025
9346
|
}
|
|
9026
9347
|
};
|
|
9027
|
-
return /* @__PURE__ */ (0,
|
|
9348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9028
9349
|
"div",
|
|
9029
9350
|
{
|
|
9030
9351
|
ref: rootRef,
|
|
9031
9352
|
className: `${imageEditorFrameClass} ${className}`,
|
|
9032
9353
|
style,
|
|
9033
9354
|
children: [
|
|
9034
|
-
/* @__PURE__ */ (0,
|
|
9035
|
-
/* @__PURE__ */ (0,
|
|
9036
|
-
/* @__PURE__ */ (0,
|
|
9355
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: imageEditorHeaderClass, children: [
|
|
9356
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { role: "tablist", className: imageTabListClass, children: [
|
|
9357
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9037
9358
|
"button",
|
|
9038
9359
|
{
|
|
9039
9360
|
type: "button",
|
|
@@ -9048,7 +9369,7 @@ var ImageEditor = ({
|
|
|
9048
9369
|
children: "Transform & Crop"
|
|
9049
9370
|
}
|
|
9050
9371
|
),
|
|
9051
|
-
/* @__PURE__ */ (0,
|
|
9372
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9052
9373
|
"button",
|
|
9053
9374
|
{
|
|
9054
9375
|
type: "button",
|
|
@@ -9063,7 +9384,7 @@ var ImageEditor = ({
|
|
|
9063
9384
|
children: "Adjustments"
|
|
9064
9385
|
}
|
|
9065
9386
|
),
|
|
9066
|
-
/* @__PURE__ */ (0,
|
|
9387
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9067
9388
|
"button",
|
|
9068
9389
|
{
|
|
9069
9390
|
type: "button",
|
|
@@ -9078,7 +9399,7 @@ var ImageEditor = ({
|
|
|
9078
9399
|
children: "Layers"
|
|
9079
9400
|
}
|
|
9080
9401
|
),
|
|
9081
|
-
/* @__PURE__ */ (0,
|
|
9402
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9082
9403
|
"button",
|
|
9083
9404
|
{
|
|
9084
9405
|
type: "button",
|
|
@@ -9093,7 +9414,7 @@ var ImageEditor = ({
|
|
|
9093
9414
|
children: "Paint"
|
|
9094
9415
|
}
|
|
9095
9416
|
),
|
|
9096
|
-
/* @__PURE__ */ (0,
|
|
9417
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9097
9418
|
"button",
|
|
9098
9419
|
{
|
|
9099
9420
|
type: "button",
|
|
@@ -9108,7 +9429,7 @@ var ImageEditor = ({
|
|
|
9108
9429
|
children: "Select & Mask"
|
|
9109
9430
|
}
|
|
9110
9431
|
),
|
|
9111
|
-
/* @__PURE__ */ (0,
|
|
9432
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9112
9433
|
"button",
|
|
9113
9434
|
{
|
|
9114
9435
|
type: "button",
|
|
@@ -9123,7 +9444,7 @@ var ImageEditor = ({
|
|
|
9123
9444
|
children: "Annotations"
|
|
9124
9445
|
}
|
|
9125
9446
|
),
|
|
9126
|
-
/* @__PURE__ */ (0,
|
|
9447
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9127
9448
|
"button",
|
|
9128
9449
|
{
|
|
9129
9450
|
type: "button",
|
|
@@ -9138,7 +9459,7 @@ var ImageEditor = ({
|
|
|
9138
9459
|
children: "Depth Mask"
|
|
9139
9460
|
}
|
|
9140
9461
|
),
|
|
9141
|
-
/* @__PURE__ */ (0,
|
|
9462
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9142
9463
|
"button",
|
|
9143
9464
|
{
|
|
9144
9465
|
type: "button",
|
|
@@ -9151,14 +9472,14 @@ var ImageEditor = ({
|
|
|
9151
9472
|
"aria-selected": activeTab === "ai",
|
|
9152
9473
|
className: `${imageTabClass(activeTab === "ai")} flex items-center gap-1.5`,
|
|
9153
9474
|
children: [
|
|
9154
|
-
/* @__PURE__ */ (0,
|
|
9475
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
9155
9476
|
"AI Tools"
|
|
9156
9477
|
]
|
|
9157
9478
|
}
|
|
9158
9479
|
)
|
|
9159
9480
|
] }),
|
|
9160
|
-
/* @__PURE__ */ (0,
|
|
9161
|
-
/* @__PURE__ */ (0,
|
|
9481
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
9482
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9162
9483
|
"button",
|
|
9163
9484
|
{
|
|
9164
9485
|
type: "button",
|
|
@@ -9169,7 +9490,7 @@ var ImageEditor = ({
|
|
|
9169
9490
|
children: "\u21A9"
|
|
9170
9491
|
}
|
|
9171
9492
|
),
|
|
9172
|
-
/* @__PURE__ */ (0,
|
|
9493
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9173
9494
|
"button",
|
|
9174
9495
|
{
|
|
9175
9496
|
type: "button",
|
|
@@ -9180,7 +9501,7 @@ var ImageEditor = ({
|
|
|
9180
9501
|
children: "\u21AA"
|
|
9181
9502
|
}
|
|
9182
9503
|
),
|
|
9183
|
-
/* @__PURE__ */ (0,
|
|
9504
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9184
9505
|
"button",
|
|
9185
9506
|
{
|
|
9186
9507
|
type: "button",
|
|
@@ -9189,8 +9510,8 @@ var ImageEditor = ({
|
|
|
9189
9510
|
children: "Reset"
|
|
9190
9511
|
}
|
|
9191
9512
|
),
|
|
9192
|
-
/* @__PURE__ */ (0,
|
|
9193
|
-
/* @__PURE__ */ (0,
|
|
9513
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
9514
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9194
9515
|
"button",
|
|
9195
9516
|
{
|
|
9196
9517
|
type: "button",
|
|
@@ -9200,11 +9521,11 @@ var ImageEditor = ({
|
|
|
9200
9521
|
children: "-"
|
|
9201
9522
|
}
|
|
9202
9523
|
),
|
|
9203
|
-
/* @__PURE__ */ (0,
|
|
9524
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono text-muted-foreground w-10 text-center", children: [
|
|
9204
9525
|
Math.round(state.zoom * 100),
|
|
9205
9526
|
"%"
|
|
9206
9527
|
] }),
|
|
9207
|
-
/* @__PURE__ */ (0,
|
|
9528
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9208
9529
|
"button",
|
|
9209
9530
|
{
|
|
9210
9531
|
type: "button",
|
|
@@ -9214,8 +9535,8 @@ var ImageEditor = ({
|
|
|
9214
9535
|
children: "+"
|
|
9215
9536
|
}
|
|
9216
9537
|
),
|
|
9217
|
-
/* @__PURE__ */ (0,
|
|
9218
|
-
/* @__PURE__ */ (0,
|
|
9538
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "h-4 w-px bg-muted mx-1" }),
|
|
9539
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9219
9540
|
"button",
|
|
9220
9541
|
{
|
|
9221
9542
|
type: "button",
|
|
@@ -9226,7 +9547,7 @@ var ImageEditor = ({
|
|
|
9226
9547
|
children: "Hold Compare"
|
|
9227
9548
|
}
|
|
9228
9549
|
),
|
|
9229
|
-
/* @__PURE__ */ (0,
|
|
9550
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9230
9551
|
"button",
|
|
9231
9552
|
{
|
|
9232
9553
|
type: "button",
|
|
@@ -9237,10 +9558,10 @@ var ImageEditor = ({
|
|
|
9237
9558
|
)
|
|
9238
9559
|
] })
|
|
9239
9560
|
] }),
|
|
9240
|
-
transformTool.active && /* @__PURE__ */ (0,
|
|
9241
|
-
!transformTool.active && transformTool.error && /* @__PURE__ */ (0,
|
|
9242
|
-
/* @__PURE__ */ (0,
|
|
9243
|
-
/* @__PURE__ */ (0,
|
|
9561
|
+
transformTool.active && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FreeTransformOptionsBar, { tool: transformTool, className: "border-b border-border bg-background/95 px-4 py-2" }),
|
|
9562
|
+
!transformTool.active && transformTool.error && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { role: "alert", className: imageErrorBannerClass, children: transformTool.error }),
|
|
9563
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
|
|
9564
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9244
9565
|
ImageEditorCanvas,
|
|
9245
9566
|
{
|
|
9246
9567
|
editor,
|
|
@@ -9264,11 +9585,11 @@ var ImageEditor = ({
|
|
|
9264
9585
|
className: "flex-1 h-[360px] md:h-full min-h-[320px] bg-muted"
|
|
9265
9586
|
}
|
|
9266
9587
|
),
|
|
9267
|
-
/* @__PURE__ */ (0,
|
|
9268
|
-
activeTab === "crop" && /* @__PURE__ */ (0,
|
|
9269
|
-
/* @__PURE__ */ (0,
|
|
9270
|
-
/* @__PURE__ */ (0,
|
|
9271
|
-
/* @__PURE__ */ (0,
|
|
9588
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: imageSidebarClass, children: [
|
|
9589
|
+
activeTab === "crop" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
9590
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Aspect Ratio Presets" }),
|
|
9591
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-3 gap-2", children: [
|
|
9592
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9272
9593
|
"button",
|
|
9273
9594
|
{
|
|
9274
9595
|
type: "button",
|
|
@@ -9280,7 +9601,7 @@ var ImageEditor = ({
|
|
|
9280
9601
|
children: "Freeform"
|
|
9281
9602
|
}
|
|
9282
9603
|
),
|
|
9283
|
-
/* @__PURE__ */ (0,
|
|
9604
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9284
9605
|
"button",
|
|
9285
9606
|
{
|
|
9286
9607
|
type: "button",
|
|
@@ -9292,7 +9613,7 @@ var ImageEditor = ({
|
|
|
9292
9613
|
children: "1:1 Square"
|
|
9293
9614
|
}
|
|
9294
9615
|
),
|
|
9295
|
-
/* @__PURE__ */ (0,
|
|
9616
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9296
9617
|
"button",
|
|
9297
9618
|
{
|
|
9298
9619
|
type: "button",
|
|
@@ -9304,7 +9625,7 @@ var ImageEditor = ({
|
|
|
9304
9625
|
children: "4:3 Standard"
|
|
9305
9626
|
}
|
|
9306
9627
|
),
|
|
9307
|
-
/* @__PURE__ */ (0,
|
|
9628
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9308
9629
|
"button",
|
|
9309
9630
|
{
|
|
9310
9631
|
type: "button",
|
|
@@ -9316,7 +9637,7 @@ var ImageEditor = ({
|
|
|
9316
9637
|
children: "16:9 Wide"
|
|
9317
9638
|
}
|
|
9318
9639
|
),
|
|
9319
|
-
/* @__PURE__ */ (0,
|
|
9640
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9320
9641
|
"button",
|
|
9321
9642
|
{
|
|
9322
9643
|
type: "button",
|
|
@@ -9328,7 +9649,7 @@ var ImageEditor = ({
|
|
|
9328
9649
|
children: "3:2 Photo"
|
|
9329
9650
|
}
|
|
9330
9651
|
),
|
|
9331
|
-
/* @__PURE__ */ (0,
|
|
9652
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9332
9653
|
"button",
|
|
9333
9654
|
{
|
|
9334
9655
|
type: "button",
|
|
@@ -9341,10 +9662,10 @@ var ImageEditor = ({
|
|
|
9341
9662
|
}
|
|
9342
9663
|
)
|
|
9343
9664
|
] }),
|
|
9344
|
-
/* @__PURE__ */ (0,
|
|
9345
|
-
/* @__PURE__ */ (0,
|
|
9346
|
-
/* @__PURE__ */ (0,
|
|
9347
|
-
/* @__PURE__ */ (0,
|
|
9665
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9666
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Orientation & Flips" }),
|
|
9667
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
9668
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9348
9669
|
"button",
|
|
9349
9670
|
{
|
|
9350
9671
|
type: "button",
|
|
@@ -9353,7 +9674,7 @@ var ImageEditor = ({
|
|
|
9353
9674
|
children: "Rotate -90\xB0"
|
|
9354
9675
|
}
|
|
9355
9676
|
),
|
|
9356
|
-
/* @__PURE__ */ (0,
|
|
9677
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9357
9678
|
"button",
|
|
9358
9679
|
{
|
|
9359
9680
|
type: "button",
|
|
@@ -9362,7 +9683,7 @@ var ImageEditor = ({
|
|
|
9362
9683
|
children: "Rotate +90\xB0"
|
|
9363
9684
|
}
|
|
9364
9685
|
),
|
|
9365
|
-
/* @__PURE__ */ (0,
|
|
9686
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9366
9687
|
"button",
|
|
9367
9688
|
{
|
|
9368
9689
|
type: "button",
|
|
@@ -9371,7 +9692,7 @@ var ImageEditor = ({
|
|
|
9371
9692
|
children: "Flip Horizontal"
|
|
9372
9693
|
}
|
|
9373
9694
|
),
|
|
9374
|
-
/* @__PURE__ */ (0,
|
|
9695
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9375
9696
|
"button",
|
|
9376
9697
|
{
|
|
9377
9698
|
type: "button",
|
|
@@ -9382,10 +9703,10 @@ var ImageEditor = ({
|
|
|
9382
9703
|
)
|
|
9383
9704
|
] })
|
|
9384
9705
|
] }),
|
|
9385
|
-
activeTab === "adjust" && /* @__PURE__ */ (0,
|
|
9386
|
-
/* @__PURE__ */ (0,
|
|
9387
|
-
/* @__PURE__ */ (0,
|
|
9388
|
-
/* @__PURE__ */ (0,
|
|
9706
|
+
activeTab === "adjust" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9707
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9708
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Color Adjustments" }),
|
|
9709
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9389
9710
|
"button",
|
|
9390
9711
|
{
|
|
9391
9712
|
type: "button",
|
|
@@ -9395,25 +9716,25 @@ var ImageEditor = ({
|
|
|
9395
9716
|
}
|
|
9396
9717
|
)
|
|
9397
9718
|
] }),
|
|
9398
|
-
/* @__PURE__ */ (0,
|
|
9399
|
-
|
|
9400
|
-
/* @__PURE__ */ (0,
|
|
9719
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Histogram, { histogram: editor.histogram }),
|
|
9720
|
+
import_image_editor20.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_react67.default.Fragment, { children: [
|
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9401
9722
|
ControlSlider,
|
|
9402
9723
|
{
|
|
9403
9724
|
spec,
|
|
9404
|
-
value: (0,
|
|
9725
|
+
value: (0, import_image_editor20.readAdjustmentControls)(state.adjustments)[spec.id],
|
|
9405
9726
|
disabled: spec.requiresProcess !== void 0 && legacyProcess,
|
|
9406
9727
|
onChange: (v) => editor.setAdjustments({ [spec.id]: v })
|
|
9407
9728
|
}
|
|
9408
9729
|
),
|
|
9409
|
-
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0,
|
|
9730
|
+
spec.id === "tint" && legacyProcess && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9410
9731
|
"div",
|
|
9411
9732
|
{
|
|
9412
9733
|
className: "flex items-center justify-between gap-2 rounded border border-amber-500/30 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-600",
|
|
9413
9734
|
"data-testid": "image-editor-process-notice",
|
|
9414
9735
|
children: [
|
|
9415
|
-
/* @__PURE__ */ (0,
|
|
9416
|
-
/* @__PURE__ */ (0,
|
|
9736
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Legacy rendering (process 1). Tint needs the current process." }),
|
|
9737
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9417
9738
|
"button",
|
|
9418
9739
|
{
|
|
9419
9740
|
type: "button",
|
|
@@ -9426,7 +9747,7 @@ var ImageEditor = ({
|
|
|
9426
9747
|
}
|
|
9427
9748
|
)
|
|
9428
9749
|
] }, spec.id)),
|
|
9429
|
-
/* @__PURE__ */ (0,
|
|
9750
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9430
9751
|
AdjustmentLayersPanel,
|
|
9431
9752
|
{
|
|
9432
9753
|
controller,
|
|
@@ -9435,9 +9756,9 @@ var ImageEditor = ({
|
|
|
9435
9756
|
}
|
|
9436
9757
|
) })
|
|
9437
9758
|
] }),
|
|
9438
|
-
activeTab === "layers" && /* @__PURE__ */ (0,
|
|
9439
|
-
/* @__PURE__ */ (0,
|
|
9440
|
-
/* @__PURE__ */ (0,
|
|
9759
|
+
activeTab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9760
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Layers" }),
|
|
9761
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9441
9762
|
"button",
|
|
9442
9763
|
{
|
|
9443
9764
|
type: "button",
|
|
@@ -9448,15 +9769,15 @@ var ImageEditor = ({
|
|
|
9448
9769
|
children: "Free Transform"
|
|
9449
9770
|
}
|
|
9450
9771
|
),
|
|
9451
|
-
/* @__PURE__ */ (0,
|
|
9452
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
9453
|
-
/* @__PURE__ */ (0,
|
|
9454
|
-
/* @__PURE__ */ (0,
|
|
9772
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LayersPanel, { controller }),
|
|
9773
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ImageProviderEffectsPanel, { controller, className: imageSectionClass }),
|
|
9774
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Colour" }),
|
|
9775
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ColorProfilePanel, { controller })
|
|
9455
9776
|
] }),
|
|
9456
|
-
activeTab === "paint" && /* @__PURE__ */ (0,
|
|
9457
|
-
/* @__PURE__ */ (0,
|
|
9458
|
-
/* @__PURE__ */ (0,
|
|
9459
|
-
/* @__PURE__ */ (0,
|
|
9777
|
+
activeTab === "paint" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9778
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Paint" }),
|
|
9779
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrushOptionsBar, { controller }),
|
|
9780
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9460
9781
|
"button",
|
|
9461
9782
|
{
|
|
9462
9783
|
type: "button",
|
|
@@ -9467,12 +9788,12 @@ var ImageEditor = ({
|
|
|
9467
9788
|
children: "Free Transform"
|
|
9468
9789
|
}
|
|
9469
9790
|
),
|
|
9470
|
-
paintError && /* @__PURE__ */ (0,
|
|
9471
|
-
/* @__PURE__ */ (0,
|
|
9791
|
+
paintError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "paint-error", children: paintError }),
|
|
9792
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSectionClass, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LayersPanel, { controller }) })
|
|
9472
9793
|
] }),
|
|
9473
|
-
activeTab === "annotate" && /* @__PURE__ */ (0,
|
|
9474
|
-
/* @__PURE__ */ (0,
|
|
9475
|
-
/* @__PURE__ */ (0,
|
|
9794
|
+
activeTab === "annotate" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9795
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Shape & Type Layers" }),
|
|
9796
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "grid grid-cols-2 gap-1.5", children: ["shape", "type"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9476
9797
|
"button",
|
|
9477
9798
|
{
|
|
9478
9799
|
type: "button",
|
|
@@ -9483,13 +9804,13 @@ var ImageEditor = ({
|
|
|
9483
9804
|
},
|
|
9484
9805
|
t
|
|
9485
9806
|
)) }),
|
|
9486
|
-
state.activeTool === "shape" && /* @__PURE__ */ (0,
|
|
9487
|
-
state.activeTool === "type" && /* @__PURE__ */ (0,
|
|
9488
|
-
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0,
|
|
9489
|
-
shapeTypeError && /* @__PURE__ */ (0,
|
|
9490
|
-
/* @__PURE__ */ (0,
|
|
9491
|
-
/* @__PURE__ */ (0,
|
|
9492
|
-
/* @__PURE__ */ (0,
|
|
9807
|
+
state.activeTool === "shape" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ShapeOptionsBar, { controller, options: shapeOptions, onChange: setShapeOptions }),
|
|
9808
|
+
state.activeTool === "type" && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(TypeOptionsBar, { controller, options: typeOptions, onChange: setTypeOptions, session: typeSession }),
|
|
9809
|
+
state.activeTool === "type" && typeSession && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", onClick: finishTyping, className: "self-start rounded bg-muted px-2 py-1 text-[11px] text-foreground hover:bg-accent", children: "Done editing text" }),
|
|
9810
|
+
shapeTypeError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", "data-testid": "shape-type-error", children: shapeTypeError }),
|
|
9811
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9812
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Draw & Annotate" }),
|
|
9813
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9493
9814
|
"button",
|
|
9494
9815
|
{
|
|
9495
9816
|
type: "button",
|
|
@@ -9499,18 +9820,18 @@ var ImageEditor = ({
|
|
|
9499
9820
|
},
|
|
9500
9821
|
t
|
|
9501
9822
|
)) }),
|
|
9502
|
-
/* @__PURE__ */ (0,
|
|
9503
|
-
/* @__PURE__ */ (0,
|
|
9504
|
-
/* @__PURE__ */ (0,
|
|
9505
|
-
/* @__PURE__ */ (0,
|
|
9506
|
-
/* @__PURE__ */ (0,
|
|
9507
|
-
/* @__PURE__ */ (0,
|
|
9508
|
-
/* @__PURE__ */ (0,
|
|
9823
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
|
|
9824
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
|
|
9825
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
|
|
9826
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex-1 ml-2", children: [
|
|
9827
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
|
|
9828
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Width:" }),
|
|
9829
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9509
9830
|
strokeWidth,
|
|
9510
9831
|
"px"
|
|
9511
9832
|
] })
|
|
9512
9833
|
] }),
|
|
9513
|
-
/* @__PURE__ */ (0,
|
|
9834
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9514
9835
|
"input",
|
|
9515
9836
|
{
|
|
9516
9837
|
type: "range",
|
|
@@ -9523,10 +9844,10 @@ var ImageEditor = ({
|
|
|
9523
9844
|
)
|
|
9524
9845
|
] })
|
|
9525
9846
|
] }),
|
|
9526
|
-
/* @__PURE__ */ (0,
|
|
9527
|
-
/* @__PURE__ */ (0,
|
|
9528
|
-
/* @__PURE__ */ (0,
|
|
9529
|
-
/* @__PURE__ */ (0,
|
|
9847
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9848
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Add Text" }),
|
|
9849
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-2", children: [
|
|
9850
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9530
9851
|
"input",
|
|
9531
9852
|
{
|
|
9532
9853
|
type: "text",
|
|
@@ -9537,7 +9858,7 @@ var ImageEditor = ({
|
|
|
9537
9858
|
className: "flex-1 bg-background border border-border rounded-lg px-2.5 py-1.5 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary"
|
|
9538
9859
|
}
|
|
9539
9860
|
),
|
|
9540
|
-
/* @__PURE__ */ (0,
|
|
9861
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9541
9862
|
"button",
|
|
9542
9863
|
{
|
|
9543
9864
|
type: "button",
|
|
@@ -9547,14 +9868,14 @@ var ImageEditor = ({
|
|
|
9547
9868
|
}
|
|
9548
9869
|
)
|
|
9549
9870
|
] }),
|
|
9550
|
-
/* @__PURE__ */ (0,
|
|
9551
|
-
/* @__PURE__ */ (0,
|
|
9552
|
-
/* @__PURE__ */ (0,
|
|
9871
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between text-muted-foreground", children: [
|
|
9872
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Font Size:" }),
|
|
9873
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-mono", children: [
|
|
9553
9874
|
fontSize,
|
|
9554
9875
|
"px"
|
|
9555
9876
|
] })
|
|
9556
9877
|
] }),
|
|
9557
|
-
/* @__PURE__ */ (0,
|
|
9878
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9558
9879
|
"input",
|
|
9559
9880
|
{
|
|
9560
9881
|
type: "range",
|
|
@@ -9565,14 +9886,14 @@ var ImageEditor = ({
|
|
|
9565
9886
|
className: imageRangeClass
|
|
9566
9887
|
}
|
|
9567
9888
|
),
|
|
9568
|
-
/* @__PURE__ */ (0,
|
|
9569
|
-
/* @__PURE__ */ (0,
|
|
9570
|
-
/* @__PURE__ */ (0,
|
|
9889
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageDividerClass }),
|
|
9890
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9891
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
9571
9892
|
"Layers (",
|
|
9572
9893
|
state.annotations.length,
|
|
9573
9894
|
")"
|
|
9574
9895
|
] }),
|
|
9575
|
-
state.selectedAnnotationId && /* @__PURE__ */ (0,
|
|
9896
|
+
state.selectedAnnotationId && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9576
9897
|
"button",
|
|
9577
9898
|
{
|
|
9578
9899
|
type: "button",
|
|
@@ -9581,7 +9902,7 @@ var ImageEditor = ({
|
|
|
9581
9902
|
children: "Delete Selected"
|
|
9582
9903
|
}
|
|
9583
9904
|
),
|
|
9584
|
-
state.annotations.length > 0 && /* @__PURE__ */ (0,
|
|
9905
|
+
state.annotations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9585
9906
|
"button",
|
|
9586
9907
|
{
|
|
9587
9908
|
type: "button",
|
|
@@ -9592,10 +9913,10 @@ var ImageEditor = ({
|
|
|
9592
9913
|
)
|
|
9593
9914
|
] })
|
|
9594
9915
|
] }),
|
|
9595
|
-
activeTab === "depth" && /* @__PURE__ */ (0,
|
|
9596
|
-
/* @__PURE__ */ (0,
|
|
9597
|
-
/* @__PURE__ */ (0,
|
|
9598
|
-
/* @__PURE__ */ (0,
|
|
9916
|
+
activeTab === "depth" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-3 text-xs", children: [
|
|
9917
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
9918
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: imageSectionTitleClass, children: "Depth Masking" }),
|
|
9919
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9599
9920
|
"button",
|
|
9600
9921
|
{
|
|
9601
9922
|
type: "button",
|
|
@@ -9605,8 +9926,8 @@ var ImageEditor = ({
|
|
|
9605
9926
|
}
|
|
9606
9927
|
)
|
|
9607
9928
|
] }),
|
|
9608
|
-
/* @__PURE__ */ (0,
|
|
9609
|
-
/* @__PURE__ */ (0,
|
|
9929
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground", children: [
|
|
9930
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9610
9931
|
"input",
|
|
9611
9932
|
{
|
|
9612
9933
|
type: "checkbox",
|
|
@@ -9615,12 +9936,12 @@ var ImageEditor = ({
|
|
|
9615
9936
|
className: "rounded accent-primary"
|
|
9616
9937
|
}
|
|
9617
9938
|
),
|
|
9618
|
-
/* @__PURE__ */ (0,
|
|
9939
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Enable Depth / Alpha Mask" })
|
|
9619
9940
|
] }),
|
|
9620
|
-
state.depthMask.enabled && /* @__PURE__ */ (0,
|
|
9621
|
-
/* @__PURE__ */ (0,
|
|
9622
|
-
/* @__PURE__ */ (0,
|
|
9623
|
-
/* @__PURE__ */ (0,
|
|
9941
|
+
state.depthMask.enabled && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
9942
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9943
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { className: "text-muted-foreground block mb-1", children: "Mask Image URL:" }),
|
|
9944
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9624
9945
|
"input",
|
|
9625
9946
|
{
|
|
9626
9947
|
type: "text",
|
|
@@ -9631,8 +9952,8 @@ var ImageEditor = ({
|
|
|
9631
9952
|
}
|
|
9632
9953
|
)
|
|
9633
9954
|
] }),
|
|
9634
|
-
/* @__PURE__ */ (0,
|
|
9635
|
-
/* @__PURE__ */ (0,
|
|
9955
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-2", children: [
|
|
9956
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9636
9957
|
"button",
|
|
9637
9958
|
{
|
|
9638
9959
|
type: "button",
|
|
@@ -9641,7 +9962,7 @@ var ImageEditor = ({
|
|
|
9641
9962
|
children: "Threshold Mode"
|
|
9642
9963
|
}
|
|
9643
9964
|
),
|
|
9644
|
-
/* @__PURE__ */ (0,
|
|
9965
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9645
9966
|
"button",
|
|
9646
9967
|
{
|
|
9647
9968
|
type: "button",
|
|
@@ -9651,12 +9972,12 @@ var ImageEditor = ({
|
|
|
9651
9972
|
}
|
|
9652
9973
|
)
|
|
9653
9974
|
] }),
|
|
9654
|
-
/* @__PURE__ */ (0,
|
|
9655
|
-
/* @__PURE__ */ (0,
|
|
9656
|
-
/* @__PURE__ */ (0,
|
|
9657
|
-
/* @__PURE__ */ (0,
|
|
9975
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9976
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
9977
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Depth Start (Lower):" }),
|
|
9978
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
|
|
9658
9979
|
] }),
|
|
9659
|
-
/* @__PURE__ */ (0,
|
|
9980
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9660
9981
|
"input",
|
|
9661
9982
|
{
|
|
9662
9983
|
type: "range",
|
|
@@ -9670,12 +9991,12 @@ var ImageEditor = ({
|
|
|
9670
9991
|
}
|
|
9671
9992
|
)
|
|
9672
9993
|
] }),
|
|
9673
|
-
/* @__PURE__ */ (0,
|
|
9674
|
-
/* @__PURE__ */ (0,
|
|
9675
|
-
/* @__PURE__ */ (0,
|
|
9676
|
-
/* @__PURE__ */ (0,
|
|
9994
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
9995
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
9996
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Depth Stop (Upper):" }),
|
|
9997
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
|
|
9677
9998
|
] }),
|
|
9678
|
-
/* @__PURE__ */ (0,
|
|
9999
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9679
10000
|
"input",
|
|
9680
10001
|
{
|
|
9681
10002
|
type: "range",
|
|
@@ -9689,12 +10010,12 @@ var ImageEditor = ({
|
|
|
9689
10010
|
}
|
|
9690
10011
|
)
|
|
9691
10012
|
] }),
|
|
9692
|
-
/* @__PURE__ */ (0,
|
|
9693
|
-
/* @__PURE__ */ (0,
|
|
9694
|
-
/* @__PURE__ */ (0,
|
|
9695
|
-
/* @__PURE__ */ (0,
|
|
10013
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
10014
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-1", children: [
|
|
10015
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Softness:" }),
|
|
10016
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "font-mono", children: state.depthMask.softness })
|
|
9696
10017
|
] }),
|
|
9697
|
-
/* @__PURE__ */ (0,
|
|
10018
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9698
10019
|
"input",
|
|
9699
10020
|
{
|
|
9700
10021
|
type: "range",
|
|
@@ -9706,8 +10027,8 @@ var ImageEditor = ({
|
|
|
9706
10027
|
}
|
|
9707
10028
|
)
|
|
9708
10029
|
] }),
|
|
9709
|
-
/* @__PURE__ */ (0,
|
|
9710
|
-
/* @__PURE__ */ (0,
|
|
10030
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer text-foreground mt-1", children: [
|
|
10031
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9711
10032
|
"input",
|
|
9712
10033
|
{
|
|
9713
10034
|
type: "checkbox",
|
|
@@ -9716,24 +10037,25 @@ var ImageEditor = ({
|
|
|
9716
10037
|
className: "rounded accent-primary"
|
|
9717
10038
|
}
|
|
9718
10039
|
),
|
|
9719
|
-
/* @__PURE__ */ (0,
|
|
10040
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Invert Mask" })
|
|
9720
10041
|
] })
|
|
9721
10042
|
] })
|
|
9722
10043
|
] }),
|
|
9723
|
-
activeTab === "select" && /* @__PURE__ */ (0,
|
|
9724
|
-
/* @__PURE__ */ (0,
|
|
10044
|
+
activeTab === "select" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10045
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9725
10046
|
SelectionOptionsBar,
|
|
9726
10047
|
{
|
|
9727
10048
|
controller,
|
|
9728
10049
|
options: selectionOptions,
|
|
9729
10050
|
onOptionsChange: setSelectionOptions,
|
|
9730
10051
|
selection: state.selection ?? null,
|
|
9731
|
-
quickMask: Boolean(state.quickMask)
|
|
10052
|
+
quickMask: Boolean(state.quickMask),
|
|
10053
|
+
selectionDisplay: state.selectionDisplay
|
|
9732
10054
|
}
|
|
9733
10055
|
),
|
|
9734
|
-
selectionError && /* @__PURE__ */ (0,
|
|
9735
|
-
/* @__PURE__ */ (0,
|
|
9736
|
-
/* @__PURE__ */ (0,
|
|
10056
|
+
selectionError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { role: "alert", className: "text-destructive", children: selectionError }),
|
|
10057
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex gap-1", children: [
|
|
10058
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9737
10059
|
"button",
|
|
9738
10060
|
{
|
|
9739
10061
|
type: "button",
|
|
@@ -9744,7 +10066,7 @@ var ImageEditor = ({
|
|
|
9744
10066
|
children: "Transform Selection"
|
|
9745
10067
|
}
|
|
9746
10068
|
),
|
|
9747
|
-
/* @__PURE__ */ (0,
|
|
10069
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9748
10070
|
"button",
|
|
9749
10071
|
{
|
|
9750
10072
|
type: "button",
|
|
@@ -9756,12 +10078,13 @@ var ImageEditor = ({
|
|
|
9756
10078
|
}
|
|
9757
10079
|
)
|
|
9758
10080
|
] }),
|
|
9759
|
-
/* @__PURE__ */ (0,
|
|
10081
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RefineEdgePanel, { controller, selection: state.selection ?? null, layers: state.adjustments.layers }),
|
|
10082
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ChannelsPanel, { controller })
|
|
9760
10083
|
] }),
|
|
9761
|
-
activeTab === "ai" && /* @__PURE__ */ (0,
|
|
9762
|
-
/* @__PURE__ */ (0,
|
|
9763
|
-
/* @__PURE__ */ (0,
|
|
9764
|
-
/* @__PURE__ */ (0,
|
|
10084
|
+
activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-4 text-xs", children: [
|
|
10085
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { className: "flex items-center justify-between gap-2 text-foreground", children: [
|
|
10086
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "Results go to" }),
|
|
10087
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9765
10088
|
"select",
|
|
9766
10089
|
{
|
|
9767
10090
|
"aria-label": "AI result target",
|
|
@@ -9769,54 +10092,54 @@ var ImageEditor = ({
|
|
|
9769
10092
|
onChange: (e) => setAiTarget(e.target.value),
|
|
9770
10093
|
className: imageSelectClass,
|
|
9771
10094
|
children: [
|
|
9772
|
-
/* @__PURE__ */ (0,
|
|
9773
|
-
/* @__PURE__ */ (0,
|
|
9774
|
-
/* @__PURE__ */ (0,
|
|
10095
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "auto", children: controller.isMultiLayer ? "Auto (new layer)" : "Auto (replace image)" }),
|
|
10096
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "new-layer", children: "New layer / mask" }),
|
|
10097
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "replace", children: "Replace image" })
|
|
9775
10098
|
]
|
|
9776
10099
|
}
|
|
9777
10100
|
)
|
|
9778
10101
|
] }),
|
|
9779
|
-
/* @__PURE__ */ (0,
|
|
9780
|
-
/* @__PURE__ */ (0,
|
|
9781
|
-
/* @__PURE__ */ (0,
|
|
9782
|
-
/* @__PURE__ */ (0,
|
|
10102
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
10103
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10104
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
10105
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" }) }),
|
|
9783
10106
|
"Background Removal"
|
|
9784
10107
|
] }),
|
|
9785
|
-
isRemovingBg && /* @__PURE__ */ (0,
|
|
10108
|
+
isRemovingBg && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-primary/15 text-primary animate-pulse", children: "Removing..." })
|
|
9786
10109
|
] }),
|
|
9787
|
-
/* @__PURE__ */ (0,
|
|
9788
|
-
/* @__PURE__ */ (0,
|
|
10110
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Isolate foreground subject with AI alpha transparency segmentation." }),
|
|
10111
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9789
10112
|
"button",
|
|
9790
10113
|
{
|
|
9791
10114
|
type: "button",
|
|
9792
10115
|
onClick: handleRemoveBackground,
|
|
9793
10116
|
disabled: isRemovingBg || isInpainting,
|
|
9794
10117
|
className: "mt-1 px-3 py-2 rounded-lg bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground font-medium shadow transition-colors flex items-center justify-center gap-2",
|
|
9795
|
-
children: isRemovingBg ? /* @__PURE__ */ (0,
|
|
9796
|
-
/* @__PURE__ */ (0,
|
|
10118
|
+
children: isRemovingBg ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10119
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSpinnerClass }),
|
|
9797
10120
|
"Removing Background..."
|
|
9798
|
-
] }) : /* @__PURE__ */ (0,
|
|
9799
|
-
/* @__PURE__ */ (0,
|
|
10121
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10122
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
9800
10123
|
"Remove Background"
|
|
9801
10124
|
] })
|
|
9802
10125
|
}
|
|
9803
10126
|
)
|
|
9804
10127
|
] }),
|
|
9805
|
-
/* @__PURE__ */ (0,
|
|
9806
|
-
/* @__PURE__ */ (0,
|
|
9807
|
-
/* @__PURE__ */ (0,
|
|
9808
|
-
/* @__PURE__ */ (0,
|
|
9809
|
-
/* @__PURE__ */ (0,
|
|
9810
|
-
/* @__PURE__ */ (0,
|
|
10128
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "p-3 rounded-lg bg-muted/40 border border-border flex flex-col gap-2.5", children: [
|
|
10129
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
10130
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("span", { className: "font-semibold text-foreground uppercase tracking-wider text-[11px] flex items-center gap-1.5", children: [
|
|
10131
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("svg", { className: "w-3.5 h-3.5 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
10132
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "m21.64 3.64-1.28-1.28a1.2 1.2 0 0 0-1.7 0l-9.72 9.72-1.94 4.86 4.86-1.94 9.72-9.72a1.2 1.2 0 0 0 .06-1.64z" }),
|
|
10133
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "m14 7 3 3" })
|
|
9811
10134
|
] }),
|
|
9812
10135
|
"Generative Inpainting"
|
|
9813
10136
|
] }),
|
|
9814
|
-
isInpainting && /* @__PURE__ */ (0,
|
|
10137
|
+
isInpainting && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-primary/15 text-primary animate-pulse", children: "Inpainting..." })
|
|
9815
10138
|
] }),
|
|
9816
|
-
/* @__PURE__ */ (0,
|
|
9817
|
-
/* @__PURE__ */ (0,
|
|
9818
|
-
/* @__PURE__ */ (0,
|
|
9819
|
-
/* @__PURE__ */ (0,
|
|
10139
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "text-muted-foreground text-[11px] leading-relaxed", children: "Replace, modify, or fill selected regions using prompt-guided generative inpainting." }),
|
|
10140
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
10141
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("label", { htmlFor: "ai-inpaint-prompt-react", className: "text-foreground text-[11px] font-medium", children: "Prompt" }),
|
|
10142
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9820
10143
|
"textarea",
|
|
9821
10144
|
{
|
|
9822
10145
|
id: "ai-inpaint-prompt-react",
|
|
@@ -9828,10 +10151,10 @@ var ImageEditor = ({
|
|
|
9828
10151
|
}
|
|
9829
10152
|
)
|
|
9830
10153
|
] }),
|
|
9831
|
-
/* @__PURE__ */ (0,
|
|
9832
|
-
/* @__PURE__ */ (0,
|
|
9833
|
-
/* @__PURE__ */ (0,
|
|
9834
|
-
/* @__PURE__ */ (0,
|
|
10154
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
10155
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-foreground text-[11px] font-medium", children: "Target Mask Region" }),
|
|
10156
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
|
|
10157
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9835
10158
|
"button",
|
|
9836
10159
|
{
|
|
9837
10160
|
type: "button",
|
|
@@ -9844,7 +10167,7 @@ var ImageEditor = ({
|
|
|
9844
10167
|
]
|
|
9845
10168
|
}
|
|
9846
10169
|
),
|
|
9847
|
-
/* @__PURE__ */ (0,
|
|
10170
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
9848
10171
|
"button",
|
|
9849
10172
|
{
|
|
9850
10173
|
type: "button",
|
|
@@ -9859,25 +10182,25 @@ var ImageEditor = ({
|
|
|
9859
10182
|
)
|
|
9860
10183
|
] })
|
|
9861
10184
|
] }),
|
|
9862
|
-
/* @__PURE__ */ (0,
|
|
10185
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
9863
10186
|
"button",
|
|
9864
10187
|
{
|
|
9865
10188
|
type: "button",
|
|
9866
10189
|
onClick: handleInpaint,
|
|
9867
10190
|
disabled: isInpainting || isRemovingBg || !inpaintPrompt.trim(),
|
|
9868
10191
|
className: "mt-1 px-3 py-2 rounded-lg bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground font-medium shadow transition-colors flex items-center justify-center gap-2",
|
|
9869
|
-
children: isInpainting ? /* @__PURE__ */ (0,
|
|
9870
|
-
/* @__PURE__ */ (0,
|
|
10192
|
+
children: isInpainting ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10193
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: imageSpinnerClass }),
|
|
9871
10194
|
"Generating Inpaint..."
|
|
9872
|
-
] }) : /* @__PURE__ */ (0,
|
|
9873
|
-
/* @__PURE__ */ (0,
|
|
10195
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10196
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("svg", { className: "w-3.5 h-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }),
|
|
9874
10197
|
"Apply Inpainting"
|
|
9875
10198
|
] })
|
|
9876
10199
|
}
|
|
9877
10200
|
)
|
|
9878
10201
|
] }),
|
|
9879
|
-
aiError && /* @__PURE__ */ (0,
|
|
9880
|
-
aiSuccess && /* @__PURE__ */ (0,
|
|
10202
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "p-2.5 rounded-lg bg-destructive/10 border border-destructive/40 text-destructive text-[11px]", children: aiError }),
|
|
10203
|
+
aiSuccess && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "p-2.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-600 text-[11px]", children: aiSuccess })
|
|
9881
10204
|
] })
|
|
9882
10205
|
] })
|
|
9883
10206
|
] })
|
|
@@ -9887,7 +10210,7 @@ var ImageEditor = ({
|
|
|
9887
10210
|
};
|
|
9888
10211
|
|
|
9889
10212
|
// src/review/useReview.ts
|
|
9890
|
-
var
|
|
10213
|
+
var import_react68 = require("react");
|
|
9891
10214
|
var import_editor13 = require("@pixerate/editor");
|
|
9892
10215
|
var EMPTY_COMMENTS = Object.freeze({
|
|
9893
10216
|
threads: [],
|
|
@@ -9906,23 +10229,23 @@ function isCommentStore(value) {
|
|
|
9906
10229
|
}
|
|
9907
10230
|
function useComments(source) {
|
|
9908
10231
|
const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
|
|
9909
|
-
const subscribe = (0,
|
|
10232
|
+
const subscribe = (0, import_react68.useCallback)(
|
|
9910
10233
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
9911
10234
|
[store]
|
|
9912
10235
|
);
|
|
9913
10236
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
9914
|
-
const snapshot = (0,
|
|
9915
|
-
return (0,
|
|
10237
|
+
const snapshot = (0, import_react68.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
10238
|
+
return (0, import_react68.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
9916
10239
|
}
|
|
9917
10240
|
function useTrackChanges(editor) {
|
|
9918
10241
|
const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
|
|
9919
|
-
const subscribe = (0,
|
|
10242
|
+
const subscribe = (0, import_react68.useCallback)(
|
|
9920
10243
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
9921
10244
|
[store]
|
|
9922
10245
|
);
|
|
9923
10246
|
const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
9924
|
-
const snapshot = (0,
|
|
9925
|
-
return (0,
|
|
10247
|
+
const snapshot = (0, import_react68.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
10248
|
+
return (0, import_react68.useMemo)(() => {
|
|
9926
10249
|
const run = (fn) => () => {
|
|
9927
10250
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
9928
10251
|
};
|
|
@@ -9945,9 +10268,9 @@ function useTrackChanges(editor) {
|
|
|
9945
10268
|
}
|
|
9946
10269
|
|
|
9947
10270
|
// src/review/CommentsPanel.tsx
|
|
9948
|
-
var
|
|
10271
|
+
var import_react69 = require("react");
|
|
9949
10272
|
var import_editor14 = require("@pixerate/editor");
|
|
9950
|
-
var
|
|
10273
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9951
10274
|
var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
|
|
9952
10275
|
var primaryButtonClass = "rounded px-2 py-1 text-xs bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50";
|
|
9953
10276
|
var textareaClass = "w-full resize-y rounded-md border border-input bg-background p-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-primary";
|
|
@@ -9961,18 +10284,18 @@ var CommentsPanel = ({
|
|
|
9961
10284
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
9962
10285
|
}) => {
|
|
9963
10286
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
9964
|
-
const [showResolved, setShowResolved] = (0,
|
|
10287
|
+
const [showResolved, setShowResolved] = (0, import_react69.useState)(showResolvedInitial);
|
|
9965
10288
|
const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
9966
10289
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
9967
10290
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
9968
|
-
return /* @__PURE__ */ (0,
|
|
9969
|
-
/* @__PURE__ */ (0,
|
|
9970
|
-
/* @__PURE__ */ (0,
|
|
10291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("aside", { className, "aria-label": "Comments", children: [
|
|
10292
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
10293
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
9971
10294
|
threads.length - resolvedCount,
|
|
9972
10295
|
" open",
|
|
9973
10296
|
resolvedCount > 0 ? ` \xB7 ${resolvedCount} resolved` : ""
|
|
9974
10297
|
] }),
|
|
9975
|
-
resolvedCount > 0 && /* @__PURE__ */ (0,
|
|
10298
|
+
resolvedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9976
10299
|
"button",
|
|
9977
10300
|
{
|
|
9978
10301
|
type: "button",
|
|
@@ -9983,7 +10306,7 @@ var CommentsPanel = ({
|
|
|
9983
10306
|
}
|
|
9984
10307
|
)
|
|
9985
10308
|
] }),
|
|
9986
|
-
visible.length === 0 ? /* @__PURE__ */ (0,
|
|
10309
|
+
visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("ul", { className: "flex flex-col gap-2", role: "list", children: visible.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
9987
10310
|
CommentThreadCard,
|
|
9988
10311
|
{
|
|
9989
10312
|
thread,
|
|
@@ -10005,7 +10328,7 @@ var CommentThreadCard = ({
|
|
|
10005
10328
|
author,
|
|
10006
10329
|
formatTime
|
|
10007
10330
|
}) => {
|
|
10008
|
-
const [draft, setDraft] = (0,
|
|
10331
|
+
const [draft, setDraft] = (0, import_react69.useState)("");
|
|
10009
10332
|
const isDraft = thread.body === "";
|
|
10010
10333
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
10011
10334
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -10031,7 +10354,7 @@ var CommentThreadCard = ({
|
|
|
10031
10354
|
setDraft("");
|
|
10032
10355
|
};
|
|
10033
10356
|
const stop = (e) => e.stopPropagation();
|
|
10034
|
-
return /* @__PURE__ */ (0,
|
|
10357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
10035
10358
|
"li",
|
|
10036
10359
|
{
|
|
10037
10360
|
className: `flex flex-col gap-2 rounded-md border bg-background p-3 cursor-pointer ${active ? "border-primary ring-1 ring-primary" : "border-border"} ${thread.resolved ? "opacity-70" : ""}`,
|
|
@@ -10047,24 +10370,24 @@ var CommentThreadCard = ({
|
|
|
10047
10370
|
}
|
|
10048
10371
|
},
|
|
10049
10372
|
children: [
|
|
10050
|
-
/* @__PURE__ */ (0,
|
|
10051
|
-
/* @__PURE__ */ (0,
|
|
10052
|
-
/* @__PURE__ */ (0,
|
|
10373
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
10374
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-medium", children: thread.author.name }),
|
|
10375
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-muted-foreground", children: formatTime(thread.createdAt) })
|
|
10053
10376
|
] }),
|
|
10054
|
-
quote && /* @__PURE__ */ (0,
|
|
10055
|
-
thread.orphaned && /* @__PURE__ */ (0,
|
|
10056
|
-
thread.resolved && /* @__PURE__ */ (0,
|
|
10057
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
10058
|
-
thread.replies.length > 0 && /* @__PURE__ */ (0,
|
|
10059
|
-
/* @__PURE__ */ (0,
|
|
10060
|
-
/* @__PURE__ */ (0,
|
|
10377
|
+
quote && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("blockquote", { className: "border-l-2 border-border pl-2 text-xs text-muted-foreground line-clamp-2", children: quote }),
|
|
10378
|
+
thread.orphaned && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-destructive", children: "The commented text was deleted." }),
|
|
10379
|
+
thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-xs text-muted-foreground", children: "Resolved" }),
|
|
10380
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "whitespace-pre-wrap break-words", children: thread.body }),
|
|
10381
|
+
thread.replies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("ul", { className: "flex flex-col gap-2 border-l border-border pl-3", role: "list", children: thread.replies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("li", { className: "flex flex-col gap-0.5", "data-reply-id": reply.id, children: [
|
|
10382
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "text-xs", children: [
|
|
10383
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "font-medium", children: reply.author.name }),
|
|
10061
10384
|
" ",
|
|
10062
|
-
/* @__PURE__ */ (0,
|
|
10385
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "text-muted-foreground", children: formatTime(reply.createdAt) })
|
|
10063
10386
|
] }),
|
|
10064
|
-
/* @__PURE__ */ (0,
|
|
10387
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "whitespace-pre-wrap break-words", children: reply.body })
|
|
10065
10388
|
] }, reply.id)) }),
|
|
10066
|
-
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0,
|
|
10067
|
-
/* @__PURE__ */ (0,
|
|
10389
|
+
(active || isDraft) && !thread.resolved && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-col gap-1", onClick: stop, children: [
|
|
10390
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10068
10391
|
"textarea",
|
|
10069
10392
|
{
|
|
10070
10393
|
className: textareaClass,
|
|
@@ -10082,9 +10405,9 @@ var CommentThreadCard = ({
|
|
|
10082
10405
|
}
|
|
10083
10406
|
}
|
|
10084
10407
|
),
|
|
10085
|
-
/* @__PURE__ */ (0,
|
|
10086
|
-
isDraft && /* @__PURE__ */ (0,
|
|
10087
|
-
/* @__PURE__ */ (0,
|
|
10408
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex justify-end gap-1", children: [
|
|
10409
|
+
isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: buttonClass2, onClick: remove, children: "Cancel" }),
|
|
10410
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10088
10411
|
"button",
|
|
10089
10412
|
{
|
|
10090
10413
|
type: "button",
|
|
@@ -10096,9 +10419,9 @@ var CommentThreadCard = ({
|
|
|
10096
10419
|
)
|
|
10097
10420
|
] })
|
|
10098
10421
|
] }),
|
|
10099
|
-
!isDraft && /* @__PURE__ */ (0,
|
|
10100
|
-
/* @__PURE__ */ (0,
|
|
10101
|
-
/* @__PURE__ */ (0,
|
|
10422
|
+
!isDraft && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex justify-end gap-1", onClick: stop, children: [
|
|
10423
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("button", { type: "button", className: buttonClass2, onClick: () => setResolved(!thread.resolved), children: thread.resolved ? "Reopen" : "Resolve" }),
|
|
10424
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
10102
10425
|
"button",
|
|
10103
10426
|
{
|
|
10104
10427
|
type: "button",
|
|
@@ -10114,7 +10437,7 @@ var CommentThreadCard = ({
|
|
|
10114
10437
|
};
|
|
10115
10438
|
|
|
10116
10439
|
// src/review/ReviewToolbar.tsx
|
|
10117
|
-
var
|
|
10440
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
10118
10441
|
var defaultDescriptionClass = "max-w-[16rem] truncate px-1 text-xs text-muted-foreground";
|
|
10119
10442
|
var buttonClass3 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
10120
10443
|
var ReviewToolbar = ({
|
|
@@ -10127,8 +10450,8 @@ var ReviewToolbar = ({
|
|
|
10127
10450
|
const count = review.changes.length;
|
|
10128
10451
|
const current = review.currentChange;
|
|
10129
10452
|
const index = current ? review.changes.findIndex((c) => c.id === current.id) + 1 : 0;
|
|
10130
|
-
return /* @__PURE__ */ (0,
|
|
10131
|
-
/* @__PURE__ */ (0,
|
|
10453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className, role: "toolbar", "aria-label": "Review", children: [
|
|
10454
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10132
10455
|
"button",
|
|
10133
10456
|
{
|
|
10134
10457
|
type: "button",
|
|
@@ -10139,8 +10462,8 @@ var ReviewToolbar = ({
|
|
|
10139
10462
|
children: review.enabled ? "Tracking on" : "Track changes"
|
|
10140
10463
|
}
|
|
10141
10464
|
),
|
|
10142
|
-
/* @__PURE__ */ (0,
|
|
10143
|
-
/* @__PURE__ */ (0,
|
|
10465
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
10466
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10144
10467
|
"button",
|
|
10145
10468
|
{
|
|
10146
10469
|
type: "button",
|
|
@@ -10151,8 +10474,8 @@ var ReviewToolbar = ({
|
|
|
10151
10474
|
children: "\u2039"
|
|
10152
10475
|
}
|
|
10153
10476
|
),
|
|
10154
|
-
/* @__PURE__ */ (0,
|
|
10155
|
-
/* @__PURE__ */ (0,
|
|
10477
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "min-w-[4rem] text-center text-xs text-muted-foreground", "aria-live": "polite", children: count === 0 ? "No changes" : current ? `${index} of ${count}` : `${count} changes` }),
|
|
10478
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10156
10479
|
"button",
|
|
10157
10480
|
{
|
|
10158
10481
|
type: "button",
|
|
@@ -10163,7 +10486,7 @@ var ReviewToolbar = ({
|
|
|
10163
10486
|
children: "\u203A"
|
|
10164
10487
|
}
|
|
10165
10488
|
),
|
|
10166
|
-
showDescription && current && /* @__PURE__ */ (0,
|
|
10489
|
+
showDescription && current && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
10167
10490
|
"span",
|
|
10168
10491
|
{
|
|
10169
10492
|
className: descriptionClassName,
|
|
@@ -10175,8 +10498,8 @@ var ReviewToolbar = ({
|
|
|
10175
10498
|
]
|
|
10176
10499
|
}
|
|
10177
10500
|
),
|
|
10178
|
-
/* @__PURE__ */ (0,
|
|
10179
|
-
/* @__PURE__ */ (0,
|
|
10501
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "mx-1 h-4 w-px bg-border", "aria-hidden": "true" }),
|
|
10502
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10180
10503
|
"button",
|
|
10181
10504
|
{
|
|
10182
10505
|
type: "button",
|
|
@@ -10186,7 +10509,7 @@ var ReviewToolbar = ({
|
|
|
10186
10509
|
children: "Accept"
|
|
10187
10510
|
}
|
|
10188
10511
|
),
|
|
10189
|
-
/* @__PURE__ */ (0,
|
|
10512
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
10190
10513
|
"button",
|
|
10191
10514
|
{
|
|
10192
10515
|
type: "button",
|
|
@@ -10196,18 +10519,18 @@ var ReviewToolbar = ({
|
|
|
10196
10519
|
children: "Reject"
|
|
10197
10520
|
}
|
|
10198
10521
|
),
|
|
10199
|
-
/* @__PURE__ */ (0,
|
|
10200
|
-
/* @__PURE__ */ (0,
|
|
10522
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.acceptAll, children: "Accept all" }),
|
|
10523
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: buttonClass3, disabled: count === 0, onClick: review.rejectAll, children: "Reject all" })
|
|
10201
10524
|
] });
|
|
10202
10525
|
};
|
|
10203
10526
|
|
|
10204
10527
|
// src/review/CommentButton.tsx
|
|
10205
|
-
var
|
|
10528
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
10206
10529
|
var CommentButton = ({
|
|
10207
10530
|
editor,
|
|
10208
10531
|
className = "rounded px-2 py-1 text-xs text-popover-foreground hover:bg-muted",
|
|
10209
10532
|
children = "Comment"
|
|
10210
|
-
}) => /* @__PURE__ */ (0,
|
|
10533
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
10211
10534
|
"button",
|
|
10212
10535
|
{
|
|
10213
10536
|
type: "button",
|
|
@@ -10219,13 +10542,13 @@ var CommentButton = ({
|
|
|
10219
10542
|
);
|
|
10220
10543
|
|
|
10221
10544
|
// src/review/useDocumentCompare.ts
|
|
10222
|
-
var
|
|
10545
|
+
var import_react70 = require("react");
|
|
10223
10546
|
var import_editor15 = require("@pixerate/editor");
|
|
10224
10547
|
function useDocumentCompare(editor, options) {
|
|
10225
|
-
const [summary, setSummary] = (0,
|
|
10226
|
-
const defaults = (0,
|
|
10548
|
+
const [summary, setSummary] = (0, import_react70.useState)(null);
|
|
10549
|
+
const defaults = (0, import_react70.useRef)(options);
|
|
10227
10550
|
defaults.current = options;
|
|
10228
|
-
const compare = (0,
|
|
10551
|
+
const compare = (0, import_react70.useCallback)(
|
|
10229
10552
|
(original, revised, overrides) => {
|
|
10230
10553
|
if (!editor || editor.isDestroyed) return null;
|
|
10231
10554
|
const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
|
|
@@ -10237,13 +10560,13 @@ function useDocumentCompare(editor, options) {
|
|
|
10237
10560
|
},
|
|
10238
10561
|
[editor]
|
|
10239
10562
|
);
|
|
10240
|
-
const clear = (0,
|
|
10241
|
-
return (0,
|
|
10563
|
+
const clear = (0, import_react70.useCallback)(() => setSummary(null), []);
|
|
10564
|
+
return (0, import_react70.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
10242
10565
|
}
|
|
10243
10566
|
|
|
10244
10567
|
// src/review/TrackedChangesList.tsx
|
|
10245
10568
|
var import_editor16 = require("@pixerate/editor");
|
|
10246
|
-
var
|
|
10569
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
10247
10570
|
var buttonClass4 = "rounded px-1.5 py-0.5 text-xs text-foreground hover:bg-muted disabled:opacity-40";
|
|
10248
10571
|
var TrackedChangesList = ({
|
|
10249
10572
|
editor,
|
|
@@ -10254,18 +10577,18 @@ var TrackedChangesList = ({
|
|
|
10254
10577
|
}) => {
|
|
10255
10578
|
const review = useTrackChanges(editor);
|
|
10256
10579
|
if (review.changes.length === 0) {
|
|
10257
|
-
return /* @__PURE__ */ (0,
|
|
10580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, "data-tracked-changes-list": "", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "pixerate-changes-empty text-xs text-muted-foreground", children: emptyState }) });
|
|
10258
10581
|
}
|
|
10259
|
-
return /* @__PURE__ */ (0,
|
|
10582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className, role: "list", "aria-label": "Tracked changes", "data-tracked-changes-list": "", children: review.changes.map((change) => {
|
|
10260
10583
|
const active = change.id === review.currentChangeId;
|
|
10261
|
-
return /* @__PURE__ */ (0,
|
|
10584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
10262
10585
|
"li",
|
|
10263
10586
|
{
|
|
10264
10587
|
className: active ? `${itemClassName} ${activeItemClassName}` : itemClassName,
|
|
10265
10588
|
"data-change-type": change.type,
|
|
10266
10589
|
"data-change-id": change.id,
|
|
10267
10590
|
children: [
|
|
10268
|
-
/* @__PURE__ */ (0,
|
|
10591
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
10269
10592
|
"button",
|
|
10270
10593
|
{
|
|
10271
10594
|
type: "button",
|
|
@@ -10273,14 +10596,14 @@ var TrackedChangesList = ({
|
|
|
10273
10596
|
title: `${change.author.name}: ${change.description}`,
|
|
10274
10597
|
onClick: () => review.select(change.id),
|
|
10275
10598
|
children: [
|
|
10276
|
-
/* @__PURE__ */ (0,
|
|
10599
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "font-medium", children: (0, import_editor16.trackedChangeLabel)(change) }),
|
|
10277
10600
|
change.author.name ? ` \xB7 ${change.author.name}` : "",
|
|
10278
|
-
/* @__PURE__ */ (0,
|
|
10601
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "block truncate text-muted-foreground", children: change.description })
|
|
10279
10602
|
]
|
|
10280
10603
|
}
|
|
10281
10604
|
),
|
|
10282
|
-
/* @__PURE__ */ (0,
|
|
10283
|
-
/* @__PURE__ */ (0,
|
|
10605
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.accept(change.id), children: "Accept" }),
|
|
10606
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: buttonClass4, onClick: () => review.reject(change.id), children: "Reject" })
|
|
10284
10607
|
]
|
|
10285
10608
|
},
|
|
10286
10609
|
`${change.type}:${change.id}`
|
|
@@ -10289,12 +10612,12 @@ var TrackedChangesList = ({
|
|
|
10289
10612
|
};
|
|
10290
10613
|
|
|
10291
10614
|
// src/commands/useCommandPalette.ts
|
|
10292
|
-
var
|
|
10615
|
+
var import_react71 = require("react");
|
|
10293
10616
|
var import_commands2 = require("@pixerate/editor/commands");
|
|
10294
10617
|
function useCommandPalette(registry, options = {}) {
|
|
10295
|
-
const optionsRef = (0,
|
|
10618
|
+
const optionsRef = (0, import_react71.useRef)(options);
|
|
10296
10619
|
optionsRef.current = options;
|
|
10297
|
-
const controller = (0,
|
|
10620
|
+
const controller = (0, import_react71.useMemo)(
|
|
10298
10621
|
() => (0, import_commands2.createCommandPaletteController)(registry, {
|
|
10299
10622
|
context: () => {
|
|
10300
10623
|
const c = optionsRef.current.context;
|
|
@@ -10315,9 +10638,9 @@ function useCommandPalette(registry, options = {}) {
|
|
|
10315
10638
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10316
10639
|
[registry]
|
|
10317
10640
|
);
|
|
10318
|
-
const state = (0,
|
|
10641
|
+
const state = (0, import_react71.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
10319
10642
|
const { hotkey, hotkeyTarget } = options;
|
|
10320
|
-
(0,
|
|
10643
|
+
(0, import_react71.useEffect)(() => {
|
|
10321
10644
|
if (!hotkey) return;
|
|
10322
10645
|
const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
|
|
10323
10646
|
if (!target) return;
|
|
@@ -10345,13 +10668,13 @@ function useCommandPalette(registry, options = {}) {
|
|
|
10345
10668
|
}
|
|
10346
10669
|
|
|
10347
10670
|
// src/commands/CommandPalette.tsx
|
|
10348
|
-
var
|
|
10349
|
-
var
|
|
10671
|
+
var import_react72 = __toESM(require("react"), 1);
|
|
10672
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
10350
10673
|
function HighlightedLabel({ item }) {
|
|
10351
|
-
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0,
|
|
10674
|
+
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: item.label });
|
|
10352
10675
|
const marked = new Set(item.labelIndices);
|
|
10353
|
-
return /* @__PURE__ */ (0,
|
|
10354
|
-
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0,
|
|
10676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_jsx_runtime52.Fragment, { children: Array.from(item.label).map(
|
|
10677
|
+
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react72.default.Fragment, { children: ch }, i)
|
|
10355
10678
|
) });
|
|
10356
10679
|
}
|
|
10357
10680
|
var CommandPalette = ({
|
|
@@ -10360,22 +10683,22 @@ var CommandPalette = ({
|
|
|
10360
10683
|
emptyMessage = "No matching commands",
|
|
10361
10684
|
className = ""
|
|
10362
10685
|
}) => {
|
|
10363
|
-
const inputRef = (0,
|
|
10364
|
-
const listRef = (0,
|
|
10365
|
-
const baseId = (0,
|
|
10686
|
+
const inputRef = (0, import_react72.useRef)(null);
|
|
10687
|
+
const listRef = (0, import_react72.useRef)(null);
|
|
10688
|
+
const baseId = (0, import_react72.useId)();
|
|
10366
10689
|
const listId = `${baseId}-list`;
|
|
10367
10690
|
const optionId = (index) => `${baseId}-option-${index}`;
|
|
10368
10691
|
const { open, query, items, activeIndex } = palette;
|
|
10369
|
-
(0,
|
|
10692
|
+
(0, import_react72.useEffect)(() => {
|
|
10370
10693
|
if (open) inputRef.current?.focus();
|
|
10371
10694
|
}, [open]);
|
|
10372
|
-
(0,
|
|
10695
|
+
(0, import_react72.useEffect)(() => {
|
|
10373
10696
|
if (!open) return;
|
|
10374
10697
|
const active = listRef.current?.querySelector('[aria-selected="true"]');
|
|
10375
10698
|
active?.scrollIntoView?.({ block: "nearest" });
|
|
10376
10699
|
}, [open, activeIndex]);
|
|
10377
10700
|
if (!open) return null;
|
|
10378
|
-
return /* @__PURE__ */ (0,
|
|
10701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10379
10702
|
"div",
|
|
10380
10703
|
{
|
|
10381
10704
|
className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 px-4 pt-[15vh]",
|
|
@@ -10383,7 +10706,7 @@ var CommandPalette = ({
|
|
|
10383
10706
|
onMouseDown: (e) => {
|
|
10384
10707
|
if (e.target === e.currentTarget) palette.setOpen(false);
|
|
10385
10708
|
},
|
|
10386
|
-
children: /* @__PURE__ */ (0,
|
|
10709
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
10387
10710
|
"div",
|
|
10388
10711
|
{
|
|
10389
10712
|
role: "dialog",
|
|
@@ -10392,7 +10715,7 @@ var CommandPalette = ({
|
|
|
10392
10715
|
className: `w-full max-w-lg overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl ${className}`,
|
|
10393
10716
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
10394
10717
|
children: [
|
|
10395
|
-
/* @__PURE__ */ (0,
|
|
10718
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
10396
10719
|
"input",
|
|
10397
10720
|
{
|
|
10398
10721
|
ref: inputRef,
|
|
@@ -10412,7 +10735,7 @@ var CommandPalette = ({
|
|
|
10412
10735
|
className: "w-full border-b border-border bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground"
|
|
10413
10736
|
}
|
|
10414
10737
|
),
|
|
10415
|
-
items.length === 0 ? /* @__PURE__ */ (0,
|
|
10738
|
+
items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": "Commands", className: "max-h-80 overflow-y-auto py-1", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
10416
10739
|
"li",
|
|
10417
10740
|
{
|
|
10418
10741
|
id: optionId(index),
|
|
@@ -10427,12 +10750,12 @@ var CommandPalette = ({
|
|
|
10427
10750
|
onClick: () => palette.run(item.id),
|
|
10428
10751
|
className: `flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm ${index === activeIndex ? "bg-muted" : ""} ${item.enabled ? "" : "cursor-default opacity-50"}`,
|
|
10429
10752
|
children: [
|
|
10430
|
-
/* @__PURE__ */ (0,
|
|
10431
|
-
/* @__PURE__ */ (0,
|
|
10432
|
-
item.disabledReason && /* @__PURE__ */ (0,
|
|
10753
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
10754
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(HighlightedLabel, { item }),
|
|
10755
|
+
item.disabledReason && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "ml-2 text-xs text-muted-foreground", "data-disabled-reason": "", children: item.disabledReason })
|
|
10433
10756
|
] }),
|
|
10434
|
-
item.group && /* @__PURE__ */ (0,
|
|
10435
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
10757
|
+
item.group && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "shrink-0 text-xs text-muted-foreground", children: item.group }),
|
|
10758
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("kbd", { className: "shrink-0 rounded border border-border px-1.5 font-mono text-[10px] text-muted-foreground", children: item.shortcut })
|
|
10436
10759
|
]
|
|
10437
10760
|
},
|
|
10438
10761
|
item.id
|
|
@@ -10445,12 +10768,12 @@ var CommandPalette = ({
|
|
|
10445
10768
|
};
|
|
10446
10769
|
|
|
10447
10770
|
// src/commands/useCommandShortcuts.ts
|
|
10448
|
-
var
|
|
10771
|
+
var import_react73 = require("react");
|
|
10449
10772
|
function useCommandShortcuts(registry, options = {}) {
|
|
10450
|
-
const optionsRef = (0,
|
|
10773
|
+
const optionsRef = (0, import_react73.useRef)(options);
|
|
10451
10774
|
optionsRef.current = options;
|
|
10452
10775
|
const { enabled = true, target } = options;
|
|
10453
|
-
(0,
|
|
10776
|
+
(0, import_react73.useEffect)(() => {
|
|
10454
10777
|
if (!registry || !enabled) return;
|
|
10455
10778
|
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
10456
10779
|
if (!eventTarget) return;
|
|
@@ -10468,14 +10791,14 @@ function useCommandShortcuts(registry, options = {}) {
|
|
|
10468
10791
|
}, [registry, enabled, target]);
|
|
10469
10792
|
}
|
|
10470
10793
|
function useRegisterCommands(registry, specs) {
|
|
10471
|
-
(0,
|
|
10794
|
+
(0, import_react73.useEffect)(() => {
|
|
10472
10795
|
if (!registry || !specs || specs.length === 0) return;
|
|
10473
10796
|
return registry.register(specs);
|
|
10474
10797
|
}, [registry, specs]);
|
|
10475
10798
|
}
|
|
10476
10799
|
|
|
10477
10800
|
// src/persistence/useAutosave.ts
|
|
10478
|
-
var
|
|
10801
|
+
var import_react74 = require("react");
|
|
10479
10802
|
var import_persistence = require("@pixerate/editor/persistence");
|
|
10480
10803
|
var IDLE = {
|
|
10481
10804
|
status: "idle",
|
|
@@ -10486,18 +10809,18 @@ var IDLE = {
|
|
|
10486
10809
|
ready: false
|
|
10487
10810
|
};
|
|
10488
10811
|
function useAutosave(options) {
|
|
10489
|
-
const optionsRef = (0,
|
|
10812
|
+
const optionsRef = (0, import_react74.useRef)(options);
|
|
10490
10813
|
optionsRef.current = options;
|
|
10491
10814
|
const { storage, key, history, dirty } = options;
|
|
10492
10815
|
const recover = options.recover !== false;
|
|
10493
10816
|
const flushOnHide = options.flushOnHide !== false;
|
|
10494
10817
|
const ready = options.ready !== false;
|
|
10495
|
-
const [controller, setController] = (0,
|
|
10496
|
-
const [status, setStatus] = (0,
|
|
10497
|
-
const [recovery, setRecovery] = (0,
|
|
10498
|
-
const [pendingRecovery, setPendingRecovery] = (0,
|
|
10499
|
-
const revisionsRef = (0,
|
|
10500
|
-
(0,
|
|
10818
|
+
const [controller, setController] = (0, import_react74.useState)(null);
|
|
10819
|
+
const [status, setStatus] = (0, import_react74.useState)(IDLE);
|
|
10820
|
+
const [recovery, setRecovery] = (0, import_react74.useState)(null);
|
|
10821
|
+
const [pendingRecovery, setPendingRecovery] = (0, import_react74.useState)(recover);
|
|
10822
|
+
const revisionsRef = (0, import_react74.useRef)(null);
|
|
10823
|
+
(0, import_react74.useEffect)(() => {
|
|
10501
10824
|
const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
|
|
10502
10825
|
const o = optionsRef.current;
|
|
10503
10826
|
const instance = (0, import_persistence.createAutosaveController)({
|
|
@@ -10540,10 +10863,10 @@ function useAutosave(options) {
|
|
|
10540
10863
|
if (revisionsRef.current === revisions) revisionsRef.current = null;
|
|
10541
10864
|
};
|
|
10542
10865
|
}, [storage, key, history, dirty, recover]);
|
|
10543
|
-
(0,
|
|
10866
|
+
(0, import_react74.useEffect)(() => {
|
|
10544
10867
|
if (controller && ready && !pendingRecovery) controller.ready();
|
|
10545
10868
|
}, [controller, ready, pendingRecovery]);
|
|
10546
|
-
(0,
|
|
10869
|
+
(0, import_react74.useEffect)(() => {
|
|
10547
10870
|
if (!controller || !flushOnHide || typeof window === "undefined") return;
|
|
10548
10871
|
const flush = () => void controller.flushNow();
|
|
10549
10872
|
const onVisibility = () => {
|
|
@@ -10556,33 +10879,33 @@ function useAutosave(options) {
|
|
|
10556
10879
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
10557
10880
|
};
|
|
10558
10881
|
}, [controller, flushOnHide]);
|
|
10559
|
-
const restore = (0,
|
|
10882
|
+
const restore = (0, import_react74.useCallback)(() => {
|
|
10560
10883
|
const snapshot = recovery?.snapshot;
|
|
10561
10884
|
setRecovery(null);
|
|
10562
10885
|
setPendingRecovery(false);
|
|
10563
10886
|
return snapshot;
|
|
10564
10887
|
}, [recovery]);
|
|
10565
|
-
const discard = (0,
|
|
10888
|
+
const discard = (0, import_react74.useCallback)(async () => {
|
|
10566
10889
|
if (controller) await controller.discardRecovery();
|
|
10567
10890
|
setRecovery(null);
|
|
10568
10891
|
setPendingRecovery(false);
|
|
10569
10892
|
}, [controller]);
|
|
10570
|
-
const flushNow = (0,
|
|
10893
|
+
const flushNow = (0, import_react74.useCallback)(async () => {
|
|
10571
10894
|
await controller?.flushNow();
|
|
10572
10895
|
}, [controller]);
|
|
10573
|
-
const markClean = (0,
|
|
10896
|
+
const markClean = (0, import_react74.useCallback)(async () => {
|
|
10574
10897
|
revisionsRef.current?.markSaved();
|
|
10575
10898
|
await controller?.markClean();
|
|
10576
10899
|
}, [controller]);
|
|
10577
|
-
const notifyChange = (0,
|
|
10900
|
+
const notifyChange = (0, import_react74.useCallback)(() => revisionsRef.current?.bump(), []);
|
|
10578
10901
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
10579
10902
|
}
|
|
10580
10903
|
|
|
10581
10904
|
// src/persistence/useEditorAutosave.ts
|
|
10582
|
-
var
|
|
10905
|
+
var import_react75 = require("react");
|
|
10583
10906
|
var import_persistence2 = require("@pixerate/editor/persistence");
|
|
10584
10907
|
function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
10585
|
-
const storage = (0,
|
|
10908
|
+
const storage = (0, import_react75.useMemo)(
|
|
10586
10909
|
() => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
|
|
10587
10910
|
[options.storage, doc.assets]
|
|
10588
10911
|
);
|
|
@@ -10595,19 +10918,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
10595
10918
|
history: doc
|
|
10596
10919
|
});
|
|
10597
10920
|
const take = autosave.restore;
|
|
10598
|
-
const restore = (0,
|
|
10921
|
+
const restore = (0, import_react75.useCallback)(() => {
|
|
10599
10922
|
const snapshot = take();
|
|
10600
10923
|
return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
|
|
10601
10924
|
}, [take, doc]);
|
|
10602
10925
|
const { markClean: clean, discard: drop } = autosave;
|
|
10603
10926
|
const rawStorage = options.storage;
|
|
10604
|
-
const gcRef = (0,
|
|
10927
|
+
const gcRef = (0, import_react75.useRef)(collectAssetGarbage);
|
|
10605
10928
|
gcRef.current = collectAssetGarbage;
|
|
10606
|
-
const markClean = (0,
|
|
10929
|
+
const markClean = (0, import_react75.useCallback)(async () => {
|
|
10607
10930
|
await clean();
|
|
10608
10931
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
10609
10932
|
}, [clean, rawStorage, doc]);
|
|
10610
|
-
const discard = (0,
|
|
10933
|
+
const discard = (0, import_react75.useCallback)(async () => {
|
|
10611
10934
|
await drop();
|
|
10612
10935
|
await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
|
|
10613
10936
|
}, [drop, rawStorage, doc]);
|
|
@@ -10616,7 +10939,7 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
|
|
|
10616
10939
|
|
|
10617
10940
|
// src/persistence/RecoveryPrompt.tsx
|
|
10618
10941
|
var import_persistence3 = require("@pixerate/editor/persistence");
|
|
10619
|
-
var
|
|
10942
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
10620
10943
|
var RecoveryPrompt = ({
|
|
10621
10944
|
recovery,
|
|
10622
10945
|
onRestore,
|
|
@@ -10628,7 +10951,7 @@ var RecoveryPrompt = ({
|
|
|
10628
10951
|
}) => {
|
|
10629
10952
|
if (!recovery) return null;
|
|
10630
10953
|
const { name } = recovery.meta;
|
|
10631
|
-
return /* @__PURE__ */ (0,
|
|
10954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
10632
10955
|
"div",
|
|
10633
10956
|
{
|
|
10634
10957
|
role: "alertdialog",
|
|
@@ -10636,15 +10959,15 @@ var RecoveryPrompt = ({
|
|
|
10636
10959
|
"data-recovery-prompt": "",
|
|
10637
10960
|
className: `flex flex-wrap items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground shadow-sm ${className}`,
|
|
10638
10961
|
children: [
|
|
10639
|
-
/* @__PURE__ */ (0,
|
|
10962
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
10640
10963
|
(0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
|
|
10641
|
-
name ? /* @__PURE__ */ (0,
|
|
10964
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
|
|
10642
10965
|
"(",
|
|
10643
10966
|
name,
|
|
10644
10967
|
")"
|
|
10645
10968
|
] }) : null
|
|
10646
10969
|
] }),
|
|
10647
|
-
/* @__PURE__ */ (0,
|
|
10970
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10648
10971
|
"button",
|
|
10649
10972
|
{
|
|
10650
10973
|
type: "button",
|
|
@@ -10654,7 +10977,7 @@ var RecoveryPrompt = ({
|
|
|
10654
10977
|
children: restoreLabel
|
|
10655
10978
|
}
|
|
10656
10979
|
),
|
|
10657
|
-
/* @__PURE__ */ (0,
|
|
10980
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
10658
10981
|
"button",
|
|
10659
10982
|
{
|
|
10660
10983
|
type: "button",
|
|
@@ -10670,17 +10993,17 @@ var RecoveryPrompt = ({
|
|
|
10670
10993
|
};
|
|
10671
10994
|
|
|
10672
10995
|
// src/generation/useGenerationPlan.ts
|
|
10673
|
-
var
|
|
10996
|
+
var import_react76 = require("react");
|
|
10674
10997
|
var import_generation = require("@pixerate/editor/generation");
|
|
10675
10998
|
function useGenerationPlan(request, capabilities, options = {}) {
|
|
10676
10999
|
const key = JSON.stringify([request, capabilities, options]);
|
|
10677
|
-
return (0,
|
|
11000
|
+
return (0, import_react76.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
|
|
10678
11001
|
}
|
|
10679
11002
|
function useJobProgress(options) {
|
|
10680
11003
|
const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
|
|
10681
|
-
const [tick, setTick] = (0,
|
|
11004
|
+
const [tick, setTick] = (0, import_react76.useState)(() => Date.now());
|
|
10682
11005
|
const ticking = !done && now === void 0;
|
|
10683
|
-
(0,
|
|
11006
|
+
(0, import_react76.useEffect)(() => {
|
|
10684
11007
|
if (!ticking) return;
|
|
10685
11008
|
setTick(Date.now());
|
|
10686
11009
|
const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
|
|
@@ -10690,9 +11013,9 @@ function useJobProgress(options) {
|
|
|
10690
11013
|
}
|
|
10691
11014
|
|
|
10692
11015
|
// src/generation/GenerationSettings.tsx
|
|
10693
|
-
var
|
|
11016
|
+
var import_react77 = require("react");
|
|
10694
11017
|
var import_generation2 = require("@pixerate/editor/generation");
|
|
10695
|
-
var
|
|
11018
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
10696
11019
|
var inputClass2 = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
|
|
10697
11020
|
function Control({
|
|
10698
11021
|
control,
|
|
@@ -10702,7 +11025,7 @@ function Control({
|
|
|
10702
11025
|
}) {
|
|
10703
11026
|
const shown = value ?? control.defaultValue;
|
|
10704
11027
|
if (control.kind === "checkbox") {
|
|
10705
|
-
return /* @__PURE__ */ (0,
|
|
11028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10706
11029
|
"input",
|
|
10707
11030
|
{
|
|
10708
11031
|
id,
|
|
@@ -10714,7 +11037,7 @@ function Control({
|
|
|
10714
11037
|
);
|
|
10715
11038
|
}
|
|
10716
11039
|
if (control.kind === "select") {
|
|
10717
|
-
return /* @__PURE__ */ (0,
|
|
11040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
10718
11041
|
"select",
|
|
10719
11042
|
{
|
|
10720
11043
|
id,
|
|
@@ -10723,14 +11046,14 @@ function Control({
|
|
|
10723
11046
|
value: shown === void 0 ? "" : String(shown),
|
|
10724
11047
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value)),
|
|
10725
11048
|
children: [
|
|
10726
|
-
shown === void 0 && /* @__PURE__ */ (0,
|
|
10727
|
-
control.options.map((option) => /* @__PURE__ */ (0,
|
|
11049
|
+
shown === void 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("option", { value: "", children: "Default" }),
|
|
11050
|
+
control.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("option", { value: String(option.value), children: option.label }, String(option.value)))
|
|
10728
11051
|
]
|
|
10729
11052
|
}
|
|
10730
11053
|
);
|
|
10731
11054
|
}
|
|
10732
11055
|
if (control.kind === "textarea") {
|
|
10733
|
-
return /* @__PURE__ */ (0,
|
|
11056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10734
11057
|
"textarea",
|
|
10735
11058
|
{
|
|
10736
11059
|
id,
|
|
@@ -10744,8 +11067,8 @@ function Control({
|
|
|
10744
11067
|
);
|
|
10745
11068
|
}
|
|
10746
11069
|
const numeric = typeof shown === "number" ? shown : void 0;
|
|
10747
|
-
return /* @__PURE__ */ (0,
|
|
10748
|
-
/* @__PURE__ */ (0,
|
|
11070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11071
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10749
11072
|
"input",
|
|
10750
11073
|
{
|
|
10751
11074
|
id,
|
|
@@ -10759,7 +11082,7 @@ function Control({
|
|
|
10759
11082
|
onChange: (e) => onValue((0, import_generation2.parseControlValue)(control, e.target.value))
|
|
10760
11083
|
}
|
|
10761
11084
|
),
|
|
10762
|
-
control.kind === "range" && /* @__PURE__ */ (0,
|
|
11085
|
+
control.kind === "range" && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "w-10 text-right tabular-nums text-muted-foreground", "data-field-value": "", children: numeric ?? "\u2013" })
|
|
10763
11086
|
] });
|
|
10764
11087
|
}
|
|
10765
11088
|
var GenerationSettings = ({
|
|
@@ -10773,17 +11096,17 @@ var GenerationSettings = ({
|
|
|
10773
11096
|
renderReference,
|
|
10774
11097
|
className = ""
|
|
10775
11098
|
}) => {
|
|
10776
|
-
const baseId = (0,
|
|
10777
|
-
const controls = (0,
|
|
11099
|
+
const baseId = (0, import_react77.useId)();
|
|
11100
|
+
const controls = (0, import_react77.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
|
|
10778
11101
|
const computed = useGenerationPlan(value, capabilities, { strategy });
|
|
10779
11102
|
const plan = planProp ?? computed;
|
|
10780
11103
|
const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
|
|
10781
|
-
return /* @__PURE__ */ (0,
|
|
11104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: `flex flex-col gap-3 text-sm ${className}`, "data-generation-settings": "", "data-model": capabilities.id, children: [
|
|
10782
11105
|
controls.map((control) => {
|
|
10783
11106
|
const id = `${baseId}-${control.key}`;
|
|
10784
|
-
return /* @__PURE__ */ (0,
|
|
10785
|
-
/* @__PURE__ */ (0,
|
|
10786
|
-
/* @__PURE__ */ (0,
|
|
11107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex flex-col gap-1", "data-control": control.key, children: [
|
|
11108
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("label", { htmlFor: id, className: "text-xs font-medium text-muted-foreground", title: control.description, children: control.label }),
|
|
11109
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10787
11110
|
Control,
|
|
10788
11111
|
{
|
|
10789
11112
|
control,
|
|
@@ -10794,23 +11117,23 @@ var GenerationSettings = ({
|
|
|
10794
11117
|
)
|
|
10795
11118
|
] }, control.key);
|
|
10796
11119
|
}),
|
|
10797
|
-
slots.map((slot) => /* @__PURE__ */ (0,
|
|
10798
|
-
/* @__PURE__ */ (0,
|
|
11120
|
+
slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("fieldset", { className: "flex flex-col gap-1", "data-reference-role": slot.role, children: [
|
|
11121
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("legend", { className: "text-xs font-medium text-muted-foreground", title: slot.description, children: [
|
|
10799
11122
|
slot.label,
|
|
10800
11123
|
" ",
|
|
10801
|
-
/* @__PURE__ */ (0,
|
|
11124
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "tabular-nums", "data-reference-count": "", children: [
|
|
10802
11125
|
"(",
|
|
10803
11126
|
slot.references.length,
|
|
10804
11127
|
"/",
|
|
10805
11128
|
slot.max,
|
|
10806
11129
|
")"
|
|
10807
11130
|
] }),
|
|
10808
|
-
slot.min > 0 && /* @__PURE__ */ (0,
|
|
11131
|
+
slot.min > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-destructive", children: " *" })
|
|
10809
11132
|
] }),
|
|
10810
|
-
/* @__PURE__ */ (0,
|
|
10811
|
-
slot.references.map((ref) => /* @__PURE__ */ (0,
|
|
10812
|
-
renderReference ? renderReference(ref) : /* @__PURE__ */ (0,
|
|
10813
|
-
/* @__PURE__ */ (0,
|
|
11133
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("ul", { className: "flex flex-wrap gap-1", children: [
|
|
11134
|
+
slot.references.map((ref) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("li", { className: "flex items-center gap-1 rounded border border-border px-1.5 py-0.5", "data-reference-id": ref.id, children: [
|
|
11135
|
+
renderReference ? renderReference(ref) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "max-w-[10rem] truncate", children: ref.id }),
|
|
11136
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10814
11137
|
"button",
|
|
10815
11138
|
{
|
|
10816
11139
|
type: "button",
|
|
@@ -10821,7 +11144,7 @@ var GenerationSettings = ({
|
|
|
10821
11144
|
}
|
|
10822
11145
|
)
|
|
10823
11146
|
] }, ref.id)),
|
|
10824
|
-
onAddReference && slot.canAdd && /* @__PURE__ */ (0,
|
|
11147
|
+
onAddReference && slot.canAdd && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
10825
11148
|
"button",
|
|
10826
11149
|
{
|
|
10827
11150
|
type: "button",
|
|
@@ -10832,21 +11155,21 @@ var GenerationSettings = ({
|
|
|
10832
11155
|
) })
|
|
10833
11156
|
] })
|
|
10834
11157
|
] }, slot.role)),
|
|
10835
|
-
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0,
|
|
10836
|
-
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0,
|
|
11158
|
+
showAdjustments && plan.adjustments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { role: "status", className: "flex flex-col gap-0.5 text-xs text-muted-foreground", "data-generation-adjustments": "", children: plan.adjustments.map((adjustment, index) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { "data-adjustment-field": adjustment.field, "data-adjustment-kind": adjustment.kind, children: adjustment.reason }, index)) }),
|
|
11159
|
+
showAdjustments && plan.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ul", { role: "alert", className: "flex flex-col gap-0.5 text-xs text-destructive", "data-generation-errors": "", children: plan.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("li", { "data-error-field": error.field, children: error.message }, index)) })
|
|
10837
11160
|
] });
|
|
10838
11161
|
};
|
|
10839
11162
|
|
|
10840
11163
|
// src/generation/JobProgress.tsx
|
|
10841
|
-
var
|
|
11164
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
10842
11165
|
var JobProgress = ({ title, className = "", ...options }) => {
|
|
10843
11166
|
const progress = useJobProgress(options);
|
|
10844
|
-
return /* @__PURE__ */ (0,
|
|
10845
|
-
/* @__PURE__ */ (0,
|
|
10846
|
-
title && /* @__PURE__ */ (0,
|
|
10847
|
-
/* @__PURE__ */ (0,
|
|
11167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: `flex flex-col gap-1 text-sm ${className}`, "data-job-progress": "", "data-done": options.done ? "" : void 0, children: [
|
|
11168
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex items-center justify-between gap-2 text-muted-foreground", children: [
|
|
11169
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "truncate text-foreground", children: title }),
|
|
11170
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { "data-job-progress-label": "", "aria-live": "polite", children: progress.label })
|
|
10848
11171
|
] }),
|
|
10849
|
-
/* @__PURE__ */ (0,
|
|
11172
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
10850
11173
|
"div",
|
|
10851
11174
|
{
|
|
10852
11175
|
role: "progressbar",
|
|
@@ -10856,7 +11179,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
10856
11179
|
"aria-valuenow": progress.percent,
|
|
10857
11180
|
"aria-valuetext": `${progress.percent}%, ${progress.label}`,
|
|
10858
11181
|
className: "h-1.5 w-full overflow-hidden rounded-full bg-muted",
|
|
10859
|
-
children: /* @__PURE__ */ (0,
|
|
11182
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
10860
11183
|
"div",
|
|
10861
11184
|
{
|
|
10862
11185
|
className: "h-full rounded-full bg-primary transition-[width] duration-500",
|
|
@@ -10869,9 +11192,9 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
10869
11192
|
};
|
|
10870
11193
|
|
|
10871
11194
|
// src/generation/AssetMentionChips.tsx
|
|
10872
|
-
var
|
|
11195
|
+
var import_react78 = require("react");
|
|
10873
11196
|
var import_generation3 = require("@pixerate/editor/generation");
|
|
10874
|
-
var
|
|
11197
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
10875
11198
|
var AssetMentionChips = ({
|
|
10876
11199
|
content,
|
|
10877
11200
|
onChange,
|
|
@@ -10881,14 +11204,14 @@ var AssetMentionChips = ({
|
|
|
10881
11204
|
renderAsset,
|
|
10882
11205
|
className = ""
|
|
10883
11206
|
}) => {
|
|
10884
|
-
const [open, setOpen] = (0,
|
|
10885
|
-
const rootRef = (0,
|
|
10886
|
-
const chips = (0,
|
|
11207
|
+
const [open, setOpen] = (0, import_react78.useState)(null);
|
|
11208
|
+
const rootRef = (0, import_react78.useRef)(null);
|
|
11209
|
+
const chips = (0, import_react78.useMemo)(
|
|
10887
11210
|
() => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
|
|
10888
11211
|
[content, assets, capabilities]
|
|
10889
11212
|
);
|
|
10890
11213
|
const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
|
|
10891
|
-
(0,
|
|
11214
|
+
(0, import_react78.useEffect)(() => {
|
|
10892
11215
|
if (open === null) return;
|
|
10893
11216
|
const onPointer = (event) => {
|
|
10894
11217
|
if (!rootRef.current?.contains(event.target)) setOpen(null);
|
|
@@ -10902,13 +11225,13 @@ var AssetMentionChips = ({
|
|
|
10902
11225
|
onChange((0, import_generation3.setMentionRoleInText)(content, chip2.start, role));
|
|
10903
11226
|
};
|
|
10904
11227
|
if (chips.length === 0) return null;
|
|
10905
|
-
return /* @__PURE__ */ (0,
|
|
11228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { ref: rootRef, className: `flex flex-wrap gap-1.5 ${className}`, "data-asset-mention-chips": "", children: chips.map((chip2) => {
|
|
10906
11229
|
const error = chip2.issues.find((issue) => issue.severity === "error");
|
|
10907
11230
|
const warning = chip2.issues.find((issue) => issue.severity === "warning");
|
|
10908
11231
|
const problem = error ?? warning;
|
|
10909
11232
|
const isOpen = open === chip2.index;
|
|
10910
|
-
return /* @__PURE__ */ (0,
|
|
10911
|
-
/* @__PURE__ */ (0,
|
|
11233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("span", { className: "relative inline-flex", "data-asset-chip": chip2.asset.id, children: [
|
|
11234
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
10912
11235
|
"button",
|
|
10913
11236
|
{
|
|
10914
11237
|
type: "button",
|
|
@@ -10922,8 +11245,8 @@ var AssetMentionChips = ({
|
|
|
10922
11245
|
},
|
|
10923
11246
|
className: `inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs ${error ? "border-red-500/60" : warning ? "border-amber-500/60" : "border-border"} bg-muted/40 hover:bg-muted`,
|
|
10924
11247
|
children: [
|
|
10925
|
-
/* @__PURE__ */ (0,
|
|
10926
|
-
/* @__PURE__ */ (0,
|
|
11248
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: renderAsset ? renderAsset(chip2) : `@${chip2.asset.label ?? chip2.handle}` }),
|
|
11249
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
10927
11250
|
"span",
|
|
10928
11251
|
{
|
|
10929
11252
|
className: `rounded px-1 text-[10px] uppercase tracking-wide ${chip2.role ? "bg-primary/15" : "opacity-60"}`,
|
|
@@ -10934,7 +11257,7 @@ var AssetMentionChips = ({
|
|
|
10934
11257
|
]
|
|
10935
11258
|
}
|
|
10936
11259
|
),
|
|
10937
|
-
isOpen && /* @__PURE__ */ (0,
|
|
11260
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
10938
11261
|
"div",
|
|
10939
11262
|
{
|
|
10940
11263
|
role: "listbox",
|
|
@@ -10945,7 +11268,7 @@ var AssetMentionChips = ({
|
|
|
10945
11268
|
if (e.key === "Escape") setOpen(null);
|
|
10946
11269
|
},
|
|
10947
11270
|
children: [
|
|
10948
|
-
options.map((option) => /* @__PURE__ */ (0,
|
|
11271
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
10949
11272
|
"button",
|
|
10950
11273
|
{
|
|
10951
11274
|
type: "button",
|
|
@@ -10956,13 +11279,13 @@ var AssetMentionChips = ({
|
|
|
10956
11279
|
onClick: () => pick(chip2, option.role),
|
|
10957
11280
|
className: "flex items-center justify-between gap-2 rounded px-2 py-1 text-left hover:bg-muted",
|
|
10958
11281
|
children: [
|
|
10959
|
-
/* @__PURE__ */ (0,
|
|
10960
|
-
option.accepts?.length ? /* @__PURE__ */ (0,
|
|
11282
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: option.label }),
|
|
11283
|
+
option.accepts?.length ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "text-[10px] opacity-60", children: option.accepts.join(", ") }) : null
|
|
10961
11284
|
]
|
|
10962
11285
|
},
|
|
10963
11286
|
option.role
|
|
10964
11287
|
)),
|
|
10965
|
-
/* @__PURE__ */ (0,
|
|
11288
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
10966
11289
|
"button",
|
|
10967
11290
|
{
|
|
10968
11291
|
type: "button",
|
|
@@ -10974,7 +11297,7 @@ var AssetMentionChips = ({
|
|
|
10974
11297
|
children: "No role"
|
|
10975
11298
|
}
|
|
10976
11299
|
),
|
|
10977
|
-
chip2.issues.length > 0 && /* @__PURE__ */ (0,
|
|
11300
|
+
chip2.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("ul", { className: "mt-1 border-t border-border px-2 pt-1 text-[10px]", "data-chip-issues": "", children: chip2.issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : "text-amber-500", children: issue.message }, i)) })
|
|
10978
11301
|
]
|
|
10979
11302
|
}
|
|
10980
11303
|
)
|
|
@@ -10983,15 +11306,15 @@ var AssetMentionChips = ({
|
|
|
10983
11306
|
};
|
|
10984
11307
|
|
|
10985
11308
|
// src/generation/GenerationHistory.tsx
|
|
10986
|
-
var
|
|
11309
|
+
var import_react79 = require("react");
|
|
10987
11310
|
var import_generation4 = require("@pixerate/editor/generation");
|
|
10988
|
-
var
|
|
11311
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
10989
11312
|
function useGenerationRecords(store, filter) {
|
|
10990
|
-
const [records, setRecords] = (0,
|
|
10991
|
-
const [loading, setLoading] = (0,
|
|
10992
|
-
const [error, setError] = (0,
|
|
11313
|
+
const [records, setRecords] = (0, import_react79.useState)([]);
|
|
11314
|
+
const [loading, setLoading] = (0, import_react79.useState)(!!store);
|
|
11315
|
+
const [error, setError] = (0, import_react79.useState)(null);
|
|
10993
11316
|
const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
|
|
10994
|
-
const refresh = (0,
|
|
11317
|
+
const refresh = (0, import_react79.useCallback)(async () => {
|
|
10995
11318
|
if (!store) {
|
|
10996
11319
|
setRecords([]);
|
|
10997
11320
|
setLoading(false);
|
|
@@ -11008,7 +11331,7 @@ function useGenerationRecords(store, filter) {
|
|
|
11008
11331
|
setLoading(false);
|
|
11009
11332
|
}
|
|
11010
11333
|
}, [store, filterKey]);
|
|
11011
|
-
(0,
|
|
11334
|
+
(0, import_react79.useEffect)(() => {
|
|
11012
11335
|
void refresh();
|
|
11013
11336
|
if (!store) return;
|
|
11014
11337
|
return store.subscribe(() => void refresh());
|
|
@@ -11034,21 +11357,21 @@ var GenerationHistory = ({
|
|
|
11034
11357
|
emptyText = "No generations yet.",
|
|
11035
11358
|
className = ""
|
|
11036
11359
|
}) => {
|
|
11037
|
-
const [innerMode, setInnerMode] = (0,
|
|
11360
|
+
const [innerMode, setInnerMode] = (0, import_react79.useState)("exact");
|
|
11038
11361
|
const mode = modeProp ?? innerMode;
|
|
11039
11362
|
const setMode = (next) => {
|
|
11040
11363
|
if (modeProp === void 0) setInnerMode(next);
|
|
11041
11364
|
onModeChange?.(next);
|
|
11042
11365
|
};
|
|
11043
|
-
const options = (0,
|
|
11044
|
-
const results = (0,
|
|
11045
|
-
const models = (0,
|
|
11366
|
+
const options = (0, import_react79.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
|
|
11367
|
+
const results = (0, import_react79.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
|
|
11368
|
+
const models = (0, import_react79.useMemo)(
|
|
11046
11369
|
() => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
|
|
11047
11370
|
[capabilities]
|
|
11048
11371
|
);
|
|
11049
|
-
return /* @__PURE__ */ (0,
|
|
11050
|
-
/* @__PURE__ */ (0,
|
|
11051
|
-
/* @__PURE__ */ (0,
|
|
11372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: `flex flex-col gap-2 text-sm ${className}`, "data-generation-history": "", children: [
|
|
11373
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center gap-2 text-xs", role: "radiogroup", "aria-label": "Recreate mode", children: ["exact", "latest"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("label", { className: "inline-flex items-center gap-1", children: [
|
|
11374
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11052
11375
|
"input",
|
|
11053
11376
|
{
|
|
11054
11377
|
type: "radio",
|
|
@@ -11061,34 +11384,34 @@ var GenerationHistory = ({
|
|
|
11061
11384
|
),
|
|
11062
11385
|
value === "exact" ? "Exact (recorded versions)" : "Latest templates & settings"
|
|
11063
11386
|
] }, value)) }),
|
|
11064
|
-
records.length === 0 && /* @__PURE__ */ (0,
|
|
11065
|
-
/* @__PURE__ */ (0,
|
|
11387
|
+
records.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyText }),
|
|
11388
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className: "flex flex-col gap-2", children: records.map((record, i) => {
|
|
11066
11389
|
const result = results[i];
|
|
11067
11390
|
const model = models.find((m) => m.id === record.provenance.modelId);
|
|
11068
11391
|
const blocked = !result.ok;
|
|
11069
|
-
return /* @__PURE__ */ (0,
|
|
11392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11070
11393
|
"li",
|
|
11071
11394
|
{
|
|
11072
11395
|
className: "rounded-md border border-border p-2",
|
|
11073
11396
|
"data-record": record.id,
|
|
11074
11397
|
"data-drift": result.drift.length,
|
|
11075
11398
|
children: [
|
|
11076
|
-
/* @__PURE__ */ (0,
|
|
11077
|
-
/* @__PURE__ */ (0,
|
|
11078
|
-
/* @__PURE__ */ (0,
|
|
11079
|
-
record.kind !== "generate" && /* @__PURE__ */ (0,
|
|
11399
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs", children: [
|
|
11400
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "font-medium", children: model?.name ?? record.provenance.modelId }),
|
|
11401
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
11402
|
+
record.kind !== "generate" && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("span", { "data-kind": "", children: [
|
|
11080
11403
|
record.kind,
|
|
11081
11404
|
" \xB7 "
|
|
11082
11405
|
] }),
|
|
11083
|
-
/* @__PURE__ */ (0,
|
|
11084
|
-
record.seed !== void 0 && /* @__PURE__ */ (0,
|
|
11406
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("time", { dateTime: record.createdAt, children: record.createdAt.replace("T", " ").slice(0, 16) }),
|
|
11407
|
+
record.seed !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
|
|
11085
11408
|
" \xB7 seed ",
|
|
11086
11409
|
record.seed
|
|
11087
11410
|
] })
|
|
11088
11411
|
] })
|
|
11089
11412
|
] }),
|
|
11090
|
-
/* @__PURE__ */ (0,
|
|
11091
|
-
record.assets.length > 0 && /* @__PURE__ */ (0,
|
|
11413
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "mt-1 line-clamp-3 break-words text-xs", "data-record-prompt": "", children: record.provenance.resolvedPrompt }),
|
|
11414
|
+
record.assets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "mt-1 flex flex-wrap gap-1", children: record.assets.map((asset) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
11092
11415
|
"span",
|
|
11093
11416
|
{
|
|
11094
11417
|
className: "rounded-full bg-muted px-2 py-0.5 text-[10px]",
|
|
@@ -11102,16 +11425,16 @@ var GenerationHistory = ({
|
|
|
11102
11425
|
`${asset.role}:${asset.id}`
|
|
11103
11426
|
)) }),
|
|
11104
11427
|
renderPreview?.(record),
|
|
11105
|
-
result.drift.length > 0 && /* @__PURE__ */ (0,
|
|
11106
|
-
/* @__PURE__ */ (0,
|
|
11428
|
+
result.drift.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { className: "mt-1 flex flex-col gap-0.5 text-[11px]", "data-drift-report": "", children: result.drift.map((item, j) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("li", { className: severityClass[item.severity], "data-drift-type": item.type, children: [
|
|
11429
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("strong", { children: [
|
|
11107
11430
|
import_generation4.DRIFT_TYPE_LABELS[item.type],
|
|
11108
11431
|
":"
|
|
11109
11432
|
] }),
|
|
11110
11433
|
" ",
|
|
11111
11434
|
item.message
|
|
11112
11435
|
] }, j)) }),
|
|
11113
|
-
/* @__PURE__ */ (0,
|
|
11114
|
-
onRecreate && /* @__PURE__ */ (0,
|
|
11436
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "mt-2 flex gap-2", children: [
|
|
11437
|
+
onRecreate && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11115
11438
|
"button",
|
|
11116
11439
|
{
|
|
11117
11440
|
type: "button",
|
|
@@ -11123,7 +11446,7 @@ var GenerationHistory = ({
|
|
|
11123
11446
|
children: "Recreate"
|
|
11124
11447
|
}
|
|
11125
11448
|
),
|
|
11126
|
-
onVariation && /* @__PURE__ */ (0,
|
|
11449
|
+
onVariation && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11127
11450
|
"button",
|
|
11128
11451
|
{
|
|
11129
11452
|
type: "button",
|
|
@@ -11133,7 +11456,7 @@ var GenerationHistory = ({
|
|
|
11133
11456
|
children: "Variation"
|
|
11134
11457
|
}
|
|
11135
11458
|
),
|
|
11136
|
-
onRemove && /* @__PURE__ */ (0,
|
|
11459
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
11137
11460
|
"button",
|
|
11138
11461
|
{
|
|
11139
11462
|
type: "button",
|
|
@@ -11153,19 +11476,19 @@ var GenerationHistory = ({
|
|
|
11153
11476
|
};
|
|
11154
11477
|
|
|
11155
11478
|
// src/find-replace/useFindReplace.ts
|
|
11156
|
-
var
|
|
11479
|
+
var import_react80 = require("react");
|
|
11157
11480
|
var import_editor17 = require("@pixerate/editor");
|
|
11158
11481
|
var noopUnsubscribe2 = () => {
|
|
11159
11482
|
};
|
|
11160
11483
|
function useFindReplace(editor) {
|
|
11161
11484
|
const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
|
|
11162
|
-
const subscribe = (0,
|
|
11485
|
+
const subscribe = (0, import_react80.useCallback)(
|
|
11163
11486
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
11164
11487
|
[store]
|
|
11165
11488
|
);
|
|
11166
11489
|
const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
11167
|
-
const snapshot = (0,
|
|
11168
|
-
return (0,
|
|
11490
|
+
const snapshot = (0, import_react80.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
|
|
11491
|
+
return (0, import_react80.useMemo)(() => {
|
|
11169
11492
|
const run = (fn) => {
|
|
11170
11493
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
11171
11494
|
};
|
|
@@ -11189,9 +11512,9 @@ function useFindReplace(editor) {
|
|
|
11189
11512
|
}
|
|
11190
11513
|
|
|
11191
11514
|
// src/find-replace/FindReplaceBar.tsx
|
|
11192
|
-
var
|
|
11515
|
+
var import_react81 = require("react");
|
|
11193
11516
|
var import_editor18 = require("@pixerate/editor");
|
|
11194
|
-
var
|
|
11517
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
11195
11518
|
var inputClass3 = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
|
|
11196
11519
|
var buttonClass5 = "rounded px-2 py-1 text-xs text-foreground hover:bg-muted disabled:opacity-40 disabled:hover:bg-transparent";
|
|
11197
11520
|
var toggleClass = (on) => `${buttonClass5} font-mono ${on ? "bg-primary/10 text-primary" : "text-muted-foreground"}`;
|
|
@@ -11204,10 +11527,10 @@ var FindReplaceBar = ({
|
|
|
11204
11527
|
onClose
|
|
11205
11528
|
}) => {
|
|
11206
11529
|
const find = useFindReplace(editor);
|
|
11207
|
-
const findInput = (0,
|
|
11208
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
11530
|
+
const findInput = (0, import_react81.useRef)(null);
|
|
11531
|
+
const [moreOpen, setMoreOpen] = (0, import_react81.useState)(false);
|
|
11209
11532
|
const visible = find.available && (alwaysOpen || find.open);
|
|
11210
|
-
(0,
|
|
11533
|
+
(0, import_react81.useEffect)(() => {
|
|
11211
11534
|
if (!visible || find.focusRequest === 0) return;
|
|
11212
11535
|
findInput.current?.focus();
|
|
11213
11536
|
findInput.current?.select();
|
|
@@ -11245,9 +11568,9 @@ var FindReplaceBar = ({
|
|
|
11245
11568
|
if (isMod(e)) find.replaceAll();
|
|
11246
11569
|
else find.replace();
|
|
11247
11570
|
};
|
|
11248
|
-
return /* @__PURE__ */ (0,
|
|
11249
|
-
/* @__PURE__ */ (0,
|
|
11250
|
-
/* @__PURE__ */ (0,
|
|
11571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className, role: "search", "aria-label": "Find and replace", onKeyDown: onBarKeyDown, children: [
|
|
11572
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
11573
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11251
11574
|
"button",
|
|
11252
11575
|
{
|
|
11253
11576
|
type: "button",
|
|
@@ -11258,7 +11581,7 @@ var FindReplaceBar = ({
|
|
|
11258
11581
|
children: showReplace ? "\u25BE" : "\u25B8"
|
|
11259
11582
|
}
|
|
11260
11583
|
),
|
|
11261
|
-
/* @__PURE__ */ (0,
|
|
11584
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11262
11585
|
"input",
|
|
11263
11586
|
{
|
|
11264
11587
|
ref: findInput,
|
|
@@ -11272,7 +11595,7 @@ var FindReplaceBar = ({
|
|
|
11272
11595
|
onKeyDown: onFindKeyDown
|
|
11273
11596
|
}
|
|
11274
11597
|
),
|
|
11275
|
-
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0,
|
|
11598
|
+
import_editor18.FIND_OPTION_TOGGLES.filter((t) => !t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11276
11599
|
"button",
|
|
11277
11600
|
{
|
|
11278
11601
|
type: "button",
|
|
@@ -11285,7 +11608,7 @@ var FindReplaceBar = ({
|
|
|
11285
11608
|
},
|
|
11286
11609
|
t.key
|
|
11287
11610
|
)),
|
|
11288
|
-
/* @__PURE__ */ (0,
|
|
11611
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11289
11612
|
"span",
|
|
11290
11613
|
{
|
|
11291
11614
|
className: `min-w-[5rem] px-1 text-center text-xs ${find.error ? "text-destructive" : "text-muted-foreground"}`,
|
|
@@ -11295,9 +11618,9 @@ var FindReplaceBar = ({
|
|
|
11295
11618
|
children: status
|
|
11296
11619
|
}
|
|
11297
11620
|
),
|
|
11298
|
-
/* @__PURE__ */ (0,
|
|
11299
|
-
/* @__PURE__ */ (0,
|
|
11300
|
-
showMoreOptions && /* @__PURE__ */ (0,
|
|
11621
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Previous match", disabled: !hasMatches, onClick: find.previous, children: "\u2191" }),
|
|
11622
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Next match", disabled: !hasMatches, onClick: find.next, children: "\u2193" }),
|
|
11623
|
+
showMoreOptions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11301
11624
|
"button",
|
|
11302
11625
|
{
|
|
11303
11626
|
type: "button",
|
|
@@ -11308,10 +11631,10 @@ var FindReplaceBar = ({
|
|
|
11308
11631
|
children: "\u2026"
|
|
11309
11632
|
}
|
|
11310
11633
|
),
|
|
11311
|
-
/* @__PURE__ */ (0,
|
|
11634
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Close find", onClick: close, children: "\xD7" })
|
|
11312
11635
|
] }),
|
|
11313
|
-
showReplace && /* @__PURE__ */ (0,
|
|
11314
|
-
/* @__PURE__ */ (0,
|
|
11636
|
+
showReplace && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-1 pl-7", children: [
|
|
11637
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11315
11638
|
"input",
|
|
11316
11639
|
{
|
|
11317
11640
|
type: "text",
|
|
@@ -11323,7 +11646,7 @@ var FindReplaceBar = ({
|
|
|
11323
11646
|
onKeyDown: onReplaceKeyDown
|
|
11324
11647
|
}
|
|
11325
11648
|
),
|
|
11326
|
-
/* @__PURE__ */ (0,
|
|
11649
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11327
11650
|
"button",
|
|
11328
11651
|
{
|
|
11329
11652
|
type: "button",
|
|
@@ -11333,11 +11656,11 @@ var FindReplaceBar = ({
|
|
|
11333
11656
|
children: "Replace"
|
|
11334
11657
|
}
|
|
11335
11658
|
),
|
|
11336
|
-
/* @__PURE__ */ (0,
|
|
11337
|
-
find.lastReplaceCount !== null && /* @__PURE__ */ (0,
|
|
11659
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { type: "button", className: buttonClass5, disabled: !hasMatches, onClick: find.replaceAll, children: "Replace all" }),
|
|
11660
|
+
find.lastReplaceCount !== null && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "px-1 text-xs text-muted-foreground", "aria-live": "polite", children: find.lastReplaceCount === 1 ? "1 replaced" : `${find.lastReplaceCount} replaced` })
|
|
11338
11661
|
] }),
|
|
11339
|
-
showMoreOptions && moreOpen && /* @__PURE__ */ (0,
|
|
11340
|
-
/* @__PURE__ */ (0,
|
|
11662
|
+
showMoreOptions && moreOpen && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 pl-7 text-xs text-muted-foreground", children: import_editor18.FIND_OPTION_TOGGLES.filter((t) => t.advanced).map((t) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
11663
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
11341
11664
|
"input",
|
|
11342
11665
|
{
|
|
11343
11666
|
type: "checkbox",
|
|
@@ -11351,12 +11674,12 @@ var FindReplaceBar = ({
|
|
|
11351
11674
|
};
|
|
11352
11675
|
|
|
11353
11676
|
// src/tables/useTableMenu.ts
|
|
11354
|
-
var
|
|
11677
|
+
var import_react82 = require("react");
|
|
11355
11678
|
var import_editor19 = require("@pixerate/editor");
|
|
11356
11679
|
function useTableMenu(editor) {
|
|
11357
|
-
const store = (0,
|
|
11358
|
-
const snapshot = (0,
|
|
11359
|
-
return (0,
|
|
11680
|
+
const store = (0, import_react82.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
|
|
11681
|
+
const snapshot = (0, import_react82.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
11682
|
+
return (0, import_react82.useMemo)(
|
|
11360
11683
|
() => ({
|
|
11361
11684
|
...snapshot,
|
|
11362
11685
|
run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
|
|
@@ -11367,9 +11690,9 @@ function useTableMenu(editor) {
|
|
|
11367
11690
|
}
|
|
11368
11691
|
|
|
11369
11692
|
// src/tables/TableToolbar.tsx
|
|
11370
|
-
var
|
|
11693
|
+
var import_react83 = __toESM(require("react"), 1);
|
|
11371
11694
|
var import_editor20 = require("@pixerate/editor");
|
|
11372
|
-
var
|
|
11695
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
11373
11696
|
var keepSelection2 = (event) => event.preventDefault();
|
|
11374
11697
|
var TableToolbar = ({
|
|
11375
11698
|
editor,
|
|
@@ -11383,14 +11706,14 @@ var TableToolbar = ({
|
|
|
11383
11706
|
}) => {
|
|
11384
11707
|
const table = useTableMenu(editor);
|
|
11385
11708
|
if (!editor || !table.inTable && !showWhenOutside) return null;
|
|
11386
|
-
return /* @__PURE__ */ (0,
|
|
11709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, role: "toolbar", "aria-label": "Table", "data-table-toolbar": "", children: items.map((item, index) => {
|
|
11387
11710
|
const status = table.check(item.action, item.params);
|
|
11388
11711
|
const enabled = status === true;
|
|
11389
11712
|
const active = item.active?.(table);
|
|
11390
11713
|
const separator = index > 0 && items[index - 1].group !== item.group;
|
|
11391
|
-
return /* @__PURE__ */ (0,
|
|
11392
|
-
separator && /* @__PURE__ */ (0,
|
|
11393
|
-
/* @__PURE__ */ (0,
|
|
11714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react83.default.Fragment, { children: [
|
|
11715
|
+
separator && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
|
|
11716
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
11394
11717
|
"button",
|
|
11395
11718
|
{
|
|
11396
11719
|
type: "button",
|
|
@@ -11412,8 +11735,8 @@ var TableToolbar = ({
|
|
|
11412
11735
|
};
|
|
11413
11736
|
|
|
11414
11737
|
// src/tables/InsertTableGrid.tsx
|
|
11415
|
-
var
|
|
11416
|
-
var
|
|
11738
|
+
var import_react84 = require("react");
|
|
11739
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
11417
11740
|
var keepSelection3 = (event) => event.preventDefault();
|
|
11418
11741
|
var InsertTableGrid = ({
|
|
11419
11742
|
editor,
|
|
@@ -11426,14 +11749,14 @@ var InsertTableGrid = ({
|
|
|
11426
11749
|
onInsert
|
|
11427
11750
|
}) => {
|
|
11428
11751
|
const table = useTableMenu(editor);
|
|
11429
|
-
const [hover, setHover] = (0,
|
|
11752
|
+
const [hover, setHover] = (0, import_react84.useState)(null);
|
|
11430
11753
|
const status = table.actions.insertTable;
|
|
11431
11754
|
const disabled = !editor || !status.enabled;
|
|
11432
11755
|
const insert = (size) => {
|
|
11433
11756
|
if (table.run("insertTable", { ...size, withHeaderRow })) onInsert?.(size);
|
|
11434
11757
|
setHover(null);
|
|
11435
11758
|
};
|
|
11436
|
-
return /* @__PURE__ */ (0,
|
|
11759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
11437
11760
|
"div",
|
|
11438
11761
|
{
|
|
11439
11762
|
className,
|
|
@@ -11443,7 +11766,7 @@ var InsertTableGrid = ({
|
|
|
11443
11766
|
"data-insert-table-grid": "",
|
|
11444
11767
|
onMouseLeave: () => setHover(null),
|
|
11445
11768
|
children: [
|
|
11446
|
-
/* @__PURE__ */ (0,
|
|
11769
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
11447
11770
|
"div",
|
|
11448
11771
|
{
|
|
11449
11772
|
role: "grid",
|
|
@@ -11452,7 +11775,7 @@ var InsertTableGrid = ({
|
|
|
11452
11775
|
children: Array.from({ length: rows * cols }, (_, i) => {
|
|
11453
11776
|
const size = { rows: Math.floor(i / cols) + 1, cols: i % cols + 1 };
|
|
11454
11777
|
const active = !!hover && size.rows <= hover.rows && size.cols <= hover.cols;
|
|
11455
|
-
return /* @__PURE__ */ (0,
|
|
11778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
11456
11779
|
"button",
|
|
11457
11780
|
{
|
|
11458
11781
|
type: "button",
|
|
@@ -11472,7 +11795,7 @@ var InsertTableGrid = ({
|
|
|
11472
11795
|
})
|
|
11473
11796
|
}
|
|
11474
11797
|
),
|
|
11475
|
-
/* @__PURE__ */ (0,
|
|
11798
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { "aria-live": "polite", "data-testid": "insert-table-size", children: disabled ? status.reason : hover ? `${hover.rows} \xD7 ${hover.cols}` : "Insert table" })
|
|
11476
11799
|
]
|
|
11477
11800
|
}
|
|
11478
11801
|
);
|
|
@@ -11480,31 +11803,31 @@ var InsertTableGrid = ({
|
|
|
11480
11803
|
|
|
11481
11804
|
// src/tables/TableBubbleMenu.tsx
|
|
11482
11805
|
var import_editor21 = require("@pixerate/editor");
|
|
11483
|
-
var
|
|
11806
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
11484
11807
|
var TableBubbleMenu = ({
|
|
11485
11808
|
editor,
|
|
11486
11809
|
children,
|
|
11487
11810
|
toolbarProps,
|
|
11488
11811
|
pluginKey = "tableBubbleMenu",
|
|
11489
11812
|
...rest
|
|
11490
|
-
}) => /* @__PURE__ */ (0,
|
|
11813
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(BubbleMenu, { editor, pluginKey, shouldShow: import_editor21.shouldShowTableBubbleMenu, ...rest, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TableToolbar, { editor, ...toolbarProps }) });
|
|
11491
11814
|
|
|
11492
11815
|
// src/chart-node/ChartNodeView.tsx
|
|
11493
11816
|
var import_client = require("react-dom/client");
|
|
11494
11817
|
|
|
11495
11818
|
// src/chart/ChartCanvas.tsx
|
|
11496
|
-
var
|
|
11819
|
+
var import_react86 = require("react");
|
|
11497
11820
|
var import_chart2 = require("@pixerate/editor/chart");
|
|
11498
11821
|
|
|
11499
11822
|
// src/chart/useChartEditor.ts
|
|
11500
|
-
var
|
|
11823
|
+
var import_react85 = require("react");
|
|
11501
11824
|
var import_chart = require("@pixerate/editor/chart");
|
|
11502
11825
|
function useChartState(controller) {
|
|
11503
|
-
return (0,
|
|
11826
|
+
return (0, import_react85.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
11504
11827
|
}
|
|
11505
11828
|
|
|
11506
11829
|
// src/chart/ChartCanvas.tsx
|
|
11507
|
-
var
|
|
11830
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
11508
11831
|
function renderChartMark(mark, fontFamily, interactive) {
|
|
11509
11832
|
const common = {
|
|
11510
11833
|
"data-role": mark.role,
|
|
@@ -11516,9 +11839,9 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11516
11839
|
};
|
|
11517
11840
|
switch (mark.kind) {
|
|
11518
11841
|
case "rect":
|
|
11519
|
-
return /* @__PURE__ */ (0,
|
|
11842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("rect", { ...common, x: mark.x, y: mark.y, width: mark.width, height: mark.height, rx: mark.radius, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
11520
11843
|
case "path":
|
|
11521
|
-
return /* @__PURE__ */ (0,
|
|
11844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11522
11845
|
"path",
|
|
11523
11846
|
{
|
|
11524
11847
|
...common,
|
|
@@ -11531,11 +11854,11 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11531
11854
|
mark.key
|
|
11532
11855
|
);
|
|
11533
11856
|
case "circle":
|
|
11534
|
-
return /* @__PURE__ */ (0,
|
|
11857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
11535
11858
|
case "line":
|
|
11536
|
-
return /* @__PURE__ */ (0,
|
|
11859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("line", { ...common, x1: mark.x1, y1: mark.y1, x2: mark.x2, y2: mark.y2, strokeDasharray: mark.dash, style: { stroke: mark.stroke, strokeWidth: mark.strokeWidth } }, mark.key);
|
|
11537
11860
|
case "text":
|
|
11538
|
-
return /* @__PURE__ */ (0,
|
|
11861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11539
11862
|
"text",
|
|
11540
11863
|
{
|
|
11541
11864
|
...common,
|
|
@@ -11552,36 +11875,36 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
11552
11875
|
}
|
|
11553
11876
|
}
|
|
11554
11877
|
function ChartPresenceLayer({ presence }) {
|
|
11555
|
-
const { actors } = (0,
|
|
11556
|
-
return /* @__PURE__ */ (0,
|
|
11557
|
-
/* @__PURE__ */ (0,
|
|
11558
|
-
/* @__PURE__ */ (0,
|
|
11559
|
-
/* @__PURE__ */ (0,
|
|
11560
|
-
/* @__PURE__ */ (0,
|
|
11878
|
+
const { actors } = (0, import_react86.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
11879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
|
|
11880
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 }, transform: a.pressed ? "scale(0.9)" : void 0 }),
|
|
11881
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("g", { transform: "translate(13 16)", children: [
|
|
11882
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("rect", { x: 0, y: 0, rx: 4, height: 18, width: Math.max(28, (a.message ?? a.name).length * 6.4 + 12), style: { fill: a.color } }),
|
|
11883
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("text", { x: 6, y: 9, dominantBaseline: "central", style: { fill: "#ffffff", fontSize: 11, fontWeight: 600, fontFamily: "inherit" }, children: a.message ?? a.name })
|
|
11561
11884
|
] })
|
|
11562
11885
|
] }, a.id)) });
|
|
11563
11886
|
}
|
|
11564
11887
|
function ChartTooltipContent({ tooltip }) {
|
|
11565
|
-
return /* @__PURE__ */ (0,
|
|
11566
|
-
tooltip.title && /* @__PURE__ */ (0,
|
|
11567
|
-
tooltip.items.map((item) => /* @__PURE__ */ (0,
|
|
11568
|
-
/* @__PURE__ */ (0,
|
|
11569
|
-
/* @__PURE__ */ (0,
|
|
11570
|
-
/* @__PURE__ */ (0,
|
|
11888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
|
|
11889
|
+
tooltip.title && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "mb-1 font-medium", children: tooltip.title }),
|
|
11890
|
+
tooltip.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11891
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { background: item.color } }),
|
|
11892
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { style: { color: "var(--muted-foreground, #64748b)" }, children: item.name }),
|
|
11893
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ml-auto pl-3 font-medium tabular-nums", children: item.text })
|
|
11571
11894
|
] }, item.seriesId))
|
|
11572
11895
|
] });
|
|
11573
11896
|
}
|
|
11574
11897
|
function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
|
|
11575
11898
|
const state = useChartState(controller);
|
|
11576
|
-
const wrapper = (0,
|
|
11577
|
-
const svg = (0,
|
|
11578
|
-
const drag = (0,
|
|
11579
|
-
const [measured, setMeasured] = (0,
|
|
11580
|
-
const [frozen, setFrozen] = (0,
|
|
11899
|
+
const wrapper = (0, import_react86.useRef)(null);
|
|
11900
|
+
const svg = (0, import_react86.useRef)(null);
|
|
11901
|
+
const drag = (0, import_react86.useRef)(null);
|
|
11902
|
+
const [measured, setMeasured] = (0, import_react86.useState)(null);
|
|
11903
|
+
const [frozen, setFrozen] = (0, import_react86.useState)(null);
|
|
11581
11904
|
const tooltipMode = tooltip === true ? "point" : tooltip || null;
|
|
11582
|
-
const [tip, setTip] = (0,
|
|
11583
|
-
const [tipAt, setTipAt] = (0,
|
|
11584
|
-
(0,
|
|
11905
|
+
const [tip, setTip] = (0, import_react86.useState)(null);
|
|
11906
|
+
const [tipAt, setTipAt] = (0, import_react86.useState)({ left: 0, top: 0, flip: false });
|
|
11907
|
+
(0, import_react86.useEffect)(() => {
|
|
11585
11908
|
const el = wrapper.current;
|
|
11586
11909
|
if (!responsive || !el || typeof ResizeObserver === "undefined") return;
|
|
11587
11910
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -11592,8 +11915,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11592
11915
|
return () => observer.disconnect();
|
|
11593
11916
|
}, [responsive]);
|
|
11594
11917
|
const sceneWidth = responsive && measured || width;
|
|
11595
|
-
const fullTheme = (0,
|
|
11596
|
-
const scene = (0,
|
|
11918
|
+
const fullTheme = (0, import_react86.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
|
|
11919
|
+
const scene = (0, import_react86.useMemo)(
|
|
11597
11920
|
() => (0, import_chart2.layoutChart)(state.spec, {
|
|
11598
11921
|
width: sceneWidth,
|
|
11599
11922
|
height,
|
|
@@ -11610,8 +11933,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11610
11933
|
[state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
|
|
11611
11934
|
);
|
|
11612
11935
|
if (sceneRef) sceneRef.current = scene;
|
|
11613
|
-
const byKey = (0,
|
|
11614
|
-
(0,
|
|
11936
|
+
const byKey = (0, import_react86.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
|
|
11937
|
+
(0, import_react86.useEffect)(() => () => drag.current?.end(), []);
|
|
11615
11938
|
const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
|
|
11616
11939
|
const onPointerDown = (e) => {
|
|
11617
11940
|
if (!editable || e.button !== 0) return;
|
|
@@ -11658,8 +11981,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11658
11981
|
if (editable && (0, import_chart2.handleChartKey)(controller, scene, e)) e.preventDefault();
|
|
11659
11982
|
};
|
|
11660
11983
|
const label = state.spec.title || "Chart";
|
|
11661
|
-
return /* @__PURE__ */ (0,
|
|
11662
|
-
/* @__PURE__ */ (0,
|
|
11984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { ref: wrapper, className: `relative w-full ${className ?? ""}`, "data-chart-canvas": "", children: [
|
|
11985
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
|
|
11663
11986
|
"svg",
|
|
11664
11987
|
{
|
|
11665
11988
|
ref: svg,
|
|
@@ -11678,11 +12001,11 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11678
12001
|
onKeyDown,
|
|
11679
12002
|
children: [
|
|
11680
12003
|
scene.marks.map((m) => renderChartMark(m, scene.theme.fontFamily, editable)),
|
|
11681
|
-
presence && /* @__PURE__ */ (0,
|
|
12004
|
+
presence && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ChartPresenceLayer, { presence })
|
|
11682
12005
|
]
|
|
11683
12006
|
}
|
|
11684
12007
|
),
|
|
11685
|
-
tip && /* @__PURE__ */ (0,
|
|
12008
|
+
tip && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
11686
12009
|
"div",
|
|
11687
12010
|
{
|
|
11688
12011
|
role: "tooltip",
|
|
@@ -11697,14 +12020,14 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
11697
12020
|
borderColor: "var(--border, #e2e8f0)",
|
|
11698
12021
|
fontFamily: scene.theme.fontFamily
|
|
11699
12022
|
},
|
|
11700
|
-
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0,
|
|
12023
|
+
children: renderTooltip ? renderTooltip(tip) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ChartTooltipContent, { tooltip: tip })
|
|
11701
12024
|
}
|
|
11702
12025
|
)
|
|
11703
12026
|
] });
|
|
11704
12027
|
}
|
|
11705
12028
|
|
|
11706
12029
|
// src/chart/ChartDataGrid.tsx
|
|
11707
|
-
var
|
|
12030
|
+
var import_react87 = require("react");
|
|
11708
12031
|
var import_chart3 = require("@pixerate/editor/chart");
|
|
11709
12032
|
|
|
11710
12033
|
// src/chart/styles.ts
|
|
@@ -11717,11 +12040,11 @@ var chartSectionClass = "space-y-2 border-b border-border pb-3 last:border-b-0";
|
|
|
11717
12040
|
var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right text-xs tabular-nums text-foreground focus-visible:bg-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary";
|
|
11718
12041
|
|
|
11719
12042
|
// src/chart/ChartDataGrid.tsx
|
|
11720
|
-
var
|
|
12043
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
11721
12044
|
function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
11722
|
-
const [draft, setDraft] = (0,
|
|
11723
|
-
const typing = (0,
|
|
11724
|
-
(0,
|
|
12045
|
+
const [draft, setDraft] = (0, import_react87.useState)(value);
|
|
12046
|
+
const typing = (0, import_react87.useRef)(false);
|
|
12047
|
+
(0, import_react87.useEffect)(() => {
|
|
11725
12048
|
if (!typing.current) setDraft(value);
|
|
11726
12049
|
}, [value]);
|
|
11727
12050
|
const commit = () => {
|
|
@@ -11730,7 +12053,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
11730
12053
|
if (draft === value) return;
|
|
11731
12054
|
if (onCommit(draft) === false) setDraft(value);
|
|
11732
12055
|
};
|
|
11733
|
-
return /* @__PURE__ */ (0,
|
|
12056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11734
12057
|
"input",
|
|
11735
12058
|
{
|
|
11736
12059
|
...rest,
|
|
@@ -11759,20 +12082,20 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
|
11759
12082
|
}
|
|
11760
12083
|
function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
11761
12084
|
const { spec } = useChartState(controller);
|
|
11762
|
-
const [columns, setColumns] = (0,
|
|
12085
|
+
const [columns, setColumns] = (0, import_react87.useState)(1);
|
|
11763
12086
|
const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
|
|
11764
12087
|
const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
|
|
11765
12088
|
const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
|
|
11766
12089
|
const commit = (next) => controller.setTreeRows(next).ok;
|
|
11767
|
-
return /* @__PURE__ */ (0,
|
|
11768
|
-
/* @__PURE__ */ (0,
|
|
11769
|
-
/* @__PURE__ */ (0,
|
|
11770
|
-
labels.map((label) => /* @__PURE__ */ (0,
|
|
11771
|
-
/* @__PURE__ */ (0,
|
|
11772
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-tree-grid": "", children: [
|
|
12091
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12092
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12093
|
+
labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
12094
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
12095
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border" })
|
|
11773
12096
|
] }) }),
|
|
11774
|
-
/* @__PURE__ */ (0,
|
|
11775
|
-
labels.map((_, k) => /* @__PURE__ */ (0,
|
|
12097
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: rows.map((row, r) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-tree-row": r, children: [
|
|
12098
|
+
labels.map((_, k) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11776
12099
|
ChartCommitInput,
|
|
11777
12100
|
{
|
|
11778
12101
|
value: row.path[k] ?? "",
|
|
@@ -11783,7 +12106,7 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
11783
12106
|
className: `${chartCellClass} text-left`
|
|
11784
12107
|
}
|
|
11785
12108
|
) }, k)),
|
|
11786
|
-
/* @__PURE__ */ (0,
|
|
12109
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11787
12110
|
ChartCommitInput,
|
|
11788
12111
|
{
|
|
11789
12112
|
value: String(row.value),
|
|
@@ -11796,14 +12119,14 @@ function ChartTreeGrid({ controller, readOnly = false, className }) {
|
|
|
11796
12119
|
className: chartCellClass
|
|
11797
12120
|
}
|
|
11798
12121
|
) }),
|
|
11799
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12122
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete item", "aria-label": `Delete ${row.path.join(" / ")}`, "data-action": "tree-remove-row", onClick: () => commit((0, import_chart3.removeChartTreeRow)(rows, r)), children: "\xD7" }) })
|
|
11800
12123
|
] }, r)) })
|
|
11801
12124
|
] }),
|
|
11802
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
11803
|
-
/* @__PURE__ */ (0,
|
|
11804
|
-
/* @__PURE__ */ (0,
|
|
11805
|
-
/* @__PURE__ */ (0,
|
|
11806
|
-
/* @__PURE__ */ (0,
|
|
12125
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
12126
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-row", onClick: () => commit((0, import_chart3.addChartTreeRow)(rows)), children: "+ Add item" }),
|
|
12127
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "tree-add-level", disabled: depth >= 6, onClick: () => setColumns(depth + 1), children: "+ Level" }),
|
|
12128
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "flex-1" }),
|
|
12129
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "tree-ungroup", title: "Keep the group totals as plain data", onClick: () => controller.setTree([]), children: "Ungroup" })
|
|
11807
12130
|
] })
|
|
11808
12131
|
] });
|
|
11809
12132
|
}
|
|
@@ -11811,30 +12134,30 @@ function ChartLinksGrid({ controller, readOnly = false, className }) {
|
|
|
11811
12134
|
const { spec } = useChartState(controller);
|
|
11812
12135
|
const links = spec.links;
|
|
11813
12136
|
const commit = (next) => controller.setLinks(next).ok;
|
|
11814
|
-
return /* @__PURE__ */ (0,
|
|
11815
|
-
/* @__PURE__ */ (0,
|
|
11816
|
-
/* @__PURE__ */ (0,
|
|
11817
|
-
["Source", "Target"].map((label) => /* @__PURE__ */ (0,
|
|
11818
|
-
/* @__PURE__ */ (0,
|
|
11819
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", "data-chart-links-grid": "", children: [
|
|
12138
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12139
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12140
|
+
["Source", "Target"].map((label) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: label }, label)),
|
|
12141
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-right font-medium text-muted-foreground", children: "Value" }),
|
|
12142
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border" })
|
|
11820
12143
|
] }) }),
|
|
11821
|
-
/* @__PURE__ */ (0,
|
|
11822
|
-
["source", "target"].map((field) => /* @__PURE__ */ (0,
|
|
11823
|
-
/* @__PURE__ */ (0,
|
|
11824
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12144
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: links.map((link, i) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-link-row": i, children: [
|
|
12145
|
+
["source", "target"].map((field) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartCommitInput, { value: link[field], "aria-label": `${field === "source" ? "Source" : "Target"} of flow ${i + 1}`, "data-link-cell": `${i}:${field}`, readOnly, onCommit: (text) => commit((0, import_chart3.setChartLinkField)(links, i, field, text)), className: `${chartCellClass} text-left` }) }, field)),
|
|
12146
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-r border-border p-0", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartCommitInput, { value: String(link.value), inputMode: "decimal", "aria-label": `Value of ${link.source} \u2192 ${link.target}`, "data-link-cell": `${i}:value`, readOnly, onCommit: (text) => commit((0, import_chart3.setChartLinkField)(links, i, "value", text)), className: chartCellClass }) }),
|
|
12147
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete flow", "aria-label": `Delete ${link.source} \u2192 ${link.target}`, "data-action": "link-remove", onClick: () => controller.removeLink(i), children: "\xD7" }) })
|
|
11825
12148
|
] }, i)) })
|
|
11826
12149
|
] }),
|
|
11827
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
11828
|
-
/* @__PURE__ */ (0,
|
|
11829
|
-
/* @__PURE__ */ (0,
|
|
11830
|
-
links.length > 0 && /* @__PURE__ */ (0,
|
|
12150
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex flex-wrap gap-1 p-1", children: [
|
|
12151
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "link-add", onClick: () => commit((0, import_chart3.addChartLink)(links)), children: "+ Add flow" }),
|
|
12152
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "flex-1" }),
|
|
12153
|
+
links.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6`, "data-action": "links-clear", title: "Keep how much passes through each node as plain data", onClick: () => controller.setLinks([]), children: "Remove flows" })
|
|
11831
12154
|
] })
|
|
11832
12155
|
] });
|
|
11833
12156
|
}
|
|
11834
12157
|
function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = false, className }) {
|
|
11835
12158
|
const { spec, selection } = useChartState(controller);
|
|
11836
|
-
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0,
|
|
11837
|
-
if (spec.tree.length) return /* @__PURE__ */ (0,
|
|
12159
|
+
if (spec.links.length || spec.type === "sankey") return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartLinksGrid, { controller, readOnly, className });
|
|
12160
|
+
if (spec.tree.length) return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ChartTreeGrid, { controller, readOnly, className });
|
|
11838
12161
|
const canGroup = spec.type === "treemap" || spec.type === "sunburst";
|
|
11839
12162
|
const paste = (row, column) => (e) => {
|
|
11840
12163
|
const text = e.clipboardData?.getData("text/plain") ?? "";
|
|
@@ -11842,15 +12165,15 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11842
12165
|
e.preventDefault();
|
|
11843
12166
|
controller.pasteCells(row, column, text);
|
|
11844
12167
|
};
|
|
11845
|
-
return /* @__PURE__ */ (0,
|
|
11846
|
-
/* @__PURE__ */ (0,
|
|
11847
|
-
/* @__PURE__ */ (0,
|
|
11848
|
-
/* @__PURE__ */ (0,
|
|
12168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `overflow-auto rounded-md border border-border ${className ?? ""}`, "data-chart-grid": "", children: [
|
|
12169
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
|
|
12170
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("thead", { className: "bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { children: [
|
|
12171
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border px-2 py-1 text-left font-medium text-muted-foreground", children: categoryHeader }),
|
|
11849
12172
|
spec.series.map((s, si) => {
|
|
11850
12173
|
const color = (0, import_chart3.chartSeriesColor)(spec, si);
|
|
11851
12174
|
const selected = selection?.kind === "series" && selection.seriesId === s.id;
|
|
11852
|
-
return /* @__PURE__ */ (0,
|
|
11853
|
-
/* @__PURE__ */ (0,
|
|
12175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { "data-series-id": s.id, className: `border-b border-r border-border px-1 py-1 font-medium ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12176
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11854
12177
|
"input",
|
|
11855
12178
|
{
|
|
11856
12179
|
type: "color",
|
|
@@ -11863,7 +12186,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11863
12186
|
className: "h-5 w-5 shrink-0 cursor-pointer rounded border-0 bg-transparent p-0"
|
|
11864
12187
|
}
|
|
11865
12188
|
),
|
|
11866
|
-
/* @__PURE__ */ (0,
|
|
12189
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11867
12190
|
ChartCommitInput,
|
|
11868
12191
|
{
|
|
11869
12192
|
value: s.name,
|
|
@@ -11873,8 +12196,8 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11873
12196
|
className: `${chartInputClass} h-6 min-w-[5rem] border-transparent bg-transparent font-medium ${s.hidden ? "text-muted-foreground line-through" : ""}`
|
|
11874
12197
|
}
|
|
11875
12198
|
),
|
|
11876
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
11877
|
-
/* @__PURE__ */ (0,
|
|
12199
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
|
|
12200
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11878
12201
|
"button",
|
|
11879
12202
|
{
|
|
11880
12203
|
type: "button",
|
|
@@ -11887,16 +12210,16 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11887
12210
|
children: s.hidden ? "\u25CB" : "\u25CF"
|
|
11888
12211
|
}
|
|
11889
12212
|
),
|
|
11890
|
-
/* @__PURE__ */ (0,
|
|
12213
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete series", "aria-label": `Delete ${s.name}`, "data-action": "remove-series", onClick: () => controller.removeSeries(s.id), children: "\xD7" })
|
|
11891
12214
|
] })
|
|
11892
12215
|
] }) }, s.id);
|
|
11893
12216
|
}),
|
|
11894
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12217
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "w-8 border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Add series", "aria-label": "Add series", "data-action": "add-series", onClick: () => controller.addSeries(), children: "+" }) })
|
|
11895
12218
|
] }) }),
|
|
11896
|
-
/* @__PURE__ */ (0,
|
|
12219
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tbody", { children: spec.categories.map((category, i) => {
|
|
11897
12220
|
const rowSelected = selection?.kind === "category" && selection.index === i;
|
|
11898
|
-
return /* @__PURE__ */ (0,
|
|
11899
|
-
/* @__PURE__ */ (0,
|
|
12221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("tr", { "data-category-index": i, className: rowSelected ? "bg-primary/10" : void 0, children: [
|
|
12222
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("th", { className: "border-b border-r border-border p-0 text-left font-normal", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11900
12223
|
ChartCommitInput,
|
|
11901
12224
|
{
|
|
11902
12225
|
value: category,
|
|
@@ -11910,7 +12233,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11910
12233
|
spec.series.map((s) => {
|
|
11911
12234
|
const value = s.values[i];
|
|
11912
12235
|
const selected = selection?.kind === "point" && selection.seriesId === s.id && selection.index === i;
|
|
11913
|
-
return /* @__PURE__ */ (0,
|
|
12236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: `border-b border-r border-border p-0 ${selected ? "bg-primary/10" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11914
12237
|
ChartCommitInput,
|
|
11915
12238
|
{
|
|
11916
12239
|
value: value === null || value === void 0 ? "" : String(value),
|
|
@@ -11925,13 +12248,13 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11925
12248
|
}
|
|
11926
12249
|
) }, s.id);
|
|
11927
12250
|
}),
|
|
11928
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
12251
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("td", { className: "border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: chartIconButtonClass, title: "Delete category", "aria-label": `Delete ${category}`, "data-action": "remove-category", onClick: () => controller.removeCategory(i), children: "\xD7" }) })
|
|
11929
12252
|
] }, i);
|
|
11930
12253
|
}) })
|
|
11931
12254
|
] }),
|
|
11932
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
11933
|
-
/* @__PURE__ */ (0,
|
|
11934
|
-
canGroup && /* @__PURE__ */ (0,
|
|
12255
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "p-1", children: [
|
|
12256
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("button", { type: "button", className: `${chartButtonClass} h-6 border-dashed`, "data-action": "add-category", onClick: () => controller.addCategory(), children: "+ Add category" }),
|
|
12257
|
+
canGroup && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11935
12258
|
"button",
|
|
11936
12259
|
{
|
|
11937
12260
|
type: "button",
|
|
@@ -11947,29 +12270,29 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
11947
12270
|
}
|
|
11948
12271
|
|
|
11949
12272
|
// src/chart/ChartInspector.tsx
|
|
11950
|
-
var
|
|
12273
|
+
var import_react88 = require("react");
|
|
11951
12274
|
var import_chart4 = require("@pixerate/editor/chart");
|
|
11952
|
-
var
|
|
12275
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
11953
12276
|
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
11954
12277
|
function Field({ label, htmlFor, children }) {
|
|
11955
|
-
return /* @__PURE__ */ (0,
|
|
11956
|
-
/* @__PURE__ */ (0,
|
|
11957
|
-
/* @__PURE__ */ (0,
|
|
12278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12279
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("label", { htmlFor, className: `${chartLabelClass} w-20 shrink-0`, children: label }),
|
|
12280
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "min-w-0 flex-1", children })
|
|
11958
12281
|
] });
|
|
11959
12282
|
}
|
|
11960
12283
|
function Toggle({ label, checked, onChange, name }) {
|
|
11961
|
-
return /* @__PURE__ */ (0,
|
|
11962
|
-
/* @__PURE__ */ (0,
|
|
12284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("label", { className: "flex cursor-pointer items-center gap-2 text-xs text-foreground", children: [
|
|
12285
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("input", { type: "checkbox", className: "h-3.5 w-3.5 accent-primary", checked, "data-option": name, onChange: (e) => onChange(e.currentTarget.checked) }),
|
|
11963
12286
|
label
|
|
11964
12287
|
] });
|
|
11965
12288
|
}
|
|
11966
12289
|
function Select({ id, value, options, onChange, name, labels }) {
|
|
11967
|
-
return /* @__PURE__ */ (0,
|
|
12290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { id, className: chartInputClass, value, "data-option": name, onChange: (e) => onChange(e.currentTarget.value), children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: o, children: labels?.[o] ?? cap(o) }, o)) });
|
|
11968
12291
|
}
|
|
11969
12292
|
function AxisSection({ controller, axis, value, idBase, horizontal, numeric = false, scales = false }) {
|
|
11970
12293
|
const set = (patch) => controller.setAxis(axis, patch);
|
|
11971
12294
|
const setFormat = (patch) => set({ format: { ...value.format, ...patch } });
|
|
11972
|
-
const bound = (key2) => /* @__PURE__ */ (0,
|
|
12295
|
+
const bound = (key2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
11973
12296
|
ChartCommitInput,
|
|
11974
12297
|
{
|
|
11975
12298
|
id: `${idBase}-${axis}-${key2}`,
|
|
@@ -11984,26 +12307,26 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
11984
12307
|
const name = axis === "x" ? numeric ? "X axis" : "Category axis" : axis === "y" ? "Value axis" : "Secondary axis";
|
|
11985
12308
|
const valueAxis = axis !== "x" || numeric;
|
|
11986
12309
|
const key = axis === "y2" ? "yAxis2" : `${axis}Axis`;
|
|
11987
|
-
return /* @__PURE__ */ (0,
|
|
11988
|
-
/* @__PURE__ */ (0,
|
|
11989
|
-
/* @__PURE__ */ (0,
|
|
12310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": `axis-${axis}`, children: [
|
|
12311
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
12312
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("h4", { className: "text-xs font-semibold text-foreground", children: [
|
|
11990
12313
|
name,
|
|
11991
|
-
/* @__PURE__ */ (0,
|
|
12314
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
11992
12315
|
"(",
|
|
11993
12316
|
axis === "x" ? horizontal ? "left" : "bottom" : axis === "y2" ? horizontal ? "top" : "right" : horizontal ? "bottom" : "left",
|
|
11994
12317
|
")"
|
|
11995
12318
|
] })
|
|
11996
12319
|
] }),
|
|
11997
|
-
/* @__PURE__ */ (0,
|
|
12320
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Show", name: `${axis}Axis.show`, checked: value.show, onChange: (show) => set({ show }) })
|
|
11998
12321
|
] }),
|
|
11999
|
-
/* @__PURE__ */ (0,
|
|
12000
|
-
/* @__PURE__ */ (0,
|
|
12001
|
-
/* @__PURE__ */ (0,
|
|
12002
|
-
axis === "x" && !numeric && /* @__PURE__ */ (0,
|
|
12003
|
-
scales && /* @__PURE__ */ (0,
|
|
12004
|
-
scales && valueAxis && /* @__PURE__ */ (0,
|
|
12322
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Title", htmlFor: `${idBase}-${axis}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-title`, value: value.title, "data-option": `${axis}Axis.title`, className: chartInputClass, onCommit: (title) => void set({ title }) }) }),
|
|
12323
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
12324
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Grid lines", name: `${key}.gridlines`, checked: value.gridlines, onChange: (gridlines) => set({ gridlines }) }),
|
|
12325
|
+
axis === "x" && !numeric && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Dates", name: "xAxis.kind", checked: value.kind === "date", onChange: (dates) => set({ kind: dates ? "date" : void 0 }) }),
|
|
12326
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Reverse", name: `${key}.reverse`, checked: !!value.reverse, onChange: (reverse) => set({ reverse }) }),
|
|
12327
|
+
scales && valueAxis && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Log scale", name: `${key}.scale`, checked: value.scale === "log", onChange: (log) => set({ scale: log ? "log" : "linear" }) })
|
|
12005
12328
|
] }),
|
|
12006
|
-
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0,
|
|
12329
|
+
scales && valueAxis && value.scale === "log" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Log base", htmlFor: `${idBase}-${axis}-log-base`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12007
12330
|
ChartCommitInput,
|
|
12008
12331
|
{
|
|
12009
12332
|
id: `${idBase}-${axis}-log-base`,
|
|
@@ -12014,7 +12337,7 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12014
12337
|
onCommit: (text) => set({ logBase: text.trim() === "" ? void 0 : Number(text) }).ok
|
|
12015
12338
|
}
|
|
12016
12339
|
) }),
|
|
12017
|
-
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0,
|
|
12340
|
+
valueAxis && value.scale !== "log" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Step", htmlFor: `${idBase}-${axis}-step`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12018
12341
|
ChartCommitInput,
|
|
12019
12342
|
{
|
|
12020
12343
|
id: `${idBase}-${axis}-step`,
|
|
@@ -12026,14 +12349,14 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12026
12349
|
onCommit: (text) => set({ step: text.trim() === "" ? null : Number(text) }).ok
|
|
12027
12350
|
}
|
|
12028
12351
|
) }),
|
|
12029
|
-
valueAxis && /* @__PURE__ */ (0,
|
|
12030
|
-
/* @__PURE__ */ (0,
|
|
12352
|
+
valueAxis && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12353
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Min / max", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12031
12354
|
bound("min"),
|
|
12032
12355
|
bound("max")
|
|
12033
12356
|
] }) }),
|
|
12034
|
-
/* @__PURE__ */ (0,
|
|
12035
|
-
/* @__PURE__ */ (0,
|
|
12036
|
-
/* @__PURE__ */ (0,
|
|
12357
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Format", htmlFor: `${idBase}-${axis}-format`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12358
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-${axis}-format`, name: `${key}.format.style`, value: value.format.style ?? "number", options: import_chart4.CHART_NUMBER_STYLES, onChange: (style) => setFormat({ style }) }),
|
|
12359
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12037
12360
|
ChartCommitInput,
|
|
12038
12361
|
{
|
|
12039
12362
|
value: value.format.decimals === void 0 ? "" : String(value.format.decimals),
|
|
@@ -12052,8 +12375,8 @@ function AxisSection({ controller, axis, value, idBase, horizontal, numeric = fa
|
|
|
12052
12375
|
}
|
|
12053
12376
|
)
|
|
12054
12377
|
] }) }),
|
|
12055
|
-
value.format.style === "currency" && /* @__PURE__ */ (0,
|
|
12056
|
-
/* @__PURE__ */ (0,
|
|
12378
|
+
value.format.style === "currency" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Currency", htmlFor: `${idBase}-${axis}-currency`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-${axis}-currency`, value: value.format.currency ?? "USD", "data-option": `${key}.format.currency`, className: chartInputClass, onCommit: (currency) => void setFormat({ currency: currency.toUpperCase() }) }) }),
|
|
12379
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Code", htmlFor: `${idBase}-${axis}-code`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12057
12380
|
ChartCommitInput,
|
|
12058
12381
|
{
|
|
12059
12382
|
id: `${idBase}-${axis}-code`,
|
|
@@ -12079,15 +12402,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
12079
12402
|
const values = which === "xErrorBars" ? series.x ?? [] : series.values;
|
|
12080
12403
|
const set = (next) => controller.updateSeries(series.id, { [which]: next });
|
|
12081
12404
|
const patch = (p) => bars && set({ ...bars, ...p });
|
|
12082
|
-
return /* @__PURE__ */ (0,
|
|
12083
|
-
/* @__PURE__ */ (0,
|
|
12084
|
-
/* @__PURE__ */ (0,
|
|
12085
|
-
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "space-y-1.5", "data-section": which === "errorBars" ? "error-bars" : "x-error-bars", children: [
|
|
12406
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: which === "errorBars" ? "Error bars" : "X error bars", htmlFor: `${id}-type`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("select", { id: `${id}-type`, className: chartInputClass, value: bars?.type ?? "", "data-option": `${key}.type`, onChange: (e) => set((0, import_chart4.chartErrorBarsOfType)(e.currentTarget.value, bars, values)), children: [
|
|
12407
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "None" }),
|
|
12408
|
+
import_chart4.CHART_ERROR_BAR_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: import_chart4.CHART_ERROR_BAR_LABELS[t] }, t))
|
|
12086
12409
|
] }) }),
|
|
12087
|
-
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0,
|
|
12088
|
-
bars?.type === "custom" && /* @__PURE__ */ (0,
|
|
12089
|
-
/* @__PURE__ */ (0,
|
|
12090
|
-
/* @__PURE__ */ (0,
|
|
12410
|
+
bars && (bars.type === "fixed" || bars.type === "percent" || bars.type === "stddev") && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: bars.type === "percent" ? "Percent" : bars.type === "stddev" ? "Deviations" : "Amount", htmlFor: `${id}-value`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${id}-value`, value: String(bars.value ?? (0, import_chart4.defaultChartErrorBarValue)(bars.type)), inputMode: "decimal", "data-option": `${key}.value`, className: chartInputClass, onCommit: (text) => !!patch({ value: text.trim() === "" ? void 0 : Number(text) })?.ok }) }),
|
|
12411
|
+
bars?.type === "custom" && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12412
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Plus", htmlFor: `${id}-plus`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${id}-plus`, value: (0, import_chart4.formatChartAmountList)(bars.plus), placeholder: "1, 2, -, 0.5", "data-option": `${key}.plus`, className: chartInputClass, onCommit: (text) => !!patch({ plus: (0, import_chart4.parseChartAmountList)(text) })?.ok }) }),
|
|
12413
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Minus", htmlFor: `${id}-minus`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12091
12414
|
ChartCommitInput,
|
|
12092
12415
|
{
|
|
12093
12416
|
id: `${id}-minus`,
|
|
@@ -12104,15 +12427,15 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
12104
12427
|
}
|
|
12105
12428
|
) })
|
|
12106
12429
|
] }),
|
|
12107
|
-
bars && /* @__PURE__ */ (0,
|
|
12108
|
-
/* @__PURE__ */ (0,
|
|
12109
|
-
/* @__PURE__ */ (0,
|
|
12430
|
+
bars && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12431
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { className: `${chartInputClass} flex-1`, "aria-label": "Error bar direction", value: bars.direction ?? "both", "data-option": `${key}.direction`, onChange: (e) => patch({ direction: e.currentTarget.value }), children: import_chart4.CHART_ERROR_BAR_DIRECTIONS.map((d) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: d, children: d === "both" ? "Both ways" : d === "plus" ? "Plus only" : "Minus only" }, d)) }),
|
|
12432
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Caps", name: `${key}.cap`, checked: bars.cap !== false, onChange: (cap2) => patch({ cap: cap2 }) })
|
|
12110
12433
|
] })
|
|
12111
12434
|
] });
|
|
12112
12435
|
}
|
|
12113
12436
|
function ChartInspector({ controller, sections, className }) {
|
|
12114
12437
|
const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
|
|
12115
|
-
const idBase = (0,
|
|
12438
|
+
const idBase = (0, import_react88.useId)();
|
|
12116
12439
|
const show = (section) => !sections || sections.includes(section);
|
|
12117
12440
|
const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
|
|
12118
12441
|
const family = (0, import_chart4.chartFamily)(spec);
|
|
@@ -12127,30 +12450,30 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12127
12450
|
const annotated = scales;
|
|
12128
12451
|
const oneSeries = cartesian && spec.series.filter((s) => !s.hidden).length === 1;
|
|
12129
12452
|
const calloutIndex = selection?.kind === "point" && selection.seriesId === selectedSeries?.id ? selection.index : null;
|
|
12130
|
-
return /* @__PURE__ */ (0,
|
|
12131
|
-
show("type") && /* @__PURE__ */ (0,
|
|
12132
|
-
show("style") && /* @__PURE__ */ (0,
|
|
12133
|
-
/* @__PURE__ */ (0,
|
|
12134
|
-
/* @__PURE__ */ (0,
|
|
12135
|
-
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0,
|
|
12453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: `space-y-3 text-xs ${className ?? ""}`, "data-chart-inspector": "", children: [
|
|
12454
|
+
show("type") && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: chartSectionClass, "data-section": "type", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "grid grid-cols-3 gap-0.5 rounded-md bg-muted p-0.5", role: "radiogroup", "aria-label": "Chart type", children: import_chart4.CHART_TYPES.map((type) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", role: "radio", "aria-checked": spec.type === type, "data-chart-type": type, className: chartSegmentClass(spec.type === type), onClick: () => controller.setType(type), children: import_chart4.CHART_TYPE_LABELS[type] }, type)) }) }),
|
|
12455
|
+
show("style") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "style", children: [
|
|
12456
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Layout", htmlFor: `${idBase}-layout`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("select", { id: `${idBase}-layout`, className: chartInputClass, value: "", "data-option": "preset.layout", onChange: (e) => e.currentTarget.value && controller.applyPreset({ layout: e.currentTarget.value }), children: [
|
|
12457
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Quick layout\u2026" }),
|
|
12458
|
+
import_chart4.CHART_LAYOUT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: p.id, title: p.description, children: p.label }, p.id))
|
|
12136
12459
|
] }) }),
|
|
12137
|
-
/* @__PURE__ */ (0,
|
|
12138
|
-
/* @__PURE__ */ (0,
|
|
12139
|
-
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0,
|
|
12460
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Colours", htmlFor: `${idBase}-colors`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("select", { id: `${idBase}-colors`, className: chartInputClass, value: import_chart4.CHART_COLOR_SCHEMES.find((c) => c.palette.join() === spec.palette.join())?.id ?? "", "data-option": "preset.colors", onChange: (e) => e.currentTarget.value && controller.applyPreset({ colors: e.currentTarget.value }), children: [
|
|
12461
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Custom" }),
|
|
12462
|
+
import_chart4.CHART_COLOR_SCHEMES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: c.id, title: c.description, children: c.label }, c.id))
|
|
12140
12463
|
] }) }),
|
|
12141
|
-
!colorCheck.ok && /* @__PURE__ */ (0,
|
|
12142
|
-
/* @__PURE__ */ (0,
|
|
12464
|
+
!colorCheck.ok && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { className: "text-[11px] leading-snug text-amber-600 dark:text-amber-400", "data-chart-color-warning": "", children: colorCheck.issues[0] }),
|
|
12465
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "transpose", onClick: () => controller.transpose(), children: "Switch rows and columns" })
|
|
12143
12466
|
] }),
|
|
12144
|
-
show("titles") && /* @__PURE__ */ (0,
|
|
12145
|
-
/* @__PURE__ */ (0,
|
|
12146
|
-
/* @__PURE__ */ (0,
|
|
12147
|
-
/* @__PURE__ */ (0,
|
|
12467
|
+
show("titles") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "titles", children: [
|
|
12468
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Title", htmlFor: `${idBase}-title`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-title`, value: spec.title, "data-option": "title", className: chartInputClass, onCommit: (title) => void controller.setTitle(title) }) }),
|
|
12469
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Subtitle", htmlFor: `${idBase}-subtitle`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-subtitle`, value: spec.subtitle, "data-option": "subtitle", className: chartInputClass, onCommit: (subtitle) => void controller.setSubtitle(subtitle) }) }),
|
|
12470
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Note", htmlFor: `${idBase}-note`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-note`, value: spec.note, placeholder: "Source or footnote", "data-option": "note", className: chartInputClass, onCommit: (note) => void controller.setNote(note) }) })
|
|
12148
12471
|
] }),
|
|
12149
|
-
show("options") && /* @__PURE__ */ (0,
|
|
12150
|
-
cartesian && /* @__PURE__ */ (0,
|
|
12151
|
-
hasBars && /* @__PURE__ */ (0,
|
|
12152
|
-
hasLines && /* @__PURE__ */ (0,
|
|
12153
|
-
spec.type === "donut" && /* @__PURE__ */ (0,
|
|
12472
|
+
show("options") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "options", children: [
|
|
12473
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Stacking", htmlFor: `${idBase}-stacking`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-stacking`, name: "stacking", value: spec.stacking, options: import_chart4.CHART_STACKINGS, labels: { none: "None", stacked: "Stacked", percent: "100%" }, onChange: (stacking) => controller.update({ stacking }) }) }),
|
|
12474
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bars", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: ["vertical", "horizontal"].map((o) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", "aria-pressed": spec.orientation === o, "data-option": `orientation.${o}`, className: chartSegmentClass(spec.orientation === o), onClick: () => controller.update({ orientation: o }), children: cap(o) }, o)) }) }),
|
|
12475
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Lines", htmlFor: `${idBase}-curve`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-curve`, name: "curve", value: spec.curve, options: import_chart4.CHART_CURVES, onChange: (curve) => controller.update({ curve }) }) }),
|
|
12476
|
+
spec.type === "donut" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Hole", htmlFor: `${idBase}-hole`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12154
12477
|
"input",
|
|
12155
12478
|
{
|
|
12156
12479
|
id: `${idBase}-hole`,
|
|
@@ -12166,7 +12489,7 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12166
12489
|
onChange: (e) => controller.update({ innerRadius: Number(e.currentTarget.value) })
|
|
12167
12490
|
}
|
|
12168
12491
|
) }),
|
|
12169
|
-
hasBars && /* @__PURE__ */ (0,
|
|
12492
|
+
hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Spacing", htmlFor: `${idBase}-gap`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12170
12493
|
"input",
|
|
12171
12494
|
{
|
|
12172
12495
|
id: `${idBase}-gap`,
|
|
@@ -12182,9 +12505,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12182
12505
|
onChange: (e) => controller.update({ gapWidth: Number(e.currentTarget.value) })
|
|
12183
12506
|
}
|
|
12184
12507
|
) }),
|
|
12185
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12186
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12187
|
-
spec.type === "choropleth" && /* @__PURE__ */ (0,
|
|
12508
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Map", htmlFor: `${idBase}-map`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { id: `${idBase}-map`, className: chartInputClass, value: spec.map, "data-option": "map", onChange: (e) => controller.update({ map: e.currentTarget.value }), children: [.../* @__PURE__ */ new Set([spec.map, ...(0, import_chart4.listChartMaps)().map((m) => m.id)])].map((id) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: id, children: (0, import_chart4.listChartMaps)().find((m) => m.id === id)?.name ?? `${id} (not loaded)` }, id)) }) }),
|
|
12509
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Classes", htmlFor: `${idBase}-map-steps`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-map-steps`, value: String(spec.mapSteps), inputMode: "numeric", "data-option": "mapSteps", disabled: spec.mapThresholds.length > 0, className: chartInputClass, onCommit: (text) => controller.update({ mapSteps: Number(text) }).ok }) }),
|
|
12510
|
+
spec.type === "choropleth" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Breaks", htmlFor: `${idBase}-map-breaks`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12188
12511
|
ChartCommitInput,
|
|
12189
12512
|
{
|
|
12190
12513
|
id: `${idBase}-map-breaks`,
|
|
@@ -12195,10 +12518,10 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12195
12518
|
onCommit: (text) => controller.update({ mapThresholds: text.trim() ? text.split(",").map((t) => Number(t.trim())) : [] }).ok
|
|
12196
12519
|
}
|
|
12197
12520
|
) }),
|
|
12198
|
-
spec.type === "barrace" && /* @__PURE__ */ (0,
|
|
12199
|
-
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0,
|
|
12200
|
-
/* @__PURE__ */ (0,
|
|
12201
|
-
/* @__PURE__ */ (0,
|
|
12521
|
+
spec.type === "barrace" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bars", htmlFor: `${idBase}-race-top`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-race-top`, value: String(spec.raceTopN), inputMode: "numeric", "data-option": "raceTopN", className: chartInputClass, onCommit: (text) => controller.update({ raceTopN: Number(text) }).ok }) }),
|
|
12522
|
+
spec.type === "barrace" && spec.categories.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Time", htmlFor: `${idBase}-race-frame`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12523
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "race-play", "aria-label": racePlaying ? "Pause the race" : "Play the race", onClick: () => racePlaying ? controller.pauseRace() : controller.playRace(), children: racePlaying ? "Pause" : "Play" }),
|
|
12524
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12202
12525
|
"input",
|
|
12203
12526
|
{
|
|
12204
12527
|
id: `${idBase}-race-frame`,
|
|
@@ -12213,13 +12536,13 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12213
12536
|
onChange: (e) => controller.setRaceFrame(Number(e.currentTarget.value))
|
|
12214
12537
|
}
|
|
12215
12538
|
),
|
|
12216
|
-
/* @__PURE__ */ (0,
|
|
12539
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "w-12 shrink-0 truncate text-right tabular-nums text-muted-foreground", "data-race-time": "", children: spec.categories[Math.round(raceFrame ?? spec.categories.length - 1)] })
|
|
12217
12540
|
] }) }),
|
|
12218
|
-
spec.type === "sankey" && /* @__PURE__ */ (0,
|
|
12219
|
-
spec.type === "sunburst" && /* @__PURE__ */ (0,
|
|
12220
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
12221
|
-
spec.type === "likert" && /* @__PURE__ */ (0,
|
|
12222
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12541
|
+
spec.type === "sankey" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Flows", htmlFor: `${idBase}-sankey-color`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-sankey-color`, name: "sankeyLinkColor", value: spec.sankeyLinkColor, options: import_chart4.CHART_SANKEY_LINK_COLORS, labels: { source: "Coloured by source", target: "Coloured by target", gray: "Grey" }, onChange: (sankeyLinkColor) => controller.update({ sankeyLinkColor }) }) }),
|
|
12542
|
+
spec.type === "sunburst" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-sunburst-label`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-sunburst-label`, value: spec.sunburstLabel, placeholder: "Under the total", "data-option": "sunburstLabel", className: chartInputClass, onCommit: (sunburstLabel) => controller.update({ sunburstLabel }).ok }) }),
|
|
12543
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Neutral", htmlFor: `${idBase}-likert-neutral`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-likert-neutral`, name: "likertNeutral", value: spec.likertNeutral, options: import_chart4.CHART_LIKERT_NEUTRALS, labels: { split: "Across the centre", separate: "In its own column" }, onChange: (likertNeutral) => controller.update({ likertNeutral }) }) }),
|
|
12544
|
+
spec.type === "likert" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Order", htmlFor: `${idBase}-likert-sort`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-likert-sort`, name: "likertSort", value: spec.likertSort, options: import_chart4.CHART_LIKERT_SORTS, labels: { none: "As entered", positive: "Most agreement first", negative: "Most disagreement first" }, onChange: (likertSort) => controller.update({ likertSort }) }) }),
|
|
12545
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Sweep", htmlFor: `${idBase}-parliament-arc`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12223
12546
|
"input",
|
|
12224
12547
|
{
|
|
12225
12548
|
id: `${idBase}-parliament-arc`,
|
|
@@ -12235,34 +12558,34 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12235
12558
|
onChange: (e) => controller.update({ parliamentArc: Number(e.currentTarget.value) })
|
|
12236
12559
|
}
|
|
12237
12560
|
) }),
|
|
12238
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12239
|
-
spec.type === "parliament" && /* @__PURE__ */ (0,
|
|
12240
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
12241
|
-
spec.type === "radar" && /* @__PURE__ */ (0,
|
|
12242
|
-
spec.dataLabels && hasBars && /* @__PURE__ */ (0,
|
|
12243
|
-
spec.type === "histogram" && /* @__PURE__ */ (0,
|
|
12244
|
-
/* @__PURE__ */ (0,
|
|
12245
|
-
spec.type === "waterfall" && /* @__PURE__ */ (0,
|
|
12246
|
-
hasLines && /* @__PURE__ */ (0,
|
|
12247
|
-
oneSeries && /* @__PURE__ */ (0,
|
|
12248
|
-
/* @__PURE__ */ (0,
|
|
12561
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Majority", htmlFor: `${idBase}-parliament-majority`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-parliament-majority`, value: spec.parliamentMajority === null ? "" : String(spec.parliamentMajority), placeholder: "Half plus one", inputMode: "numeric", "data-option": "parliamentMajority", className: chartInputClass, onCommit: (text) => controller.update({ parliamentMajority: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
12562
|
+
spec.type === "parliament" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Caption", htmlFor: `${idBase}-parliament-label`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-parliament-label`, value: spec.parliamentLabel, placeholder: "seats", "data-option": "parliamentLabel", className: chartInputClass, onCommit: (parliamentLabel) => controller.update({ parliamentLabel }).ok }) }),
|
|
12563
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Rings", htmlFor: `${idBase}-radar-ticks`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-radar-ticks`, value: spec.radarTicks === null ? "" : String(spec.radarTicks), placeholder: "Auto", inputMode: "numeric", "data-option": "radarTicks", className: chartInputClass, onCommit: (text) => controller.update({ radarTicks: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
12564
|
+
spec.type === "radar" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Grid", htmlFor: `${idBase}-radar-graticule`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-radar-graticule`, name: "radarGraticule", value: spec.radarGraticule, options: import_chart4.CHART_RADAR_GRATICULES, labels: { polygon: "Polygons", circle: "Circles" }, onChange: (radarGraticule) => controller.update({ radarGraticule }) }) }),
|
|
12565
|
+
spec.dataLabels && hasBars && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Labels", htmlFor: `${idBase}-label-position`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { id: `${idBase}-label-position`, name: "labelPosition", value: spec.labelPosition, options: import_chart4.CHART_LABEL_POSITIONS, onChange: (labelPosition) => controller.update({ labelPosition }) }) }),
|
|
12566
|
+
spec.type === "histogram" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Bins", htmlFor: `${idBase}-bins`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-bins`, value: spec.bins === null ? "" : String(spec.bins), placeholder: "Auto", inputMode: "numeric", "data-option": "bins", className: chartInputClass, onCommit: (text) => controller.update({ bins: text.trim() === "" ? null : Number(text) }).ok }) }),
|
|
12567
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
|
|
12568
|
+
spec.type === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Total bar", name: "showTotal", checked: spec.showTotal, onChange: (showTotal) => controller.update({ showTotal }) }),
|
|
12569
|
+
hasLines && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Points", name: "points", checked: spec.points, onChange: (points) => controller.update({ points }) }),
|
|
12570
|
+
oneSeries && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Colour by category", name: "varyColors", checked: spec.varyColors, onChange: (varyColors) => controller.update({ varyColors }) }),
|
|
12571
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Data labels", name: "dataLabels", checked: spec.dataLabels, onChange: (dataLabels) => controller.update({ dataLabels }) })
|
|
12249
12572
|
] })
|
|
12250
12573
|
] }),
|
|
12251
|
-
show("legend") && /* @__PURE__ */ (0,
|
|
12252
|
-
/* @__PURE__ */ (0,
|
|
12253
|
-
/* @__PURE__ */ (0,
|
|
12254
|
-
/* @__PURE__ */ (0,
|
|
12574
|
+
show("legend") && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "legend", children: [
|
|
12575
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
12576
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Legend" }),
|
|
12577
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Show", name: "legend.show", checked: spec.legend.show, onChange: (v) => controller.setLegend({ show: v }) })
|
|
12255
12578
|
] }),
|
|
12256
|
-
spec.legend.show && /* @__PURE__ */ (0,
|
|
12579
|
+
spec.legend.show && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "flex gap-0.5 rounded-md bg-muted p-0.5", children: import_chart4.CHART_LEGEND_POSITIONS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", "aria-pressed": spec.legend.position === p, "data-option": `legend.${p}`, className: chartSegmentClass(spec.legend.position === p), onClick: () => controller.setLegend({ position: p }), children: cap(p) }, p)) })
|
|
12257
12580
|
] }),
|
|
12258
|
-
show("axes") && hasAxes && /* @__PURE__ */ (0,
|
|
12259
|
-
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0,
|
|
12260
|
-
/* @__PURE__ */ (0,
|
|
12261
|
-
usesSecondary && /* @__PURE__ */ (0,
|
|
12581
|
+
show("axes") && hasAxes && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
12582
|
+
family !== "box" && family !== "histogram" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "x", value: spec.xAxis, idBase, horizontal: spec.orientation === "horizontal", numeric: family === "xy", scales }),
|
|
12583
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "y", value: spec.yAxis, idBase, horizontal: spec.orientation === "horizontal", scales }),
|
|
12584
|
+
usesSecondary && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(AxisSection, { controller, axis: "y2", value: spec.yAxis2, idBase, horizontal: spec.orientation === "horizontal", scales })
|
|
12262
12585
|
] }),
|
|
12263
|
-
show("annotations") && annotated && /* @__PURE__ */ (0,
|
|
12264
|
-
/* @__PURE__ */ (0,
|
|
12265
|
-
/* @__PURE__ */ (0,
|
|
12586
|
+
show("annotations") && annotated && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "annotations", children: [
|
|
12587
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Annotations" }),
|
|
12588
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Highlight", htmlFor: `${idBase}-highlight`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12266
12589
|
ChartCommitInput,
|
|
12267
12590
|
{
|
|
12268
12591
|
id: `${idBase}-highlight`,
|
|
@@ -12273,27 +12596,27 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12273
12596
|
onCommit: (text) => controller.setHighlight(text.split(",").map((n) => n.trim()).filter(Boolean)).ok
|
|
12274
12597
|
}
|
|
12275
12598
|
) }),
|
|
12276
|
-
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0,
|
|
12277
|
-
/* @__PURE__ */ (0,
|
|
12278
|
-
/* @__PURE__ */ (0,
|
|
12279
|
-
/* @__PURE__ */ (0,
|
|
12599
|
+
spec.referenceLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-reference-line": i, children: [
|
|
12600
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { value: String(line.value), "aria-label": "Line value", inputMode: "decimal", "data-option": `referenceLine.${i}.value`, className: `${chartInputClass} w-16 shrink-0`, onCommit: (text) => controller.updateReferenceLine(i, { value: Number(text) }).ok }),
|
|
12601
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { value: line.label ?? "", "aria-label": "Line label", placeholder: "Label", "data-option": `referenceLine.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceLine(i, { label: text || null }).ok }),
|
|
12602
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference line", "data-action": "reference-line-delete", onClick: () => controller.removeReferenceLine(i), children: "\xD7" })
|
|
12280
12603
|
] }, `line-${i}`)),
|
|
12281
|
-
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0,
|
|
12282
|
-
/* @__PURE__ */ (0,
|
|
12283
|
-
/* @__PURE__ */ (0,
|
|
12284
|
-
/* @__PURE__ */ (0,
|
|
12285
|
-
/* @__PURE__ */ (0,
|
|
12604
|
+
spec.referenceBands.map((band, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-reference-band": i, children: [
|
|
12605
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { value: String(band.from), "aria-label": "Band from", inputMode: "decimal", "data-option": `referenceBand.${i}.from`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { from: Number(text) }).ok }),
|
|
12606
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { value: String(band.to), "aria-label": "Band to", inputMode: "decimal", "data-option": `referenceBand.${i}.to`, className: `${chartInputClass} w-14 shrink-0`, onCommit: (text) => controller.updateReferenceBand(i, { to: Number(text) }).ok }),
|
|
12607
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { value: band.label ?? "", "aria-label": "Band label", placeholder: "Label", "data-option": `referenceBand.${i}.label`, className: `${chartInputClass} flex-1`, onCommit: (text) => controller.updateReferenceBand(i, { label: text || null }).ok }),
|
|
12608
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete reference band", "data-action": "reference-band-delete", onClick: () => controller.removeReferenceBand(i), children: "\xD7" })
|
|
12286
12609
|
] }, `band-${i}`)),
|
|
12287
|
-
/* @__PURE__ */ (0,
|
|
12288
|
-
/* @__PURE__ */ (0,
|
|
12289
|
-
/* @__PURE__ */ (0,
|
|
12610
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex gap-1", children: [
|
|
12611
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceLine.add", onClick: () => controller.addReferenceLine((0, import_chart4.suggestChartReferences)(spec).line), children: "Add line" }),
|
|
12612
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-option": "referenceBand.add", onClick: () => controller.addReferenceBand((0, import_chart4.suggestChartReferences)(spec).band), children: "Add band" })
|
|
12290
12613
|
] })
|
|
12291
12614
|
] }),
|
|
12292
|
-
show("series") && selectedSeries && /* @__PURE__ */ (0,
|
|
12293
|
-
/* @__PURE__ */ (0,
|
|
12294
|
-
/* @__PURE__ */ (0,
|
|
12295
|
-
/* @__PURE__ */ (0,
|
|
12296
|
-
/* @__PURE__ */ (0,
|
|
12615
|
+
show("series") && selectedSeries && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: chartSectionClass, "data-section": "series", "data-series-id": selectedSeries.id, children: [
|
|
12616
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("h4", { className: "text-xs font-semibold text-foreground", children: "Series" }),
|
|
12617
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Name", htmlFor: `${idBase}-series-name`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ChartCommitInput, { id: `${idBase}-series-name`, value: selectedSeries.name, "data-option": "series.name", className: chartInputClass, onCommit: (name) => void controller.updateSeries(selectedSeries.id, { name }) }) }),
|
|
12618
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Colour", htmlFor: `${idBase}-series-color`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12619
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12297
12620
|
"input",
|
|
12298
12621
|
{
|
|
12299
12622
|
id: `${idBase}-series-color`,
|
|
@@ -12306,9 +12629,9 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12306
12629
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { color: e.currentTarget.value })
|
|
12307
12630
|
}
|
|
12308
12631
|
),
|
|
12309
|
-
selectedSeries.color && /* @__PURE__ */ (0,
|
|
12632
|
+
selectedSeries.color && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "reset-color", onClick: () => controller.updateSeries(selectedSeries.id, { color: null }), children: "Palette" })
|
|
12310
12633
|
] }) }),
|
|
12311
|
-
cartesian && /* @__PURE__ */ (0,
|
|
12634
|
+
cartesian && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Draw as", htmlFor: `${idBase}-series-type`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12312
12635
|
"select",
|
|
12313
12636
|
{
|
|
12314
12637
|
id: `${idBase}-series-type`,
|
|
@@ -12317,12 +12640,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12317
12640
|
"data-option": "series.type",
|
|
12318
12641
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { type: e.currentTarget.value || null }),
|
|
12319
12642
|
children: [
|
|
12320
|
-
/* @__PURE__ */ (0,
|
|
12321
|
-
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12643
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Chart type" }),
|
|
12644
|
+
import_chart4.CHART_SERIES_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: import_chart4.CHART_TYPE_LABELS[t] }, t))
|
|
12322
12645
|
]
|
|
12323
12646
|
}
|
|
12324
12647
|
) }),
|
|
12325
|
-
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0,
|
|
12648
|
+
(cartesian || family === "xy") && ["line", "area", "scatter"].includes((0, import_chart4.chartSeriesType)(spec, selectedSeries)) && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Marker", htmlFor: `${idBase}-series-marker`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12326
12649
|
"select",
|
|
12327
12650
|
{
|
|
12328
12651
|
id: `${idBase}-series-marker`,
|
|
@@ -12331,12 +12654,12 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12331
12654
|
"data-option": "series.marker",
|
|
12332
12655
|
onChange: (e) => controller.updateSeries(selectedSeries.id, { marker: e.currentTarget.value || null }),
|
|
12333
12656
|
children: [
|
|
12334
|
-
/* @__PURE__ */ (0,
|
|
12335
|
-
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0,
|
|
12657
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Default" }),
|
|
12658
|
+
import_chart4.CHART_MARKERS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: m, children: cap(m) }, m))
|
|
12336
12659
|
]
|
|
12337
12660
|
}
|
|
12338
12661
|
) }),
|
|
12339
|
-
annotated && calloutIndex !== null && /* @__PURE__ */ (0,
|
|
12662
|
+
annotated && calloutIndex !== null && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Field, { label: "Callout", htmlFor: `${idBase}-series-callout`, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
12340
12663
|
ChartCommitInput,
|
|
12341
12664
|
{
|
|
12342
12665
|
id: `${idBase}-series-callout`,
|
|
@@ -12347,15 +12670,15 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12347
12670
|
onCommit: (text) => controller.setCallout(selectedSeries.id, calloutIndex, text || null).ok
|
|
12348
12671
|
}
|
|
12349
12672
|
) }),
|
|
12350
|
-
scales && /* @__PURE__ */ (0,
|
|
12351
|
-
family === "xy" && /* @__PURE__ */ (0,
|
|
12352
|
-
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0,
|
|
12353
|
-
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0,
|
|
12354
|
-
/* @__PURE__ */ (0,
|
|
12355
|
-
/* @__PURE__ */ (0,
|
|
12356
|
-
/* @__PURE__ */ (0,
|
|
12673
|
+
scales && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "errorBars", idBase }),
|
|
12674
|
+
family === "xy" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ErrorBarFields, { controller, series: selectedSeries, which: "xErrorBars", idBase }),
|
|
12675
|
+
(0, import_chart4.chartSupportsTrendlines)(spec.type, spec.stacking) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "space-y-1", "data-section": "trendlines", children: [
|
|
12676
|
+
(selectedSeries.trendlines ?? []).map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center gap-1", "data-trendline": i, children: [
|
|
12677
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "flex-1 truncate text-muted-foreground", children: (0, import_chart4.chartTrendlineName)(t, selectedSeries.name) }),
|
|
12678
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "R\xB2", name: `trendline.${i}.showR2`, checked: !!t.showR2, onChange: (showR2) => controller.updateTrendline(selectedSeries.id, i, { showR2 }) }),
|
|
12679
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, "aria-label": "Delete trendline", "data-action": "trendline-delete", onClick: () => controller.removeTrendline(selectedSeries.id, i), children: "\xD7" })
|
|
12357
12680
|
] }, i)),
|
|
12358
|
-
/* @__PURE__ */ (0,
|
|
12681
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
12359
12682
|
"select",
|
|
12360
12683
|
{
|
|
12361
12684
|
className: chartInputClass,
|
|
@@ -12364,32 +12687,32 @@ function ChartInspector({ controller, sections, className }) {
|
|
|
12364
12687
|
"data-option": "trendline.add",
|
|
12365
12688
|
onChange: (e) => e.currentTarget.value && controller.addTrendline(selectedSeries.id, { type: e.currentTarget.value }),
|
|
12366
12689
|
children: [
|
|
12367
|
-
/* @__PURE__ */ (0,
|
|
12368
|
-
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0,
|
|
12690
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "", children: "Add trendline\u2026" }),
|
|
12691
|
+
import_chart4.CHART_TRENDLINE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: t, children: cap(t.replace("-", " ")) }, t))
|
|
12369
12692
|
]
|
|
12370
12693
|
}
|
|
12371
12694
|
)
|
|
12372
12695
|
] }),
|
|
12373
|
-
/* @__PURE__ */ (0,
|
|
12374
|
-
/* @__PURE__ */ (0,
|
|
12375
|
-
family === "cartesian" && /* @__PURE__ */ (0,
|
|
12376
|
-
/* @__PURE__ */ (0,
|
|
12377
|
-
/* @__PURE__ */ (0,
|
|
12378
|
-
/* @__PURE__ */ (0,
|
|
12379
|
-
/* @__PURE__ */ (0,
|
|
12696
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
12697
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Hidden", name: "series.hidden", checked: !!selectedSeries.hidden, onChange: (hidden) => controller.updateSeries(selectedSeries.id, { hidden }) }),
|
|
12698
|
+
family === "cartesian" && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Toggle, { label: "Secondary axis", name: "series.axis", checked: selectedSeries.axis === "secondary", onChange: (secondary) => controller.updateSeries(selectedSeries.id, { axis: secondary ? "secondary" : null }) }),
|
|
12699
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "flex-1" }),
|
|
12700
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, disabled: seriesIndex <= 0, "aria-label": "Move series earlier", "data-action": "series-up", onClick: () => controller.moveSeries(selectedSeries.id, seriesIndex - 1), children: "\u2191" }),
|
|
12701
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: chartButtonClass, disabled: seriesIndex >= spec.series.length - 1, "aria-label": "Move series later", "data-action": "series-down", onClick: () => controller.moveSeries(selectedSeries.id, seriesIndex + 1), children: "\u2193" }),
|
|
12702
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: `${chartButtonClass} text-destructive`, "data-action": "series-delete", onClick: () => controller.removeSeries(selectedSeries.id), children: "Delete" })
|
|
12380
12703
|
] })
|
|
12381
12704
|
] })
|
|
12382
12705
|
] });
|
|
12383
12706
|
}
|
|
12384
12707
|
|
|
12385
12708
|
// src/chart-node/ChartNodeView.tsx
|
|
12386
|
-
var
|
|
12709
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
12387
12710
|
function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
12388
12711
|
const { controller, editing, editable, selected, width, height, setEditing } = state;
|
|
12389
12712
|
const open = () => {
|
|
12390
12713
|
if (editable && !editing) setEditing(true);
|
|
12391
12714
|
};
|
|
12392
|
-
return /* @__PURE__ */ (0,
|
|
12715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
12393
12716
|
"div",
|
|
12394
12717
|
{
|
|
12395
12718
|
className: `not-prose my-2 rounded-md border bg-background p-1 ${selected ? "border-primary ring-1 ring-primary" : "border-border"}`,
|
|
@@ -12402,24 +12725,24 @@ function ChartNodeView({ state, theme, showDataGrid = true }) {
|
|
|
12402
12725
|
}
|
|
12403
12726
|
},
|
|
12404
12727
|
children: [
|
|
12405
|
-
editing && /* @__PURE__ */ (0,
|
|
12406
|
-
/* @__PURE__ */ (0,
|
|
12407
|
-
/* @__PURE__ */ (0,
|
|
12728
|
+
editing && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "mb-1 flex items-center justify-between gap-2 px-1", "data-chart-node-toolbar": "", children: [
|
|
12729
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-xs text-muted-foreground", children: "Editing chart" }),
|
|
12730
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("button", { type: "button", className: chartButtonClass, "data-action": "done", onClick: () => setEditing(false), children: "Done" })
|
|
12408
12731
|
] }),
|
|
12409
|
-
/* @__PURE__ */ (0,
|
|
12732
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
12410
12733
|
"div",
|
|
12411
12734
|
{
|
|
12412
12735
|
className: editable && !editing ? "cursor-pointer" : void 0,
|
|
12413
12736
|
onClick: open,
|
|
12414
12737
|
title: editable && !editing ? "Click to edit the chart" : void 0,
|
|
12415
12738
|
"data-chart-node-canvas": "",
|
|
12416
|
-
children: /* @__PURE__ */ (0,
|
|
12739
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartCanvas, { controller, width: width ?? 640, height, responsive: width === null, editable: editing, theme })
|
|
12417
12740
|
}
|
|
12418
12741
|
),
|
|
12419
12742
|
editing && // Wraps by the document's width, not the viewport's: side by side when there is room.
|
|
12420
|
-
/* @__PURE__ */ (0,
|
|
12421
|
-
showDataGrid && /* @__PURE__ */ (0,
|
|
12422
|
-
/* @__PURE__ */ (0,
|
|
12743
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "mt-2 flex flex-wrap items-start gap-2", "data-chart-node-panel": "", children: [
|
|
12744
|
+
showDataGrid && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "min-w-0 flex-[1_1_20rem] overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartDataGrid, { controller }) }),
|
|
12745
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ChartInspector, { controller, className: "max-h-96 min-w-0 flex-[1_1_16rem] overflow-y-auto rounded-md border border-border p-3" })
|
|
12423
12746
|
] })
|
|
12424
12747
|
]
|
|
12425
12748
|
}
|
|
@@ -12437,7 +12760,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
12437
12760
|
scheduled = true;
|
|
12438
12761
|
queueMicrotask(() => {
|
|
12439
12762
|
scheduled = false;
|
|
12440
|
-
if (!destroyed) root.render(/* @__PURE__ */ (0,
|
|
12763
|
+
if (!destroyed) root.render(/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Component, { ...props, state: latest }));
|
|
12441
12764
|
});
|
|
12442
12765
|
};
|
|
12443
12766
|
schedule();
|
|
@@ -12455,10 +12778,10 @@ function createReactChartNodeView(options = {}) {
|
|
|
12455
12778
|
}
|
|
12456
12779
|
|
|
12457
12780
|
// src/style/useStyle.ts
|
|
12458
|
-
var
|
|
12781
|
+
var import_react89 = require("react");
|
|
12459
12782
|
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
12460
12783
|
function useResolverTask(styles, run, deliver, deps) {
|
|
12461
|
-
(0,
|
|
12784
|
+
(0, import_react89.useEffect)(() => {
|
|
12462
12785
|
if (!styles || !run) {
|
|
12463
12786
|
deliver({ value: null, error: null });
|
|
12464
12787
|
return;
|
|
@@ -12485,7 +12808,7 @@ function useResolverTask(styles, run, deliver, deps) {
|
|
|
12485
12808
|
}, [styles, ...deps]);
|
|
12486
12809
|
}
|
|
12487
12810
|
function useStyle(styles, domain) {
|
|
12488
|
-
const [result, setResult] = (0,
|
|
12811
|
+
const [result, setResult] = (0, import_react89.useState)({ style: null, error: null });
|
|
12489
12812
|
useResolverTask(
|
|
12490
12813
|
styles,
|
|
12491
12814
|
(s) => s.resolve(domain),
|
|
@@ -12495,7 +12818,7 @@ function useStyle(styles, domain) {
|
|
|
12495
12818
|
return result;
|
|
12496
12819
|
}
|
|
12497
12820
|
function useStyleFindings(styles, domain, state) {
|
|
12498
|
-
const [result, setResult] = (0,
|
|
12821
|
+
const [result, setResult] = (0, import_react89.useState)({ report: null, style: null, error: null });
|
|
12499
12822
|
useResolverTask(
|
|
12500
12823
|
styles,
|
|
12501
12824
|
(s) => s.check(domain, state),
|
|
@@ -12512,7 +12835,7 @@ function useStyleFindings(styles, domain, state) {
|
|
|
12512
12835
|
}
|
|
12513
12836
|
|
|
12514
12837
|
// src/style/StyleFindings.tsx
|
|
12515
|
-
var
|
|
12838
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
12516
12839
|
var SEVERITY_CLASS = {
|
|
12517
12840
|
error: "text-destructive",
|
|
12518
12841
|
warning: "text-amber-600",
|
|
@@ -12521,24 +12844,24 @@ var SEVERITY_CLASS = {
|
|
|
12521
12844
|
function StyleFindings({ report, onSelect, title = "House style", className = "" }) {
|
|
12522
12845
|
if (!report) return null;
|
|
12523
12846
|
const { findings, ran, skipped } = report;
|
|
12524
|
-
return /* @__PURE__ */ (0,
|
|
12525
|
-
/* @__PURE__ */ (0,
|
|
12526
|
-
findings.length > 0 && /* @__PURE__ */ (0,
|
|
12847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("section", { "data-style-findings": "", "aria-label": title, className: `flex flex-col gap-1.5 text-xs text-foreground ${className}`, children: [
|
|
12848
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("h3", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
|
|
12849
|
+
findings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("ul", { className: "flex flex-col gap-1", children: findings.map((finding, i) => {
|
|
12527
12850
|
const selectable = finding.target !== void 0 && !!onSelect;
|
|
12528
|
-
const body = /* @__PURE__ */ (0,
|
|
12529
|
-
/* @__PURE__ */ (0,
|
|
12530
|
-
/* @__PURE__ */ (0,
|
|
12531
|
-
/* @__PURE__ */ (0,
|
|
12532
|
-
/* @__PURE__ */ (0,
|
|
12533
|
-
/* @__PURE__ */ (0,
|
|
12534
|
-
finding.layer && /* @__PURE__ */ (0,
|
|
12851
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
12852
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { "data-style-severity": finding.severity, className: `shrink-0 font-semibold uppercase text-[10px] ${SEVERITY_CLASS[finding.severity]}`, children: finding.severity }),
|
|
12853
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "flex min-w-0 flex-col", children: [
|
|
12854
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { "data-style-message": "", children: finding.message }),
|
|
12855
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
12856
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("code", { children: finding.check }),
|
|
12857
|
+
finding.layer && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
12535
12858
|
" \xB7 ",
|
|
12536
12859
|
finding.layer
|
|
12537
12860
|
] })
|
|
12538
12861
|
] })
|
|
12539
12862
|
] })
|
|
12540
12863
|
] });
|
|
12541
|
-
return /* @__PURE__ */ (0,
|
|
12864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("li", { "data-style-finding": finding.check, children: selectable ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
12542
12865
|
"button",
|
|
12543
12866
|
{
|
|
12544
12867
|
type: "button",
|
|
@@ -12546,19 +12869,19 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
12546
12869
|
onClick: () => onSelect(finding),
|
|
12547
12870
|
children: body
|
|
12548
12871
|
}
|
|
12549
|
-
) : /* @__PURE__ */ (0,
|
|
12872
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "flex items-start gap-2 rounded border border-border px-2 py-1", children: body }) }, `${finding.check}-${i}`);
|
|
12550
12873
|
}) }),
|
|
12551
|
-
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0,
|
|
12874
|
+
findings.length === 0 && ran.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("p", { "data-style-clear": "", className: "text-emerald-600", children: [
|
|
12552
12875
|
"All clear: ",
|
|
12553
12876
|
ran.length,
|
|
12554
12877
|
" ",
|
|
12555
12878
|
ran.length === 1 ? "check" : "checks",
|
|
12556
12879
|
" passed."
|
|
12557
12880
|
] }),
|
|
12558
|
-
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0,
|
|
12559
|
-
skipped.length > 0 && /* @__PURE__ */ (0,
|
|
12881
|
+
findings.length === 0 && ran.length === 0 && skipped.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "text-muted-foreground", children: "No house-style checks apply." }),
|
|
12882
|
+
skipped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("ul", { "data-style-skipped": "", "aria-label": "Skipped checks", className: "flex flex-col gap-0.5 text-muted-foreground", children: skipped.map((s) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("li", { "data-style-skipped-check": s.check, children: [
|
|
12560
12883
|
"Skipped ",
|
|
12561
|
-
/* @__PURE__ */ (0,
|
|
12884
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("code", { children: s.check }),
|
|
12562
12885
|
": ",
|
|
12563
12886
|
s.reason
|
|
12564
12887
|
] }, s.check)) })
|
|
@@ -12571,6 +12894,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
|
|
|
12571
12894
|
AssetMentionChips,
|
|
12572
12895
|
BrushOptionsBar,
|
|
12573
12896
|
BubbleMenu,
|
|
12897
|
+
ChannelsPanel,
|
|
12574
12898
|
ChartNodeView,
|
|
12575
12899
|
ColorProfilePanel,
|
|
12576
12900
|
CommandPalette,
|