@pixerate/editor-react 0.71.0 → 0.72.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.
@@ -1254,7 +1254,19 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
1254
1254
 
1255
1255
  // src/image-editor/BrushOptionsBar.tsx
1256
1256
  import { useEffect as useEffect6, useState as useState7 } from "react";
1257
- import { BRUSH_OPTION_CONTROLS, MIXER_MIXING_OPTIONS, MIXER_OPTION_CONTROLS, PAINT_TOOLS, rgbUnitToHex } from "@pixerate/editor/image-editor";
1257
+ import {
1258
+ BRUSH_OPTION_CONTROLS,
1259
+ MIXER_MIXING_OPTIONS,
1260
+ MIXER_OPTION_CONTROLS,
1261
+ PAINT_TOOLS,
1262
+ RETOUCH_CHOICES,
1263
+ RETOUCH_OPTION_CONTROLS,
1264
+ RETOUCH_TOGGLES,
1265
+ cloneSourceLabel,
1266
+ isRetouchPaintTool,
1267
+ rgbUnitToHex,
1268
+ setRetouchChoice
1269
+ } from "@pixerate/editor/image-editor";
1258
1270
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1259
1271
  var chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
1260
1272
  var BrushOptionsBar = ({ controller, className }) => {
@@ -1262,7 +1274,8 @@ var BrushOptionsBar = ({ controller, className }) => {
1262
1274
  useEffect6(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
1263
1275
  const [error, setError] = useState7(null);
1264
1276
  const state = controller.getState();
1265
- const { brush, foreground, background, mixer, mixerLoad } = state.paint;
1277
+ const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource } = state.paint;
1278
+ const tool = state.activeTool;
1266
1279
  const attempt = (fn) => {
1267
1280
  try {
1268
1281
  setError(null);
@@ -1272,12 +1285,12 @@ var BrushOptionsBar = ({ controller, className }) => {
1272
1285
  }
1273
1286
  };
1274
1287
  return /* @__PURE__ */ jsxs7("div", { className: `flex flex-col gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "brush-options", children: [
1275
- /* @__PURE__ */ jsx7("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Paint tools", children: PAINT_TOOLS.map((t) => /* @__PURE__ */ jsx7(
1288
+ /* @__PURE__ */ jsx7("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Paint tools", children: PAINT_TOOLS.map((t) => /* @__PURE__ */ jsx7(
1276
1289
  "button",
1277
1290
  {
1278
1291
  type: "button",
1279
1292
  "aria-pressed": state.activeTool === t.id,
1280
- title: `${t.label} (${t.shortcut})`,
1293
+ title: t.shortcut ? `${t.label} (${t.shortcut})` : t.label,
1281
1294
  className: chip(state.activeTool === t.id),
1282
1295
  onClick: () => controller.setTool(t.id),
1283
1296
  children: t.label
@@ -1379,6 +1392,41 @@ var BrushOptionsBar = ({ controller, className }) => {
1379
1392
  ] })
1380
1393
  ] })
1381
1394
  ] }),
1395
+ isRetouchPaintTool(tool) && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-2 border-t border-slate-800 pt-2", role: "group", "aria-label": "Retouch options", "data-testid": "retouch-options", children: [
1396
+ (tool === "clone" || tool === "heal") && /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
1397
+ /* @__PURE__ */ jsx7("span", { className: "text-slate-400", "data-testid": "clone-source", children: cloneSourceLabel(controller) }),
1398
+ cloneSource && /* @__PURE__ */ jsx7("button", { type: "button", title: "Forget the source point", className: chip(false), onClick: () => controller.setCloneSource(null), children: "Clear source" })
1399
+ ] }),
1400
+ RETOUCH_CHOICES.filter((c) => c.tools.includes(tool)).map((choice) => /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": choice.label, children: [
1401
+ /* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: choice.label }),
1402
+ choice.options.map((o) => /* @__PURE__ */ jsx7(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ "aria-pressed": retouch[choice.id] === o.id,
1407
+ title: o.title,
1408
+ className: chip(retouch[choice.id] === o.id),
1409
+ onClick: () => setRetouchChoice(controller, choice.id, o.id),
1410
+ children: o.label
1411
+ },
1412
+ o.id
1413
+ ))
1414
+ ] }, choice.id)),
1415
+ RETOUCH_OPTION_CONTROLS.filter((c) => c.tools.includes(tool)).map((spec) => /* @__PURE__ */ jsx7(ControlSlider, { spec, value: retouch[spec.id], onChange: (v) => controller.setPaintOptions({ retouch: { [spec.id]: v } }) }, spec.id)),
1416
+ /* @__PURE__ */ jsx7("div", { className: "flex flex-wrap gap-3 text-slate-300", children: RETOUCH_TOGGLES.filter((t) => t.tools.includes(tool)).map((t) => /* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-1.5", children: [
1417
+ /* @__PURE__ */ jsx7(
1418
+ "input",
1419
+ {
1420
+ type: "checkbox",
1421
+ "aria-label": t.label,
1422
+ checked: retouch[t.id],
1423
+ onChange: (e) => controller.setPaintOptions({ retouch: { [t.id]: e.target.checked } }),
1424
+ className: "accent-indigo-500"
1425
+ }
1426
+ ),
1427
+ t.label
1428
+ ] }, t.id)) })
1429
+ ] }),
1382
1430
  /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-3 text-slate-300", role: "group", "aria-label": "Pressure", children: [
1383
1431
  /* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-1.5", children: [
1384
1432
  /* @__PURE__ */ jsx7(
@@ -2347,7 +2395,7 @@ var ImageEditor = ({
2347
2395
  } catch {
2348
2396
  }
2349
2397
  const [first] = paintSamples(e);
2350
- setPaintError(paintGestureRef.current.down(first));
2398
+ setPaintError(paintGestureRef.current.down({ ...first, altKey: e.altKey }));
2351
2399
  };
2352
2400
  const handlePaintPointerMove = (e) => {
2353
2401
  if (handleTransformPointerMove(e)) return;
@@ -3641,4 +3689,4 @@ export {
3641
3689
  TypeOptionsBar,
3642
3690
  ImageEditor
3643
3691
  };
3644
- //# sourceMappingURL=chunk-63FQB5BT.js.map
3692
+ //# sourceMappingURL=chunk-YAFNCBDA.js.map