@pixerate/editor-react 0.167.0 → 0.170.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.
- package/dist/{chunk-65EL63YS.js → chunk-2UD3JH4W.js} +1137 -1376
- package/dist/chunk-EP6C5N54.js +406 -0
- package/dist/image-editor/LayerEffectsPanel.d.cts +3 -2
- package/dist/image-editor/LayerEffectsPanel.d.ts +3 -2
- package/dist/image-editor/index.cjs +121 -121
- package/dist/image-editor/index.js +10 -9
- package/dist/index.cjs +121 -121
- package/dist/index.js +10 -9
- package/dist/paint-editor/PaintLayersPanel.d.cts +2 -1
- package/dist/paint-editor/PaintLayersPanel.d.ts +2 -1
- package/dist/paint-editor/StickerPanel.d.cts +1 -1
- package/dist/paint-editor/StickerPanel.d.ts +1 -1
- package/dist/paint-editor/StickerPicker.d.cts +17 -0
- package/dist/paint-editor/StickerPicker.d.ts +17 -0
- package/dist/paint-editor/index.cjs +947 -626
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +464 -373
- package/package.json +3 -3
- package/dist/chunk-AJCWF6SN.js +0 -125
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.170.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.249.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.249.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|
package/dist/chunk-AJCWF6SN.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
// src/paint-editor/PaintGradientEditorView.tsx
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
var button = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
|
|
5
|
-
var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
|
|
6
|
-
var number = "w-16 rounded bg-slate-800 px-1 py-0.5 text-[11px]";
|
|
7
|
-
var pct = (v) => Math.round(v * 1e3) / 10;
|
|
8
|
-
var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
9
|
-
const {
|
|
10
|
-
PAINT_GRADIENT_MAPPINGS,
|
|
11
|
-
PAINT_GRADIENT_MAPPING_LABELS,
|
|
12
|
-
PAINT_GRADIENT_PRESETS,
|
|
13
|
-
PAINT_GRADIENT_REPEATS,
|
|
14
|
-
PAINT_GRADIENT_REPEAT_LABELS,
|
|
15
|
-
PAINT_GRADIENT_SPACES,
|
|
16
|
-
PAINT_GRADIENT_SPACE_LABELS,
|
|
17
|
-
addPaintGradientStop,
|
|
18
|
-
paintGradientMappingFor,
|
|
19
|
-
paintSourceCss,
|
|
20
|
-
removePaintGradientStop,
|
|
21
|
-
reversePaintGradient,
|
|
22
|
-
updatePaintGradientStop
|
|
23
|
-
} = kit;
|
|
24
|
-
const [selected, setSelected] = useState(0);
|
|
25
|
-
const sel = Math.min(selected, value.stops.length - 1);
|
|
26
|
-
const stop = value.stops[sel];
|
|
27
|
-
const map = value.map;
|
|
28
|
-
const stopHex = (c) => c === "paint" ? colors.paint : c === "secondary" ? colors.secondary : c;
|
|
29
|
-
const patchStop = (patch) => {
|
|
30
|
-
const r = updatePaintGradientStop(value, sel, patch);
|
|
31
|
-
setSelected(r.index);
|
|
32
|
-
onChange(r.paint);
|
|
33
|
-
};
|
|
34
|
-
return /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-1.5 text-xs text-slate-200 ${className ?? ""}`, "data-testid": "paint-gradient-editor", "aria-label": "Gradient paint", children: [
|
|
35
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
36
|
-
/* @__PURE__ */ jsxs("select", { "aria-label": "Gradient preset", className: select, value: "", onChange: (e) => e.target.value && (setSelected(0), onChange(PAINT_GRADIENT_PRESETS[Number(e.target.value)].paint)), children: [
|
|
37
|
-
/* @__PURE__ */ jsx("option", { value: "", children: "Presets\u2026" }),
|
|
38
|
-
PAINT_GRADIENT_PRESETS.map((p, i) => /* @__PURE__ */ jsx("option", { value: i, children: p.name }, p.name))
|
|
39
|
-
] }),
|
|
40
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: button, onClick: () => onChange(reversePaintGradient(value)), children: "Reverse" })
|
|
41
|
-
] }),
|
|
42
|
-
/* @__PURE__ */ jsx(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
role: "slider",
|
|
46
|
-
tabIndex: 0,
|
|
47
|
-
"aria-label": "Gradient ramp: click to add a stop",
|
|
48
|
-
"aria-valuemin": 0,
|
|
49
|
-
"aria-valuemax": 100,
|
|
50
|
-
"aria-valuenow": pct(stop.offset),
|
|
51
|
-
"data-testid": "paint-gradient-ramp",
|
|
52
|
-
className: "relative h-6 cursor-copy rounded ring-1 ring-slate-700",
|
|
53
|
-
style: { background: paintSourceCss(value, colors) },
|
|
54
|
-
onClick: (e) => {
|
|
55
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
56
|
-
const r = addPaintGradientStop(value, rect.width ? (e.clientX - rect.left) / rect.width : 0.5, colors);
|
|
57
|
-
if (r.index >= 0) {
|
|
58
|
-
setSelected(r.index);
|
|
59
|
-
onChange(r.paint);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
),
|
|
64
|
-
/* @__PURE__ */ jsx("div", { className: "relative h-4", "aria-label": "Stops", children: value.stops.map((s, i) => /* @__PURE__ */ jsx(
|
|
65
|
-
"button",
|
|
66
|
-
{
|
|
67
|
-
type: "button",
|
|
68
|
-
"aria-label": `Stop ${i + 1} at ${pct(s.offset)}%`,
|
|
69
|
-
"aria-pressed": i === sel,
|
|
70
|
-
className: `absolute top-0 h-4 w-3 -translate-x-1/2 rounded-sm ring-1 ${i === sel ? "ring-white" : "ring-slate-600"}`,
|
|
71
|
-
style: { left: `${s.offset * 100}%`, background: stopHex(s.color) },
|
|
72
|
-
onClick: () => setSelected(i)
|
|
73
|
-
},
|
|
74
|
-
i
|
|
75
|
-
)) }),
|
|
76
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-stop", children: [
|
|
77
|
-
/* @__PURE__ */ jsxs("select", { "aria-label": "Stop colour source", className: select, value: stop.color === "paint" || stop.color === "secondary" ? stop.color : "color", onChange: (e) => patchStop({ color: e.target.value === "color" ? stopHex(stop.color) : e.target.value }), children: [
|
|
78
|
-
/* @__PURE__ */ jsx("option", { value: "color", children: "Colour" }),
|
|
79
|
-
/* @__PURE__ */ jsx("option", { value: "paint", children: "Paint colour" }),
|
|
80
|
-
/* @__PURE__ */ jsx("option", { value: "secondary", children: "Second colour" })
|
|
81
|
-
] }),
|
|
82
|
-
stop.color !== "paint" && stop.color !== "secondary" && /* @__PURE__ */ jsx("input", { type: "color", "aria-label": "Stop colour", value: stop.color, onChange: (e) => patchStop({ color: e.target.value }), className: "h-6 w-8 rounded bg-transparent" }),
|
|
83
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1", children: [
|
|
84
|
-
"At",
|
|
85
|
-
/* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Stop position", min: 0, max: 100, step: 1, value: pct(stop.offset), onChange: (e) => patchStop({ offset: Number(e.target.value) / 100 }), className: number }),
|
|
86
|
-
"%"
|
|
87
|
-
] }),
|
|
88
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1", children: [
|
|
89
|
-
"Opacity",
|
|
90
|
-
/* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Stop opacity", min: 0, max: 100, step: 5, value: pct(stop.opacity ?? 1), onChange: (e) => patchStop({ opacity: Number(e.target.value) / 100 }), className: number }),
|
|
91
|
-
"%"
|
|
92
|
-
] }),
|
|
93
|
-
sel < value.stops.length - 1 && /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1", children: [
|
|
94
|
-
"Midpoint",
|
|
95
|
-
/* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Stop midpoint", min: 5, max: 95, step: 1, value: pct(stop.midpoint ?? 0.5), onChange: (e) => patchStop({ midpoint: Number(e.target.value) / 100 }), className: number }),
|
|
96
|
-
"%"
|
|
97
|
-
] }),
|
|
98
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: button, disabled: value.stops.length <= 2, onClick: () => (setSelected(Math.max(0, sel - 1)), onChange(removePaintGradientStop(value, sel))), children: "Remove stop" })
|
|
99
|
-
] }),
|
|
100
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "paint-gradient-mapping", children: [
|
|
101
|
-
/* @__PURE__ */ jsx("select", { "aria-label": "Gradient follows", className: select, value: map.by, onChange: (e) => onChange({ ...value, map: paintGradientMappingFor(e.target.value, map) }), children: PAINT_GRADIENT_MAPPINGS.map((m) => /* @__PURE__ */ jsx("option", { value: m, children: PAINT_GRADIENT_MAPPING_LABELS[m] }, m)) }),
|
|
102
|
-
map.by === "distance" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
-
/* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Gradient length", min: 1, max: 1e5, value: map.length, onChange: (e) => onChange({ ...value, map: { ...map, length: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
|
|
104
|
-
/* @__PURE__ */ jsxs("select", { "aria-label": "Gradient length unit", className: select, value: map.unit ?? "px", onChange: (e) => onChange({ ...value, map: { ...map, unit: e.target.value } }), children: [
|
|
105
|
-
/* @__PURE__ */ jsx("option", { value: "px", children: "px" }),
|
|
106
|
-
/* @__PURE__ */ jsx("option", { value: "dabs", children: "dabs" })
|
|
107
|
-
] })
|
|
108
|
-
] }),
|
|
109
|
-
map.by === "time" && /* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Gradient duration", min: 1, max: 6e5, value: map.duration, onChange: (e) => onChange({ ...value, map: { ...map, duration: Math.max(1, Number(e.target.value) || 1) } }), className: number }),
|
|
110
|
-
map.by === "random" && /* @__PURE__ */ jsx("input", { type: "number", "aria-label": "Dabs per pick", min: 1, max: 500, value: map.every ?? 1, onChange: (e) => onChange({ ...value, map: { ...map, every: Math.max(1, Math.round(Number(e.target.value) || 1)) } }), className: number }),
|
|
111
|
-
(map.by === "distance" || map.by === "time") && /* @__PURE__ */ jsx("select", { "aria-label": "Gradient repeat", className: select, value: map.repeat ?? "clamp", onChange: (e) => onChange({ ...value, map: { ...map, repeat: e.target.value } }), children: PAINT_GRADIENT_REPEATS.map((r) => /* @__PURE__ */ jsx("option", { value: r, children: PAINT_GRADIENT_REPEAT_LABELS[r] }, r)) })
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
114
|
-
/* @__PURE__ */ jsx("select", { "aria-label": "Gradient mixing", className: select, value: value.space, onChange: (e) => onChange({ ...value, space: e.target.value }), children: PAINT_GRADIENT_SPACES.map((s) => /* @__PURE__ */ jsx("option", { value: s, children: PAINT_GRADIENT_SPACE_LABELS[s] }, s)) }),
|
|
115
|
-
/* @__PURE__ */ jsxs("label", { className: "flex flex-1 items-center gap-1", children: [
|
|
116
|
-
"Softness",
|
|
117
|
-
/* @__PURE__ */ jsx("input", { type: "range", "aria-label": "Gradient softness", min: 0, max: 1, step: 0.05, value: value.softness ?? 1, onChange: (e) => onChange({ ...value, softness: Number(e.target.value) }), className: "flex-1 accent-indigo-500" })
|
|
118
|
-
] })
|
|
119
|
-
] })
|
|
120
|
-
] });
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export {
|
|
124
|
-
PaintGradientEditorView
|
|
125
|
-
};
|