@pixerate/editor-react 0.114.1 → 0.114.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +342 -215
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +520 -393
- package/dist/canvas/index.js +2 -2
- package/dist/chart/index.cjs +2 -2
- package/dist/chart/index.js +1 -1
- package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
- package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
- package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
- package/dist/{chunk-N2F53ESC.js → chunk-VUSYAHIU.js} +2 -2
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +348 -221
- package/dist/effects/index.js +2 -2
- package/dist/image-editor/ImageEffectControls.d.cts +4 -1
- package/dist/image-editor/ImageEffectControls.d.ts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
- package/dist/image-editor/controls/parameterControls.d.cts +4 -0
- package/dist/image-editor/controls/parameterControls.d.ts +4 -0
- package/dist/image-editor/index.cjs +868 -697
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1390 -1219
- package/dist/index.js +4 -4
- package/dist/paint-editor/index.cjs +335 -208
- package/dist/paint-editor/index.js +2 -2
- package/dist/parameters/ParametersPanel.d.cts +4 -1
- package/dist/parameters/ParametersPanel.d.ts +4 -1
- package/dist/parameters/controls.d.cts +72 -0
- package/dist/parameters/controls.d.ts +72 -0
- package/dist/parameters/fields.d.cts +19 -6
- package/dist/parameters/fields.d.ts +19 -6
- package/dist/parameters/index.cjs +350 -183
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +70 -14
- package/dist/vector/index.cjs +321 -194
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +418 -291
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
package/dist/canvas/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
EffectParameters,
|
|
3
3
|
EffectsBrowser,
|
|
4
4
|
useEffectDescription
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-TOGMXZM4.js";
|
|
6
|
+
import "../chunk-354TA5QV.js";
|
|
7
7
|
import "../chunk-KIRIU53A.js";
|
|
8
8
|
import "../chunk-3I7FOSLF.js";
|
|
9
9
|
import {
|
package/dist/chart/index.cjs
CHANGED
|
@@ -349,8 +349,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
349
349
|
left: tipAt.left,
|
|
350
350
|
top: tipAt.top,
|
|
351
351
|
transform: `translate(${tipAt.flip ? "calc(-100% - 12px)" : "12px"}, calc(-100% - 8px))`,
|
|
352
|
-
background: "var(--popover, #ffffff)",
|
|
353
|
-
color: "var(--popover-foreground, #0f172a)",
|
|
352
|
+
background: "var(--popover, var(--background, #ffffff))",
|
|
353
|
+
color: "var(--popover-foreground, var(--foreground, #0f172a))",
|
|
354
354
|
borderColor: "var(--border, #e2e8f0)",
|
|
355
355
|
fontFamily: scene.theme.fontFamily
|
|
356
356
|
},
|
package/dist/chart/index.js
CHANGED
|
@@ -2,32 +2,76 @@ import {
|
|
|
2
2
|
ColorPicker
|
|
3
3
|
} from "./chunk-3I7FOSLF.js";
|
|
4
4
|
|
|
5
|
+
// src/parameters/controls.tsx
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var ParameterComponentsContext = createContext({});
|
|
9
|
+
function ParameterComponentsProvider({ components, children }) {
|
|
10
|
+
return /* @__PURE__ */ jsx(ParameterComponentsContext.Provider, { value: components, children });
|
|
11
|
+
}
|
|
12
|
+
function useParameterComponents() {
|
|
13
|
+
return useContext(ParameterComponentsContext);
|
|
14
|
+
}
|
|
15
|
+
function resolveParameterComponents(explicit, context) {
|
|
16
|
+
return {
|
|
17
|
+
input: explicit?.input ?? context?.input,
|
|
18
|
+
slider: explicit?.slider ?? context?.slider,
|
|
19
|
+
select: explicit?.select ?? context?.select
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
// src/parameters/fields.tsx
|
|
6
|
-
import { useEffect, useRef, useState } from "react";
|
|
24
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
25
|
import {
|
|
8
26
|
choiceOptionLabel,
|
|
9
27
|
formatParameterNumber,
|
|
10
28
|
getChoiceOptions,
|
|
11
29
|
isSliderField,
|
|
30
|
+
matchParameterOptionValue,
|
|
12
31
|
normalizeHexColor,
|
|
13
32
|
parameterLabel,
|
|
14
33
|
parameterStep,
|
|
34
|
+
parameterThemeStyles,
|
|
15
35
|
parseParameterNumberInput,
|
|
16
36
|
clampParameterNumber,
|
|
17
37
|
vectorComponentField,
|
|
18
38
|
vectorSize
|
|
19
39
|
} from "@pixerate/editor/parameters";
|
|
20
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
40
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
41
|
+
var parameterInputStyle = parameterThemeStyles.input;
|
|
42
|
+
var parameterSelectStyle = parameterThemeStyles.select;
|
|
43
|
+
var parameterButtonStyle = parameterThemeStyles.button;
|
|
44
|
+
var parameterRangeStyle = parameterThemeStyles.range;
|
|
21
45
|
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";
|
|
22
46
|
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";
|
|
23
47
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
24
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
48
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
49
|
+
const inputRef = useRef(null);
|
|
50
|
+
const lastCommitted = useRef(null);
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
lastCommitted.current = null;
|
|
53
|
+
const el = inputRef.current;
|
|
54
|
+
if (el && el.value !== value) el.value = value;
|
|
55
|
+
}, [value]);
|
|
25
56
|
const commit = (el) => {
|
|
26
|
-
|
|
57
|
+
const text = el.value;
|
|
58
|
+
if (text === value || text === lastCommitted.current) return;
|
|
59
|
+
onCommit(text, el);
|
|
60
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
27
61
|
};
|
|
62
|
+
const commitRef = useRef(commit);
|
|
63
|
+
commitRef.current = commit;
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const el = inputRef.current;
|
|
66
|
+
if (!el) return;
|
|
67
|
+
const change = () => commitRef.current(el);
|
|
68
|
+
el.addEventListener("change", change);
|
|
69
|
+
return () => el.removeEventListener("change", change);
|
|
70
|
+
}, [multiline]);
|
|
28
71
|
const keyDown = (e) => {
|
|
29
72
|
onKeyDown?.(e);
|
|
30
73
|
if (e.defaultPrevented) return;
|
|
74
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
31
75
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
32
76
|
e.preventDefault();
|
|
33
77
|
commit(e.currentTarget);
|
|
@@ -37,86 +81,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
37
81
|
const props = {
|
|
38
82
|
defaultValue: value,
|
|
39
83
|
className: className ?? parameterInputClass,
|
|
84
|
+
style: { ...parameterInputStyle, ...style },
|
|
40
85
|
onBlur: (e) => commit(e.currentTarget),
|
|
41
86
|
onKeyDown: keyDown,
|
|
42
87
|
...rest
|
|
43
88
|
};
|
|
44
|
-
|
|
89
|
+
const forwarded = rest.ref;
|
|
90
|
+
const setRef = (el) => {
|
|
91
|
+
inputRef.current = el;
|
|
92
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
93
|
+
else if (forwarded) forwarded.current = el;
|
|
94
|
+
};
|
|
95
|
+
return multiline ? /* @__PURE__ */ jsx2("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ jsx2("input", { type: "text", ...props, ref: setRef });
|
|
45
96
|
}
|
|
46
97
|
var plainNumber = (field, value) => formatParameterNumber({ ...field, unit: void 0 }, value);
|
|
47
|
-
function ParameterNumberInput({
|
|
48
|
-
field,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
function ParameterNumberInput(props) {
|
|
99
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
100
|
+
const ctx = useParameterComponents();
|
|
101
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
102
|
+
const CustomInput = resolved.input;
|
|
103
|
+
const plain = plainNumber(field, value);
|
|
104
|
+
const handleCommit = (text, input) => {
|
|
105
|
+
const n = parseParameterNumberInput(field, text);
|
|
106
|
+
if (n === null || n === value) {
|
|
107
|
+
if (input) input.value = plain;
|
|
108
|
+
} else {
|
|
109
|
+
onChange(n);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const handleKeyDown = (e) => {
|
|
113
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
const step = parameterStep(field) * (e.shiftKey ? 10 : 1);
|
|
116
|
+
onChange(clampParameterNumber(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
117
|
+
};
|
|
118
|
+
const inputProps = {
|
|
119
|
+
id,
|
|
120
|
+
inputMode: "decimal",
|
|
121
|
+
"aria-label": ariaLabel ?? parameterLabel(field),
|
|
122
|
+
value: plain,
|
|
123
|
+
disabled: disabled || field.readOnly,
|
|
124
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
125
|
+
style: parameterInputStyle,
|
|
126
|
+
onCommit: handleCommit,
|
|
127
|
+
onKeyDown: handleKeyDown
|
|
128
|
+
};
|
|
55
129
|
return /* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
id,
|
|
60
|
-
inputMode: "decimal",
|
|
61
|
-
"aria-label": ariaLabel ?? parameterLabel(field),
|
|
62
|
-
value: plainNumber(field, value),
|
|
63
|
-
disabled: disabled || field.readOnly,
|
|
64
|
-
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
65
|
-
onCommit: (text, input) => {
|
|
66
|
-
const n = parseParameterNumberInput(field, text);
|
|
67
|
-
if (n === null || n === value) input.value = plainNumber(field, value);
|
|
68
|
-
else onChange(n);
|
|
69
|
-
},
|
|
70
|
-
onKeyDown: (e) => {
|
|
71
|
-
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
const step = parameterStep(field) * (e.shiftKey ? 10 : 1);
|
|
74
|
-
onChange(clampParameterNumber(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
field.unit && /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
130
|
+
CustomInput ? /* @__PURE__ */ jsx2(CustomInput, { ...inputProps, label: parameterLabel(field) }) : /* @__PURE__ */ jsx2(ParameterCommitInput, { ...inputProps }),
|
|
131
|
+
field.unit && /* @__PURE__ */ jsx2("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
79
132
|
] });
|
|
80
133
|
}
|
|
81
134
|
function ParameterSlider(props) {
|
|
82
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
135
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
136
|
+
const ctx = useParameterComponents();
|
|
137
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
138
|
+
const CustomSlider = resolved.slider;
|
|
83
139
|
const dragging = useRef(false);
|
|
140
|
+
const start = () => {
|
|
141
|
+
if (dragging.current) return;
|
|
142
|
+
dragging.current = true;
|
|
143
|
+
onGestureStart?.();
|
|
144
|
+
};
|
|
84
145
|
const end = () => {
|
|
85
146
|
if (!dragging.current) return;
|
|
86
147
|
dragging.current = false;
|
|
87
148
|
onGestureEnd?.();
|
|
88
149
|
};
|
|
89
|
-
if (!isSliderField(field)) return /* @__PURE__ */
|
|
150
|
+
if (!isSliderField(field)) return /* @__PURE__ */ jsx2(ParameterNumberInput, { ...props });
|
|
90
151
|
const step = parameterStep(field);
|
|
152
|
+
const sliderProps = {
|
|
153
|
+
"aria-label": parameterLabel(field),
|
|
154
|
+
"aria-valuetext": formatParameterNumber(field, value),
|
|
155
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
156
|
+
min: field.min ?? 0,
|
|
157
|
+
max: field.max ?? 100,
|
|
158
|
+
step,
|
|
159
|
+
value,
|
|
160
|
+
disabled: disabled || field.readOnly,
|
|
161
|
+
className: rangeClass,
|
|
162
|
+
style: parameterRangeStyle
|
|
163
|
+
};
|
|
91
164
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
92
|
-
/* @__PURE__ */
|
|
165
|
+
CustomSlider ? /* @__PURE__ */ jsx2(
|
|
166
|
+
CustomSlider,
|
|
167
|
+
{
|
|
168
|
+
...sliderProps,
|
|
169
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
170
|
+
label: parameterLabel(field),
|
|
171
|
+
onChange: (v) => onChange(clampParameterNumber(field, v)),
|
|
172
|
+
onGestureStart: start,
|
|
173
|
+
onGestureEnd: end
|
|
174
|
+
}
|
|
175
|
+
) : /* @__PURE__ */ jsx2(
|
|
93
176
|
"input",
|
|
94
177
|
{
|
|
95
178
|
type: "range",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
min: field.min,
|
|
99
|
-
max: field.max,
|
|
100
|
-
step,
|
|
101
|
-
value,
|
|
102
|
-
disabled: disabled || field.readOnly,
|
|
103
|
-
className: rangeClass,
|
|
104
|
-
onPointerDown: () => {
|
|
105
|
-
if (dragging.current) return;
|
|
106
|
-
dragging.current = true;
|
|
107
|
-
onGestureStart?.();
|
|
108
|
-
},
|
|
179
|
+
...sliderProps,
|
|
180
|
+
onPointerDown: start,
|
|
109
181
|
onPointerUp: end,
|
|
110
182
|
onPointerCancel: end,
|
|
111
183
|
onBlur: end,
|
|
112
184
|
onChange: (e) => onChange(clampParameterNumber(field, Number(e.target.value)))
|
|
113
185
|
}
|
|
114
186
|
),
|
|
115
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ jsx2("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ jsx2(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${parameterLabel(field)} value` }) })
|
|
116
188
|
] });
|
|
117
189
|
}
|
|
118
190
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
119
|
-
return /* @__PURE__ */
|
|
191
|
+
return /* @__PURE__ */ jsx2(
|
|
120
192
|
"button",
|
|
121
193
|
{
|
|
122
194
|
type: "button",
|
|
@@ -127,7 +199,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
127
199
|
disabled: disabled || field.readOnly,
|
|
128
200
|
onClick: () => onChange(!value),
|
|
129
201
|
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"}`,
|
|
130
|
-
children: /* @__PURE__ */
|
|
202
|
+
children: /* @__PURE__ */ jsx2(
|
|
131
203
|
"span",
|
|
132
204
|
{
|
|
133
205
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -136,11 +208,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
136
208
|
}
|
|
137
209
|
);
|
|
138
210
|
}
|
|
139
|
-
function ParameterSelect(
|
|
211
|
+
function ParameterSelect(props) {
|
|
212
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
213
|
+
const ctx = useParameterComponents();
|
|
214
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
215
|
+
const CustomSelect = resolved.select;
|
|
140
216
|
const options = getChoiceOptions(field);
|
|
141
217
|
const off = disabled || field.readOnly;
|
|
142
218
|
if (field.control === "segmented") {
|
|
143
|
-
return /* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ jsx2("div", { role: "radiogroup", "aria-label": parameterLabel(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ jsx2(
|
|
144
220
|
"button",
|
|
145
221
|
{
|
|
146
222
|
type: "button",
|
|
@@ -155,8 +231,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
155
231
|
String(o.value)
|
|
156
232
|
)) });
|
|
157
233
|
}
|
|
234
|
+
if (CustomSelect) {
|
|
235
|
+
const customOptions = options.map((o) => ({ value: o.value, label: choiceOptionLabel(o), description: o.description }));
|
|
236
|
+
return /* @__PURE__ */ jsx2(
|
|
237
|
+
CustomSelect,
|
|
238
|
+
{
|
|
239
|
+
id,
|
|
240
|
+
label: parameterLabel(field),
|
|
241
|
+
"aria-label": parameterLabel(field),
|
|
242
|
+
value,
|
|
243
|
+
options: customOptions,
|
|
244
|
+
disabled: off,
|
|
245
|
+
className: parameterInputClass,
|
|
246
|
+
style: parameterSelectStyle,
|
|
247
|
+
onChange: (v) => onChange(matchParameterOptionValue(options, v))
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
158
251
|
const index = options.findIndex((o) => o.value === value);
|
|
159
|
-
return /* @__PURE__ */
|
|
252
|
+
return /* @__PURE__ */ jsx2(
|
|
160
253
|
"select",
|
|
161
254
|
{
|
|
162
255
|
id,
|
|
@@ -168,7 +261,8 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
168
261
|
if (option) onChange(option.value);
|
|
169
262
|
},
|
|
170
263
|
className: parameterInputClass,
|
|
171
|
-
|
|
264
|
+
style: parameterSelectStyle,
|
|
265
|
+
children: options.map((o, i) => /* @__PURE__ */ jsx2("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: choiceOptionLabel(o) }, String(o.value)))
|
|
172
266
|
}
|
|
173
267
|
);
|
|
174
268
|
}
|
|
@@ -206,7 +300,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
206
300
|
}, [open]);
|
|
207
301
|
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
208
302
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
209
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ jsx2(
|
|
210
304
|
"button",
|
|
211
305
|
{
|
|
212
306
|
ref: buttonRef,
|
|
@@ -217,10 +311,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
217
311
|
disabled: off,
|
|
218
312
|
onClick: () => setOpen((prev) => !prev),
|
|
219
313
|
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",
|
|
220
|
-
children: /* @__PURE__ */
|
|
314
|
+
children: /* @__PURE__ */ jsx2("span", { className: "absolute inset-0", style: { background: shown } })
|
|
221
315
|
}
|
|
222
316
|
),
|
|
223
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ jsx2(
|
|
224
318
|
ParameterCommitInput,
|
|
225
319
|
{
|
|
226
320
|
id,
|
|
@@ -236,7 +330,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
236
330
|
}
|
|
237
331
|
)
|
|
238
332
|
] }),
|
|
239
|
-
open && /* @__PURE__ */
|
|
333
|
+
open && /* @__PURE__ */ jsx2(
|
|
240
334
|
"div",
|
|
241
335
|
{
|
|
242
336
|
ref: popoverRef,
|
|
@@ -250,7 +344,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
250
344
|
},
|
|
251
345
|
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",
|
|
252
346
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
253
|
-
children: /* @__PURE__ */
|
|
347
|
+
children: /* @__PURE__ */ jsx2(
|
|
254
348
|
ColorPicker,
|
|
255
349
|
{
|
|
256
350
|
value: shown,
|
|
@@ -266,13 +360,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
266
360
|
)
|
|
267
361
|
] });
|
|
268
362
|
}
|
|
269
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
363
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
270
364
|
const size = vectorSize(field);
|
|
271
|
-
return /* @__PURE__ */
|
|
365
|
+
return /* @__PURE__ */ jsx2("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
272
366
|
const component = vectorComponentField(field, i);
|
|
273
367
|
return /* @__PURE__ */ jsxs("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ jsx2("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
369
|
+
/* @__PURE__ */ jsx2(
|
|
276
370
|
ParameterNumberInput,
|
|
277
371
|
{
|
|
278
372
|
field: component,
|
|
@@ -280,6 +374,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
280
374
|
id: i === 0 ? id : void 0,
|
|
281
375
|
"aria-label": `${parameterLabel(field)} ${component.label}`,
|
|
282
376
|
disabled: disabled || field.readOnly,
|
|
377
|
+
components,
|
|
283
378
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
284
379
|
}
|
|
285
380
|
)
|
|
@@ -291,9 +386,9 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
291
386
|
const name = parameterLabel(field);
|
|
292
387
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
293
388
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
294
|
-
/* @__PURE__ */
|
|
389
|
+
/* @__PURE__ */ jsx2("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__ */ jsx2("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
295
390
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
296
|
-
/* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ jsx2(
|
|
297
392
|
ParameterCommitInput,
|
|
298
393
|
{
|
|
299
394
|
id,
|
|
@@ -305,29 +400,47 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
305
400
|
}
|
|
306
401
|
),
|
|
307
402
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
308
|
-
resolveFile && /* @__PURE__ */ jsxs(
|
|
309
|
-
"
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
{
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
403
|
+
resolveFile && /* @__PURE__ */ jsxs(
|
|
404
|
+
"label",
|
|
405
|
+
{
|
|
406
|
+
style: parameterButtonStyle,
|
|
407
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
408
|
+
children: [
|
|
409
|
+
"Choose file\u2026",
|
|
410
|
+
/* @__PURE__ */ jsx2(
|
|
411
|
+
"input",
|
|
412
|
+
{
|
|
413
|
+
type: "file",
|
|
414
|
+
className: "sr-only",
|
|
415
|
+
accept: field.accept ?? "image/*",
|
|
416
|
+
disabled: off,
|
|
417
|
+
"aria-label": `${name} file`,
|
|
418
|
+
onChange: async (e) => {
|
|
419
|
+
const file = e.target.files?.[0];
|
|
420
|
+
e.target.value = "";
|
|
421
|
+
if (file) onChange(await resolveFile(file));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
)
|
|
425
|
+
]
|
|
426
|
+
}
|
|
427
|
+
),
|
|
428
|
+
value && /* @__PURE__ */ jsx2(
|
|
429
|
+
"button",
|
|
430
|
+
{
|
|
431
|
+
type: "button",
|
|
432
|
+
style: parameterButtonStyle,
|
|
433
|
+
className: parameterButtonClass,
|
|
434
|
+
disabled: off,
|
|
435
|
+
onClick: () => onChange(""),
|
|
436
|
+
"aria-label": `Clear ${name}`,
|
|
437
|
+
children: "Clear"
|
|
438
|
+
}
|
|
439
|
+
)
|
|
327
440
|
] })
|
|
328
441
|
] })
|
|
329
442
|
] }),
|
|
330
|
-
field.options && field.options.length > 0 && /* @__PURE__ */
|
|
443
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ jsx2("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ jsx2(
|
|
331
444
|
"button",
|
|
332
445
|
{
|
|
333
446
|
type: "button",
|
|
@@ -337,14 +450,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
337
450
|
disabled: off,
|
|
338
451
|
onClick: () => onChange(o.url),
|
|
339
452
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
340
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ jsx2("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
341
454
|
},
|
|
342
455
|
o.url
|
|
343
456
|
)) })
|
|
344
457
|
] });
|
|
345
458
|
}
|
|
346
459
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
347
|
-
return /* @__PURE__ */
|
|
460
|
+
return /* @__PURE__ */ jsx2(
|
|
348
461
|
ParameterCommitInput,
|
|
349
462
|
{
|
|
350
463
|
id,
|
|
@@ -360,7 +473,7 @@ function ParameterText({ field, value, onChange, disabled, id }) {
|
|
|
360
473
|
}
|
|
361
474
|
function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
|
|
362
475
|
const keyed = state === "keyed";
|
|
363
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ jsx2(
|
|
364
477
|
"button",
|
|
365
478
|
{
|
|
366
479
|
type: "button",
|
|
@@ -371,7 +484,7 @@ function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
|
|
|
371
484
|
disabled,
|
|
372
485
|
onClick: onToggle,
|
|
373
486
|
className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-40 ${state === "none" ? "text-muted-foreground hover:text-foreground" : "text-amber-500"} ${className}`,
|
|
374
|
-
children: /* @__PURE__ */
|
|
487
|
+
children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
|
|
375
488
|
"path",
|
|
376
489
|
{
|
|
377
490
|
d: "M5 0.8 9.2 5 5 9.2 0.8 5Z",
|
|
@@ -389,23 +502,30 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
389
502
|
switch (field.type) {
|
|
390
503
|
case "number":
|
|
391
504
|
case "int":
|
|
392
|
-
return /* @__PURE__ */
|
|
505
|
+
return /* @__PURE__ */ jsx2(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
393
506
|
case "boolean":
|
|
394
|
-
return /* @__PURE__ */
|
|
507
|
+
return /* @__PURE__ */ jsx2(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
395
508
|
case "choice":
|
|
396
|
-
return /* @__PURE__ */
|
|
509
|
+
return /* @__PURE__ */ jsx2(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
397
510
|
case "color":
|
|
398
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ jsx2(ParameterColor, { field, value, onChange: set, ...rest });
|
|
399
512
|
case "vector":
|
|
400
|
-
return /* @__PURE__ */
|
|
513
|
+
return /* @__PURE__ */ jsx2(ParameterVector, { field, value, onChange: set, ...rest });
|
|
401
514
|
case "image":
|
|
402
|
-
return /* @__PURE__ */
|
|
515
|
+
return /* @__PURE__ */ jsx2(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
403
516
|
case "text":
|
|
404
|
-
return /* @__PURE__ */
|
|
517
|
+
return /* @__PURE__ */ jsx2(ParameterText, { field, value, onChange: set, ...rest });
|
|
405
518
|
}
|
|
406
519
|
}
|
|
407
520
|
|
|
408
521
|
export {
|
|
522
|
+
ParameterComponentsProvider,
|
|
523
|
+
useParameterComponents,
|
|
524
|
+
resolveParameterComponents,
|
|
525
|
+
parameterInputStyle,
|
|
526
|
+
parameterSelectStyle,
|
|
527
|
+
parameterButtonStyle,
|
|
528
|
+
parameterRangeStyle,
|
|
409
529
|
parameterInputClass,
|
|
410
530
|
parameterButtonClass,
|
|
411
531
|
ParameterCommitInput,
|