@pixerate/editor-react 0.65.0 → 0.67.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.
@@ -211,9 +211,10 @@ interface FreeTransformOptionsBarProps {
211
211
  }
212
212
  /**
213
213
  * Free Transform's options bar (Photoshop's): the mode switch (Free, Rotate, Skew, Distort,
214
- * Perspective), the reference-point locator, X / Y of the reference point, W / H in percent with
215
- * the proportional chain, the angle and skews, the interpolation, and Commit (Enter) / Cancel
216
- * (Esc). Typed values apply on Enter or when the field loses focus.
214
+ * Perspective, Warp), the reference-point locator, X / Y of the reference point, W / H in percent
215
+ * with the proportional chain, the angle and skews, the interpolation, and Commit (Enter) / Cancel
216
+ * (Esc). In Warp mode the numbers give way to the warp style, bend, horizontal and vertical
217
+ * distortion, orientation and grid. Typed values apply on Enter or when the field loses focus.
217
218
  */
218
219
  declare const FreeTransformOptionsBar: React__default.FC<FreeTransformOptionsBarProps>;
219
220
 
@@ -211,9 +211,10 @@ interface FreeTransformOptionsBarProps {
211
211
  }
212
212
  /**
213
213
  * Free Transform's options bar (Photoshop's): the mode switch (Free, Rotate, Skew, Distort,
214
- * Perspective), the reference-point locator, X / Y of the reference point, W / H in percent with
215
- * the proportional chain, the angle and skews, the interpolation, and Commit (Enter) / Cancel
216
- * (Esc). Typed values apply on Enter or when the field loses focus.
214
+ * Perspective, Warp), the reference-point locator, X / Y of the reference point, W / H in percent
215
+ * with the proportional chain, the angle and skews, the interpolation, and Commit (Enter) / Cancel
216
+ * (Esc). In Warp mode the numbers give way to the warp style, bend, horizontal and vertical
217
+ * distortion, orientation and grid. Typed values apply on Enter or when the field loses focus.
217
218
  */
218
219
  declare const FreeTransformOptionsBar: React__default.FC<FreeTransformOptionsBarProps>;
219
220
 
@@ -12,7 +12,7 @@ import {
12
12
  SelectionOptionsBar,
13
13
  useImageEditor,
14
14
  useImageHistogram
15
- } from "../chunk-OSBDCFF4.js";
15
+ } from "../chunk-LCTQWNTL.js";
16
16
  export {
17
17
  AdjustmentLayersPanel,
18
18
  BrushOptionsBar,
package/dist/index.cjs CHANGED
@@ -5243,6 +5243,11 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
5243
5243
  (0, import_react43.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
5244
5244
  const bar = tool.bar();
5245
5245
  if (!tool.active || !bar) return null;
5246
+ const warp = tool.warpBar();
5247
+ const warpNumber = (key, raw) => {
5248
+ const v = Number(raw);
5249
+ if (raw.trim() !== "" && Number.isFinite(v) && v !== warp[key]) tool.setWarp({ [key]: Math.max(-100, Math.min(100, v)) });
5250
+ };
5246
5251
  const apply = (field, raw) => {
5247
5252
  const v = Number(raw);
5248
5253
  if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
@@ -5250,7 +5255,66 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
5250
5255
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: `flex flex-wrap items-center gap-2 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "free-transform-options", role: "toolbar", "aria-label": "Free Transform options", children: [
5251
5256
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: import_image_editor11.FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", title: m.title, "aria-pressed": tool.mode === m.id, className: chip2(tool.mode === m.id), onClick: () => tool.setMode(m.id), children: m.label }, m.id)) }),
5252
5257
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: import_image_editor11.TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", "aria-label": `Reference point ${a}`, title: `Reference point: ${a}`, className: "h-2.5 w-2.5 rounded-sm bg-slate-700 hover:bg-indigo-500", onClick: () => tool.setReference(a) }, a)) }),
5253
- import_image_editor11.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
5258
+ tool.mode === "warp" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
5259
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center gap-1", children: [
5260
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-slate-400", children: "Warp" }),
5261
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("select", { "aria-label": "Warp style", value: warp.style, onChange: (e) => tool.setWarp({ style: e.target.value }), className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5", children: import_image_editor11.WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: o.id, children: o.label }, o.id)) })
5262
+ ] }),
5263
+ ["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center gap-1", children: [
5264
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-slate-400", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
5265
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5266
+ "input",
5267
+ {
5268
+ type: "number",
5269
+ "aria-label": k === "bend" ? "Warp bend in percent" : `Warp ${k} distortion in percent`,
5270
+ defaultValue: warp[k],
5271
+ min: -100,
5272
+ max: 100,
5273
+ disabled: warp.style === "custom",
5274
+ className: "w-14 rounded border border-slate-700 bg-slate-900 px-1 py-0.5 text-right disabled:opacity-40",
5275
+ onBlur: (e) => warpNumber(k, e.currentTarget.value),
5276
+ onKeyDown: (e) => {
5277
+ if (e.key === "Enter") {
5278
+ e.preventDefault();
5279
+ e.stopPropagation();
5280
+ warpNumber(k, e.currentTarget.value);
5281
+ }
5282
+ }
5283
+ },
5284
+ `${k}:${warp[k]}`
5285
+ ),
5286
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-slate-500", children: "%" })
5287
+ ] }, k)),
5288
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5289
+ "button",
5290
+ {
5291
+ type: "button",
5292
+ title: "Bend along the vertical axis",
5293
+ "aria-pressed": warp.orientation === "vertical",
5294
+ disabled: warp.style === "custom",
5295
+ className: chip2(warp.orientation === "vertical"),
5296
+ onClick: () => tool.setWarp({ orientation: warp.orientation === "vertical" ? "horizontal" : "vertical" }),
5297
+ children: "Vertical"
5298
+ }
5299
+ ),
5300
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center gap-1", children: [
5301
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-slate-400", children: "Grid" }),
5302
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5303
+ "select",
5304
+ {
5305
+ "aria-label": "Warp grid",
5306
+ value: import_image_editor11.WARP_GRID_OPTIONS.find((g) => g.columns === warp.columns && g.rows === warp.rows)?.id ?? "1x1",
5307
+ onChange: (e) => {
5308
+ const g = import_image_editor11.WARP_GRID_OPTIONS.find((o) => o.id === e.target.value);
5309
+ tool.setWarp({ columns: g.columns, rows: g.rows });
5310
+ },
5311
+ className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5",
5312
+ children: import_image_editor11.WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: g.id, children: g.label }, g.id))
5313
+ }
5314
+ )
5315
+ ] })
5316
+ ] }),
5317
+ tool.mode !== "warp" && import_image_editor11.FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center gap-1", title: f.title, children: [
5254
5318
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-slate-400", children: f.label }),
5255
5319
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
5256
5320
  "input",