@pixerate/editor-react 0.114.2 → 0.114.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/animation-editor/index.cjs +342 -215
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +520 -393
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
  6. package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
  7. package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.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 +348 -221
  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/parameterControls.d.cts +4 -0
  17. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  18. package/dist/image-editor/index.cjs +868 -697
  19. package/dist/image-editor/index.js +3 -3
  20. package/dist/index.cjs +1388 -1217
  21. package/dist/index.js +3 -3
  22. package/dist/paint-editor/index.cjs +335 -208
  23. package/dist/paint-editor/index.js +2 -2
  24. package/dist/parameters/ParametersPanel.d.cts +4 -1
  25. package/dist/parameters/ParametersPanel.d.ts +4 -1
  26. package/dist/parameters/controls.d.cts +72 -0
  27. package/dist/parameters/controls.d.ts +72 -0
  28. package/dist/parameters/fields.d.cts +19 -6
  29. package/dist/parameters/fields.d.ts +19 -6
  30. package/dist/parameters/index.cjs +350 -183
  31. package/dist/parameters/index.d.cts +1 -0
  32. package/dist/parameters/index.d.ts +1 -0
  33. package/dist/parameters/index.js +70 -14
  34. package/dist/vector/index.cjs +321 -194
  35. package/dist/vector/index.js +2 -2
  36. package/dist/video-editor/index.cjs +418 -291
  37. package/dist/video-editor/index.js +2 -2
  38. package/package.json +3 -3
@@ -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-354TA5QV.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;
@@ -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.js';
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;