@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.
@@ -1666,7 +1666,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
1666
1666
 
1667
1667
  // src/image-editor/FreeTransformOptionsBar.tsx
1668
1668
  import { useEffect as useEffect7, useState as useState10 } from "react";
1669
- import { FREE_TRANSFORM_FIELDS, FREE_TRANSFORM_MODE_OPTIONS, INTERPOLATIONS, TRANSFORM_ANCHORS } from "@pixerate/editor/image-editor";
1669
+ import { FREE_TRANSFORM_FIELDS, FREE_TRANSFORM_MODE_OPTIONS, INTERPOLATIONS, TRANSFORM_ANCHORS, WARP_GRID_OPTIONS, WARP_STYLE_OPTIONS } from "@pixerate/editor/image-editor";
1670
1670
  import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
1671
1671
  var chip2 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
1672
1672
  var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
@@ -1675,6 +1675,11 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
1675
1675
  useEffect7(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
1676
1676
  const bar = tool.bar();
1677
1677
  if (!tool.active || !bar) return null;
1678
+ const warp = tool.warpBar();
1679
+ const warpNumber = (key, raw) => {
1680
+ const v = Number(raw);
1681
+ if (raw.trim() !== "" && Number.isFinite(v) && v !== warp[key]) tool.setWarp({ [key]: Math.max(-100, Math.min(100, v)) });
1682
+ };
1678
1683
  const apply = (field, raw) => {
1679
1684
  const v = Number(raw);
1680
1685
  if (raw.trim() !== "" && Number.isFinite(v) && Math.abs(v - bar[field]) > 1e-9) tool.setField(field, v);
@@ -1682,7 +1687,66 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
1682
1687
  return /* @__PURE__ */ jsxs10("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: [
1683
1688
  /* @__PURE__ */ jsx10("div", { className: "flex gap-1", role: "group", "aria-label": "Transform mode", children: FREE_TRANSFORM_MODE_OPTIONS.map((m) => /* @__PURE__ */ jsx10("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)) }),
1684
1689
  /* @__PURE__ */ jsx10("div", { className: "grid grid-cols-3 gap-px", role: "group", "aria-label": "Reference point", children: TRANSFORM_ANCHORS.map((a) => /* @__PURE__ */ jsx10("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)) }),
1685
- FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1", title: f.title, children: [
1690
+ tool.mode === "warp" && /* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap items-center gap-2", role: "group", "aria-label": "Warp options", children: [
1691
+ /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1", children: [
1692
+ /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Warp" }),
1693
+ /* @__PURE__ */ jsx10("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: WARP_STYLE_OPTIONS.map((o) => /* @__PURE__ */ jsx10("option", { value: o.id, children: o.label }, o.id)) })
1694
+ ] }),
1695
+ ["bend", "horizontal", "vertical"].map((k) => /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1", children: [
1696
+ /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: k === "bend" ? "Bend" : k === "horizontal" ? "H" : "V" }),
1697
+ /* @__PURE__ */ jsx10(
1698
+ "input",
1699
+ {
1700
+ type: "number",
1701
+ "aria-label": k === "bend" ? "Warp bend in percent" : `Warp ${k} distortion in percent`,
1702
+ defaultValue: warp[k],
1703
+ min: -100,
1704
+ max: 100,
1705
+ disabled: warp.style === "custom",
1706
+ className: "w-14 rounded border border-slate-700 bg-slate-900 px-1 py-0.5 text-right disabled:opacity-40",
1707
+ onBlur: (e) => warpNumber(k, e.currentTarget.value),
1708
+ onKeyDown: (e) => {
1709
+ if (e.key === "Enter") {
1710
+ e.preventDefault();
1711
+ e.stopPropagation();
1712
+ warpNumber(k, e.currentTarget.value);
1713
+ }
1714
+ }
1715
+ },
1716
+ `${k}:${warp[k]}`
1717
+ ),
1718
+ /* @__PURE__ */ jsx10("span", { className: "text-slate-500", children: "%" })
1719
+ ] }, k)),
1720
+ /* @__PURE__ */ jsx10(
1721
+ "button",
1722
+ {
1723
+ type: "button",
1724
+ title: "Bend along the vertical axis",
1725
+ "aria-pressed": warp.orientation === "vertical",
1726
+ disabled: warp.style === "custom",
1727
+ className: chip2(warp.orientation === "vertical"),
1728
+ onClick: () => tool.setWarp({ orientation: warp.orientation === "vertical" ? "horizontal" : "vertical" }),
1729
+ children: "Vertical"
1730
+ }
1731
+ ),
1732
+ /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1", children: [
1733
+ /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Grid" }),
1734
+ /* @__PURE__ */ jsx10(
1735
+ "select",
1736
+ {
1737
+ "aria-label": "Warp grid",
1738
+ value: WARP_GRID_OPTIONS.find((g) => g.columns === warp.columns && g.rows === warp.rows)?.id ?? "1x1",
1739
+ onChange: (e) => {
1740
+ const g = WARP_GRID_OPTIONS.find((o) => o.id === e.target.value);
1741
+ tool.setWarp({ columns: g.columns, rows: g.rows });
1742
+ },
1743
+ className: "rounded border border-slate-700 bg-slate-900 px-1 py-0.5",
1744
+ children: WARP_GRID_OPTIONS.map((g) => /* @__PURE__ */ jsx10("option", { value: g.id, children: g.label }, g.id))
1745
+ }
1746
+ )
1747
+ ] })
1748
+ ] }),
1749
+ tool.mode !== "warp" && FREE_TRANSFORM_FIELDS.map((f) => /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1", title: f.title, children: [
1686
1750
  /* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: f.label }),
1687
1751
  /* @__PURE__ */ jsx10(
1688
1752
  "input",
@@ -3226,4 +3290,4 @@ export {
3226
3290
  FreeTransformOptionsBar,
3227
3291
  ImageEditor
3228
3292
  };
3229
- //# sourceMappingURL=chunk-OSBDCFF4.js.map
3293
+ //# sourceMappingURL=chunk-LCTQWNTL.js.map