@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.
Files changed (42) hide show
  1. package/dist/animation-editor/index.cjs +361 -216
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +539 -394
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
  6. package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
  7. package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.js} +40 -18
  8. package/dist/effects/EffectParameters.d.cts +4 -1
  9. package/dist/effects/EffectParameters.d.ts +4 -1
  10. package/dist/effects/index.cjs +367 -222
  11. package/dist/effects/index.js +2 -2
  12. package/dist/image-editor/ImageEffectControls.d.cts +4 -1
  13. package/dist/image-editor/ImageEffectControls.d.ts +4 -1
  14. package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
  15. package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
  16. package/dist/image-editor/controls/controls.d.cts +19 -0
  17. package/dist/image-editor/controls/controls.d.ts +19 -0
  18. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  19. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  20. package/dist/image-editor/index.cjs +924 -765
  21. package/dist/image-editor/index.d.cts +1 -1
  22. package/dist/image-editor/index.d.ts +1 -1
  23. package/dist/image-editor/index.js +5 -3
  24. package/dist/index.cjs +1444 -1285
  25. package/dist/index.js +5 -3
  26. package/dist/paint-editor/index.cjs +354 -209
  27. package/dist/paint-editor/index.js +2 -2
  28. package/dist/parameters/ParametersPanel.d.cts +4 -1
  29. package/dist/parameters/ParametersPanel.d.ts +4 -1
  30. package/dist/parameters/controls.d.cts +92 -0
  31. package/dist/parameters/controls.d.ts +92 -0
  32. package/dist/parameters/fields.d.cts +20 -7
  33. package/dist/parameters/fields.d.ts +20 -7
  34. package/dist/parameters/index.cjs +369 -184
  35. package/dist/parameters/index.d.cts +1 -0
  36. package/dist/parameters/index.d.ts +1 -0
  37. package/dist/parameters/index.js +70 -14
  38. package/dist/vector/index.cjs +340 -195
  39. package/dist/vector/index.js +2 -2
  40. package/dist/video-editor/index.cjs +437 -292
  41. package/dist/video-editor/index.js +2 -2
  42. package/package.json +3 -3
@@ -2,32 +2,77 @@ 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
+ color: explicit?.color ?? context?.color
21
+ };
22
+ }
23
+
5
24
  // src/parameters/fields.tsx
6
- import { useEffect, useRef, useState } from "react";
25
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
7
26
  import {
8
27
  choiceOptionLabel,
9
28
  formatParameterNumber,
10
29
  getChoiceOptions,
11
30
  isSliderField,
31
+ matchParameterOptionValue,
12
32
  normalizeHexColor,
13
33
  parameterLabel,
14
34
  parameterStep,
35
+ parameterThemeStyles,
15
36
  parseParameterNumberInput,
16
37
  clampParameterNumber,
17
38
  vectorComponentField,
18
39
  vectorSize
19
40
  } from "@pixerate/editor/parameters";
20
- import { jsx, jsxs } from "react/jsx-runtime";
41
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
42
+ var parameterInputStyle = parameterThemeStyles.input;
43
+ var parameterSelectStyle = parameterThemeStyles.select;
44
+ var parameterButtonStyle = parameterThemeStyles.button;
45
+ var parameterRangeStyle = parameterThemeStyles.range;
21
46
  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
47
  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
48
  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 }) {
49
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
50
+ const inputRef = useRef(null);
51
+ const lastCommitted = useRef(null);
52
+ useLayoutEffect(() => {
53
+ lastCommitted.current = null;
54
+ const el = inputRef.current;
55
+ if (el && el.value !== value) el.value = value;
56
+ }, [value]);
25
57
  const commit = (el) => {
26
- if (el.value !== value) onCommit(el.value, el);
58
+ const text = el.value;
59
+ if (text === value || text === lastCommitted.current) return;
60
+ onCommit(text, el);
61
+ lastCommitted.current = el.value === text ? text : null;
27
62
  };
63
+ const commitRef = useRef(commit);
64
+ commitRef.current = commit;
65
+ useEffect(() => {
66
+ const el = inputRef.current;
67
+ if (!el) return;
68
+ const change = () => commitRef.current(el);
69
+ el.addEventListener("change", change);
70
+ return () => el.removeEventListener("change", change);
71
+ }, [multiline]);
28
72
  const keyDown = (e) => {
29
73
  onKeyDown?.(e);
30
74
  if (e.defaultPrevented) return;
75
+ if (e.key === "Tab") commit(e.currentTarget);
31
76
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
32
77
  e.preventDefault();
33
78
  commit(e.currentTarget);
@@ -37,86 +82,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
37
82
  const props = {
38
83
  defaultValue: value,
39
84
  className: className ?? parameterInputClass,
85
+ style: { ...parameterInputStyle, ...style },
40
86
  onBlur: (e) => commit(e.currentTarget),
41
87
  onKeyDown: keyDown,
42
88
  ...rest
43
89
  };
44
- return multiline ? /* @__PURE__ */ jsx("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ jsx("input", { type: "text", ...props }, value);
90
+ const forwarded = rest.ref;
91
+ const setRef = (el) => {
92
+ inputRef.current = el;
93
+ if (typeof forwarded === "function") forwarded(el);
94
+ else if (forwarded) forwarded.current = el;
95
+ };
96
+ 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
97
  }
46
98
  var plainNumber = (field, value) => formatParameterNumber({ ...field, unit: void 0 }, value);
47
- function ParameterNumberInput({
48
- field,
49
- value,
50
- onChange,
51
- disabled,
52
- id,
53
- "aria-label": ariaLabel
54
- }) {
99
+ function ParameterNumberInput(props) {
100
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
101
+ const ctx = useParameterComponents();
102
+ const resolved = resolveParameterComponents(components, ctx);
103
+ const CustomInput = resolved.input;
104
+ const plain = plainNumber(field, value);
105
+ const handleCommit = (text, input) => {
106
+ const n = parseParameterNumberInput(field, text);
107
+ if (n === null || n === value) {
108
+ if (input) input.value = plain;
109
+ } else {
110
+ onChange(n);
111
+ }
112
+ };
113
+ const handleKeyDown = (e) => {
114
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
115
+ e.preventDefault();
116
+ const step = parameterStep(field) * (e.shiftKey ? 10 : 1);
117
+ onChange(clampParameterNumber(field, value + (e.key === "ArrowUp" ? step : -step)));
118
+ };
119
+ const inputProps = {
120
+ id,
121
+ inputMode: "decimal",
122
+ "aria-label": ariaLabel ?? parameterLabel(field),
123
+ value: plain,
124
+ disabled: disabled || field.readOnly,
125
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
126
+ style: parameterInputStyle,
127
+ onCommit: handleCommit,
128
+ onKeyDown: handleKeyDown
129
+ };
55
130
  return /* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
56
- /* @__PURE__ */ jsx(
57
- ParameterCommitInput,
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 })
131
+ CustomInput ? /* @__PURE__ */ jsx2(CustomInput, { ...inputProps, label: parameterLabel(field) }) : /* @__PURE__ */ jsx2(ParameterCommitInput, { ...inputProps }),
132
+ 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
133
  ] });
80
134
  }
81
135
  function ParameterSlider(props) {
82
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
136
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
137
+ const ctx = useParameterComponents();
138
+ const resolved = resolveParameterComponents(components, ctx);
139
+ const CustomSlider = resolved.slider;
83
140
  const dragging = useRef(false);
141
+ const start = () => {
142
+ if (dragging.current) return;
143
+ dragging.current = true;
144
+ onGestureStart?.();
145
+ };
84
146
  const end = () => {
85
147
  if (!dragging.current) return;
86
148
  dragging.current = false;
87
149
  onGestureEnd?.();
88
150
  };
89
- if (!isSliderField(field)) return /* @__PURE__ */ jsx(ParameterNumberInput, { ...props });
151
+ if (!isSliderField(field)) return /* @__PURE__ */ jsx2(ParameterNumberInput, { ...props });
90
152
  const step = parameterStep(field);
153
+ const sliderProps = {
154
+ "aria-label": parameterLabel(field),
155
+ "aria-valuetext": formatParameterNumber(field, value),
156
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
157
+ min: field.min ?? 0,
158
+ max: field.max ?? 100,
159
+ step,
160
+ value,
161
+ disabled: disabled || field.readOnly,
162
+ className: rangeClass,
163
+ style: parameterRangeStyle
164
+ };
91
165
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
92
- /* @__PURE__ */ jsx(
166
+ CustomSlider ? /* @__PURE__ */ jsx2(
167
+ CustomSlider,
168
+ {
169
+ ...sliderProps,
170
+ id: props.id ? `${props.id}-slider` : void 0,
171
+ label: parameterLabel(field),
172
+ onChange: (v) => onChange(clampParameterNumber(field, v)),
173
+ onGestureStart: start,
174
+ onGestureEnd: end
175
+ }
176
+ ) : /* @__PURE__ */ jsx2(
93
177
  "input",
94
178
  {
95
179
  type: "range",
96
- "aria-label": parameterLabel(field),
97
- "aria-valuetext": formatParameterNumber(field, value),
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
- },
180
+ ...sliderProps,
181
+ onPointerDown: start,
109
182
  onPointerUp: end,
110
183
  onPointerCancel: end,
111
184
  onBlur: end,
112
185
  onChange: (e) => onChange(clampParameterNumber(field, Number(e.target.value)))
113
186
  }
114
187
  ),
115
- /* @__PURE__ */ jsx("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ jsx(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${parameterLabel(field)} value` }) })
188
+ /* @__PURE__ */ jsx2("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ jsx2(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${parameterLabel(field)} value` }) })
116
189
  ] });
117
190
  }
118
191
  function ParameterToggle({ field, value, onChange, disabled, id }) {
119
- return /* @__PURE__ */ jsx(
192
+ return /* @__PURE__ */ jsx2(
120
193
  "button",
121
194
  {
122
195
  type: "button",
@@ -127,7 +200,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
127
200
  disabled: disabled || field.readOnly,
128
201
  onClick: () => onChange(!value),
129
202
  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__ */ jsx(
203
+ children: /* @__PURE__ */ jsx2(
131
204
  "span",
132
205
  {
133
206
  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 +209,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
136
209
  }
137
210
  );
138
211
  }
139
- function ParameterSelect({ field, value, onChange, disabled, id }) {
212
+ function ParameterSelect(props) {
213
+ const { field, value, onChange, disabled, id, components } = props;
214
+ const ctx = useParameterComponents();
215
+ const resolved = resolveParameterComponents(components, ctx);
216
+ const CustomSelect = resolved.select;
140
217
  const options = getChoiceOptions(field);
141
218
  const off = disabled || field.readOnly;
142
219
  if (field.control === "segmented") {
143
- return /* @__PURE__ */ jsx("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__ */ jsx(
220
+ 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
221
  "button",
145
222
  {
146
223
  type: "button",
@@ -155,8 +232,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
155
232
  String(o.value)
156
233
  )) });
157
234
  }
235
+ if (CustomSelect) {
236
+ const customOptions = options.map((o) => ({ value: o.value, label: choiceOptionLabel(o), description: o.description }));
237
+ return /* @__PURE__ */ jsx2(
238
+ CustomSelect,
239
+ {
240
+ id,
241
+ label: parameterLabel(field),
242
+ "aria-label": parameterLabel(field),
243
+ value,
244
+ options: customOptions,
245
+ disabled: off,
246
+ className: parameterInputClass,
247
+ style: parameterSelectStyle,
248
+ onChange: (v) => onChange(matchParameterOptionValue(options, v))
249
+ }
250
+ );
251
+ }
158
252
  const index = options.findIndex((o) => o.value === value);
159
- return /* @__PURE__ */ jsx(
253
+ return /* @__PURE__ */ jsx2(
160
254
  "select",
161
255
  {
162
256
  id,
@@ -168,11 +262,13 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
168
262
  if (option) onChange(option.value);
169
263
  },
170
264
  className: parameterInputClass,
171
- children: options.map((o, i) => /* @__PURE__ */ jsx("option", { value: String(i), title: o.description, children: choiceOptionLabel(o) }, String(o.value)))
265
+ style: parameterSelectStyle,
266
+ children: options.map((o, i) => /* @__PURE__ */ jsx2("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: choiceOptionLabel(o) }, String(o.value)))
172
267
  }
173
268
  );
174
269
  }
175
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
270
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
271
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
176
272
  const [open, setOpen] = useState(false);
177
273
  const containerRef = useRef(null);
178
274
  const buttonRef = useRef(null);
@@ -204,9 +300,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
204
300
  window.removeEventListener("keydown", onKeyDown, true);
205
301
  };
206
302
  }, [open]);
303
+ if (CustomColor) {
304
+ return /* @__PURE__ */ jsx2(
305
+ CustomColor,
306
+ {
307
+ id,
308
+ value: shown,
309
+ alpha,
310
+ swatches: field.swatches,
311
+ disabled: off,
312
+ label: name,
313
+ onChange,
314
+ onGestureStart,
315
+ onGestureEnd
316
+ }
317
+ );
318
+ }
207
319
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "relative space-y-1.5", children: [
208
320
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
209
- /* @__PURE__ */ jsx(
321
+ /* @__PURE__ */ jsx2(
210
322
  "button",
211
323
  {
212
324
  ref: buttonRef,
@@ -217,10 +329,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
217
329
  disabled: off,
218
330
  onClick: () => setOpen((prev) => !prev),
219
331
  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__ */ jsx("span", { className: "absolute inset-0", style: { background: shown } })
332
+ children: /* @__PURE__ */ jsx2("span", { className: "absolute inset-0", style: { background: shown } })
221
333
  }
222
334
  ),
223
- /* @__PURE__ */ jsx(
335
+ /* @__PURE__ */ jsx2(
224
336
  ParameterCommitInput,
225
337
  {
226
338
  id,
@@ -236,7 +348,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
236
348
  }
237
349
  )
238
350
  ] }),
239
- open && /* @__PURE__ */ jsx(
351
+ open && /* @__PURE__ */ jsx2(
240
352
  "div",
241
353
  {
242
354
  ref: popoverRef,
@@ -250,7 +362,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
250
362
  },
251
363
  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
364
  style: { background: "var(--popover, var(--background, #fff))" },
253
- children: /* @__PURE__ */ jsx(
365
+ children: /* @__PURE__ */ jsx2(
254
366
  ColorPicker,
255
367
  {
256
368
  value: shown,
@@ -266,13 +378,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
266
378
  )
267
379
  ] });
268
380
  }
269
- function ParameterVector({ field, value, onChange, disabled, id }) {
381
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
270
382
  const size = vectorSize(field);
271
- return /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
383
+ return /* @__PURE__ */ jsx2("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
272
384
  const component = vectorComponentField(field, i);
273
385
  return /* @__PURE__ */ jsxs("label", { className: "flex min-w-0 items-center gap-1", children: [
274
- /* @__PURE__ */ jsx("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
275
- /* @__PURE__ */ jsx(
386
+ /* @__PURE__ */ jsx2("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
387
+ /* @__PURE__ */ jsx2(
276
388
  ParameterNumberInput,
277
389
  {
278
390
  field: component,
@@ -280,6 +392,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
280
392
  id: i === 0 ? id : void 0,
281
393
  "aria-label": `${parameterLabel(field)} ${component.label}`,
282
394
  disabled: disabled || field.readOnly,
395
+ components,
283
396
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
284
397
  }
285
398
  )
@@ -291,9 +404,9 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
291
404
  const name = parameterLabel(field);
292
405
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
293
406
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
294
- /* @__PURE__ */ 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__ */ jsx("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
407
+ /* @__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
408
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
296
- /* @__PURE__ */ jsx(
409
+ /* @__PURE__ */ jsx2(
297
410
  ParameterCommitInput,
298
411
  {
299
412
  id,
@@ -305,29 +418,47 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
305
418
  }
306
419
  ),
307
420
  /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
308
- resolveFile && /* @__PURE__ */ jsxs("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
309
- "Choose file\u2026",
310
- /* @__PURE__ */ jsx(
311
- "input",
312
- {
313
- type: "file",
314
- className: "sr-only",
315
- accept: field.accept ?? "image/*",
316
- disabled: off,
317
- "aria-label": `${name} file`,
318
- onChange: async (e) => {
319
- const file = e.target.files?.[0];
320
- e.target.value = "";
321
- if (file) onChange(await resolveFile(file));
322
- }
323
- }
324
- )
325
- ] }),
326
- value && /* @__PURE__ */ jsx("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
421
+ resolveFile && /* @__PURE__ */ jsxs(
422
+ "label",
423
+ {
424
+ style: parameterButtonStyle,
425
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
426
+ children: [
427
+ "Choose file\u2026",
428
+ /* @__PURE__ */ jsx2(
429
+ "input",
430
+ {
431
+ type: "file",
432
+ className: "sr-only",
433
+ accept: field.accept ?? "image/*",
434
+ disabled: off,
435
+ "aria-label": `${name} file`,
436
+ onChange: async (e) => {
437
+ const file = e.target.files?.[0];
438
+ e.target.value = "";
439
+ if (file) onChange(await resolveFile(file));
440
+ }
441
+ }
442
+ )
443
+ ]
444
+ }
445
+ ),
446
+ value && /* @__PURE__ */ jsx2(
447
+ "button",
448
+ {
449
+ type: "button",
450
+ style: parameterButtonStyle,
451
+ className: parameterButtonClass,
452
+ disabled: off,
453
+ onClick: () => onChange(""),
454
+ "aria-label": `Clear ${name}`,
455
+ children: "Clear"
456
+ }
457
+ )
327
458
  ] })
328
459
  ] })
329
460
  ] }),
330
- field.options && field.options.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ jsx(
461
+ field.options && field.options.length > 0 && /* @__PURE__ */ jsx2("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ jsx2(
331
462
  "button",
332
463
  {
333
464
  type: "button",
@@ -337,14 +468,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
337
468
  disabled: off,
338
469
  onClick: () => onChange(o.url),
339
470
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
340
- children: /* @__PURE__ */ jsx("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
471
+ children: /* @__PURE__ */ jsx2("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
341
472
  },
342
473
  o.url
343
474
  )) })
344
475
  ] });
345
476
  }
346
477
  function ParameterText({ field, value, onChange, disabled, id }) {
347
- return /* @__PURE__ */ jsx(
478
+ return /* @__PURE__ */ jsx2(
348
479
  ParameterCommitInput,
349
480
  {
350
481
  id,
@@ -360,7 +491,7 @@ function ParameterText({ field, value, onChange, disabled, id }) {
360
491
  }
361
492
  function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
362
493
  const keyed = state === "keyed";
363
- return /* @__PURE__ */ jsx(
494
+ return /* @__PURE__ */ jsx2(
364
495
  "button",
365
496
  {
366
497
  type: "button",
@@ -371,7 +502,7 @@ function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
371
502
  disabled,
372
503
  onClick: onToggle,
373
504
  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__ */ jsx("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
505
+ children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
375
506
  "path",
376
507
  {
377
508
  d: "M5 0.8 9.2 5 5 9.2 0.8 5Z",
@@ -389,23 +520,30 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
389
520
  switch (field.type) {
390
521
  case "number":
391
522
  case "int":
392
- return /* @__PURE__ */ jsx(ParameterSlider, { field, value, onChange: set, ...rest });
523
+ return /* @__PURE__ */ jsx2(ParameterSlider, { field, value, onChange: set, ...rest });
393
524
  case "boolean":
394
- return /* @__PURE__ */ jsx(ParameterToggle, { field, value, onChange: set, ...rest });
525
+ return /* @__PURE__ */ jsx2(ParameterToggle, { field, value, onChange: set, ...rest });
395
526
  case "choice":
396
- return /* @__PURE__ */ jsx(ParameterSelect, { field, value, onChange: set, ...rest });
527
+ return /* @__PURE__ */ jsx2(ParameterSelect, { field, value, onChange: set, ...rest });
397
528
  case "color":
398
- return /* @__PURE__ */ jsx(ParameterColor, { field, value, onChange: set, ...rest });
529
+ return /* @__PURE__ */ jsx2(ParameterColor, { field, value, onChange: set, ...rest });
399
530
  case "vector":
400
- return /* @__PURE__ */ jsx(ParameterVector, { field, value, onChange: set, ...rest });
531
+ return /* @__PURE__ */ jsx2(ParameterVector, { field, value, onChange: set, ...rest });
401
532
  case "image":
402
- return /* @__PURE__ */ jsx(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
533
+ return /* @__PURE__ */ jsx2(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
403
534
  case "text":
404
- return /* @__PURE__ */ jsx(ParameterText, { field, value, onChange: set, ...rest });
535
+ return /* @__PURE__ */ jsx2(ParameterText, { field, value, onChange: set, ...rest });
405
536
  }
406
537
  }
407
538
 
408
539
  export {
540
+ ParameterComponentsProvider,
541
+ useParameterComponents,
542
+ resolveParameterComponents,
543
+ parameterInputStyle,
544
+ parameterSelectStyle,
545
+ parameterButtonStyle,
546
+ parameterRangeStyle,
409
547
  parameterInputClass,
410
548
  parameterButtonClass,
411
549
  ParameterCommitInput,
@@ -1,6 +1,9 @@
1
1
  import {
2
- ParameterFieldControl
3
- } from "./chunk-5LFQ2UQZ.js";
2
+ ParameterFieldControl,
3
+ parameterSelectStyle,
4
+ resolveParameterComponents,
5
+ useParameterComponents
6
+ } from "./chunk-5RPB4WGT.js";
4
7
 
5
8
  // src/effects/useEffects.ts
6
9
  import { useEffect, useState } from "react";
@@ -154,36 +157,54 @@ function EffectParameters({
154
157
  renderControlAddon,
155
158
  fonts,
156
159
  disabled = false,
157
- className = ""
160
+ className = "",
161
+ components
158
162
  }) {
159
163
  const fields = useMemo2(() => effectParameterFields(description, { fonts }), [description, fonts]);
160
164
  const idBase = useId();
161
165
  const gesture = React3.useRef(null);
162
166
  const count = React3.useRef(0);
167
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
168
+ const handlePresetSelect = (name) => {
169
+ if (!name) return;
170
+ if (onPresetName) {
171
+ onPresetName(name);
172
+ } else if (onPreset) {
173
+ const preset = description.presets.find((p) => p.name === name);
174
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
175
+ }
176
+ };
163
177
  return /* @__PURE__ */ jsxs2("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
164
- (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ jsxs2(
178
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ jsx3(
179
+ CustomPresetSelect,
180
+ {
181
+ "aria-label": `${description.name} presets`,
182
+ label: `${description.name} presets`,
183
+ value: "",
184
+ disabled,
185
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
186
+ style: parameterSelectStyle,
187
+ options: [
188
+ { value: "", label: "Presets\u2026" },
189
+ ...description.presets.map((p) => ({ value: p.name, label: p.name }))
190
+ ],
191
+ onChange: (name) => handlePresetSelect(String(name))
192
+ }
193
+ ) : /* @__PURE__ */ jsxs2(
165
194
  "select",
166
195
  {
167
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
196
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
197
+ style: parameterSelectStyle,
168
198
  "aria-label": `${description.name} presets`,
169
199
  value: "",
170
200
  disabled,
171
- onChange: (e) => {
172
- const name = e.currentTarget.value;
173
- if (!name) return;
174
- if (onPresetName) {
175
- onPresetName(name);
176
- } else if (onPreset) {
177
- const preset = description.presets.find((p) => p.name === name);
178
- if (preset) onPreset({ ...description.defaults, ...preset.values });
179
- }
180
- },
201
+ onChange: (e) => handlePresetSelect(e.currentTarget.value),
181
202
  children: [
182
- /* @__PURE__ */ jsx3("option", { value: "", children: "Presets\u2026" }),
183
- description.presets.map((p) => /* @__PURE__ */ jsx3("option", { value: p.name, children: p.name }, p.name))
203
+ /* @__PURE__ */ jsx3("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
204
+ description.presets.map((p) => /* @__PURE__ */ jsx3("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
184
205
  ]
185
206
  }
186
- ),
207
+ )),
187
208
  fields.map((field) => {
188
209
  const label = parameterLabel(field);
189
210
  const inputId = `${idBase}-${field.id}`;
@@ -204,6 +225,7 @@ function EffectParameters({
204
225
  value,
205
226
  id: inputId,
206
227
  disabled: disabled || keyed,
228
+ components,
207
229
  onChange: (v) => onChange(field.id, v, gesture.current),
208
230
  onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
209
231
  onGestureEnd: () => gesture.current = null
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type EffectDescription, type EffectFieldOptions } from '@pixerate/editor/effects';
3
3
  import { type ParameterValue } from '@pixerate/editor/parameters';
4
+ import { type ParameterComponents } from '../parameters/controls.cjs';
4
5
  export interface EffectParametersProps {
5
6
  /** The effect's description (`describe`). */
6
7
  description: EffectDescription;
@@ -25,10 +26,12 @@ export interface EffectParametersProps {
25
26
  fonts?: EffectFieldOptions['fonts'];
26
27
  disabled?: boolean;
27
28
  className?: string;
29
+ /** Custom host controls (input, slider, select). */
30
+ components?: ParameterComponents;
28
31
  }
29
32
  /**
30
33
  * The parameter panel of an effect, generated from its JSON Schema controls: sliders for bounded
31
34
  * numbers, switches, choices, colour pickers, vectors and text, with each control's description,
32
35
  * per-control reset and the effect's presets.
33
36
  */
34
- export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, fonts, disabled, className }: EffectParametersProps): React.JSX.Element;
37
+ export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, fonts, disabled, className, components, }: EffectParametersProps): React.JSX.Element;