@pixerate/editor-react 0.114.2 → 0.115.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/animation-editor/index.cjs +361 -216
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +539 -394
- package/dist/canvas/index.js +2 -2
- package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
- package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
- package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.js} +40 -18
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +367 -222
- 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/controls.d.cts +19 -0
- package/dist/image-editor/controls/controls.d.ts +19 -0
- 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 +924 -765
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +1444 -1285
- package/dist/index.js +5 -3
- package/dist/paint-editor/index.cjs +354 -209
- 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 +92 -0
- package/dist/parameters/controls.d.ts +92 -0
- package/dist/parameters/fields.d.cts +20 -7
- package/dist/parameters/fields.d.ts +20 -7
- package/dist/parameters/index.cjs +369 -184
- 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 +340 -195
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +437 -292
- 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,58 @@ 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
|
+
color: explicit?.color ?? context?.color
|
|
2341
|
+
};
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
// src/parameters/fields.tsx
|
|
2345
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2346
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2347
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2348
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
2349
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
2330
2350
|
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
2351
|
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
2352
|
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 }) {
|
|
2353
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2354
|
+
const inputRef = (0, import_react19.useRef)(null);
|
|
2355
|
+
const lastCommitted = (0, import_react19.useRef)(null);
|
|
2356
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
2357
|
+
lastCommitted.current = null;
|
|
2358
|
+
const el = inputRef.current;
|
|
2359
|
+
if (el && el.value !== value) el.value = value;
|
|
2360
|
+
}, [value]);
|
|
2334
2361
|
const commit = (el) => {
|
|
2335
|
-
|
|
2362
|
+
const text = el.value;
|
|
2363
|
+
if (text === value || text === lastCommitted.current) return;
|
|
2364
|
+
onCommit(text, el);
|
|
2365
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
2336
2366
|
};
|
|
2367
|
+
const commitRef = (0, import_react19.useRef)(commit);
|
|
2368
|
+
commitRef.current = commit;
|
|
2369
|
+
(0, import_react19.useEffect)(() => {
|
|
2370
|
+
const el = inputRef.current;
|
|
2371
|
+
if (!el) return;
|
|
2372
|
+
const change = () => commitRef.current(el);
|
|
2373
|
+
el.addEventListener("change", change);
|
|
2374
|
+
return () => el.removeEventListener("change", change);
|
|
2375
|
+
}, [multiline]);
|
|
2337
2376
|
const keyDown = (e) => {
|
|
2338
2377
|
onKeyDown?.(e);
|
|
2339
2378
|
if (e.defaultPrevented) return;
|
|
2379
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
2340
2380
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
2341
2381
|
e.preventDefault();
|
|
2342
2382
|
commit(e.currentTarget);
|
|
@@ -2346,86 +2386,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2346
2386
|
const props = {
|
|
2347
2387
|
defaultValue: value,
|
|
2348
2388
|
className: className ?? parameterInputClass,
|
|
2389
|
+
style: { ...parameterInputStyle, ...style },
|
|
2349
2390
|
onBlur: (e) => commit(e.currentTarget),
|
|
2350
2391
|
onKeyDown: keyDown,
|
|
2351
2392
|
...rest
|
|
2352
2393
|
};
|
|
2353
|
-
|
|
2394
|
+
const forwarded = rest.ref;
|
|
2395
|
+
const setRef = (el) => {
|
|
2396
|
+
inputRef.current = el;
|
|
2397
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
2398
|
+
else if (forwarded) forwarded.current = el;
|
|
2399
|
+
};
|
|
2400
|
+
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
2401
|
}
|
|
2355
2402
|
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
|
-
|
|
2403
|
+
function ParameterNumberInput(props) {
|
|
2404
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
2405
|
+
const ctx = useParameterComponents();
|
|
2406
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2407
|
+
const CustomInput = resolved.input;
|
|
2408
|
+
const plain = plainNumber(field, value);
|
|
2409
|
+
const handleCommit = (text, input4) => {
|
|
2410
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
2411
|
+
if (n === null || n === value) {
|
|
2412
|
+
if (input4) input4.value = plain;
|
|
2413
|
+
} else {
|
|
2414
|
+
onChange(n);
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
const handleKeyDown = (e) => {
|
|
2418
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2419
|
+
e.preventDefault();
|
|
2420
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
2421
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
2422
|
+
};
|
|
2423
|
+
const inputProps = {
|
|
2424
|
+
id,
|
|
2425
|
+
inputMode: "decimal",
|
|
2426
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
2427
|
+
value: plain,
|
|
2428
|
+
disabled: disabled || field.readOnly,
|
|
2429
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
2430
|
+
style: parameterInputStyle,
|
|
2431
|
+
onCommit: handleCommit,
|
|
2432
|
+
onKeyDown: handleKeyDown
|
|
2433
|
+
};
|
|
2434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2435
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2436
|
+
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
2437
|
] });
|
|
2389
2438
|
}
|
|
2390
2439
|
function ParameterSlider(props) {
|
|
2391
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
2392
|
-
const
|
|
2440
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
2441
|
+
const ctx = useParameterComponents();
|
|
2442
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2443
|
+
const CustomSlider = resolved.slider;
|
|
2444
|
+
const dragging = (0, import_react19.useRef)(false);
|
|
2445
|
+
const start = () => {
|
|
2446
|
+
if (dragging.current) return;
|
|
2447
|
+
dragging.current = true;
|
|
2448
|
+
onGestureStart?.();
|
|
2449
|
+
};
|
|
2393
2450
|
const end = () => {
|
|
2394
2451
|
if (!dragging.current) return;
|
|
2395
2452
|
dragging.current = false;
|
|
2396
2453
|
onGestureEnd?.();
|
|
2397
2454
|
};
|
|
2398
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2455
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterNumberInput, { ...props });
|
|
2399
2456
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2400
|
-
|
|
2401
|
-
|
|
2457
|
+
const sliderProps = {
|
|
2458
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2459
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
2460
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
2461
|
+
min: field.min ?? 0,
|
|
2462
|
+
max: field.max ?? 100,
|
|
2463
|
+
step,
|
|
2464
|
+
value,
|
|
2465
|
+
disabled: disabled || field.readOnly,
|
|
2466
|
+
className: rangeClass,
|
|
2467
|
+
style: parameterRangeStyle
|
|
2468
|
+
};
|
|
2469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2470
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2471
|
+
CustomSlider,
|
|
2472
|
+
{
|
|
2473
|
+
...sliderProps,
|
|
2474
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
2475
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2476
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
2477
|
+
onGestureStart: start,
|
|
2478
|
+
onGestureEnd: end
|
|
2479
|
+
}
|
|
2480
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2402
2481
|
"input",
|
|
2403
2482
|
{
|
|
2404
2483
|
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
|
-
},
|
|
2484
|
+
...sliderProps,
|
|
2485
|
+
onPointerDown: start,
|
|
2418
2486
|
onPointerUp: end,
|
|
2419
2487
|
onPointerCancel: end,
|
|
2420
2488
|
onBlur: end,
|
|
2421
2489
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2422
2490
|
}
|
|
2423
2491
|
),
|
|
2424
|
-
/* @__PURE__ */ (0,
|
|
2492
|
+
/* @__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
2493
|
] });
|
|
2426
2494
|
}
|
|
2427
2495
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2428
|
-
return /* @__PURE__ */ (0,
|
|
2496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2429
2497
|
"button",
|
|
2430
2498
|
{
|
|
2431
2499
|
type: "button",
|
|
@@ -2436,7 +2504,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2436
2504
|
disabled: disabled || field.readOnly,
|
|
2437
2505
|
onClick: () => onChange(!value),
|
|
2438
2506
|
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,
|
|
2507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2440
2508
|
"span",
|
|
2441
2509
|
{
|
|
2442
2510
|
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 +2513,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2445
2513
|
}
|
|
2446
2514
|
);
|
|
2447
2515
|
}
|
|
2448
|
-
function ParameterSelect(
|
|
2516
|
+
function ParameterSelect(props) {
|
|
2517
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
2518
|
+
const ctx = useParameterComponents();
|
|
2519
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2520
|
+
const CustomSelect = resolved.select;
|
|
2449
2521
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2450
2522
|
const off = disabled || field.readOnly;
|
|
2451
2523
|
if (field.control === "segmented") {
|
|
2452
|
-
return /* @__PURE__ */ (0,
|
|
2524
|
+
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
2525
|
"button",
|
|
2454
2526
|
{
|
|
2455
2527
|
type: "button",
|
|
@@ -2464,8 +2536,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2464
2536
|
String(o.value)
|
|
2465
2537
|
)) });
|
|
2466
2538
|
}
|
|
2539
|
+
if (CustomSelect) {
|
|
2540
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2542
|
+
CustomSelect,
|
|
2543
|
+
{
|
|
2544
|
+
id,
|
|
2545
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2546
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2547
|
+
value,
|
|
2548
|
+
options: customOptions,
|
|
2549
|
+
disabled: off,
|
|
2550
|
+
className: parameterInputClass,
|
|
2551
|
+
style: parameterSelectStyle,
|
|
2552
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
2553
|
+
}
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2467
2556
|
const index = options.findIndex((o) => o.value === value);
|
|
2468
|
-
return /* @__PURE__ */ (0,
|
|
2557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2469
2558
|
"select",
|
|
2470
2559
|
{
|
|
2471
2560
|
id,
|
|
@@ -2477,22 +2566,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2477
2566
|
if (option) onChange(option.value);
|
|
2478
2567
|
},
|
|
2479
2568
|
className: parameterInputClass,
|
|
2480
|
-
|
|
2569
|
+
style: parameterSelectStyle,
|
|
2570
|
+
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
2571
|
}
|
|
2482
2572
|
);
|
|
2483
2573
|
}
|
|
2484
|
-
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2485
|
-
const
|
|
2486
|
-
const
|
|
2487
|
-
const
|
|
2488
|
-
const
|
|
2574
|
+
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2575
|
+
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2576
|
+
const [open, setOpen] = (0, import_react19.useState)(false);
|
|
2577
|
+
const containerRef = (0, import_react19.useRef)(null);
|
|
2578
|
+
const buttonRef = (0, import_react19.useRef)(null);
|
|
2579
|
+
const popoverRef = (0, import_react19.useRef)(null);
|
|
2489
2580
|
const alpha = !!field.alpha;
|
|
2490
2581
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2491
2582
|
const rgb = hex.slice(0, 7);
|
|
2492
2583
|
const shown = alpha ? hex : rgb;
|
|
2493
2584
|
const off = disabled || field.readOnly;
|
|
2494
2585
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2495
|
-
(0,
|
|
2586
|
+
(0, import_react19.useEffect)(() => {
|
|
2496
2587
|
if (!open) return;
|
|
2497
2588
|
const onPointerDown = (e) => {
|
|
2498
2589
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2513,9 +2604,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2513
2604
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
2514
2605
|
};
|
|
2515
2606
|
}, [open]);
|
|
2516
|
-
|
|
2517
|
-
/* @__PURE__ */ (0,
|
|
2518
|
-
|
|
2607
|
+
if (CustomColor) {
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2609
|
+
CustomColor,
|
|
2610
|
+
{
|
|
2611
|
+
id,
|
|
2612
|
+
value: shown,
|
|
2613
|
+
alpha,
|
|
2614
|
+
swatches: field.swatches,
|
|
2615
|
+
disabled: off,
|
|
2616
|
+
label: name,
|
|
2617
|
+
onChange,
|
|
2618
|
+
onGestureStart,
|
|
2619
|
+
onGestureEnd
|
|
2620
|
+
}
|
|
2621
|
+
);
|
|
2622
|
+
}
|
|
2623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2624
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2625
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2519
2626
|
"button",
|
|
2520
2627
|
{
|
|
2521
2628
|
ref: buttonRef,
|
|
@@ -2526,10 +2633,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2526
2633
|
disabled: off,
|
|
2527
2634
|
onClick: () => setOpen((prev) => !prev),
|
|
2528
2635
|
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,
|
|
2636
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2530
2637
|
}
|
|
2531
2638
|
),
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
2639
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2533
2640
|
ParameterCommitInput,
|
|
2534
2641
|
{
|
|
2535
2642
|
id,
|
|
@@ -2545,7 +2652,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2545
2652
|
}
|
|
2546
2653
|
)
|
|
2547
2654
|
] }),
|
|
2548
|
-
open && /* @__PURE__ */ (0,
|
|
2655
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2549
2656
|
"div",
|
|
2550
2657
|
{
|
|
2551
2658
|
ref: popoverRef,
|
|
@@ -2559,7 +2666,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2559
2666
|
},
|
|
2560
2667
|
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
2668
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2562
|
-
children: /* @__PURE__ */ (0,
|
|
2669
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2563
2670
|
ColorPicker,
|
|
2564
2671
|
{
|
|
2565
2672
|
value: shown,
|
|
@@ -2575,13 +2682,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2575
2682
|
)
|
|
2576
2683
|
] });
|
|
2577
2684
|
}
|
|
2578
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
2685
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
2579
2686
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2580
|
-
return /* @__PURE__ */ (0,
|
|
2687
|
+
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
2688
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2582
|
-
return /* @__PURE__ */ (0,
|
|
2583
|
-
/* @__PURE__ */ (0,
|
|
2584
|
-
/* @__PURE__ */ (0,
|
|
2689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2690
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2691
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2585
2692
|
ParameterNumberInput,
|
|
2586
2693
|
{
|
|
2587
2694
|
field: component,
|
|
@@ -2589,6 +2696,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2589
2696
|
id: i === 0 ? id : void 0,
|
|
2590
2697
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
2591
2698
|
disabled: disabled || field.readOnly,
|
|
2699
|
+
components,
|
|
2592
2700
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
2593
2701
|
}
|
|
2594
2702
|
)
|
|
@@ -2598,11 +2706,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2598
2706
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2599
2707
|
const off = disabled || field.readOnly;
|
|
2600
2708
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2601
|
-
return /* @__PURE__ */ (0,
|
|
2602
|
-
/* @__PURE__ */ (0,
|
|
2603
|
-
/* @__PURE__ */ (0,
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
2605
|
-
/* @__PURE__ */ (0,
|
|
2709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2710
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2711
|
+
/* @__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" }) }),
|
|
2712
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2713
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2606
2714
|
ParameterCommitInput,
|
|
2607
2715
|
{
|
|
2608
2716
|
id,
|
|
@@ -2613,30 +2721,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2613
2721
|
onCommit: (text) => onChange(text.trim())
|
|
2614
2722
|
}
|
|
2615
2723
|
),
|
|
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
|
-
|
|
2724
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
|
|
2725
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2726
|
+
"label",
|
|
2727
|
+
{
|
|
2728
|
+
style: parameterButtonStyle,
|
|
2729
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
2730
|
+
children: [
|
|
2731
|
+
"Choose file\u2026",
|
|
2732
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2733
|
+
"input",
|
|
2734
|
+
{
|
|
2735
|
+
type: "file",
|
|
2736
|
+
className: "sr-only",
|
|
2737
|
+
accept: field.accept ?? "image/*",
|
|
2738
|
+
disabled: off,
|
|
2739
|
+
"aria-label": `${name} file`,
|
|
2740
|
+
onChange: async (e) => {
|
|
2741
|
+
const file = e.target.files?.[0];
|
|
2742
|
+
e.target.value = "";
|
|
2743
|
+
if (file) onChange(await resolveFile(file));
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
)
|
|
2747
|
+
]
|
|
2748
|
+
}
|
|
2749
|
+
),
|
|
2750
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2751
|
+
"button",
|
|
2752
|
+
{
|
|
2753
|
+
type: "button",
|
|
2754
|
+
style: parameterButtonStyle,
|
|
2755
|
+
className: parameterButtonClass,
|
|
2756
|
+
disabled: off,
|
|
2757
|
+
onClick: () => onChange(""),
|
|
2758
|
+
"aria-label": `Clear ${name}`,
|
|
2759
|
+
children: "Clear"
|
|
2760
|
+
}
|
|
2761
|
+
)
|
|
2636
2762
|
] })
|
|
2637
2763
|
] })
|
|
2638
2764
|
] }),
|
|
2639
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2765
|
+
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
2766
|
"button",
|
|
2641
2767
|
{
|
|
2642
2768
|
type: "button",
|
|
@@ -2646,14 +2772,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2646
2772
|
disabled: off,
|
|
2647
2773
|
onClick: () => onChange(o.url),
|
|
2648
2774
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2649
|
-
children: /* @__PURE__ */ (0,
|
|
2775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2650
2776
|
},
|
|
2651
2777
|
o.url
|
|
2652
2778
|
)) })
|
|
2653
2779
|
] });
|
|
2654
2780
|
}
|
|
2655
2781
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2656
|
-
return /* @__PURE__ */ (0,
|
|
2782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2657
2783
|
ParameterCommitInput,
|
|
2658
2784
|
{
|
|
2659
2785
|
id,
|
|
@@ -2672,24 +2798,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2672
2798
|
switch (field.type) {
|
|
2673
2799
|
case "number":
|
|
2674
2800
|
case "int":
|
|
2675
|
-
return /* @__PURE__ */ (0,
|
|
2801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2676
2802
|
case "boolean":
|
|
2677
|
-
return /* @__PURE__ */ (0,
|
|
2803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2678
2804
|
case "choice":
|
|
2679
|
-
return /* @__PURE__ */ (0,
|
|
2805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2680
2806
|
case "color":
|
|
2681
|
-
return /* @__PURE__ */ (0,
|
|
2807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2682
2808
|
case "vector":
|
|
2683
|
-
return /* @__PURE__ */ (0,
|
|
2809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2684
2810
|
case "image":
|
|
2685
|
-
return /* @__PURE__ */ (0,
|
|
2811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2686
2812
|
case "text":
|
|
2687
|
-
return /* @__PURE__ */ (0,
|
|
2813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2688
2814
|
}
|
|
2689
2815
|
}
|
|
2690
2816
|
|
|
2691
2817
|
// src/effects/EffectParameters.tsx
|
|
2692
|
-
var
|
|
2818
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2693
2819
|
function EffectParameters({
|
|
2694
2820
|
description,
|
|
2695
2821
|
values,
|
|
@@ -2701,56 +2827,75 @@ function EffectParameters({
|
|
|
2701
2827
|
renderControlAddon,
|
|
2702
2828
|
fonts,
|
|
2703
2829
|
disabled = false,
|
|
2704
|
-
className = ""
|
|
2830
|
+
className = "",
|
|
2831
|
+
components
|
|
2705
2832
|
}) {
|
|
2706
|
-
const fields = (0,
|
|
2707
|
-
const idBase = (0,
|
|
2708
|
-
const gesture =
|
|
2709
|
-
const count =
|
|
2710
|
-
|
|
2711
|
-
|
|
2833
|
+
const fields = (0, import_react20.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
2834
|
+
const idBase = (0, import_react20.useId)();
|
|
2835
|
+
const gesture = import_react20.default.useRef(null);
|
|
2836
|
+
const count = import_react20.default.useRef(0);
|
|
2837
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
2838
|
+
const handlePresetSelect = (name) => {
|
|
2839
|
+
if (!name) return;
|
|
2840
|
+
if (onPresetName) {
|
|
2841
|
+
onPresetName(name);
|
|
2842
|
+
} else if (onPreset) {
|
|
2843
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
2844
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2845
|
+
}
|
|
2846
|
+
};
|
|
2847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2848
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2849
|
+
CustomPresetSelect,
|
|
2850
|
+
{
|
|
2851
|
+
"aria-label": `${description.name} presets`,
|
|
2852
|
+
label: `${description.name} presets`,
|
|
2853
|
+
value: "",
|
|
2854
|
+
disabled,
|
|
2855
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
2856
|
+
style: parameterSelectStyle,
|
|
2857
|
+
options: [
|
|
2858
|
+
{ value: "", label: "Presets\u2026" },
|
|
2859
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
2860
|
+
],
|
|
2861
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
2862
|
+
}
|
|
2863
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2712
2864
|
"select",
|
|
2713
2865
|
{
|
|
2714
|
-
className: "w-full rounded border border-border
|
|
2866
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
2867
|
+
style: parameterSelectStyle,
|
|
2715
2868
|
"aria-label": `${description.name} presets`,
|
|
2716
2869
|
value: "",
|
|
2717
2870
|
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
|
-
},
|
|
2871
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
2728
2872
|
children: [
|
|
2729
|
-
/* @__PURE__ */ (0,
|
|
2730
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
2874
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
2731
2875
|
]
|
|
2732
2876
|
}
|
|
2733
|
-
),
|
|
2877
|
+
)),
|
|
2734
2878
|
fields.map((field) => {
|
|
2735
2879
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
2736
2880
|
const inputId = `${idBase}-${field.id}`;
|
|
2737
2881
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
2738
2882
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
2739
2883
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
2740
|
-
return /* @__PURE__ */ (0,
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
2743
|
-
keyed && /* @__PURE__ */ (0,
|
|
2884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2885
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2886
|
+
/* @__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 }),
|
|
2887
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2744
2888
|
renderControlAddon?.(field.id),
|
|
2745
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
2889
|
+
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
2890
|
] }),
|
|
2747
|
-
/* @__PURE__ */ (0,
|
|
2891
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2748
2892
|
ParameterFieldControl,
|
|
2749
2893
|
{
|
|
2750
2894
|
field,
|
|
2751
2895
|
value,
|
|
2752
2896
|
id: inputId,
|
|
2753
2897
|
disabled: disabled || keyed,
|
|
2898
|
+
components,
|
|
2754
2899
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
2755
2900
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
2756
2901
|
onGestureEnd: () => gesture.current = null
|
|
@@ -2758,25 +2903,25 @@ function EffectParameters({
|
|
|
2758
2903
|
)
|
|
2759
2904
|
] }, field.id);
|
|
2760
2905
|
}),
|
|
2761
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2906
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
2762
2907
|
] });
|
|
2763
2908
|
}
|
|
2764
2909
|
|
|
2765
2910
|
// src/animation-editor/AnimationEffectsPanel.tsx
|
|
2766
|
-
var
|
|
2911
|
+
var import_react21 = require("react");
|
|
2767
2912
|
var import_animation_editor10 = require("@pixerate/editor/animation-editor");
|
|
2768
|
-
var
|
|
2913
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2769
2914
|
var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2770
2915
|
function Controls({ controller, instance, effect, values }) {
|
|
2771
2916
|
const provider = controller.effectsProvider;
|
|
2772
2917
|
const { description, error } = useEffectDescription(provider, effect);
|
|
2773
|
-
const [message, setMessage] = (0,
|
|
2918
|
+
const [message, setMessage] = (0, import_react21.useState)(null);
|
|
2774
2919
|
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,
|
|
2920
|
+
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." });
|
|
2921
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2922
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
2923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2924
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2780
2925
|
EffectParameters,
|
|
2781
2926
|
{
|
|
2782
2927
|
description,
|
|
@@ -2786,60 +2931,60 @@ function Controls({ controller, instance, effect, values }) {
|
|
|
2786
2931
|
onPreset: (v) => report(controller.updateMotionEffect(instance, v))
|
|
2787
2932
|
}
|
|
2788
2933
|
),
|
|
2789
|
-
message && /* @__PURE__ */ (0,
|
|
2934
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2790
2935
|
] });
|
|
2791
2936
|
}
|
|
2792
2937
|
function AnimationEffectsPanel({ controller, node, className = "" }) {
|
|
2793
2938
|
const state = useAnimationEditorState(controller);
|
|
2794
2939
|
const provider = state.effectsProvider;
|
|
2795
|
-
const nodes = (0,
|
|
2796
|
-
const [chosen, setChosen] = (0,
|
|
2940
|
+
const nodes = (0, import_react21.useMemo)(() => [...(0, import_animation_editor10.indexMotionNodes)(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
|
|
2941
|
+
const [chosen, setChosen] = (0, import_react21.useState)("");
|
|
2797
2942
|
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,
|
|
2943
|
+
const [browse, setBrowse] = (0, import_react21.useState)(null);
|
|
2944
|
+
const [open, setOpen] = (0, import_react21.useState)(null);
|
|
2945
|
+
const [message, setMessage] = (0, import_react21.useState)(null);
|
|
2801
2946
|
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,
|
|
2947
|
+
const applied = (0, import_react21.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
|
|
2803
2948
|
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,
|
|
2949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
|
|
2950
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2951
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
2952
|
+
/* @__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: [
|
|
2953
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", children: "Node\u2026" }),
|
|
2954
|
+
nodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: id, children: id }, id))
|
|
2810
2955
|
] }),
|
|
2811
|
-
/* @__PURE__ */ (0,
|
|
2812
|
-
/* @__PURE__ */ (0,
|
|
2956
|
+
/* @__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" }),
|
|
2957
|
+
/* @__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
2958
|
] }),
|
|
2814
|
-
!provider && /* @__PURE__ */ (0,
|
|
2815
|
-
browse === "motion" && /* @__PURE__ */ (0,
|
|
2816
|
-
browse === "vector" && /* @__PURE__ */ (0,
|
|
2817
|
-
/* @__PURE__ */ (0,
|
|
2818
|
-
/* @__PURE__ */ (0,
|
|
2819
|
-
/* @__PURE__ */ (0,
|
|
2959
|
+
!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." }),
|
|
2960
|
+
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]))) }),
|
|
2961
|
+
browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
|
|
2962
|
+
/* @__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: [
|
|
2963
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2964
|
+
/* @__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
2965
|
e.name ?? e.effect,
|
|
2821
2966
|
" ",
|
|
2822
|
-
/* @__PURE__ */ (0,
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
2823
2968
|
"\xB7 ",
|
|
2824
2969
|
e.kind === "vector" ? "picture" : e.targets.join(", ")
|
|
2825
2970
|
] })
|
|
2826
2971
|
] }),
|
|
2827
|
-
/* @__PURE__ */ (0,
|
|
2972
|
+
/* @__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
2973
|
] }),
|
|
2829
|
-
open === e.instance && /* @__PURE__ */ (0,
|
|
2974
|
+
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
2975
|
] }, e.instance)) }),
|
|
2831
|
-
!applied.length && /* @__PURE__ */ (0,
|
|
2832
|
-
message && /* @__PURE__ */ (0,
|
|
2976
|
+
!applied.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
|
|
2977
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
|
|
2833
2978
|
] });
|
|
2834
2979
|
}
|
|
2835
2980
|
|
|
2836
2981
|
// src/animation-editor/AnimationEditor.tsx
|
|
2837
|
-
var
|
|
2982
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2838
2983
|
var ONION = { before: 3, after: 1 };
|
|
2839
2984
|
var btn6 = "rounded border border-border px-2 py-0.5 text-xs disabled:opacity-40";
|
|
2840
2985
|
function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssues = true, editable = true, effects, className = "", playback, playbackId = "animation", onPlaybackReveal }) {
|
|
2841
2986
|
const state = useAnimationEditorState(controller);
|
|
2842
|
-
const rootRef = (0,
|
|
2987
|
+
const rootRef = (0, import_react22.useRef)(null);
|
|
2843
2988
|
const ambientPlayback = useAgentPlayback();
|
|
2844
2989
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
2845
2990
|
const rectIn = (el) => {
|
|
@@ -2874,16 +3019,16 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2874
3019
|
},
|
|
2875
3020
|
reveal: () => onPlaybackReveal?.()
|
|
2876
3021
|
});
|
|
2877
|
-
const presenceLayer = playing ? /* @__PURE__ */ (0,
|
|
3022
|
+
const presenceLayer = playing ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PresenceLayer, { presence: agentPresence }) : null;
|
|
2878
3023
|
useEffects(controller, effects);
|
|
2879
3024
|
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,
|
|
3025
|
+
const [picked, setPicked] = (0, import_react22.useState)(null);
|
|
3026
|
+
const [onion, setOnion] = (0, import_react22.useState)(false);
|
|
3027
|
+
const [paths, setPaths] = (0, import_react22.useState)(false);
|
|
3028
|
+
const [recordMode, setRecordMode] = (0, import_react22.useState)("move");
|
|
2884
3029
|
const command = selection?.command !== void 0 ? scene.shots.find((s) => s.id === selection.shot)?.run[selection.command] : void 0;
|
|
2885
3030
|
const targets = command && "targets" in command ? command.targets : [];
|
|
2886
|
-
const nodes = (0,
|
|
3031
|
+
const nodes = (0, import_react22.useMemo)(() => (0, import_animation_editor11.indexMotionNodes)(scene.artwork.nodes), [scene.artwork]);
|
|
2887
3032
|
const pickedValid = picked && nodes.has(picked) ? picked : null;
|
|
2888
3033
|
const onPick = (id, event) => {
|
|
2889
3034
|
if (event.shiftKey && id && command && "targets" in command && selection?.command !== void 0 && !readOnly) {
|
|
@@ -2893,7 +3038,7 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2893
3038
|
}
|
|
2894
3039
|
setPicked(id);
|
|
2895
3040
|
};
|
|
2896
|
-
const stage = /* @__PURE__ */ (0,
|
|
3041
|
+
const stage = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2897
3042
|
AnimationStage,
|
|
2898
3043
|
{
|
|
2899
3044
|
controller,
|
|
@@ -2906,15 +3051,15 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2906
3051
|
className: "rounded-md border border-border bg-muted/40"
|
|
2907
3052
|
}
|
|
2908
3053
|
);
|
|
2909
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
3054
|
+
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
3055
|
if (!editable)
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
3056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 ${className}`, "data-animation-editor": "", children: [
|
|
2912
3057
|
presenceLayer,
|
|
2913
3058
|
stage,
|
|
2914
|
-
/* @__PURE__ */ (0,
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PlayheadScrubber, { controller }),
|
|
2915
3060
|
issueList
|
|
2916
3061
|
] });
|
|
2917
|
-
return /* @__PURE__ */ (0,
|
|
3062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2918
3063
|
"div",
|
|
2919
3064
|
{
|
|
2920
3065
|
ref: rootRef,
|
|
@@ -2929,41 +3074,41 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
2929
3074
|
},
|
|
2930
3075
|
children: [
|
|
2931
3076
|
presenceLayer,
|
|
2932
|
-
/* @__PURE__ */ (0,
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
2933
3078
|
stage,
|
|
2934
|
-
/* @__PURE__ */ (0,
|
|
2935
|
-
/* @__PURE__ */ (0,
|
|
2936
|
-
/* @__PURE__ */ (0,
|
|
2937
|
-
/* @__PURE__ */ (0,
|
|
2938
|
-
onionSkin === void 0 && /* @__PURE__ */ (0,
|
|
2939
|
-
/* @__PURE__ */ (0,
|
|
3079
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PlayheadScrubber, { controller }),
|
|
3080
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
3081
|
+
/* @__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" }),
|
|
3082
|
+
/* @__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" }),
|
|
3083
|
+
onionSkin === void 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3084
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", checked: onion, onChange: (e) => setOnion(e.target.checked) }),
|
|
2940
3085
|
" Onion skin"
|
|
2941
3086
|
] }),
|
|
2942
|
-
motionPaths === void 0 && /* @__PURE__ */ (0,
|
|
2943
|
-
/* @__PURE__ */ (0,
|
|
3087
|
+
motionPaths === void 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { type: "checkbox", checked: paths, onChange: (e) => setPaths(e.target.checked) }),
|
|
2944
3089
|
" Motion paths"
|
|
2945
3090
|
] }),
|
|
2946
|
-
/* @__PURE__ */ (0,
|
|
3091
|
+
/* @__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
3092
|
"Picked ",
|
|
2948
|
-
/* @__PURE__ */ (0,
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { className: "text-rose-500", children: pickedValid }),
|
|
2949
3094
|
" ",
|
|
2950
|
-
/* @__PURE__ */ (0,
|
|
3095
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: "underline", onClick: () => setPicked(null), children: "clear" })
|
|
2951
3096
|
] }) : "Click the stage to pick an element; shift-click to toggle it as a target." })
|
|
2952
3097
|
] }),
|
|
2953
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3098
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AnimationRecordPanel, { controller, node: pickedValid, mode: recordMode, onModeChange: setRecordMode, className: "border-t border-border pt-2" }),
|
|
2954
3099
|
issueList
|
|
2955
3100
|
] }),
|
|
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,
|
|
3101
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
3102
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CommandList, { controller, targets: pickedValid ? [pickedValid] : void 0 }),
|
|
3103
|
+
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AnimationEffectsPanel, { controller, node: pickedValid, className: "border-t border-border pt-2" }),
|
|
3104
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CommandInspector, { controller, picked: pickedValid, className: "border-t border-border pt-2" }),
|
|
3105
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { open: true, className: "border-t border-border pt-2", children: [
|
|
3106
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Shot" }),
|
|
3107
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ShotInspector, { controller, className: "mt-1" })
|
|
2963
3108
|
] }),
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
3109
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("details", { className: "border-t border-border pt-2", children: [
|
|
3110
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Scene settings" }),
|
|
3111
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SceneSettings, { controller, className: "mt-1" })
|
|
2967
3112
|
] })
|
|
2968
3113
|
] })
|
|
2969
3114
|
]
|