@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.
Files changed (41) 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/chart/index.cjs +2 -2
  6. package/dist/chart/index.js +1 -1
  7. package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
  8. package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
  9. package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
  10. package/dist/{chunk-N2F53ESC.js → chunk-VUSYAHIU.js} +2 -2
  11. package/dist/effects/EffectParameters.d.cts +4 -1
  12. package/dist/effects/EffectParameters.d.ts +4 -1
  13. package/dist/effects/index.cjs +348 -221
  14. package/dist/effects/index.js +2 -2
  15. package/dist/image-editor/ImageEffectControls.d.cts +4 -1
  16. package/dist/image-editor/ImageEffectControls.d.ts +4 -1
  17. package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
  18. package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
  19. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  20. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  21. package/dist/image-editor/index.cjs +868 -697
  22. package/dist/image-editor/index.js +3 -3
  23. package/dist/index.cjs +1390 -1219
  24. package/dist/index.js +4 -4
  25. package/dist/paint-editor/index.cjs +335 -208
  26. package/dist/paint-editor/index.js +2 -2
  27. package/dist/parameters/ParametersPanel.d.cts +4 -1
  28. package/dist/parameters/ParametersPanel.d.ts +4 -1
  29. package/dist/parameters/controls.d.cts +72 -0
  30. package/dist/parameters/controls.d.ts +72 -0
  31. package/dist/parameters/fields.d.cts +19 -6
  32. package/dist/parameters/fields.d.ts +19 -6
  33. package/dist/parameters/index.cjs +350 -183
  34. package/dist/parameters/index.d.cts +1 -0
  35. package/dist/parameters/index.d.ts +1 -0
  36. package/dist/parameters/index.js +70 -14
  37. package/dist/vector/index.cjs +321 -194
  38. package/dist/vector/index.js +2 -2
  39. package/dist/video-editor/index.cjs +418 -291
  40. package/dist/video-editor/index.js +2 -2
  41. package/package.json +3 -3
@@ -3248,12 +3248,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
3248
3248
  }
3249
3249
 
3250
3250
  // src/effects/EffectParameters.tsx
3251
- var import_react22 = __toESM(require("react"), 1);
3251
+ var import_react23 = __toESM(require("react"), 1);
3252
3252
  var import_effects3 = require("@pixerate/editor/effects");
3253
3253
  var import_parameters2 = require("@pixerate/editor/parameters");
3254
3254
 
3255
3255
  // src/parameters/fields.tsx
3256
- var import_react21 = require("react");
3256
+ var import_react22 = require("react");
3257
3257
  var import_parameters = require("@pixerate/editor/parameters");
3258
3258
 
3259
3259
  // src/color/index.ts
@@ -4295,18 +4295,57 @@ function useResolvedColor(value, scheme) {
4295
4295
  // src/color/index.ts
4296
4296
  __reExport(color_exports, require("@pixerate/editor/color"));
4297
4297
 
4298
- // src/parameters/fields.tsx
4298
+ // src/parameters/controls.tsx
4299
+ var import_react21 = require("react");
4299
4300
  var import_jsx_runtime26 = require("react/jsx-runtime");
4301
+ var ParameterComponentsContext = (0, import_react21.createContext)({});
4302
+ function useParameterComponents() {
4303
+ return (0, import_react21.useContext)(ParameterComponentsContext);
4304
+ }
4305
+ function resolveParameterComponents(explicit, context) {
4306
+ return {
4307
+ input: explicit?.input ?? context?.input,
4308
+ slider: explicit?.slider ?? context?.slider,
4309
+ select: explicit?.select ?? context?.select
4310
+ };
4311
+ }
4312
+
4313
+ // src/parameters/fields.tsx
4314
+ var import_jsx_runtime27 = require("react/jsx-runtime");
4315
+ var parameterInputStyle = import_parameters.parameterThemeStyles.input;
4316
+ var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
4317
+ var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
4318
+ var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
4300
4319
  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";
4301
4320
  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";
4302
4321
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
4303
- function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
4322
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
4323
+ const inputRef = (0, import_react22.useRef)(null);
4324
+ const lastCommitted = (0, import_react22.useRef)(null);
4325
+ (0, import_react22.useLayoutEffect)(() => {
4326
+ lastCommitted.current = null;
4327
+ const el = inputRef.current;
4328
+ if (el && el.value !== value) el.value = value;
4329
+ }, [value]);
4304
4330
  const commit = (el) => {
4305
- if (el.value !== value) onCommit(el.value, el);
4331
+ const text = el.value;
4332
+ if (text === value || text === lastCommitted.current) return;
4333
+ onCommit(text, el);
4334
+ lastCommitted.current = el.value === text ? text : null;
4306
4335
  };
4336
+ const commitRef = (0, import_react22.useRef)(commit);
4337
+ commitRef.current = commit;
4338
+ (0, import_react22.useEffect)(() => {
4339
+ const el = inputRef.current;
4340
+ if (!el) return;
4341
+ const change = () => commitRef.current(el);
4342
+ el.addEventListener("change", change);
4343
+ return () => el.removeEventListener("change", change);
4344
+ }, [multiline]);
4307
4345
  const keyDown = (e) => {
4308
4346
  onKeyDown?.(e);
4309
4347
  if (e.defaultPrevented) return;
4348
+ if (e.key === "Tab") commit(e.currentTarget);
4310
4349
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
4311
4350
  e.preventDefault();
4312
4351
  commit(e.currentTarget);
@@ -4316,86 +4355,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
4316
4355
  const props = {
4317
4356
  defaultValue: value,
4318
4357
  className: className ?? parameterInputClass,
4358
+ style: { ...parameterInputStyle, ...style },
4319
4359
  onBlur: (e) => commit(e.currentTarget),
4320
4360
  onKeyDown: keyDown,
4321
4361
  ...rest
4322
4362
  };
4323
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { type: "text", ...props }, value);
4363
+ const forwarded = rest.ref;
4364
+ const setRef = (el) => {
4365
+ inputRef.current = el;
4366
+ if (typeof forwarded === "function") forwarded(el);
4367
+ else if (forwarded) forwarded.current = el;
4368
+ };
4369
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("input", { type: "text", ...props, ref: setRef });
4324
4370
  }
4325
4371
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
4326
- function ParameterNumberInput({
4327
- field,
4328
- value,
4329
- onChange,
4330
- disabled,
4331
- id,
4332
- "aria-label": ariaLabel
4333
- }) {
4334
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
4335
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4336
- ParameterCommitInput,
4337
- {
4338
- id,
4339
- inputMode: "decimal",
4340
- "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
4341
- value: plainNumber(field, value),
4342
- disabled: disabled || field.readOnly,
4343
- className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
4344
- onCommit: (text, input) => {
4345
- const n = (0, import_parameters.parseParameterNumberInput)(field, text);
4346
- if (n === null || n === value) input.value = plainNumber(field, value);
4347
- else onChange(n);
4348
- },
4349
- onKeyDown: (e) => {
4350
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
4351
- e.preventDefault();
4352
- const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
4353
- onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
4354
- }
4355
- }
4356
- ),
4357
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
4372
+ function ParameterNumberInput(props) {
4373
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
4374
+ const ctx = useParameterComponents();
4375
+ const resolved = resolveParameterComponents(components, ctx);
4376
+ const CustomInput = resolved.input;
4377
+ const plain = plainNumber(field, value);
4378
+ const handleCommit = (text, input) => {
4379
+ const n = (0, import_parameters.parseParameterNumberInput)(field, text);
4380
+ if (n === null || n === value) {
4381
+ if (input) input.value = plain;
4382
+ } else {
4383
+ onChange(n);
4384
+ }
4385
+ };
4386
+ const handleKeyDown = (e) => {
4387
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
4388
+ e.preventDefault();
4389
+ const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
4390
+ onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
4391
+ };
4392
+ const inputProps = {
4393
+ id,
4394
+ inputMode: "decimal",
4395
+ "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
4396
+ value: plain,
4397
+ disabled: disabled || field.readOnly,
4398
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
4399
+ style: parameterInputStyle,
4400
+ onCommit: handleCommit,
4401
+ onKeyDown: handleKeyDown
4402
+ };
4403
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
4404
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterCommitInput, { ...inputProps }),
4405
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
4358
4406
  ] });
4359
4407
  }
4360
4408
  function ParameterSlider(props) {
4361
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
4362
- const dragging = (0, import_react21.useRef)(false);
4409
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
4410
+ const ctx = useParameterComponents();
4411
+ const resolved = resolveParameterComponents(components, ctx);
4412
+ const CustomSlider = resolved.slider;
4413
+ const dragging = (0, import_react22.useRef)(false);
4414
+ const start = () => {
4415
+ if (dragging.current) return;
4416
+ dragging.current = true;
4417
+ onGestureStart?.();
4418
+ };
4363
4419
  const end = () => {
4364
4420
  if (!dragging.current) return;
4365
4421
  dragging.current = false;
4366
4422
  onGestureEnd?.();
4367
4423
  };
4368
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props });
4424
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterNumberInput, { ...props });
4369
4425
  const step = (0, import_parameters.parameterStep)(field);
4370
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4371
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4426
+ const sliderProps = {
4427
+ "aria-label": (0, import_parameters.parameterLabel)(field),
4428
+ "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
4429
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
4430
+ min: field.min ?? 0,
4431
+ max: field.max ?? 100,
4432
+ step,
4433
+ value,
4434
+ disabled: disabled || field.readOnly,
4435
+ className: rangeClass,
4436
+ style: parameterRangeStyle
4437
+ };
4438
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4439
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4440
+ CustomSlider,
4441
+ {
4442
+ ...sliderProps,
4443
+ id: props.id ? `${props.id}-slider` : void 0,
4444
+ label: (0, import_parameters.parameterLabel)(field),
4445
+ onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
4446
+ onGestureStart: start,
4447
+ onGestureEnd: end
4448
+ }
4449
+ ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4372
4450
  "input",
4373
4451
  {
4374
4452
  type: "range",
4375
- "aria-label": (0, import_parameters.parameterLabel)(field),
4376
- "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
4377
- min: field.min,
4378
- max: field.max,
4379
- step,
4380
- value,
4381
- disabled: disabled || field.readOnly,
4382
- className: rangeClass,
4383
- onPointerDown: () => {
4384
- if (dragging.current) return;
4385
- dragging.current = true;
4386
- onGestureStart?.();
4387
- },
4453
+ ...sliderProps,
4454
+ onPointerDown: start,
4388
4455
  onPointerUp: end,
4389
4456
  onPointerCancel: end,
4390
4457
  onBlur: end,
4391
4458
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
4392
4459
  }
4393
4460
  ),
4394
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
4461
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
4395
4462
  ] });
4396
4463
  }
4397
4464
  function ParameterToggle({ field, value, onChange, disabled, id }) {
4398
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4465
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4399
4466
  "button",
4400
4467
  {
4401
4468
  type: "button",
@@ -4406,7 +4473,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
4406
4473
  disabled: disabled || field.readOnly,
4407
4474
  onClick: () => onChange(!value),
4408
4475
  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"}`,
4409
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4476
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4410
4477
  "span",
4411
4478
  {
4412
4479
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -4415,11 +4482,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
4415
4482
  }
4416
4483
  );
4417
4484
  }
4418
- function ParameterSelect({ field, value, onChange, disabled, id }) {
4485
+ function ParameterSelect(props) {
4486
+ const { field, value, onChange, disabled, id, components } = props;
4487
+ const ctx = useParameterComponents();
4488
+ const resolved = resolveParameterComponents(components, ctx);
4489
+ const CustomSelect = resolved.select;
4419
4490
  const options = (0, import_parameters.getChoiceOptions)(field);
4420
4491
  const off = disabled || field.readOnly;
4421
4492
  if (field.control === "segmented") {
4422
- return /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)(
4493
+ return /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)(
4423
4494
  "button",
4424
4495
  {
4425
4496
  type: "button",
@@ -4434,8 +4505,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
4434
4505
  String(o.value)
4435
4506
  )) });
4436
4507
  }
4508
+ if (CustomSelect) {
4509
+ const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
4510
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4511
+ CustomSelect,
4512
+ {
4513
+ id,
4514
+ label: (0, import_parameters.parameterLabel)(field),
4515
+ "aria-label": (0, import_parameters.parameterLabel)(field),
4516
+ value,
4517
+ options: customOptions,
4518
+ disabled: off,
4519
+ className: parameterInputClass,
4520
+ style: parameterSelectStyle,
4521
+ onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
4522
+ }
4523
+ );
4524
+ }
4437
4525
  const index = options.findIndex((o) => o.value === value);
4438
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4526
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4439
4527
  "select",
4440
4528
  {
4441
4529
  id,
@@ -4447,22 +4535,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
4447
4535
  if (option) onChange(option.value);
4448
4536
  },
4449
4537
  className: parameterInputClass,
4450
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
4538
+ style: parameterSelectStyle,
4539
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
4451
4540
  }
4452
4541
  );
4453
4542
  }
4454
4543
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
4455
- const [open, setOpen] = (0, import_react21.useState)(false);
4456
- const containerRef = (0, import_react21.useRef)(null);
4457
- const buttonRef = (0, import_react21.useRef)(null);
4458
- const popoverRef = (0, import_react21.useRef)(null);
4544
+ const [open, setOpen] = (0, import_react22.useState)(false);
4545
+ const containerRef = (0, import_react22.useRef)(null);
4546
+ const buttonRef = (0, import_react22.useRef)(null);
4547
+ const popoverRef = (0, import_react22.useRef)(null);
4459
4548
  const alpha = !!field.alpha;
4460
4549
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
4461
4550
  const rgb = hex.slice(0, 7);
4462
4551
  const shown = alpha ? hex : rgb;
4463
4552
  const off = disabled || field.readOnly;
4464
4553
  const name = (0, import_parameters.parameterLabel)(field);
4465
- (0, import_react21.useEffect)(() => {
4554
+ (0, import_react22.useEffect)(() => {
4466
4555
  if (!open) return;
4467
4556
  const onPointerDown = (e) => {
4468
4557
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -4483,9 +4572,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4483
4572
  window.removeEventListener("keydown", onKeyDown, true);
4484
4573
  };
4485
4574
  }, [open]);
4486
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
4487
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4488
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4575
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
4576
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4577
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4489
4578
  "button",
4490
4579
  {
4491
4580
  ref: buttonRef,
@@ -4496,10 +4585,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4496
4585
  disabled: off,
4497
4586
  onClick: () => setOpen((prev) => !prev),
4498
4587
  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",
4499
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
4588
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
4500
4589
  }
4501
4590
  ),
4502
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4591
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4503
4592
  ParameterCommitInput,
4504
4593
  {
4505
4594
  id,
@@ -4515,7 +4604,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4515
4604
  }
4516
4605
  )
4517
4606
  ] }),
4518
- open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4607
+ open && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4519
4608
  "div",
4520
4609
  {
4521
4610
  ref: popoverRef,
@@ -4529,7 +4618,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4529
4618
  },
4530
4619
  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",
4531
4620
  style: { background: "var(--popover, var(--background, #fff))" },
4532
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4621
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4533
4622
  ColorPicker,
4534
4623
  {
4535
4624
  value: shown,
@@ -4545,13 +4634,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4545
4634
  )
4546
4635
  ] });
4547
4636
  }
4548
- function ParameterVector({ field, value, onChange, disabled, id }) {
4637
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
4549
4638
  const size = (0, import_parameters.vectorSize)(field);
4550
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
4639
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
4551
4640
  const component = (0, import_parameters.vectorComponentField)(field, i);
4552
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
4553
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
4554
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4641
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
4642
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
4643
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4555
4644
  ParameterNumberInput,
4556
4645
  {
4557
4646
  field: component,
@@ -4559,6 +4648,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
4559
4648
  id: i === 0 ? id : void 0,
4560
4649
  "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
4561
4650
  disabled: disabled || field.readOnly,
4651
+ components,
4562
4652
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
4563
4653
  }
4564
4654
  )
@@ -4568,11 +4658,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
4568
4658
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4569
4659
  const off = disabled || field.readOnly;
4570
4660
  const name = (0, import_parameters.parameterLabel)(field);
4571
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "space-y-1.5", children: [
4572
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4573
- /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
4574
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
4575
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4661
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "space-y-1.5", children: [
4662
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4663
+ /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
4664
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
4665
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4576
4666
  ParameterCommitInput,
4577
4667
  {
4578
4668
  id,
@@ -4583,30 +4673,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4583
4673
  onCommit: (text) => onChange(text.trim())
4584
4674
  }
4585
4675
  ),
4586
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex gap-1", children: [
4587
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
4588
- "Choose file\u2026",
4589
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4590
- "input",
4591
- {
4592
- type: "file",
4593
- className: "sr-only",
4594
- accept: field.accept ?? "image/*",
4595
- disabled: off,
4596
- "aria-label": `${name} file`,
4597
- onChange: async (e) => {
4598
- const file = e.target.files?.[0];
4599
- e.target.value = "";
4600
- if (file) onChange(await resolveFile(file));
4601
- }
4602
- }
4603
- )
4604
- ] }),
4605
- value && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
4676
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex gap-1", children: [
4677
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4678
+ "label",
4679
+ {
4680
+ style: parameterButtonStyle,
4681
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
4682
+ children: [
4683
+ "Choose file\u2026",
4684
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4685
+ "input",
4686
+ {
4687
+ type: "file",
4688
+ className: "sr-only",
4689
+ accept: field.accept ?? "image/*",
4690
+ disabled: off,
4691
+ "aria-label": `${name} file`,
4692
+ onChange: async (e) => {
4693
+ const file = e.target.files?.[0];
4694
+ e.target.value = "";
4695
+ if (file) onChange(await resolveFile(file));
4696
+ }
4697
+ }
4698
+ )
4699
+ ]
4700
+ }
4701
+ ),
4702
+ value && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4703
+ "button",
4704
+ {
4705
+ type: "button",
4706
+ style: parameterButtonStyle,
4707
+ className: parameterButtonClass,
4708
+ disabled: off,
4709
+ onClick: () => onChange(""),
4710
+ "aria-label": `Clear ${name}`,
4711
+ children: "Clear"
4712
+ }
4713
+ )
4606
4714
  ] })
4607
4715
  ] })
4608
4716
  ] }),
4609
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4717
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4610
4718
  "button",
4611
4719
  {
4612
4720
  type: "button",
@@ -4616,14 +4724,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4616
4724
  disabled: off,
4617
4725
  onClick: () => onChange(o.url),
4618
4726
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
4619
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
4727
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
4620
4728
  },
4621
4729
  o.url
4622
4730
  )) })
4623
4731
  ] });
4624
4732
  }
4625
4733
  function ParameterText({ field, value, onChange, disabled, id }) {
4626
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4734
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4627
4735
  ParameterCommitInput,
4628
4736
  {
4629
4737
  id,
@@ -4642,24 +4750,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
4642
4750
  switch (field.type) {
4643
4751
  case "number":
4644
4752
  case "int":
4645
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
4753
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
4646
4754
  case "boolean":
4647
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
4755
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
4648
4756
  case "choice":
4649
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
4757
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
4650
4758
  case "color":
4651
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
4759
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
4652
4760
  case "vector":
4653
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
4761
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
4654
4762
  case "image":
4655
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
4763
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
4656
4764
  case "text":
4657
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterText, { field, value, onChange: set, ...rest });
4765
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterText, { field, value, onChange: set, ...rest });
4658
4766
  }
4659
4767
  }
4660
4768
 
4661
4769
  // src/effects/EffectParameters.tsx
4662
- var import_jsx_runtime27 = require("react/jsx-runtime");
4770
+ var import_jsx_runtime28 = require("react/jsx-runtime");
4663
4771
  function EffectParameters({
4664
4772
  description,
4665
4773
  values,
@@ -4671,56 +4779,75 @@ function EffectParameters({
4671
4779
  renderControlAddon,
4672
4780
  fonts,
4673
4781
  disabled = false,
4674
- className = ""
4782
+ className = "",
4783
+ components
4675
4784
  }) {
4676
- const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
4677
- const idBase = (0, import_react22.useId)();
4678
- const gesture = import_react22.default.useRef(null);
4679
- const count = import_react22.default.useRef(0);
4680
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
4681
- (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4785
+ const fields = (0, import_react23.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
4786
+ const idBase = (0, import_react23.useId)();
4787
+ const gesture = import_react23.default.useRef(null);
4788
+ const count = import_react23.default.useRef(0);
4789
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
4790
+ const handlePresetSelect = (name) => {
4791
+ if (!name) return;
4792
+ if (onPresetName) {
4793
+ onPresetName(name);
4794
+ } else if (onPreset) {
4795
+ const preset = description.presets.find((p) => p.name === name);
4796
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
4797
+ }
4798
+ };
4799
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
4800
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4801
+ CustomPresetSelect,
4802
+ {
4803
+ "aria-label": `${description.name} presets`,
4804
+ label: `${description.name} presets`,
4805
+ value: "",
4806
+ disabled,
4807
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
4808
+ style: parameterSelectStyle,
4809
+ options: [
4810
+ { value: "", label: "Presets\u2026" },
4811
+ ...description.presets.map((p) => ({ value: p.name, label: p.name }))
4812
+ ],
4813
+ onChange: (name) => handlePresetSelect(String(name))
4814
+ }
4815
+ ) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4682
4816
  "select",
4683
4817
  {
4684
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
4818
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
4819
+ style: parameterSelectStyle,
4685
4820
  "aria-label": `${description.name} presets`,
4686
4821
  value: "",
4687
4822
  disabled,
4688
- onChange: (e) => {
4689
- const name = e.currentTarget.value;
4690
- if (!name) return;
4691
- if (onPresetName) {
4692
- onPresetName(name);
4693
- } else if (onPreset) {
4694
- const preset = description.presets.find((p) => p.name === name);
4695
- if (preset) onPreset({ ...description.defaults, ...preset.values });
4696
- }
4697
- },
4823
+ onChange: (e) => handlePresetSelect(e.currentTarget.value),
4698
4824
  children: [
4699
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: "", children: "Presets\u2026" }),
4700
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: p.name, children: p.name }, p.name))
4825
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
4826
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
4701
4827
  ]
4702
4828
  }
4703
- ),
4829
+ )),
4704
4830
  fields.map((field) => {
4705
4831
  const label = (0, import_parameters2.parameterLabel)(field);
4706
4832
  const inputId = `${idBase}-${field.id}`;
4707
4833
  const keyed = keyframed?.has(field.id) ?? false;
4708
4834
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
4709
4835
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
4710
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
4711
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1.5", children: [
4712
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
4713
- keyed && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
4836
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
4837
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1.5", children: [
4838
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
4839
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
4714
4840
  renderControlAddon?.(field.id),
4715
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime27.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" })
4841
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime28.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" })
4716
4842
  ] }),
4717
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4843
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4718
4844
  ParameterFieldControl,
4719
4845
  {
4720
4846
  field,
4721
4847
  value,
4722
4848
  id: inputId,
4723
4849
  disabled: disabled || keyed,
4850
+ components,
4724
4851
  onChange: (v) => onChange(field.id, v, gesture.current),
4725
4852
  onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
4726
4853
  onGestureEnd: () => gesture.current = null
@@ -4728,25 +4855,25 @@ function EffectParameters({
4728
4855
  )
4729
4856
  ] }, field.id);
4730
4857
  }),
4731
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
4858
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
4732
4859
  ] });
4733
4860
  }
4734
4861
 
4735
4862
  // src/vector/VectorProviderEffectsPanel.tsx
4736
- var import_react23 = require("react");
4737
- var import_jsx_runtime28 = require("react/jsx-runtime");
4863
+ var import_react24 = require("react");
4864
+ var import_jsx_runtime29 = require("react/jsx-runtime");
4738
4865
  var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
4739
4866
  function Controls({ controller, group }) {
4740
4867
  const provider = controller.effectsProvider;
4741
4868
  const tag = group.providerEffect;
4742
4869
  const { description, error } = useEffectDescription(provider, tag.effect);
4743
- const [message, setMessage] = (0, import_react23.useState)(null);
4870
+ const [message, setMessage] = (0, import_react24.useState)(null);
4744
4871
  const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
4745
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: the shapes are kept as they are." });
4746
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
4747
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
4748
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
4749
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4872
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: the shapes are kept as they are." });
4873
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
4874
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
4875
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
4876
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4750
4877
  EffectParameters,
4751
4878
  {
4752
4879
  description,
@@ -4756,18 +4883,18 @@ function Controls({ controller, group }) {
4756
4883
  onPreset: (v) => run(controller.updateVectorEffect(group.id, v))
4757
4884
  }
4758
4885
  ),
4759
- message && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4886
+ message && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4760
4887
  ] });
4761
4888
  }
4762
4889
  function VectorProviderEffectsPanel({ controller, className = "" }) {
4763
4890
  const state = useVectorEditorState(controller);
4764
- const provider = (0, import_react23.useSyncExternalStore)(
4891
+ const provider = (0, import_react24.useSyncExternalStore)(
4765
4892
  (cb) => controller.effects.subscribe(cb),
4766
4893
  () => controller.effects.provider,
4767
4894
  () => controller.effects.provider
4768
4895
  );
4769
- const [browse, setBrowse] = (0, import_react23.useState)(false);
4770
- const [message, setMessage] = (0, import_react23.useState)(null);
4896
+ const [browse, setBrowse] = (0, import_react24.useState)(false);
4897
+ const [message, setMessage] = (0, import_react24.useState)(null);
4771
4898
  void state;
4772
4899
  const groups = controller.vectorEffectGroups();
4773
4900
  const selected = groups.filter((g) => state.selection.includes(g.id));
@@ -4775,60 +4902,60 @@ function VectorProviderEffectsPanel({ controller, className = "" }) {
4775
4902
  setMessage(null);
4776
4903
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
4777
4904
  };
4778
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Vector effects", "data-vector-provider-effects": "", children: [
4779
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
4780
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
4781
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse, onClick: () => setBrowse(!browse), children: "Add effect\u2026" })
4905
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Vector effects", "data-vector-provider-effects": "", children: [
4906
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1", children: [
4907
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
4908
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse, onClick: () => setBrowse(!browse), children: "Add effect\u2026" })
4782
4909
  ] }),
4783
- !provider && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effect groups are kept as shapes." }),
4784
- browse && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(false), run(() => controller.addVectorEffect(e.id))) }),
4785
- selected.map((g) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-effect-group": g.id, children: [
4786
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
4787
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium", children: g.providerEffect.name ?? g.providerEffect.effect }),
4788
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: btn, title: "Keep the shapes as a plain group", onClick: () => run(() => controller.detachVectorEffect(g.id)), children: "Detach" })
4910
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effect groups are kept as shapes." }),
4911
+ browse && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(false), run(() => controller.addVectorEffect(e.id))) }),
4912
+ selected.map((g) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-effect-group": g.id, children: [
4913
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1", children: [
4914
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium", children: g.providerEffect.name ?? g.providerEffect.effect }),
4915
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: btn, title: "Keep the shapes as a plain group", onClick: () => run(() => controller.detachVectorEffect(g.id)), children: "Detach" })
4789
4916
  ] }),
4790
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Controls, { controller, group: g })
4917
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Controls, { controller, group: g })
4791
4918
  ] }, g.id)),
4792
- groups.length > 0 && !selected.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
4919
+ groups.length > 0 && !selected.length && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
4793
4920
  "Select an effect group (",
4794
4921
  groups.length,
4795
4922
  " in the drawing) to change it."
4796
4923
  ] }),
4797
- message && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4924
+ message && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4798
4925
  ] });
4799
4926
  }
4800
4927
 
4801
4928
  // src/vector/VectorEditor.tsx
4802
- var import_jsx_runtime29 = require("react/jsx-runtime");
4929
+ var import_jsx_runtime30 = require("react/jsx-runtime");
4803
4930
  function VectorEditor({ controller, tools, showStylePanel = true, height = 520, canvasProps, effects, className }) {
4804
4931
  useEffects(controller, effects);
4805
4932
  const effectsShown = !!effects || controller.vectorEffectGroups().length > 0;
4806
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-vector-editor": "", children: [
4807
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorToolbar, { controller, tools }),
4808
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
4809
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "relative min-h-[320px] flex-1 overflow-hidden rounded-md border border-border bg-muted/40", style: { height }, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorCanvas, { controller, ...canvasProps }) }),
4810
- showStylePanel && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-full shrink-0 flex-col gap-2 md:w-56", children: [
4811
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorStylePanel, { controller, className: "rounded-md border border-border p-3" }),
4812
- effectsShown && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorProviderEffectsPanel, { controller, className: "rounded-md border border-border p-3" })
4933
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-vector-editor": "", children: [
4934
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorToolbar, { controller, tools }),
4935
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
4936
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "relative min-h-[320px] flex-1 overflow-hidden rounded-md border border-border bg-muted/40", style: { height }, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorCanvas, { controller, ...canvasProps }) }),
4937
+ showStylePanel && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full shrink-0 flex-col gap-2 md:w-56", children: [
4938
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorStylePanel, { controller, className: "rounded-md border border-border p-3" }),
4939
+ effectsShown && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorProviderEffectsPanel, { controller, className: "rounded-md border border-border p-3" })
4813
4940
  ] })
4814
4941
  ] })
4815
4942
  ] });
4816
4943
  }
4817
4944
 
4818
4945
  // src/vector/VectorGeneratePanel.tsx
4819
- var import_react24 = require("react");
4946
+ var import_react25 = require("react");
4820
4947
  var import_vector21 = require("@pixerate/editor/vector");
4821
- var import_jsx_runtime30 = require("react/jsx-runtime");
4948
+ var import_jsx_runtime31 = require("react/jsx-runtime");
4822
4949
  var buttonClass17 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
4823
4950
  var selectClass15 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
4824
4951
  var AS_LABELS = { color: "Traced in colour", threshold: "Traced in one colour", mosaic: "Mosaic", halftone: "Halftone", lowPoly: "Low poly", hatch: "Engraving" };
4825
4952
  function VectorGeneratePanel({ controller, models, generate, className }) {
4826
4953
  const usable = (0, import_vector21.vectorArtModels)(models);
4827
- const [prompt, setPrompt] = (0, import_react24.useState)("");
4828
- const [model, setModel] = (0, import_react24.useState)("");
4829
- const [as, setAs] = (0, import_react24.useState)("color");
4830
- const [busy, setBusy] = (0, import_react24.useState)(false);
4831
- const [message, setMessage] = (0, import_react24.useState)(null);
4954
+ const [prompt, setPrompt] = (0, import_react25.useState)("");
4955
+ const [model, setModel] = (0, import_react25.useState)("");
4956
+ const [as, setAs] = (0, import_react25.useState)("color");
4957
+ const [busy, setBusy] = (0, import_react25.useState)(false);
4958
+ const [message, setMessage] = (0, import_react25.useState)(null);
4832
4959
  const chosen = usable.find((m) => m.id === model) ?? usable[0];
4833
4960
  if (!usable.length) return null;
4834
4961
  const run = async () => {
@@ -4838,18 +4965,18 @@ function VectorGeneratePanel({ controller, models, generate, className }) {
4838
4965
  setBusy(false);
4839
4966
  setMessage(r.ok ? null : r.message ?? "Generation failed.");
4840
4967
  };
4841
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `space-y-1 ${className ?? ""}`, "data-vector-generate-panel": "", "aria-label": "Generate", children: [
4842
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-1", children: [
4843
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Generate" }),
4844
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("select", { "aria-label": "Generation model", className: selectClass15, value: chosen.id, onChange: (e) => setModel(e.target.value), children: usable.map((m) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: m.id, children: m.name ?? m.id }, m.id)) }),
4845
- chosen.media === "image" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("select", { "aria-label": "Image to vectors", className: selectClass15, value: as, onChange: (e) => setAs(e.target.value), children: import_vector21.VECTOR_GENERATED_IMAGE_AS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: a, children: AS_LABELS[a] }, a)) })
4968
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: `space-y-1 ${className ?? ""}`, "data-vector-generate-panel": "", "aria-label": "Generate", children: [
4969
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
4970
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Generate" }),
4971
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("select", { "aria-label": "Generation model", className: selectClass15, value: chosen.id, onChange: (e) => setModel(e.target.value), children: usable.map((m) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: m.id, children: m.name ?? m.id }, m.id)) }),
4972
+ chosen.media === "image" && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("select", { "aria-label": "Image to vectors", className: selectClass15, value: as, onChange: (e) => setAs(e.target.value), children: import_vector21.VECTOR_GENERATED_IMAGE_AS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: a, children: AS_LABELS[a] }, a)) })
4846
4973
  ] }),
4847
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-1", children: [
4848
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "w-16" }),
4849
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { type: "text", "aria-label": "Prompt", placeholder: "Describe the art\u2026", className: "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1.5 text-xs", value: prompt, onChange: (e) => setPrompt(e.target.value), onKeyDown: (e) => e.key === "Enter" && prompt.trim() && !busy && void run() }),
4850
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: buttonClass17, "data-vector-generate-action": "", disabled: !prompt.trim() || busy, onClick: () => void run(), children: busy ? "Generating\u2026" : "Generate" })
4974
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
4975
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-16" }),
4976
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "text", "aria-label": "Prompt", placeholder: "Describe the art\u2026", className: "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1.5 text-xs", value: prompt, onChange: (e) => setPrompt(e.target.value), onKeyDown: (e) => e.key === "Enter" && prompt.trim() && !busy && void run() }),
4977
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: buttonClass17, "data-vector-generate-action": "", disabled: !prompt.trim() || busy, onClick: () => void run(), children: busy ? "Generating\u2026" : "Generate" })
4851
4978
  ] }),
4852
- message && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[11px] text-red-600", children: message })
4979
+ message && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[11px] text-red-600", children: message })
4853
4980
  ] });
4854
4981
  }
4855
4982
  // Annotate the CommonJS export names for ESM import in node: