@pixerate/editor-react 0.114.3 → 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.
@@ -39,6 +39,7 @@ __export(image_editor_exports, {
39
39
  FreeTransformOptionsBar: () => FreeTransformOptionsBar,
40
40
  Histogram: () => Histogram,
41
41
  ImageCheckbox: () => ImageCheckbox,
42
+ ImageColor: () => ImageColor,
42
43
  ImageEditor: () => ImageEditor,
43
44
  ImageEditorCanvas: () => ImageEditorCanvas,
44
45
  ImageEditorControlsProvider: () => ImageEditorControlsProvider,
@@ -1140,6 +1141,22 @@ function ImageSelect(props) {
1140
1141
  options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: o.value, children: o.label }, o.value))
1141
1142
  ] });
1142
1143
  }
1144
+ function ImageColor(props) {
1145
+ const Host = useImageEditorControls().Color;
1146
+ if (Host) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Host, { ...props });
1147
+ const { value, label, alpha, disabled, onChange, className = "" } = props;
1148
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1149
+ "input",
1150
+ {
1151
+ type: "color",
1152
+ "aria-label": label,
1153
+ value: value.slice(0, 7),
1154
+ disabled,
1155
+ onChange: (e) => onChange(e.target.value + (alpha ? value.slice(7, 9) : "")),
1156
+ className: `${imageColorInputClass} ${className}`
1157
+ }
1158
+ );
1159
+ }
1143
1160
 
1144
1161
  // src/image-editor/ControlSlider.tsx
1145
1162
  var import_jsx_runtime5 = require("react/jsx-runtime");
@@ -1380,32 +1397,14 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
1380
1397
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
1381
1398
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ImageCheckbox, { label: "Tint", checked: layer.params.tint !== null, onChange: (on) => setParam(layer, "tint", on ? "#e1d3b3" : null) }),
1382
1399
  "Tint",
1383
- layer.params.tint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1384
- "input",
1385
- {
1386
- type: "color",
1387
- "aria-label": "Tint colour",
1388
- value: layer.params.tint,
1389
- onChange: (e) => setParam(layer, "tint", e.target.value),
1390
- className: "h-5 w-8 bg-transparent"
1391
- }
1392
- )
1400
+ layer.params.tint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ImageColor, { label: "Tint colour", value: layer.params.tint, onChange: (v) => setParam(layer, "tint", v) })
1393
1401
  ] })
1394
1402
  ] });
1395
1403
  case "photoFilter":
1396
1404
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-col gap-2", children: [
1397
1405
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
1398
1406
  "Filter colour",
1399
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1400
- "input",
1401
- {
1402
- type: "color",
1403
- "aria-label": "Filter colour",
1404
- value: layer.params.color,
1405
- onChange: (e) => setParam(layer, "color", e.target.value),
1406
- className: "h-5 w-8 bg-transparent"
1407
- }
1408
- )
1407
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ImageColor, { label: "Filter colour", value: layer.params.color, onChange: (v) => setParam(layer, "color", v) })
1409
1408
  ] }),
1410
1409
  controlsOf(layer).map((s) => slider(layer, s)),
1411
1410
  checkbox(layer, "preserveLuminosity", "Preserve luminosity")
@@ -1595,7 +1594,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
1595
1594
  }
1596
1595
  case "color":
1597
1596
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
1598
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "color", "aria-label": label, value: c.value, disabled: model.readOnly, onChange: (e) => change(effectId, c, e.target.value) }),
1597
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ImageColor, { label, value: c.value, disabled: model.readOnly, onChange: (v) => change(effectId, c, v) }),
1599
1598
  label
1600
1599
  ] }, c.key);
1601
1600
  case "checkbox":
@@ -3315,7 +3314,8 @@ function resolveParameterComponents(explicit, context) {
3315
3314
  return {
3316
3315
  input: explicit?.input ?? context?.input,
3317
3316
  slider: explicit?.slider ?? context?.slider,
3318
- select: explicit?.select ?? context?.select
3317
+ select: explicit?.select ?? context?.select,
3318
+ color: explicit?.color ?? context?.color
3319
3319
  };
3320
3320
  }
3321
3321
 
@@ -3549,7 +3549,8 @@ function ParameterSelect(props) {
3549
3549
  }
3550
3550
  );
3551
3551
  }
3552
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
3552
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
3553
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
3553
3554
  const [open, setOpen] = (0, import_react19.useState)(false);
3554
3555
  const containerRef = (0, import_react19.useRef)(null);
3555
3556
  const buttonRef = (0, import_react19.useRef)(null);
@@ -3581,6 +3582,22 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
3581
3582
  window.removeEventListener("keydown", onKeyDown, true);
3582
3583
  };
3583
3584
  }, [open]);
3585
+ if (CustomColor) {
3586
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3587
+ CustomColor,
3588
+ {
3589
+ id,
3590
+ value: shown,
3591
+ alpha,
3592
+ swatches: field.swatches,
3593
+ disabled: off,
3594
+ label: name,
3595
+ onChange,
3596
+ onGestureStart,
3597
+ onGestureEnd
3598
+ }
3599
+ );
3600
+ }
3584
3601
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
3585
3602
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
3586
3603
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
@@ -3901,10 +3918,26 @@ function ImageParameterSelect({ value, options, label, disabled, className, onCh
3901
3918
  }
3902
3919
  );
3903
3920
  }
3921
+ function ImageParameterColor({ value, alpha, label, disabled, className, onChange, onGestureStart, onGestureEnd }) {
3922
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3923
+ ImageColor,
3924
+ {
3925
+ value,
3926
+ alpha,
3927
+ label,
3928
+ disabled,
3929
+ className,
3930
+ onChange,
3931
+ onStart: onGestureStart,
3932
+ onEnd: onGestureEnd
3933
+ }
3934
+ );
3935
+ }
3904
3936
  function imageEditorParameterComponents(controls) {
3905
3937
  return {
3906
3938
  slider: controls.Range ? ImageParameterSlider : void 0,
3907
- select: controls.Select ? ImageParameterSelect : void 0
3939
+ select: controls.Select ? ImageParameterSelect : void 0,
3940
+ color: controls.Color ? ImageParameterColor : void 0
3908
3941
  };
3909
3942
  }
3910
3943
 
@@ -4204,29 +4237,11 @@ var BrushOptionsBar = ({ controller, className }) => {
4204
4237
  )) }),
4205
4238
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", role: "group", "aria-label": "Colours", children: [
4206
4239
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
4207
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4208
- "input",
4209
- {
4210
- type: "color",
4211
- "aria-label": "Foreground colour",
4212
- value: foreground,
4213
- onChange: (e) => controller.setPaintOptions({ foreground: e.target.value }),
4214
- className: imageColorInputClass
4215
- }
4216
- ),
4240
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ImageColor, { label: "Foreground colour", value: foreground, onChange: (fg) => controller.setPaintOptions({ foreground: fg }) }),
4217
4241
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", children: "FG" })
4218
4242
  ] }),
4219
4243
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center gap-1", children: [
4220
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4221
- "input",
4222
- {
4223
- type: "color",
4224
- "aria-label": "Background colour",
4225
- value: background,
4226
- onChange: (e) => controller.setPaintOptions({ background: e.target.value }),
4227
- className: imageColorInputClass
4228
- }
4229
- ),
4244
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ImageColor, { label: "Background colour", value: background, onChange: (bg) => controller.setPaintOptions({ background: bg }) }),
4230
4245
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-muted-foreground", children: "BG" })
4231
4246
  ] }),
4232
4247
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", title: "Swap colours (X)", className: imageChipClass(false), onClick: () => controller.swapPaintColors(), children: "Swap" }),
@@ -4836,32 +4851,12 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
4836
4851
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
4837
4852
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
4838
4853
  "Fill",
4839
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4840
- "input",
4841
- {
4842
- type: "color",
4843
- "aria-label": "Fill colour",
4844
- disabled: options.fill === null,
4845
- value: options.fill ?? "#4f46e5",
4846
- onChange: (e) => set({ fill: e.target.value }),
4847
- className: imageColorInputClass
4848
- }
4849
- )
4854
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
4850
4855
  ] }),
4851
4856
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
4852
4857
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
4853
4858
  "Stroke",
4854
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4855
- "input",
4856
- {
4857
- type: "color",
4858
- "aria-label": "Stroke colour",
4859
- disabled: options.stroke === null,
4860
- value: options.stroke ?? "#000000",
4861
- onChange: (e) => set({ stroke: e.target.value }),
4862
- className: imageColorInputClass
4863
- }
4864
- )
4859
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
4865
4860
  ] }),
4866
4861
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "flex items-center gap-1", children: [
4867
4862
  "Width",
@@ -4988,7 +4983,7 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
4988
4983
  ] }),
4989
4984
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${imageChipClass(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
4990
4985
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
4991
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("input", { type: "color", "aria-label": "Text colour", value: shown.color, onChange: (e) => style({ color: e.target.value }), className: imageColorInputClass })
4986
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
4992
4987
  ] }),
4993
4988
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor18.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
4994
4989
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
@@ -5643,15 +5638,7 @@ var ImageEditor = ({
5643
5638
  )) }),
5644
5639
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
5645
5640
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
5646
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
5647
- "input",
5648
- {
5649
- type: "color",
5650
- value: activeColor,
5651
- onChange: (e) => setActiveColor(e.target.value),
5652
- className: "w-8 h-8 rounded border border-border cursor-pointer bg-transparent"
5653
- }
5654
- ),
5641
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
5655
5642
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex-1 ml-2", children: [
5656
5643
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
5657
5644
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: "Width:" }),
@@ -6045,6 +6032,7 @@ var ImageEditor = ({
6045
6032
  FreeTransformOptionsBar,
6046
6033
  Histogram,
6047
6034
  ImageCheckbox,
6035
+ ImageColor,
6048
6036
  ImageEditor,
6049
6037
  ImageEditorCanvas,
6050
6038
  ImageEditorControlsProvider,
@@ -17,4 +17,4 @@ export * from './TypeOptionsBar.cjs';
17
17
  export * from './ImageProviderEffectsPanel.cjs';
18
18
  export * from './ImageEffectControls.cjs';
19
19
  export * from './PaintGradientEditor.cjs';
20
- export { ImageEditorControlsProvider, useImageEditorControls, ImageCheckbox, ImageRange, ImageSelect, type ImageEditorControls, type ImageCheckboxProps, type ImageRangeProps, type ImageSelectProps, type ImageSelectOption, } from './controls/controls.cjs';
20
+ export { ImageEditorControlsProvider, useImageEditorControls, ImageCheckbox, ImageRange, ImageSelect, ImageColor, type ImageEditorControls, type ImageCheckboxProps, type ImageRangeProps, type ImageSelectProps, type ImageSelectOption, type ImageColorProps, } from './controls/controls.cjs';
@@ -17,4 +17,4 @@ export * from './TypeOptionsBar.js';
17
17
  export * from './ImageProviderEffectsPanel.js';
18
18
  export * from './ImageEffectControls.js';
19
19
  export * from './PaintGradientEditor.js';
20
- export { ImageEditorControlsProvider, useImageEditorControls, ImageCheckbox, ImageRange, ImageSelect, type ImageEditorControls, type ImageCheckboxProps, type ImageRangeProps, type ImageSelectProps, type ImageSelectOption, } from './controls/controls.js';
20
+ export { ImageEditorControlsProvider, useImageEditorControls, ImageCheckbox, ImageRange, ImageSelect, ImageColor, type ImageEditorControls, type ImageCheckboxProps, type ImageRangeProps, type ImageSelectProps, type ImageSelectOption, type ImageColorProps, } from './controls/controls.js';
@@ -7,6 +7,7 @@ import {
7
7
  FreeTransformOptionsBar,
8
8
  Histogram,
9
9
  ImageCheckbox,
10
+ ImageColor,
10
11
  ImageEditor,
11
12
  ImageEditorCanvas,
12
13
  ImageEditorControlsProvider,
@@ -25,10 +26,10 @@ import {
25
26
  useImageEditorControls,
26
27
  useImageEffectsTools,
27
28
  useImageHistogram
28
- } from "../chunk-SH63DFOO.js";
29
+ } from "../chunk-2KXZLZAS.js";
29
30
  import "../chunk-AJCWF6SN.js";
30
- import "../chunk-TOGMXZM4.js";
31
- import "../chunk-354TA5QV.js";
31
+ import "../chunk-6BWTJ3EE.js";
32
+ import "../chunk-5RPB4WGT.js";
32
33
  import "../chunk-KIRIU53A.js";
33
34
  import "../chunk-3I7FOSLF.js";
34
35
  import "../chunk-GNO54NFG.js";
@@ -41,6 +42,7 @@ export {
41
42
  FreeTransformOptionsBar,
42
43
  Histogram,
43
44
  ImageCheckbox,
45
+ ImageColor,
44
46
  ImageEditor,
45
47
  ImageEditorCanvas,
46
48
  ImageEditorControlsProvider,
package/dist/index.cjs CHANGED
@@ -55,6 +55,7 @@ __export(src_exports, {
55
55
  Histogram: () => Histogram,
56
56
  HistoryManager: () => import_editor23.HistoryManager,
57
57
  ImageCheckbox: () => ImageCheckbox,
58
+ ImageColor: () => ImageColor,
58
59
  ImageEditor: () => ImageEditor,
59
60
  ImageEditorCanvas: () => ImageEditorCanvas,
60
61
  ImageEditorControlsProvider: () => ImageEditorControlsProvider,
@@ -4854,6 +4855,22 @@ function ImageSelect(props) {
4854
4855
  options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: o.value, children: o.label }, o.value))
4855
4856
  ] });
4856
4857
  }
4858
+ function ImageColor(props) {
4859
+ const Host = useImageEditorControls().Color;
4860
+ if (Host) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Host, { ...props });
4861
+ const { value, label, alpha, disabled, onChange, className = "" } = props;
4862
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4863
+ "input",
4864
+ {
4865
+ type: "color",
4866
+ "aria-label": label,
4867
+ value: value.slice(0, 7),
4868
+ disabled,
4869
+ onChange: (e) => onChange(e.target.value + (alpha ? value.slice(7, 9) : "")),
4870
+ className: `${imageColorInputClass} ${className}`
4871
+ }
4872
+ );
4873
+ }
4857
4874
 
4858
4875
  // src/image-editor/ControlSlider.tsx
4859
4876
  var import_jsx_runtime21 = require("react/jsx-runtime");
@@ -5094,32 +5111,14 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
5094
5111
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
5095
5112
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageCheckbox, { label: "Tint", checked: layer.params.tint !== null, onChange: (on) => setParam(layer, "tint", on ? "#e1d3b3" : null) }),
5096
5113
  "Tint",
5097
- layer.params.tint && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5098
- "input",
5099
- {
5100
- type: "color",
5101
- "aria-label": "Tint colour",
5102
- value: layer.params.tint,
5103
- onChange: (e) => setParam(layer, "tint", e.target.value),
5104
- className: "h-5 w-8 bg-transparent"
5105
- }
5106
- )
5114
+ layer.params.tint && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageColor, { label: "Tint colour", value: layer.params.tint, onChange: (v) => setParam(layer, "tint", v) })
5107
5115
  ] })
5108
5116
  ] });
5109
5117
  case "photoFilter":
5110
5118
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-2", children: [
5111
5119
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "flex items-center gap-2 text-foreground", children: [
5112
5120
  "Filter colour",
5113
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
5114
- "input",
5115
- {
5116
- type: "color",
5117
- "aria-label": "Filter colour",
5118
- value: layer.params.color,
5119
- onChange: (e) => setParam(layer, "color", e.target.value),
5120
- className: "h-5 w-8 bg-transparent"
5121
- }
5122
- )
5121
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageColor, { label: "Filter colour", value: layer.params.color, onChange: (v) => setParam(layer, "color", v) })
5123
5122
  ] }),
5124
5123
  controlsOf(layer).map((s) => slider(layer, s)),
5125
5124
  checkbox(layer, "preserveLuminosity", "Preserve luminosity")
@@ -5309,7 +5308,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
5309
5308
  }
5310
5309
  case "color":
5311
5310
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1.5 text-foreground", children: [
5312
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("input", { type: "color", "aria-label": label, value: c.value, disabled: model.readOnly, onChange: (e) => change(effectId, c, e.target.value) }),
5311
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageColor, { label, value: c.value, disabled: model.readOnly, onChange: (v) => change(effectId, c, v) }),
5313
5312
  label
5314
5313
  ] }, c.key);
5315
5314
  case "checkbox":
@@ -7029,7 +7028,8 @@ function resolveParameterComponents(explicit, context) {
7029
7028
  return {
7030
7029
  input: explicit?.input ?? context?.input,
7031
7030
  slider: explicit?.slider ?? context?.slider,
7032
- select: explicit?.select ?? context?.select
7031
+ select: explicit?.select ?? context?.select,
7032
+ color: explicit?.color ?? context?.color
7033
7033
  };
7034
7034
  }
7035
7035
 
@@ -7263,7 +7263,8 @@ function ParameterSelect(props) {
7263
7263
  }
7264
7264
  );
7265
7265
  }
7266
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
7266
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
7267
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
7267
7268
  const [open, setOpen] = (0, import_react55.useState)(false);
7268
7269
  const containerRef = (0, import_react55.useRef)(null);
7269
7270
  const buttonRef = (0, import_react55.useRef)(null);
@@ -7295,6 +7296,22 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
7295
7296
  window.removeEventListener("keydown", onKeyDown, true);
7296
7297
  };
7297
7298
  }, [open]);
7299
+ if (CustomColor) {
7300
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
7301
+ CustomColor,
7302
+ {
7303
+ id,
7304
+ value: shown,
7305
+ alpha,
7306
+ swatches: field.swatches,
7307
+ disabled: off,
7308
+ label: name,
7309
+ onChange,
7310
+ onGestureStart,
7311
+ onGestureEnd
7312
+ }
7313
+ );
7314
+ }
7298
7315
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
7299
7316
  /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-2", children: [
7300
7317
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
@@ -7615,10 +7632,26 @@ function ImageParameterSelect({ value, options, label, disabled, className, onCh
7615
7632
  }
7616
7633
  );
7617
7634
  }
7635
+ function ImageParameterColor({ value, alpha, label, disabled, className, onChange, onGestureStart, onGestureEnd }) {
7636
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7637
+ ImageColor,
7638
+ {
7639
+ value,
7640
+ alpha,
7641
+ label,
7642
+ disabled,
7643
+ className,
7644
+ onChange,
7645
+ onStart: onGestureStart,
7646
+ onEnd: onGestureEnd
7647
+ }
7648
+ );
7649
+ }
7618
7650
  function imageEditorParameterComponents(controls) {
7619
7651
  return {
7620
7652
  slider: controls.Range ? ImageParameterSlider : void 0,
7621
- select: controls.Select ? ImageParameterSelect : void 0
7653
+ select: controls.Select ? ImageParameterSelect : void 0,
7654
+ color: controls.Color ? ImageParameterColor : void 0
7622
7655
  };
7623
7656
  }
7624
7657
 
@@ -7918,29 +7951,11 @@ var BrushOptionsBar = ({ controller, className }) => {
7918
7951
  )) }),
7919
7952
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex items-center gap-2", role: "group", "aria-label": "Colours", children: [
7920
7953
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("label", { className: "flex items-center gap-1", children: [
7921
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7922
- "input",
7923
- {
7924
- type: "color",
7925
- "aria-label": "Foreground colour",
7926
- value: foreground,
7927
- onChange: (e) => controller.setPaintOptions({ foreground: e.target.value }),
7928
- className: imageColorInputClass
7929
- }
7930
- ),
7954
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ImageColor, { label: "Foreground colour", value: foreground, onChange: (fg) => controller.setPaintOptions({ foreground: fg }) }),
7931
7955
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "text-muted-foreground", children: "FG" })
7932
7956
  ] }),
7933
7957
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("label", { className: "flex items-center gap-1", children: [
7934
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7935
- "input",
7936
- {
7937
- type: "color",
7938
- "aria-label": "Background colour",
7939
- value: background,
7940
- onChange: (e) => controller.setPaintOptions({ background: e.target.value }),
7941
- className: imageColorInputClass
7942
- }
7943
- ),
7958
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ImageColor, { label: "Background colour", value: background, onChange: (bg) => controller.setPaintOptions({ background: bg }) }),
7944
7959
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "text-muted-foreground", children: "BG" })
7945
7960
  ] }),
7946
7961
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("button", { type: "button", title: "Swap colours (X)", className: imageChipClass(false), onClick: () => controller.swapPaintColors(), children: "Swap" }),
@@ -8550,32 +8565,12 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
8550
8565
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
8551
8566
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageCheckbox, { label: "Fill", checked: options.fill !== null, onChange: (on) => set({ fill: on ? "#4f46e5" : null }) }),
8552
8567
  "Fill",
8553
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
8554
- "input",
8555
- {
8556
- type: "color",
8557
- "aria-label": "Fill colour",
8558
- disabled: options.fill === null,
8559
- value: options.fill ?? "#4f46e5",
8560
- onChange: (e) => set({ fill: e.target.value }),
8561
- className: imageColorInputClass
8562
- }
8563
- )
8568
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageColor, { label: "Fill colour", disabled: options.fill === null, value: options.fill ?? "#4f46e5", onChange: (fill) => set({ fill }) })
8564
8569
  ] }),
8565
8570
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
8566
8571
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageCheckbox, { label: "Stroke", checked: options.stroke !== null, onChange: (on) => set({ stroke: on ? "#000000" : null }) }),
8567
8572
  "Stroke",
8568
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
8569
- "input",
8570
- {
8571
- type: "color",
8572
- "aria-label": "Stroke colour",
8573
- disabled: options.stroke === null,
8574
- value: options.stroke ?? "#000000",
8575
- onChange: (e) => set({ stroke: e.target.value }),
8576
- className: imageColorInputClass
8577
- }
8578
- )
8573
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageColor, { label: "Stroke colour", disabled: options.stroke === null, value: options.stroke ?? "#000000", onChange: (stroke) => set({ stroke }) })
8579
8574
  ] }),
8580
8575
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { className: "flex items-center gap-1", children: [
8581
8576
  "Width",
@@ -8702,7 +8697,7 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
8702
8697
  ] }),
8703
8698
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-pressed": shown.fontWeight >= 600, className: `${imageChipClass(shown.fontWeight >= 600)} font-bold`, onClick: () => style({ fontWeight: shown.fontWeight >= 600 ? 400 : 700 }), children: "B" }),
8704
8699
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-pressed": shown.italic, className: `${imageChipClass(shown.italic)} italic`, onClick: () => style({ italic: !shown.italic }), children: "I" }),
8705
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { type: "color", "aria-label": "Text colour", value: shown.color, onChange: (e) => style({ color: e.target.value }), className: imageColorInputClass })
8700
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
8706
8701
  ] }),
8707
8702
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor18.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
8708
8703
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
@@ -9357,15 +9352,7 @@ var ImageEditor = ({
9357
9352
  )) }),
9358
9353
  /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex items-center gap-2 mt-2", children: [
9359
9354
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("label", { className: "text-muted-foreground", children: "Color:" }),
9360
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9361
- "input",
9362
- {
9363
- type: "color",
9364
- value: activeColor,
9365
- onChange: (e) => setActiveColor(e.target.value),
9366
- className: "w-8 h-8 rounded border border-border cursor-pointer bg-transparent"
9367
- }
9368
- ),
9355
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ImageColor, { label: "Annotation colour", value: activeColor, onChange: setActiveColor }),
9369
9356
  /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex-1 ml-2", children: [
9370
9357
  /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex justify-between text-muted-foreground mb-0.5", children: [
9371
9358
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: "Width:" }),
@@ -12454,6 +12441,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
12454
12441
  Histogram,
12455
12442
  HistoryManager,
12456
12443
  ImageCheckbox,
12444
+ ImageColor,
12457
12445
  ImageEditor,
12458
12446
  ImageEditorCanvas,
12459
12447
  ImageEditorControlsProvider,
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  FreeTransformOptionsBar,
32
32
  Histogram,
33
33
  ImageCheckbox,
34
+ ImageColor,
34
35
  ImageEditor,
35
36
  ImageEditorCanvas,
36
37
  ImageEditorControlsProvider,
@@ -49,10 +50,10 @@ import {
49
50
  useImageEditorControls,
50
51
  useImageEffectsTools,
51
52
  useImageHistogram
52
- } from "./chunk-SH63DFOO.js";
53
+ } from "./chunk-2KXZLZAS.js";
53
54
  import "./chunk-AJCWF6SN.js";
54
- import "./chunk-TOGMXZM4.js";
55
- import "./chunk-354TA5QV.js";
55
+ import "./chunk-6BWTJ3EE.js";
56
+ import "./chunk-5RPB4WGT.js";
56
57
  import "./chunk-KIRIU53A.js";
57
58
  import "./chunk-3I7FOSLF.js";
58
59
  import {
@@ -2547,6 +2548,7 @@ export {
2547
2548
  Histogram,
2548
2549
  HistoryManager2 as HistoryManager,
2549
2550
  ImageCheckbox,
2551
+ ImageColor,
2550
2552
  ImageEditor,
2551
2553
  ImageEditorCanvas,
2552
2554
  ImageEditorControlsProvider,
@@ -2624,7 +2624,8 @@ function resolveParameterComponents(explicit, context) {
2624
2624
  return {
2625
2625
  input: explicit?.input ?? context?.input,
2626
2626
  slider: explicit?.slider ?? context?.slider,
2627
- select: explicit?.select ?? context?.select
2627
+ select: explicit?.select ?? context?.select,
2628
+ color: explicit?.color ?? context?.color
2628
2629
  };
2629
2630
  }
2630
2631
 
@@ -2858,7 +2859,8 @@ function ParameterSelect(props) {
2858
2859
  }
2859
2860
  );
2860
2861
  }
2861
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
2862
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
2863
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
2862
2864
  const [open, setOpen] = (0, import_react21.useState)(false);
2863
2865
  const containerRef = (0, import_react21.useRef)(null);
2864
2866
  const buttonRef = (0, import_react21.useRef)(null);
@@ -2890,6 +2892,22 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2890
2892
  window.removeEventListener("keydown", onKeyDown, true);
2891
2893
  };
2892
2894
  }, [open]);
2895
+ if (CustomColor) {
2896
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2897
+ CustomColor,
2898
+ {
2899
+ id,
2900
+ value: shown,
2901
+ alpha,
2902
+ swatches: field.swatches,
2903
+ disabled: off,
2904
+ label: name,
2905
+ onChange,
2906
+ onGestureStart,
2907
+ onGestureEnd
2908
+ }
2909
+ );
2910
+ }
2893
2911
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2894
2912
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2895
2913
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -5,8 +5,8 @@ import {
5
5
  EffectParameters,
6
6
  EffectsBrowser,
7
7
  useEffectDescription
8
- } from "../chunk-TOGMXZM4.js";
9
- import "../chunk-354TA5QV.js";
8
+ } from "../chunk-6BWTJ3EE.js";
9
+ import "../chunk-5RPB4WGT.js";
10
10
  import "../chunk-KIRIU53A.js";
11
11
  import "../chunk-3I7FOSLF.js";
12
12
  import {
@@ -56,10 +56,30 @@ export interface ParameterSelectProps {
56
56
  onChange: (value: string | number) => void;
57
57
  }
58
58
  /** Host form controls for parameter panels. Any left out fall back to the default controls. */
59
+ /** Props for a custom colour control in parameter panels. */
60
+ export interface ParameterColorProps {
61
+ id?: string;
62
+ /** `#rrggbb`, or `#rrggbbaa` with `alpha`. */
63
+ value: string;
64
+ /** Whether the field has an alpha channel. */
65
+ alpha?: boolean;
66
+ /** Suggested colours for the field, if it has any. */
67
+ swatches?: readonly string[];
68
+ disabled?: boolean;
69
+ /** The field's label. */
70
+ label: string;
71
+ className?: string;
72
+ style?: React.CSSProperties;
73
+ onChange: (value: string) => void;
74
+ /** A pick starts: changes until `onGestureEnd` merge into one undo step. */
75
+ onGestureStart?: () => void;
76
+ onGestureEnd?: () => void;
77
+ }
59
78
  export interface ParameterComponents {
60
79
  input?: ComponentType<ParameterInputProps>;
61
80
  slider?: ComponentType<ParameterSliderProps>;
62
81
  select?: ComponentType<ParameterSelectProps>;
82
+ color?: ComponentType<ParameterColorProps>;
63
83
  }
64
84
  /** Makes the parameter panels inside it use the host's controls. */
65
85
  export declare function ParameterComponentsProvider({ components, children }: {