@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
|
@@ -1337,7 +1337,7 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1337
1337
|
};
|
|
1338
1338
|
|
|
1339
1339
|
// src/paint-editor/PaintEditor.tsx
|
|
1340
|
-
var
|
|
1340
|
+
var import_react24 = require("react");
|
|
1341
1341
|
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1342
1342
|
|
|
1343
1343
|
// src/playback/AgentPlaybackContext.tsx
|
|
@@ -1432,7 +1432,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
|
|
1434
1434
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1435
|
-
var
|
|
1435
|
+
var import_react23 = require("react");
|
|
1436
1436
|
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1437
1437
|
|
|
1438
1438
|
// src/effects/useEffects.ts
|
|
@@ -1566,12 +1566,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1566
1566
|
}
|
|
1567
1567
|
|
|
1568
1568
|
// src/effects/EffectParameters.tsx
|
|
1569
|
-
var
|
|
1569
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
1570
1570
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1571
1571
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1572
1572
|
|
|
1573
1573
|
// src/parameters/fields.tsx
|
|
1574
|
-
var
|
|
1574
|
+
var import_react21 = require("react");
|
|
1575
1575
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1576
1576
|
|
|
1577
1577
|
// src/color/index.ts
|
|
@@ -2613,18 +2613,58 @@ function useResolvedColor(value, scheme) {
|
|
|
2613
2613
|
// src/color/index.ts
|
|
2614
2614
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2615
2615
|
|
|
2616
|
-
// src/parameters/
|
|
2616
|
+
// src/parameters/controls.tsx
|
|
2617
|
+
var import_react20 = require("react");
|
|
2617
2618
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2619
|
+
var ParameterComponentsContext = (0, import_react20.createContext)({});
|
|
2620
|
+
function useParameterComponents() {
|
|
2621
|
+
return (0, import_react20.useContext)(ParameterComponentsContext);
|
|
2622
|
+
}
|
|
2623
|
+
function resolveParameterComponents(explicit, context) {
|
|
2624
|
+
return {
|
|
2625
|
+
input: explicit?.input ?? context?.input,
|
|
2626
|
+
slider: explicit?.slider ?? context?.slider,
|
|
2627
|
+
select: explicit?.select ?? context?.select,
|
|
2628
|
+
color: explicit?.color ?? context?.color
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
// src/parameters/fields.tsx
|
|
2633
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2634
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2635
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2636
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
2637
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
2618
2638
|
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";
|
|
2619
2639
|
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";
|
|
2620
2640
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2621
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
2641
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2642
|
+
const inputRef = (0, import_react21.useRef)(null);
|
|
2643
|
+
const lastCommitted = (0, import_react21.useRef)(null);
|
|
2644
|
+
(0, import_react21.useLayoutEffect)(() => {
|
|
2645
|
+
lastCommitted.current = null;
|
|
2646
|
+
const el = inputRef.current;
|
|
2647
|
+
if (el && el.value !== value) el.value = value;
|
|
2648
|
+
}, [value]);
|
|
2622
2649
|
const commit = (el) => {
|
|
2623
|
-
|
|
2650
|
+
const text = el.value;
|
|
2651
|
+
if (text === value || text === lastCommitted.current) return;
|
|
2652
|
+
onCommit(text, el);
|
|
2653
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
2624
2654
|
};
|
|
2655
|
+
const commitRef = (0, import_react21.useRef)(commit);
|
|
2656
|
+
commitRef.current = commit;
|
|
2657
|
+
(0, import_react21.useEffect)(() => {
|
|
2658
|
+
const el = inputRef.current;
|
|
2659
|
+
if (!el) return;
|
|
2660
|
+
const change = () => commitRef.current(el);
|
|
2661
|
+
el.addEventListener("change", change);
|
|
2662
|
+
return () => el.removeEventListener("change", change);
|
|
2663
|
+
}, [multiline]);
|
|
2625
2664
|
const keyDown = (e) => {
|
|
2626
2665
|
onKeyDown?.(e);
|
|
2627
2666
|
if (e.defaultPrevented) return;
|
|
2667
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
2628
2668
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
2629
2669
|
e.preventDefault();
|
|
2630
2670
|
commit(e.currentTarget);
|
|
@@ -2634,86 +2674,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2634
2674
|
const props = {
|
|
2635
2675
|
defaultValue: value,
|
|
2636
2676
|
className: className ?? parameterInputClass,
|
|
2677
|
+
style: { ...parameterInputStyle, ...style },
|
|
2637
2678
|
onBlur: (e) => commit(e.currentTarget),
|
|
2638
2679
|
onKeyDown: keyDown,
|
|
2639
2680
|
...rest
|
|
2640
2681
|
};
|
|
2641
|
-
|
|
2682
|
+
const forwarded = rest.ref;
|
|
2683
|
+
const setRef = (el) => {
|
|
2684
|
+
inputRef.current = el;
|
|
2685
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
2686
|
+
else if (forwarded) forwarded.current = el;
|
|
2687
|
+
};
|
|
2688
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
2642
2689
|
}
|
|
2643
2690
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
2644
|
-
function ParameterNumberInput({
|
|
2645
|
-
field,
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2691
|
+
function ParameterNumberInput(props) {
|
|
2692
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
2693
|
+
const ctx = useParameterComponents();
|
|
2694
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2695
|
+
const CustomInput = resolved.input;
|
|
2696
|
+
const plain = plainNumber(field, value);
|
|
2697
|
+
const handleCommit = (text, input) => {
|
|
2698
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
2699
|
+
if (n === null || n === value) {
|
|
2700
|
+
if (input) input.value = plain;
|
|
2701
|
+
} else {
|
|
2702
|
+
onChange(n);
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
const handleKeyDown = (e) => {
|
|
2706
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2707
|
+
e.preventDefault();
|
|
2708
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
2709
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
2710
|
+
};
|
|
2711
|
+
const inputProps = {
|
|
2712
|
+
id,
|
|
2713
|
+
inputMode: "decimal",
|
|
2714
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
2715
|
+
value: plain,
|
|
2716
|
+
disabled: disabled || field.readOnly,
|
|
2717
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
2718
|
+
style: parameterInputStyle,
|
|
2719
|
+
onCommit: handleCommit,
|
|
2720
|
+
onKeyDown: handleKeyDown
|
|
2721
|
+
};
|
|
2722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2723
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2724
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
2676
2725
|
] });
|
|
2677
2726
|
}
|
|
2678
2727
|
function ParameterSlider(props) {
|
|
2679
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
2680
|
-
const
|
|
2728
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
2729
|
+
const ctx = useParameterComponents();
|
|
2730
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2731
|
+
const CustomSlider = resolved.slider;
|
|
2732
|
+
const dragging = (0, import_react21.useRef)(false);
|
|
2733
|
+
const start = () => {
|
|
2734
|
+
if (dragging.current) return;
|
|
2735
|
+
dragging.current = true;
|
|
2736
|
+
onGestureStart?.();
|
|
2737
|
+
};
|
|
2681
2738
|
const end = () => {
|
|
2682
2739
|
if (!dragging.current) return;
|
|
2683
2740
|
dragging.current = false;
|
|
2684
2741
|
onGestureEnd?.();
|
|
2685
2742
|
};
|
|
2686
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2743
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterNumberInput, { ...props });
|
|
2687
2744
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2688
|
-
|
|
2689
|
-
|
|
2745
|
+
const sliderProps = {
|
|
2746
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2747
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
2748
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
2749
|
+
min: field.min ?? 0,
|
|
2750
|
+
max: field.max ?? 100,
|
|
2751
|
+
step,
|
|
2752
|
+
value,
|
|
2753
|
+
disabled: disabled || field.readOnly,
|
|
2754
|
+
className: rangeClass,
|
|
2755
|
+
style: parameterRangeStyle
|
|
2756
|
+
};
|
|
2757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2758
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2759
|
+
CustomSlider,
|
|
2760
|
+
{
|
|
2761
|
+
...sliderProps,
|
|
2762
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
2763
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2764
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
2765
|
+
onGestureStart: start,
|
|
2766
|
+
onGestureEnd: end
|
|
2767
|
+
}
|
|
2768
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2690
2769
|
"input",
|
|
2691
2770
|
{
|
|
2692
2771
|
type: "range",
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
min: field.min,
|
|
2696
|
-
max: field.max,
|
|
2697
|
-
step,
|
|
2698
|
-
value,
|
|
2699
|
-
disabled: disabled || field.readOnly,
|
|
2700
|
-
className: rangeClass,
|
|
2701
|
-
onPointerDown: () => {
|
|
2702
|
-
if (dragging.current) return;
|
|
2703
|
-
dragging.current = true;
|
|
2704
|
-
onGestureStart?.();
|
|
2705
|
-
},
|
|
2772
|
+
...sliderProps,
|
|
2773
|
+
onPointerDown: start,
|
|
2706
2774
|
onPointerUp: end,
|
|
2707
2775
|
onPointerCancel: end,
|
|
2708
2776
|
onBlur: end,
|
|
2709
2777
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2710
2778
|
}
|
|
2711
2779
|
),
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
2780
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
2713
2781
|
] });
|
|
2714
2782
|
}
|
|
2715
2783
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2716
|
-
return /* @__PURE__ */ (0,
|
|
2784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2717
2785
|
"button",
|
|
2718
2786
|
{
|
|
2719
2787
|
type: "button",
|
|
@@ -2724,7 +2792,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2724
2792
|
disabled: disabled || field.readOnly,
|
|
2725
2793
|
onClick: () => onChange(!value),
|
|
2726
2794
|
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"}`,
|
|
2727
|
-
children: /* @__PURE__ */ (0,
|
|
2795
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2728
2796
|
"span",
|
|
2729
2797
|
{
|
|
2730
2798
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2733,11 +2801,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2733
2801
|
}
|
|
2734
2802
|
);
|
|
2735
2803
|
}
|
|
2736
|
-
function ParameterSelect(
|
|
2804
|
+
function ParameterSelect(props) {
|
|
2805
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
2806
|
+
const ctx = useParameterComponents();
|
|
2807
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2808
|
+
const CustomSelect = resolved.select;
|
|
2737
2809
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2738
2810
|
const off = disabled || field.readOnly;
|
|
2739
2811
|
if (field.control === "segmented") {
|
|
2740
|
-
return /* @__PURE__ */ (0,
|
|
2812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)(
|
|
2741
2813
|
"button",
|
|
2742
2814
|
{
|
|
2743
2815
|
type: "button",
|
|
@@ -2752,8 +2824,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2752
2824
|
String(o.value)
|
|
2753
2825
|
)) });
|
|
2754
2826
|
}
|
|
2827
|
+
if (CustomSelect) {
|
|
2828
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2830
|
+
CustomSelect,
|
|
2831
|
+
{
|
|
2832
|
+
id,
|
|
2833
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
2834
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
2835
|
+
value,
|
|
2836
|
+
options: customOptions,
|
|
2837
|
+
disabled: off,
|
|
2838
|
+
className: parameterInputClass,
|
|
2839
|
+
style: parameterSelectStyle,
|
|
2840
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
2841
|
+
}
|
|
2842
|
+
);
|
|
2843
|
+
}
|
|
2755
2844
|
const index = options.findIndex((o) => o.value === value);
|
|
2756
|
-
return /* @__PURE__ */ (0,
|
|
2845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2757
2846
|
"select",
|
|
2758
2847
|
{
|
|
2759
2848
|
id,
|
|
@@ -2765,22 +2854,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
2765
2854
|
if (option) onChange(option.value);
|
|
2766
2855
|
},
|
|
2767
2856
|
className: parameterInputClass,
|
|
2768
|
-
|
|
2857
|
+
style: parameterSelectStyle,
|
|
2858
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2769
2859
|
}
|
|
2770
2860
|
);
|
|
2771
2861
|
}
|
|
2772
|
-
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2773
|
-
const
|
|
2774
|
-
const
|
|
2775
|
-
const
|
|
2776
|
-
const
|
|
2862
|
+
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2863
|
+
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2864
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
2865
|
+
const containerRef = (0, import_react21.useRef)(null);
|
|
2866
|
+
const buttonRef = (0, import_react21.useRef)(null);
|
|
2867
|
+
const popoverRef = (0, import_react21.useRef)(null);
|
|
2777
2868
|
const alpha = !!field.alpha;
|
|
2778
2869
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2779
2870
|
const rgb = hex.slice(0, 7);
|
|
2780
2871
|
const shown = alpha ? hex : rgb;
|
|
2781
2872
|
const off = disabled || field.readOnly;
|
|
2782
2873
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2783
|
-
(0,
|
|
2874
|
+
(0, import_react21.useEffect)(() => {
|
|
2784
2875
|
if (!open) return;
|
|
2785
2876
|
const onPointerDown = (e) => {
|
|
2786
2877
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2801,9 +2892,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2801
2892
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
2802
2893
|
};
|
|
2803
2894
|
}, [open]);
|
|
2804
|
-
|
|
2805
|
-
/* @__PURE__ */ (0,
|
|
2806
|
-
|
|
2895
|
+
if (CustomColor) {
|
|
2896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2897
|
+
CustomColor,
|
|
2898
|
+
{
|
|
2899
|
+
id,
|
|
2900
|
+
value: shown,
|
|
2901
|
+
alpha,
|
|
2902
|
+
swatches: field.swatches,
|
|
2903
|
+
disabled: off,
|
|
2904
|
+
label: name,
|
|
2905
|
+
onChange,
|
|
2906
|
+
onGestureStart,
|
|
2907
|
+
onGestureEnd
|
|
2908
|
+
}
|
|
2909
|
+
);
|
|
2910
|
+
}
|
|
2911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2912
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2913
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2807
2914
|
"button",
|
|
2808
2915
|
{
|
|
2809
2916
|
ref: buttonRef,
|
|
@@ -2814,10 +2921,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2814
2921
|
disabled: off,
|
|
2815
2922
|
onClick: () => setOpen((prev) => !prev),
|
|
2816
2923
|
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",
|
|
2817
|
-
children: /* @__PURE__ */ (0,
|
|
2924
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2818
2925
|
}
|
|
2819
2926
|
),
|
|
2820
|
-
/* @__PURE__ */ (0,
|
|
2927
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2821
2928
|
ParameterCommitInput,
|
|
2822
2929
|
{
|
|
2823
2930
|
id,
|
|
@@ -2833,7 +2940,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2833
2940
|
}
|
|
2834
2941
|
)
|
|
2835
2942
|
] }),
|
|
2836
|
-
open && /* @__PURE__ */ (0,
|
|
2943
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2837
2944
|
"div",
|
|
2838
2945
|
{
|
|
2839
2946
|
ref: popoverRef,
|
|
@@ -2847,7 +2954,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2847
2954
|
},
|
|
2848
2955
|
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",
|
|
2849
2956
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2850
|
-
children: /* @__PURE__ */ (0,
|
|
2957
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2851
2958
|
ColorPicker,
|
|
2852
2959
|
{
|
|
2853
2960
|
value: shown,
|
|
@@ -2863,13 +2970,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2863
2970
|
)
|
|
2864
2971
|
] });
|
|
2865
2972
|
}
|
|
2866
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
2973
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
2867
2974
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2868
|
-
return /* @__PURE__ */ (0,
|
|
2975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2869
2976
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2870
|
-
return /* @__PURE__ */ (0,
|
|
2871
|
-
/* @__PURE__ */ (0,
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
2977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2979
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2873
2980
|
ParameterNumberInput,
|
|
2874
2981
|
{
|
|
2875
2982
|
field: component,
|
|
@@ -2877,6 +2984,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2877
2984
|
id: i === 0 ? id : void 0,
|
|
2878
2985
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
2879
2986
|
disabled: disabled || field.readOnly,
|
|
2987
|
+
components,
|
|
2880
2988
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
2881
2989
|
}
|
|
2882
2990
|
)
|
|
@@ -2886,11 +2994,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
2886
2994
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2887
2995
|
const off = disabled || field.readOnly;
|
|
2888
2996
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2889
|
-
return /* @__PURE__ */ (0,
|
|
2890
|
-
/* @__PURE__ */ (0,
|
|
2891
|
-
/* @__PURE__ */ (0,
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
2893
|
-
/* @__PURE__ */ (0,
|
|
2997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2998
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2999
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3000
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3001
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2894
3002
|
ParameterCommitInput,
|
|
2895
3003
|
{
|
|
2896
3004
|
id,
|
|
@@ -2901,30 +3009,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2901
3009
|
onCommit: (text) => onChange(text.trim())
|
|
2902
3010
|
}
|
|
2903
3011
|
),
|
|
2904
|
-
/* @__PURE__ */ (0,
|
|
2905
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2906
|
-
"
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
{
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
3012
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1", children: [
|
|
3013
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
3014
|
+
"label",
|
|
3015
|
+
{
|
|
3016
|
+
style: parameterButtonStyle,
|
|
3017
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3018
|
+
children: [
|
|
3019
|
+
"Choose file\u2026",
|
|
3020
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3021
|
+
"input",
|
|
3022
|
+
{
|
|
3023
|
+
type: "file",
|
|
3024
|
+
className: "sr-only",
|
|
3025
|
+
accept: field.accept ?? "image/*",
|
|
3026
|
+
disabled: off,
|
|
3027
|
+
"aria-label": `${name} file`,
|
|
3028
|
+
onChange: async (e) => {
|
|
3029
|
+
const file = e.target.files?.[0];
|
|
3030
|
+
e.target.value = "";
|
|
3031
|
+
if (file) onChange(await resolveFile(file));
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
)
|
|
3035
|
+
]
|
|
3036
|
+
}
|
|
3037
|
+
),
|
|
3038
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3039
|
+
"button",
|
|
3040
|
+
{
|
|
3041
|
+
type: "button",
|
|
3042
|
+
style: parameterButtonStyle,
|
|
3043
|
+
className: parameterButtonClass,
|
|
3044
|
+
disabled: off,
|
|
3045
|
+
onClick: () => onChange(""),
|
|
3046
|
+
"aria-label": `Clear ${name}`,
|
|
3047
|
+
children: "Clear"
|
|
3048
|
+
}
|
|
3049
|
+
)
|
|
2924
3050
|
] })
|
|
2925
3051
|
] })
|
|
2926
3052
|
] }),
|
|
2927
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
3053
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2928
3054
|
"button",
|
|
2929
3055
|
{
|
|
2930
3056
|
type: "button",
|
|
@@ -2934,14 +3060,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2934
3060
|
disabled: off,
|
|
2935
3061
|
onClick: () => onChange(o.url),
|
|
2936
3062
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2937
|
-
children: /* @__PURE__ */ (0,
|
|
3063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2938
3064
|
},
|
|
2939
3065
|
o.url
|
|
2940
3066
|
)) })
|
|
2941
3067
|
] });
|
|
2942
3068
|
}
|
|
2943
3069
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
3070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2945
3071
|
ParameterCommitInput,
|
|
2946
3072
|
{
|
|
2947
3073
|
id,
|
|
@@ -2960,24 +3086,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2960
3086
|
switch (field.type) {
|
|
2961
3087
|
case "number":
|
|
2962
3088
|
case "int":
|
|
2963
|
-
return /* @__PURE__ */ (0,
|
|
3089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2964
3090
|
case "boolean":
|
|
2965
|
-
return /* @__PURE__ */ (0,
|
|
3091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2966
3092
|
case "choice":
|
|
2967
|
-
return /* @__PURE__ */ (0,
|
|
3093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2968
3094
|
case "color":
|
|
2969
|
-
return /* @__PURE__ */ (0,
|
|
3095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2970
3096
|
case "vector":
|
|
2971
|
-
return /* @__PURE__ */ (0,
|
|
3097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2972
3098
|
case "image":
|
|
2973
|
-
return /* @__PURE__ */ (0,
|
|
3099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2974
3100
|
case "text":
|
|
2975
|
-
return /* @__PURE__ */ (0,
|
|
3101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2976
3102
|
}
|
|
2977
3103
|
}
|
|
2978
3104
|
|
|
2979
3105
|
// src/effects/EffectParameters.tsx
|
|
2980
|
-
var
|
|
3106
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2981
3107
|
function EffectParameters({
|
|
2982
3108
|
description,
|
|
2983
3109
|
values,
|
|
@@ -2989,56 +3115,75 @@ function EffectParameters({
|
|
|
2989
3115
|
renderControlAddon,
|
|
2990
3116
|
fonts,
|
|
2991
3117
|
disabled = false,
|
|
2992
|
-
className = ""
|
|
3118
|
+
className = "",
|
|
3119
|
+
components
|
|
2993
3120
|
}) {
|
|
2994
|
-
const fields = (0,
|
|
2995
|
-
const idBase = (0,
|
|
2996
|
-
const gesture =
|
|
2997
|
-
const count =
|
|
2998
|
-
|
|
2999
|
-
|
|
3121
|
+
const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3122
|
+
const idBase = (0, import_react22.useId)();
|
|
3123
|
+
const gesture = import_react22.default.useRef(null);
|
|
3124
|
+
const count = import_react22.default.useRef(0);
|
|
3125
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3126
|
+
const handlePresetSelect = (name) => {
|
|
3127
|
+
if (!name) return;
|
|
3128
|
+
if (onPresetName) {
|
|
3129
|
+
onPresetName(name);
|
|
3130
|
+
} else if (onPreset) {
|
|
3131
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
3132
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3136
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3137
|
+
CustomPresetSelect,
|
|
3138
|
+
{
|
|
3139
|
+
"aria-label": `${description.name} presets`,
|
|
3140
|
+
label: `${description.name} presets`,
|
|
3141
|
+
value: "",
|
|
3142
|
+
disabled,
|
|
3143
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3144
|
+
style: parameterSelectStyle,
|
|
3145
|
+
options: [
|
|
3146
|
+
{ value: "", label: "Presets\u2026" },
|
|
3147
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
3148
|
+
],
|
|
3149
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
3150
|
+
}
|
|
3151
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3000
3152
|
"select",
|
|
3001
3153
|
{
|
|
3002
|
-
className: "w-full rounded border border-border
|
|
3154
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3155
|
+
style: parameterSelectStyle,
|
|
3003
3156
|
"aria-label": `${description.name} presets`,
|
|
3004
3157
|
value: "",
|
|
3005
3158
|
disabled,
|
|
3006
|
-
onChange: (e) =>
|
|
3007
|
-
const name = e.currentTarget.value;
|
|
3008
|
-
if (!name) return;
|
|
3009
|
-
if (onPresetName) {
|
|
3010
|
-
onPresetName(name);
|
|
3011
|
-
} else if (onPreset) {
|
|
3012
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
3013
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3014
|
-
}
|
|
3015
|
-
},
|
|
3159
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3016
3160
|
children: [
|
|
3017
|
-
/* @__PURE__ */ (0,
|
|
3018
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3162
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3019
3163
|
]
|
|
3020
3164
|
}
|
|
3021
|
-
),
|
|
3165
|
+
)),
|
|
3022
3166
|
fields.map((field) => {
|
|
3023
3167
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
3024
3168
|
const inputId = `${idBase}-${field.id}`;
|
|
3025
3169
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3026
3170
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3027
3171
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3028
|
-
return /* @__PURE__ */ (0,
|
|
3029
|
-
/* @__PURE__ */ (0,
|
|
3030
|
-
/* @__PURE__ */ (0,
|
|
3031
|
-
keyed && /* @__PURE__ */ (0,
|
|
3172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
3173
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3174
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
3175
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3032
3176
|
renderControlAddon?.(field.id),
|
|
3033
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3177
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime20.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" })
|
|
3034
3178
|
] }),
|
|
3035
|
-
/* @__PURE__ */ (0,
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3036
3180
|
ParameterFieldControl,
|
|
3037
3181
|
{
|
|
3038
3182
|
field,
|
|
3039
3183
|
value,
|
|
3040
3184
|
id: inputId,
|
|
3041
3185
|
disabled: disabled || keyed,
|
|
3186
|
+
components,
|
|
3042
3187
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
3043
3188
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
3044
3189
|
onGestureEnd: () => gesture.current = null
|
|
@@ -3046,15 +3191,15 @@ function EffectParameters({
|
|
|
3046
3191
|
)
|
|
3047
3192
|
] }, field.id);
|
|
3048
3193
|
}),
|
|
3049
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3194
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3050
3195
|
] });
|
|
3051
3196
|
}
|
|
3052
3197
|
|
|
3053
3198
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3054
|
-
var
|
|
3199
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3055
3200
|
function usePaintEffectsProvider(controller) {
|
|
3056
|
-
const [provider, setProvider] = (0,
|
|
3057
|
-
(0,
|
|
3201
|
+
const [provider, setProvider] = (0, import_react23.useState)(controller.effectsProvider);
|
|
3202
|
+
(0, import_react23.useEffect)(() => {
|
|
3058
3203
|
setProvider(controller.effectsProvider);
|
|
3059
3204
|
return controller.effects.subscribe(setProvider);
|
|
3060
3205
|
}, [controller]);
|
|
@@ -3062,27 +3207,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
3062
3207
|
}
|
|
3063
3208
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3064
3209
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3065
|
-
(0,
|
|
3210
|
+
(0, import_react23.useEffect)(() => {
|
|
3066
3211
|
if (!registry) return;
|
|
3067
3212
|
return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3068
3213
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3069
3214
|
}
|
|
3070
3215
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3071
3216
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3072
|
-
const drags = (0,
|
|
3073
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3217
|
+
const drags = (0, import_react23.useRef)(/* @__PURE__ */ new Set());
|
|
3218
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
3074
3219
|
'No effects provider: "',
|
|
3075
3220
|
name ?? effect,
|
|
3076
3221
|
'" is kept as it was drawn.'
|
|
3077
3222
|
] });
|
|
3078
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3079
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3223
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
|
|
3224
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
3080
3225
|
const commit = (gesture) => {
|
|
3081
3226
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
3082
3227
|
drags.current.add(gesture);
|
|
3083
3228
|
return true;
|
|
3084
3229
|
};
|
|
3085
|
-
return /* @__PURE__ */ (0,
|
|
3230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3086
3231
|
EffectParameters,
|
|
3087
3232
|
{
|
|
3088
3233
|
description,
|
|
@@ -3103,8 +3248,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3103
3248
|
const state = usePaintEditorState(controller);
|
|
3104
3249
|
const provider = usePaintEffectsProvider(controller);
|
|
3105
3250
|
const [error, attempt] = useAttempt();
|
|
3106
|
-
const [browse, setBrowse] = (0,
|
|
3107
|
-
const [busy, setBusy] = (0,
|
|
3251
|
+
const [browse, setBrowse] = (0, import_react23.useState)(null);
|
|
3252
|
+
const [busy, setBusy] = (0, import_react23.useState)(false);
|
|
3108
3253
|
const paper = controller.getPaperEffect();
|
|
3109
3254
|
const activeId = state.document.activeLayerId;
|
|
3110
3255
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -3123,27 +3268,27 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3123
3268
|
};
|
|
3124
3269
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
3125
3270
|
const pixel = active?.type === "pixel";
|
|
3126
|
-
return /* @__PURE__ */ (0,
|
|
3127
|
-
/* @__PURE__ */ (0,
|
|
3128
|
-
/* @__PURE__ */ (0,
|
|
3129
|
-
/* @__PURE__ */ (0,
|
|
3130
|
-
/* @__PURE__ */ (0,
|
|
3131
|
-
/* @__PURE__ */ (0,
|
|
3132
|
-
/* @__PURE__ */ (0,
|
|
3271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
3272
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3273
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
3274
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
3275
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
3276
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
3277
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
|
|
3133
3278
|
] }),
|
|
3134
|
-
!provider && /* @__PURE__ */ (0,
|
|
3135
|
-
browse && /* @__PURE__ */ (0,
|
|
3136
|
-
paper && /* @__PURE__ */ (0,
|
|
3137
|
-
/* @__PURE__ */ (0,
|
|
3138
|
-
/* @__PURE__ */ (0,
|
|
3279
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
3280
|
+
browse && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
3281
|
+
paper && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
3282
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3283
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3139
3284
|
"Paper: ",
|
|
3140
3285
|
paper.name ?? paper.effect
|
|
3141
3286
|
] }),
|
|
3142
|
-
/* @__PURE__ */ (0,
|
|
3287
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
3143
3288
|
] }),
|
|
3144
|
-
/* @__PURE__ */ (0,
|
|
3145
|
-
/* @__PURE__ */ (0,
|
|
3146
|
-
/* @__PURE__ */ (0,
|
|
3289
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
3291
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3147
3292
|
"input",
|
|
3148
3293
|
{
|
|
3149
3294
|
type: "range",
|
|
@@ -3165,43 +3310,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3165
3310
|
`o${paper.opacity}`
|
|
3166
3311
|
)
|
|
3167
3312
|
] }),
|
|
3168
|
-
/* @__PURE__ */ (0,
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3170
|
-
/* @__PURE__ */ (0,
|
|
3313
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3314
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
3315
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
|
|
3171
3316
|
const blend = e.currentTarget.value;
|
|
3172
3317
|
run(() => controller.updatePaperEffect({ blend }));
|
|
3173
|
-
}, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0,
|
|
3318
|
+
}, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: b, children: b }, b)) })
|
|
3174
3319
|
] }),
|
|
3175
|
-
/* @__PURE__ */ (0,
|
|
3320
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
3176
3321
|
] }),
|
|
3177
|
-
layerEffect && activeId && /* @__PURE__ */ (0,
|
|
3178
|
-
/* @__PURE__ */ (0,
|
|
3179
|
-
/* @__PURE__ */ (0,
|
|
3322
|
+
layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
3323
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3324
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
|
|
3180
3325
|
"Layer: ",
|
|
3181
3326
|
layerEffect.name ?? layerEffect.effect
|
|
3182
3327
|
] }),
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3328
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
3184
3329
|
] }),
|
|
3185
|
-
/* @__PURE__ */ (0,
|
|
3330
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
3186
3331
|
] }),
|
|
3187
|
-
/* @__PURE__ */ (0,
|
|
3332
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorLine, { error })
|
|
3188
3333
|
] });
|
|
3189
3334
|
};
|
|
3190
3335
|
|
|
3191
3336
|
// src/paint-editor/PaintEditor.tsx
|
|
3192
|
-
var
|
|
3337
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3193
3338
|
var PAINT_CONTROLS = {
|
|
3194
3339
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
3195
3340
|
lighting: '[data-testid="light-panel"]',
|
|
3196
3341
|
symmetry: '[aria-label="Symmetry"]'
|
|
3197
3342
|
};
|
|
3198
3343
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3199
|
-
const [tool, setTool] = (0,
|
|
3200
|
-
const [tab, setTab] = (0,
|
|
3201
|
-
const tabRef = (0,
|
|
3344
|
+
const [tool, setTool] = (0, import_react24.useState)("brush");
|
|
3345
|
+
const [tab, setTab] = (0, import_react24.useState)("color");
|
|
3346
|
+
const tabRef = (0, import_react24.useRef)(tab);
|
|
3202
3347
|
tabRef.current = tab;
|
|
3203
|
-
const rootRef = (0,
|
|
3204
|
-
const [ownPresence] = (0,
|
|
3348
|
+
const rootRef = (0, import_react24.useRef)(null);
|
|
3349
|
+
const [ownPresence] = (0, import_react24.useState)(() => new import_paint_editor14.PaintPresence());
|
|
3205
3350
|
const ambientPlayback = useAgentPlayback();
|
|
3206
3351
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3207
3352
|
const viewBox = () => {
|
|
@@ -3257,27 +3402,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3257
3402
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3258
3403
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3259
3404
|
};
|
|
3260
|
-
const [error, setError] = (0,
|
|
3405
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
3261
3406
|
const effects = usePaintEffectsProvider(controller);
|
|
3262
3407
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3263
|
-
return /* @__PURE__ */ (0,
|
|
3264
|
-
playing && /* @__PURE__ */ (0,
|
|
3265
|
-
/* @__PURE__ */ (0,
|
|
3266
|
-
/* @__PURE__ */ (0,
|
|
3267
|
-
/* @__PURE__ */ (0,
|
|
3268
|
-
/* @__PURE__ */ (0,
|
|
3269
|
-
/* @__PURE__ */ (0,
|
|
3270
|
-
error && /* @__PURE__ */ (0,
|
|
3408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|
|
3409
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
3411
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
3412
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
3414
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
3415
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
3271
3416
|
] }),
|
|
3272
|
-
/* @__PURE__ */ (0,
|
|
3273
|
-
/* @__PURE__ */ (0,
|
|
3274
|
-
/* @__PURE__ */ (0,
|
|
3275
|
-
tab === "color" && /* @__PURE__ */ (0,
|
|
3276
|
-
tab === "wet" && /* @__PURE__ */ (0,
|
|
3277
|
-
tab === "paper" && /* @__PURE__ */ (0,
|
|
3278
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3279
|
-
tab === "layers" && /* @__PURE__ */ (0,
|
|
3280
|
-
tab === "effects" && effects && /* @__PURE__ */ (0,
|
|
3417
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
3418
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
3419
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
3420
|
+
tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ColorPanel, { controller }),
|
|
3421
|
+
tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(WetPanel, { controller }),
|
|
3422
|
+
tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaperPanel, { controller }),
|
|
3423
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintLayersPanel, { controller }),
|
|
3424
|
+
tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(StickerPanel, { controller }),
|
|
3425
|
+
tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintEffectsPanel, { controller })
|
|
3281
3426
|
] })
|
|
3282
3427
|
] })
|
|
3283
3428
|
] })
|