@pixerate/editor-react 0.114.2 → 0.114.3
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/animation-editor/index.cjs +342 -215
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +520 -393
- package/dist/canvas/index.js +2 -2
- package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
- package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
- package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +348 -221
- package/dist/effects/index.js +2 -2
- package/dist/image-editor/ImageEffectControls.d.cts +4 -1
- package/dist/image-editor/ImageEffectControls.d.ts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
- package/dist/image-editor/controls/parameterControls.d.cts +4 -0
- package/dist/image-editor/controls/parameterControls.d.ts +4 -0
- package/dist/image-editor/index.cjs +868 -697
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1388 -1217
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +335 -208
- package/dist/paint-editor/index.js +2 -2
- package/dist/parameters/ParametersPanel.d.cts +4 -1
- package/dist/parameters/ParametersPanel.d.ts +4 -1
- package/dist/parameters/controls.d.cts +72 -0
- package/dist/parameters/controls.d.ts +72 -0
- package/dist/parameters/fields.d.cts +19 -6
- package/dist/parameters/fields.d.ts +19 -6
- package/dist/parameters/index.cjs +350 -183
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +70 -14
- package/dist/vector/index.cjs +321 -194
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +418 -291
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
|
@@ -222,7 +222,7 @@ function ShotTimeline({ controller, className = "" }) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// src/animation-editor/AnimationEditor.tsx
|
|
225
|
-
var
|
|
225
|
+
var import_react22 = require("react");
|
|
226
226
|
|
|
227
227
|
// src/playback/AgentPlaybackContext.tsx
|
|
228
228
|
var import_react3 = require("react");
|
|
@@ -1278,12 +1278,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1278
1278
|
}
|
|
1279
1279
|
|
|
1280
1280
|
// src/effects/EffectParameters.tsx
|
|
1281
|
-
var
|
|
1281
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
1282
1282
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1283
1283
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1284
1284
|
|
|
1285
1285
|
// src/parameters/fields.tsx
|
|
1286
|
-
var
|
|
1286
|
+
var import_react19 = require("react");
|
|
1287
1287
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1288
1288
|
|
|
1289
1289
|
// src/color/index.ts
|
|
@@ -2325,18 +2325,57 @@ function useResolvedColor(value, scheme) {
|
|
|
2325
2325
|
// src/color/index.ts
|
|
2326
2326
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2327
2327
|
|
|
2328
|
-
// src/parameters/
|
|
2328
|
+
// src/parameters/controls.tsx
|
|
2329
|
+
var import_react18 = require("react");
|
|
2329
2330
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2331
|
+
var ParameterComponentsContext = (0, import_react18.createContext)({});
|
|
2332
|
+
function useParameterComponents() {
|
|
2333
|
+
return (0, import_react18.useContext)(ParameterComponentsContext);
|
|
2334
|
+
}
|
|
2335
|
+
function resolveParameterComponents(explicit, context) {
|
|
2336
|
+
return {
|
|
2337
|
+
input: explicit?.input ?? context?.input,
|
|
2338
|
+
slider: explicit?.slider ?? context?.slider,
|
|
2339
|
+
select: explicit?.select ?? context?.select
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
// src/parameters/fields.tsx
|
|
2344
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2345
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2346
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2347
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
2348
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
2330
2349
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2331
2350
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
2332
2351
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2333
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
2352
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2353
|
+
const inputRef = (0, import_react19.useRef)(null);
|
|
2354
|
+
const lastCommitted = (0, import_react19.useRef)(null);
|
|
2355
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
2356
|
+
lastCommitted.current = null;
|
|
2357
|
+
const el = inputRef.current;
|
|
2358
|
+
if (el && el.value !== value) el.value = value;
|
|
2359
|
+
}, [value]);
|
|
2334
2360
|
const commit = (el) => {
|
|
2335
|
-
|
|
2361
|
+
const text = el.value;
|
|
2362
|
+
if (text === value || text === lastCommitted.current) return;
|
|
2363
|
+
onCommit(text, el);
|
|
2364
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
2336
2365
|
};
|
|
2366
|
+
const commitRef = (0, import_react19.useRef)(commit);
|
|
2367
|
+
commitRef.current = commit;
|
|
2368
|
+
(0, import_react19.useEffect)(() => {
|
|
2369
|
+
const el = inputRef.current;
|
|
2370
|
+
if (!el) return;
|
|
2371
|
+
const change = () => commitRef.current(el);
|
|
2372
|
+
el.addEventListener("change", change);
|
|
2373
|
+
return () => el.removeEventListener("change", change);
|
|
2374
|
+
}, [multiline]);
|
|
2337
2375
|
const keyDown = (e) => {
|
|
2338
2376
|
onKeyDown?.(e);
|
|
2339
2377
|
if (e.defaultPrevented) return;
|
|
2378
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
2340
2379
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
2341
2380
|
e.preventDefault();
|
|
2342
2381
|
commit(e.currentTarget);
|
|
@@ -2346,86 +2385,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2346
2385
|
const props = {
|
|
2347
2386
|
defaultValue: value,
|
|
2348
2387
|
className: className ?? parameterInputClass,
|
|
2388
|
+
style: { ...parameterInputStyle, ...style },
|
|
2349
2389
|
onBlur: (e) => commit(e.currentTarget),
|
|
2350
2390
|
onKeyDown: keyDown,
|
|
2351
2391
|
...rest
|
|
2352
2392
|
};
|
|
2353
|
-
|
|
2393
|
+
const forwarded = rest.ref;
|
|
2394
|
+
const setRef = (el) => {
|
|
2395
|
+
inputRef.current = el;
|
|
2396
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
2397
|
+
else if (forwarded) forwarded.current = el;
|
|
2398
|
+
};
|
|
2399
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
2354
2400
|
}
|
|
2355
2401
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
2356
|
-
function ParameterNumberInput({
|
|
2357
|
-
field,
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2402
|
+
function ParameterNumberInput(props) {
|
|
2403
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
2404
|
+
const ctx = useParameterComponents();
|
|
2405
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2406
|
+
const CustomInput = resolved.input;
|
|
2407
|
+
const plain = plainNumber(field, value);
|
|
2408
|
+
const handleCommit = (text, input4) => {
|
|
2409
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
2410
|
+
if (n === null || n === value) {
|
|
2411
|
+
if (input4) input4.value = plain;
|
|
2412
|
+
} else {
|
|
2413
|
+
onChange(n);
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
const handleKeyDown = (e) => {
|
|
2417
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2418
|
+
e.preventDefault();
|
|
2419
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
2420
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
2421
|
+
};
|
|
2422
|
+
const inputProps = {
|
|
2423
|
+
id,
|
|
2424
|
+
inputMode: "decimal",
|
|
2425
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
2426
|
+
value: plain,
|
|
2427
|
+
disabled: disabled || field.readOnly,
|
|
2428
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
2429
|
+
style: parameterInputStyle,
|
|
2430
|
+
onCommit: handleCommit,
|
|
2431
|
+
onKeyDown: handleKeyDown
|
|
2432
|
+
};
|
|
2433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2434
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2435
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
2388
2436
|
] });
|
|
2389
2437
|
}
|
|
2390
2438
|
function ParameterSlider(props) {
|
|
2391
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
2392
|
-
const
|
|
2439
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
2440
|
+
const ctx = useParameterComponents();
|
|
2441
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2442
|
+
const CustomSlider = resolved.slider;
|
|
2443
|
+
const dragging = (0, import_react19.useRef)(false);
|
|
2444
|
+
const start = () => {
|
|
2445
|
+
if (dragging.current) return;
|
|
2446
|
+
dragging.current = true;
|
|
2447
|
+
onGestureStart?.();
|
|
2448
|
+
};
|
|
2393
2449
|
const end = () => {
|
|
2394
2450
|
if (!dragging.current) return;
|
|
2395
2451
|
dragging.current = false;
|
|
2396
2452
|
onGestureEnd?.();
|
|
2397
2453
|
};
|
|
2398
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2454
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterNumberInput, { ...props });
|
|
2399
2455
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2400
|
-
|
|
2401
|
-
|
|
2456
|
+
const sliderProps = {
|
|
2457
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2458
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
2459
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
2460
|
+
min: field.min ?? 0,
|
|
2461
|
+
max: field.max ?? 100,
|
|
2462
|
+
step,
|
|
2463
|
+
value,
|
|
2464
|
+
disabled: disabled || field.readOnly,
|
|
2465
|
+
className: rangeClass,
|
|
2466
|
+
style: parameterRangeStyle
|
|
2467
|
+
};
|
|
2468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2469
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2470
|
+
CustomSlider,
|
|
2471
|
+
{
|
|
2472
|
+
...sliderProps,
|
|
2473
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
2474
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2475
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
2476
|
+
onGestureStart: start,
|
|
2477
|
+
onGestureEnd: end
|
|
2478
|
+
}
|
|
2479
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2402
2480
|
"input",
|
|
2403
2481
|
{
|
|
2404
2482
|
type: "range",
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
min: field.min,
|
|
2408
|
-
max: field.max,
|
|
2409
|
-
step,
|
|
2410
|
-
value,
|
|
2411
|
-
disabled: disabled || field.readOnly,
|
|
2412
|
-
className: rangeClass,
|
|
2413
|
-
onPointerDown: () => {
|
|
2414
|
-
if (dragging.current) return;
|
|
2415
|
-
dragging.current = true;
|
|
2416
|
-
onGestureStart?.();
|
|
2417
|
-
},
|
|
2483
|
+
...sliderProps,
|
|
2484
|
+
onPointerDown: start,
|
|
2418
2485
|
onPointerUp: end,
|
|
2419
2486
|
onPointerCancel: end,
|
|
2420
2487
|
onBlur: end,
|
|
2421
2488
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2422
2489
|
}
|
|
2423
2490
|
),
|
|
2424
|
-
/* @__PURE__ */ (0,
|
|
2491
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
2425
2492
|
] });
|
|
2426
2493
|
}
|
|
2427
2494
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2428
|
-
return /* @__PURE__ */ (0,
|
|
2495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2429
2496
|
"button",
|
|
2430
2497
|
{
|
|
2431
2498
|
type: "button",
|
|
@@ -2436,7 +2503,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2436
2503
|
disabled: disabled || field.readOnly,
|
|
2437
2504
|
onClick: () => onChange(!value),
|
|
2438
2505
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
2439
|
-
children: /* @__PURE__ */ (0,
|
|
2506
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2440
2507
|
"span",
|
|
2441
2508
|
{
|
|
2442
2509
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2445,11 +2512,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2445
2512
|
}
|
|
2446
2513
|
);
|
|
2447
2514
|
}
|
|
2448
|
-
function ParameterSelect(
|
|
2515
|
+
function ParameterSelect(props) {
|
|
2516
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
2517
|
+
const ctx = useParameterComponents();
|
|
2518
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2519
|
+
const CustomSelect = resolved.select;
|
|
2449
2520
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2450
2521
|
const off = disabled || field.readOnly;
|
|
2451
2522
|
if (field.control === "segmented") {
|
|
2452
|
-
return /* @__PURE__ */ (0,
|
|
2523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2453
2524
|
"button",
|
|
2454
2525
|
{
|
|
2455
2526
|
type: "button",
|
|
@@ -2464,8 +2535,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2464
2535
|
String(o.value)
|
|
2465
2536
|
)) });
|
|
2466
2537
|
}
|
|
2538
|
+
if (CustomSelect) {
|
|
2539
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2541
|
+
CustomSelect,
|
|
2542
|
+
{
|
|
2543
|
+
id,
|
|
2544
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2545
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2546
|
+
value,
|
|
2547
|
+
options: customOptions,
|
|
2548
|
+
disabled: off,
|
|
2549
|
+
className: parameterInputClass,
|
|
2550
|
+
style: parameterSelectStyle,
|
|
2551
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
2552
|
+
}
|
|
2553
|
+
);
|
|
2554
|
+
}
|
|
2467
2555
|
const index = options.findIndex((o) => o.value === value);
|
|
2468
|
-
return /* @__PURE__ */ (0,
|
|
2556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2469
2557
|
"select",
|
|
2470
2558
|
{
|
|
2471
2559
|
id,
|
|
@@ -2477,22 +2565,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2477
2565
|
if (option) onChange(option.value);
|
|
2478
2566
|
},
|
|
2479
2567
|
className: parameterInputClass,
|
|
2480
|
-
|
|
2568
|
+
style: parameterSelectStyle,
|
|
2569
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2481
2570
|
}
|
|
2482
2571
|
);
|
|
2483
2572
|
}
|
|
2484
2573
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2485
|
-
const [open, setOpen] = (0,
|
|
2486
|
-
const containerRef = (0,
|
|
2487
|
-
const buttonRef = (0,
|
|
2488
|
-
const popoverRef = (0,
|
|
2574
|
+
const [open, setOpen] = (0, import_react19.useState)(false);
|
|
2575
|
+
const containerRef = (0, import_react19.useRef)(null);
|
|
2576
|
+
const buttonRef = (0, import_react19.useRef)(null);
|
|
2577
|
+
const popoverRef = (0, import_react19.useRef)(null);
|
|
2489
2578
|
const alpha = !!field.alpha;
|
|
2490
2579
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2491
2580
|
const rgb = hex.slice(0, 7);
|
|
2492
2581
|
const shown = alpha ? hex : rgb;
|
|
2493
2582
|
const off = disabled || field.readOnly;
|
|
2494
2583
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2495
|
-
(0,
|
|
2584
|
+
(0, import_react19.useEffect)(() => {
|
|
2496
2585
|
if (!open) return;
|
|
2497
2586
|
const onPointerDown = (e) => {
|
|
2498
2587
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2513,9 +2602,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2513
2602
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
2514
2603
|
};
|
|
2515
2604
|
}, [open]);
|
|
2516
|
-
return /* @__PURE__ */ (0,
|
|
2517
|
-
/* @__PURE__ */ (0,
|
|
2518
|
-
/* @__PURE__ */ (0,
|
|
2605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2606
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2607
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2519
2608
|
"button",
|
|
2520
2609
|
{
|
|
2521
2610
|
ref: buttonRef,
|
|
@@ -2526,10 +2615,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2526
2615
|
disabled: off,
|
|
2527
2616
|
onClick: () => setOpen((prev) => !prev),
|
|
2528
2617
|
className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
2529
|
-
children: /* @__PURE__ */ (0,
|
|
2618
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2530
2619
|
}
|
|
2531
2620
|
),
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
2621
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2533
2622
|
ParameterCommitInput,
|
|
2534
2623
|
{
|
|
2535
2624
|
id,
|
|
@@ -2545,7 +2634,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2545
2634
|
}
|
|
2546
2635
|
)
|
|
2547
2636
|
] }),
|
|
2548
|
-
open && /* @__PURE__ */ (0,
|
|
2637
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2549
2638
|
"div",
|
|
2550
2639
|
{
|
|
2551
2640
|
ref: popoverRef,
|
|
@@ -2559,7 +2648,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2559
2648
|
},
|
|
2560
2649
|
className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
|
|
2561
2650
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2562
|
-
children: /* @__PURE__ */ (0,
|
|
2651
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2563
2652
|
ColorPicker,
|
|
2564
2653
|
{
|
|
2565
2654
|
value: shown,
|
|
@@ -2575,13 +2664,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2575
2664
|
)
|
|
2576
2665
|
] });
|
|
2577
2666
|
}
|
|
2578
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
2667
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
2579
2668
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2580
|
-
return /* @__PURE__ */ (0,
|
|
2669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2581
2670
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2582
|
-
return /* @__PURE__ */ (0,
|
|
2583
|
-
/* @__PURE__ */ (0,
|
|
2584
|
-
/* @__PURE__ */ (0,
|
|
2671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2672
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2585
2674
|
ParameterNumberInput,
|
|
2586
2675
|
{
|
|
2587
2676
|
field: component,
|
|
@@ -2589,6 +2678,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2589
2678
|
id: i === 0 ? id : void 0,
|
|
2590
2679
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
2591
2680
|
disabled: disabled || field.readOnly,
|
|
2681
|
+
components,
|
|
2592
2682
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
2593
2683
|
}
|
|
2594
2684
|
)
|
|
@@ -2598,11 +2688,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2598
2688
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2599
2689
|
const off = disabled || field.readOnly;
|
|
2600
2690
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2601
|
-
return /* @__PURE__ */ (0,
|
|
2602
|
-
/* @__PURE__ */ (0,
|
|
2603
|
-
/* @__PURE__ */ (0,
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
2605
|
-
/* @__PURE__ */ (0,
|
|
2691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2692
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2693
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
2694
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2695
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2606
2696
|
ParameterCommitInput,
|
|
2607
2697
|
{
|
|
2608
2698
|
id,
|
|
@@ -2613,30 +2703,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2613
2703
|
onCommit: (text) => onChange(text.trim())
|
|
2614
2704
|
}
|
|
2615
2705
|
),
|
|
2616
|
-
/* @__PURE__ */ (0,
|
|
2617
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2618
|
-
"
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
{
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2706
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
|
|
2707
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2708
|
+
"label",
|
|
2709
|
+
{
|
|
2710
|
+
style: parameterButtonStyle,
|
|
2711
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
2712
|
+
children: [
|
|
2713
|
+
"Choose file\u2026",
|
|
2714
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2715
|
+
"input",
|
|
2716
|
+
{
|
|
2717
|
+
type: "file",
|
|
2718
|
+
className: "sr-only",
|
|
2719
|
+
accept: field.accept ?? "image/*",
|
|
2720
|
+
disabled: off,
|
|
2721
|
+
"aria-label": `${name} file`,
|
|
2722
|
+
onChange: async (e) => {
|
|
2723
|
+
const file = e.target.files?.[0];
|
|
2724
|
+
e.target.value = "";
|
|
2725
|
+
if (file) onChange(await resolveFile(file));
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
)
|
|
2729
|
+
]
|
|
2730
|
+
}
|
|
2731
|
+
),
|
|
2732
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2733
|
+
"button",
|
|
2734
|
+
{
|
|
2735
|
+
type: "button",
|
|
2736
|
+
style: parameterButtonStyle,
|
|
2737
|
+
className: parameterButtonClass,
|
|
2738
|
+
disabled: off,
|
|
2739
|
+
onClick: () => onChange(""),
|
|
2740
|
+
"aria-label": `Clear ${name}`,
|
|
2741
|
+
children: "Clear"
|
|
2742
|
+
}
|
|
2743
|
+
)
|
|
2636
2744
|
] })
|
|
2637
2745
|
] })
|
|
2638
2746
|
] }),
|
|
2639
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2747
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2640
2748
|
"button",
|
|
2641
2749
|
{
|
|
2642
2750
|
type: "button",
|
|
@@ -2646,14 +2754,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2646
2754
|
disabled: off,
|
|
2647
2755
|
onClick: () => onChange(o.url),
|
|
2648
2756
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2649
|
-
children: /* @__PURE__ */ (0,
|
|
2757
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2650
2758
|
},
|
|
2651
2759
|
o.url
|
|
2652
2760
|
)) })
|
|
2653
2761
|
] });
|
|
2654
2762
|
}
|
|
2655
2763
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2656
|
-
return /* @__PURE__ */ (0,
|
|
2764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2657
2765
|
ParameterCommitInput,
|
|
2658
2766
|
{
|
|
2659
2767
|
id,
|
|
@@ -2672,24 +2780,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2672
2780
|
switch (field.type) {
|
|
2673
2781
|
case "number":
|
|
2674
2782
|
case "int":
|
|
2675
|
-
return /* @__PURE__ */ (0,
|
|
2783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2676
2784
|
case "boolean":
|
|
2677
|
-
return /* @__PURE__ */ (0,
|
|
2785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2678
2786
|
case "choice":
|
|
2679
|
-
return /* @__PURE__ */ (0,
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2680
2788
|
case "color":
|
|
2681
|
-
return /* @__PURE__ */ (0,
|
|
2789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2682
2790
|
case "vector":
|
|
2683
|
-
return /* @__PURE__ */ (0,
|
|
2791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2684
2792
|
case "image":
|
|
2685
|
-
return /* @__PURE__ */ (0,
|
|
2793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2686
2794
|
case "text":
|
|
2687
|
-
return /* @__PURE__ */ (0,
|
|
2795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2688
2796
|
}
|
|
2689
2797
|
}
|
|
2690
2798
|
|
|
2691
2799
|
// src/effects/EffectParameters.tsx
|
|
2692
|
-
var
|
|
2800
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2693
2801
|
function EffectParameters({
|
|
2694
2802
|
description,
|
|
2695
2803
|
values,
|
|
@@ -2701,56 +2809,75 @@ function EffectParameters({
|
|
|
2701
2809
|
renderControlAddon,
|
|
2702
2810
|
fonts,
|
|
2703
2811
|
disabled = false,
|
|
2704
|
-
className = ""
|
|
2812
|
+
className = "",
|
|
2813
|
+
components
|
|
2705
2814
|
}) {
|
|
2706
|
-
const fields = (0,
|
|
2707
|
-
const idBase = (0,
|
|
2708
|
-
const gesture =
|
|
2709
|
-
const count =
|
|
2710
|
-
|
|
2711
|
-
|
|
2815
|
+
const fields = (0, import_react20.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
2816
|
+
const idBase = (0, import_react20.useId)();
|
|
2817
|
+
const gesture = import_react20.default.useRef(null);
|
|
2818
|
+
const count = import_react20.default.useRef(0);
|
|
2819
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
2820
|
+
const handlePresetSelect = (name) => {
|
|
2821
|
+
if (!name) return;
|
|
2822
|
+
if (onPresetName) {
|
|
2823
|
+
onPresetName(name);
|
|
2824
|
+
} else if (onPreset) {
|
|
2825
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
2826
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2830
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2831
|
+
CustomPresetSelect,
|
|
2832
|
+
{
|
|
2833
|
+
"aria-label": `${description.name} presets`,
|
|
2834
|
+
label: `${description.name} presets`,
|
|
2835
|
+
value: "",
|
|
2836
|
+
disabled,
|
|
2837
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
2838
|
+
style: parameterSelectStyle,
|
|
2839
|
+
options: [
|
|
2840
|
+
{ value: "", label: "Presets\u2026" },
|
|
2841
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
2842
|
+
],
|
|
2843
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
2844
|
+
}
|
|
2845
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2712
2846
|
"select",
|
|
2713
2847
|
{
|
|
2714
|
-
className: "w-full rounded border border-border
|
|
2848
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
2849
|
+
style: parameterSelectStyle,
|
|
2715
2850
|
"aria-label": `${description.name} presets`,
|
|
2716
2851
|
value: "",
|
|
2717
2852
|
disabled,
|
|
2718
|
-
onChange: (e) =>
|
|
2719
|
-
const name = e.currentTarget.value;
|
|
2720
|
-
if (!name) return;
|
|
2721
|
-
if (onPresetName) {
|
|
2722
|
-
onPresetName(name);
|
|
2723
|
-
} else if (onPreset) {
|
|
2724
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
2725
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2726
|
-
}
|
|
2727
|
-
},
|
|
2853
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
2728
2854
|
children: [
|
|
2729
|
-
/* @__PURE__ */ (0,
|
|
2730
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2855
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
2856
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
2731
2857
|
]
|
|
2732
2858
|
}
|
|
2733
|
-
),
|
|
2859
|
+
)),
|
|
2734
2860
|
fields.map((field) => {
|
|
2735
2861
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
2736
2862
|
const inputId = `${idBase}-${field.id}`;
|
|
2737
2863
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
2738
2864
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
2739
2865
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
2740
|
-
return /* @__PURE__ */ (0,
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
2743
|
-
keyed && /* @__PURE__ */ (0,
|
|
2866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2867
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2868
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
2869
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2744
2870
|
renderControlAddon?.(field.id),
|
|
2745
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
2871
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
2746
2872
|
] }),
|
|
2747
|
-
/* @__PURE__ */ (0,
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2748
2874
|
ParameterFieldControl,
|
|
2749
2875
|
{
|
|
2750
2876
|
field,
|
|
2751
2877
|
value,
|
|
2752
2878
|
id: inputId,
|
|
2753
2879
|
disabled: disabled || keyed,
|
|
2880
|
+
components,
|
|
2754
2881
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
2755
2882
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
2756
2883
|
onGestureEnd: () => gesture.current = null
|
|
@@ -2758,25 +2885,25 @@ function EffectParameters({
|
|
|
2758
2885
|
)
|
|
2759
2886
|
] }, field.id);
|
|
2760
2887
|
}),
|
|
2761
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2888
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
2762
2889
|
] });
|
|
2763
2890
|
}
|
|
2764
2891
|
|
|
2765
2892
|
// src/animation-editor/AnimationEffectsPanel.tsx
|
|
2766
|
-
var
|
|
2893
|
+
var import_react21 = require("react");
|
|
2767
2894
|
var import_animation_editor10 = require("@pixerate/editor/animation-editor");
|
|
2768
|
-
var
|
|
2895
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2769
2896
|
var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2770
2897
|
function Controls({ controller, instance, effect, values }) {
|
|
2771
2898
|
const provider = controller.effectsProvider;
|
|
2772
2899
|
const { description, error } = useEffectDescription(provider, effect);
|
|
2773
|
-
const [message, setMessage] = (0,
|
|
2900
|
+
const [message, setMessage] = (0, import_react21.useState)(null);
|
|
2774
2901
|
const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
|
|
2775
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
2776
|
-
if (error) return /* @__PURE__ */ (0,
|
|
2777
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
2778
|
-
return /* @__PURE__ */ (0,
|
|
2779
|
-
/* @__PURE__ */ (0,
|
|
2902
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: its commands are kept as they are." });
|
|
2903
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2904
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
2905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2906
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2780
2907
|
EffectParameters,
|
|
2781
2908
|
{
|
|
2782
2909
|
description,
|
|
@@ -2786,60 +2913,60 @@ function Controls({ controller, instance, effect, values }) {
|
|
|
2786
2913
|
onPreset: (v) => report(controller.updateMotionEffect(instance, v))
|
|
2787
2914
|
}
|
|
2788
2915
|
),
|
|
2789
|
-
message && /* @__PURE__ */ (0,
|
|
2916
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2790
2917
|
] });
|
|
2791
2918
|
}
|
|
2792
2919
|
function AnimationEffectsPanel({ controller, node, className = "" }) {
|
|
2793
2920
|
const state = useAnimationEditorState(controller);
|
|
2794
2921
|
const provider = state.effectsProvider;
|
|
2795
|
-
const nodes = (0,
|
|
2796
|
-
const [chosen, setChosen] = (0,
|
|
2922
|
+
const nodes = (0, import_react21.useMemo)(() => [...(0, import_animation_editor10.indexMotionNodes)(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
|
|
2923
|
+
const [chosen, setChosen] = (0, import_react21.useState)("");
|
|
2797
2924
|
const target = node && nodes.includes(node) ? node : chosen && nodes.includes(chosen) ? chosen : "";
|
|
2798
|
-
const [browse, setBrowse] = (0,
|
|
2799
|
-
const [open, setOpen] = (0,
|
|
2800
|
-
const [message, setMessage] = (0,
|
|
2925
|
+
const [browse, setBrowse] = (0, import_react21.useState)(null);
|
|
2926
|
+
const [open, setOpen] = (0, import_react21.useState)(null);
|
|
2927
|
+
const [message, setMessage] = (0, import_react21.useState)(null);
|
|
2801
2928
|
const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? x.notes.length ? x.notes.join(" ") : null : x.error));
|
|
2802
|
-
const applied = (0,
|
|
2929
|
+
const applied = (0, import_react21.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
|
|
2803
2930
|
const disabled = state.readOnly;
|
|
2804
|
-
return /* @__PURE__ */ (0,
|
|
2805
|
-
/* @__PURE__ */ (0,
|
|
2806
|
-
/* @__PURE__ */ (0,
|
|
2807
|
-
/* @__PURE__ */ (0,
|
|
2808
|
-
/* @__PURE__ */ (0,
|
|
2809
|
-
nodes.map((id) => /* @__PURE__ */ (0,
|
|
2931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
|
|
2932
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2933
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
2934
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]", "aria-label": "Node to animate", value: target, disabled: !!node, onChange: (e) => setChosen(e.currentTarget.value), children: [
|
|
2935
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", children: "Node\u2026" }),
|
|
2936
|
+
nodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: id, children: id }, id))
|
|
2810
2937
|
] }),
|
|
2811
|
-
/* @__PURE__ */ (0,
|
|
2812
|
-
/* @__PURE__ */ (0,
|
|
2938
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider || !target, "aria-pressed": browse === "motion", onClick: () => setBrowse(browse === "motion" ? null : "motion"), children: "Animate\u2026" }),
|
|
2939
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "vector", onClick: () => setBrowse(browse === "vector" ? null : "vector"), children: "Vector effect\u2026" })
|
|
2813
2940
|
] }),
|
|
2814
|
-
!provider && /* @__PURE__ */ (0,
|
|
2815
|
-
browse === "motion" && /* @__PURE__ */ (0,
|
|
2816
|
-
browse === "vector" && /* @__PURE__ */ (0,
|
|
2817
|
-
/* @__PURE__ */ (0,
|
|
2818
|
-
/* @__PURE__ */ (0,
|
|
2819
|
-
/* @__PURE__ */ (0,
|
|
2941
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
|
|
2942
|
+
browse === "motion" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
|
|
2943
|
+
browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
|
|
2944
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
|
|
2945
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2946
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.instance, onClick: () => setOpen(open === e.instance ? null : e.instance), children: [
|
|
2820
2947
|
e.name ?? e.effect,
|
|
2821
2948
|
" ",
|
|
2822
|
-
/* @__PURE__ */ (0,
|
|
2949
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
2823
2950
|
"\xB7 ",
|
|
2824
2951
|
e.kind === "vector" ? "picture" : e.targets.join(", ")
|
|
2825
2952
|
] })
|
|
2826
2953
|
] }),
|
|
2827
|
-
/* @__PURE__ */ (0,
|
|
2954
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeMotionEffect(e.instance)), children: "\u2715" })
|
|
2828
2955
|
] }),
|
|
2829
|
-
open === e.instance && /* @__PURE__ */ (0,
|
|
2956
|
+
open === e.instance && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mt-1", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values }) })
|
|
2830
2957
|
] }, e.instance)) }),
|
|
2831
|
-
!applied.length && /* @__PURE__ */ (0,
|
|
2832
|
-
message && /* @__PURE__ */ (0,
|
|
2958
|
+
!applied.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
|
|
2959
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
|
|
2833
2960
|
] });
|
|
2834
2961
|
}
|
|
2835
2962
|
|
|
2836
2963
|
// src/animation-editor/AnimationEditor.tsx
|
|
2837
|
-
var
|
|
2964
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2838
2965
|
var ONION = { before: 3, after: 1 };
|
|
2839
2966
|
var btn6 = "rounded border border-border px-2 py-0.5 text-xs disabled:opacity-40";
|
|
2840
2967
|
function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssues = true, editable = true, effects, className = "", playback, playbackId = "animation", onPlaybackReveal }) {
|
|
2841
2968
|
const state = useAnimationEditorState(controller);
|
|
2842
|
-
const rootRef = (0,
|
|
2969
|
+
const rootRef = (0, import_react22.useRef)(null);
|
|
2843
2970
|
const ambientPlayback = useAgentPlayback();
|
|
2844
2971
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
2845
2972
|
const rectIn = (el) => {
|
|
@@ -2874,16 +3001,16 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2874
3001
|
},
|
|
2875
3002
|
reveal: () => onPlaybackReveal?.()
|
|
2876
3003
|
});
|
|
2877
|
-
const presenceLayer = playing ? /* @__PURE__ */ (0,
|
|
3004
|
+
const presenceLayer = playing ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PresenceLayer, { presence: agentPresence }) : null;
|
|
2878
3005
|
useEffects(controller, effects);
|
|
2879
3006
|
const { issues, scene, selection, readOnly } = state;
|
|
2880
|
-
const [picked, setPicked] = (0,
|
|
2881
|
-
const [onion, setOnion] = (0,
|
|
2882
|
-
const [paths, setPaths] = (0,
|
|
2883
|
-
const [recordMode, setRecordMode] = (0,
|
|
3007
|
+
const [picked, setPicked] = (0, import_react22.useState)(null);
|
|
3008
|
+
const [onion, setOnion] = (0, import_react22.useState)(false);
|
|
3009
|
+
const [paths, setPaths] = (0, import_react22.useState)(false);
|
|
3010
|
+
const [recordMode, setRecordMode] = (0, import_react22.useState)("move");
|
|
2884
3011
|
const command = selection?.command !== void 0 ? scene.shots.find((s) => s.id === selection.shot)?.run[selection.command] : void 0;
|
|
2885
3012
|
const targets = command && "targets" in command ? command.targets : [];
|
|
2886
|
-
const nodes = (0,
|
|
3013
|
+
const nodes = (0, import_react22.useMemo)(() => (0, import_animation_editor11.indexMotionNodes)(scene.artwork.nodes), [scene.artwork]);
|
|
2887
3014
|
const pickedValid = picked && nodes.has(picked) ? picked : null;
|
|
2888
3015
|
const onPick = (id, event) => {
|
|
2889
3016
|
if (event.shiftKey && id && command && "targets" in command && selection?.command !== void 0 && !readOnly) {
|
|
@@ -2893,7 +3020,7 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2893
3020
|
}
|
|
2894
3021
|
setPicked(id);
|
|
2895
3022
|
};
|
|
2896
|
-
const stage = /* @__PURE__ */ (0,
|
|
3023
|
+
const stage = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2897
3024
|
AnimationStage,
|
|
2898
3025
|
{
|
|
2899
3026
|
controller,
|
|
@@ -2906,15 +3033,15 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2906
3033
|
className: "rounded-md border border-border bg-muted/40"
|
|
2907
3034
|
}
|
|
2908
3035
|
);
|
|
2909
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
3036
|
+
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Animation issues", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", children: (0, import_animation_editor11.motionIssueLine)(issue) }, i)) });
|
|
2910
3037
|
if (!editable)
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
3038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 ${className}`, "data-animation-editor": "", children: [
|
|
2912
3039
|
presenceLayer,
|
|
2913
3040
|
stage,
|
|
2914
|
-
/* @__PURE__ */ (0,
|
|
3041
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PlayheadScrubber, { controller }),
|
|
2915
3042
|
issueList
|
|
2916
3043
|
] });
|
|
2917
|
-
return /* @__PURE__ */ (0,
|
|
3044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2918
3045
|
"div",
|
|
2919
3046
|
{
|
|
2920
3047
|
ref: rootRef,
|
|
@@ -2929,41 +3056,41 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2929
3056
|
},
|
|
2930
3057
|
children: [
|
|
2931
3058
|
presenceLayer,
|
|
2932
|
-
/* @__PURE__ */ (0,
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
2933
3060
|
stage,
|
|
2934
|
-
/* @__PURE__ */ (0,
|
|
2935
|
-
/* @__PURE__ */ (0,
|
|
2936
|
-
/* @__PURE__ */ (0,
|
|
2937
|
-
/* @__PURE__ */ (0,
|
|
2938
|
-
onionSkin === void 0 && /* @__PURE__ */ (0,
|
|
2939
|
-
/* @__PURE__ */ (0,
|
|
3061
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PlayheadScrubber, { controller }),
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
3063
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: btn6, onClick: () => controller.undo(), disabled: !state.canUndo, title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo", "data-undo": "", children: "Undo" }),
|
|
3064
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: btn6, onClick: () => controller.redo(), disabled: !state.canRedo, title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo", "data-redo": "", children: "Redo" }),
|
|
3065
|
+
onionSkin === void 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", checked: onion, onChange: (e) => setOnion(e.target.checked) }),
|
|
2940
3067
|
" Onion skin"
|
|
2941
3068
|
] }),
|
|
2942
|
-
motionPaths === void 0 && /* @__PURE__ */ (0,
|
|
2943
|
-
/* @__PURE__ */ (0,
|
|
3069
|
+
motionPaths === void 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3070
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", checked: paths, onChange: (e) => setPaths(e.target.checked) }),
|
|
2944
3071
|
" Motion paths"
|
|
2945
3072
|
] }),
|
|
2946
|
-
/* @__PURE__ */ (0,
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "ml-auto", "data-picked-element": pickedValid ?? void 0, children: pickedValid ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2947
3074
|
"Picked ",
|
|
2948
|
-
/* @__PURE__ */ (0,
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { className: "text-rose-500", children: pickedValid }),
|
|
2949
3076
|
" ",
|
|
2950
|
-
/* @__PURE__ */ (0,
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: "underline", onClick: () => setPicked(null), children: "clear" })
|
|
2951
3078
|
] }) : "Click the stage to pick an element; shift-click to toggle it as a target." })
|
|
2952
3079
|
] }),
|
|
2953
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3080
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AnimationRecordPanel, { controller, node: pickedValid, mode: recordMode, onModeChange: setRecordMode, className: "border-t border-border pt-2" }),
|
|
2954
3081
|
issueList
|
|
2955
3082
|
] }),
|
|
2956
|
-
/* @__PURE__ */ (0,
|
|
2957
|
-
/* @__PURE__ */ (0,
|
|
2958
|
-
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0,
|
|
2959
|
-
/* @__PURE__ */ (0,
|
|
2960
|
-
/* @__PURE__ */ (0,
|
|
2961
|
-
/* @__PURE__ */ (0,
|
|
2962
|
-
/* @__PURE__ */ (0,
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
3084
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CommandList, { controller, targets: pickedValid ? [pickedValid] : void 0 }),
|
|
3085
|
+
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AnimationEffectsPanel, { controller, node: pickedValid, className: "border-t border-border pt-2" }),
|
|
3086
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CommandInspector, { controller, picked: pickedValid, className: "border-t border-border pt-2" }),
|
|
3087
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { open: true, className: "border-t border-border pt-2", children: [
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Shot" }),
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ShotInspector, { controller, className: "mt-1" })
|
|
2963
3090
|
] }),
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { className: "border-t border-border pt-2", children: [
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Scene settings" }),
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SceneSettings, { controller, className: "mt-1" })
|
|
2967
3094
|
] })
|
|
2968
3095
|
] })
|
|
2969
3096
|
]
|