@panneau/media 5.0.0-alpha.4 → 5.0.0-alpha.6
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/README.md +94 -7
- package/dist/ImageItem.d.ts +23 -0
- package/dist/ImageItem.d.ts.map +1 -0
- package/dist/ImageItem.js +292 -0
- package/dist/ImageItem.js.map +1 -0
- package/dist/MediaField.css +127 -0
- package/dist/MediaField.d.ts +67 -15
- package/dist/MediaField.d.ts.map +1 -1
- package/dist/MediaField.js +354 -148
- package/dist/MediaField.js.map +1 -1
- package/dist/MediaField.module.js +28 -2
- package/dist/MediaField.module.js.map +1 -1
- package/dist/editor/ImageEditor.css +369 -0
- package/dist/editor/ImageEditor.d.ts +13 -0
- package/dist/editor/ImageEditor.d.ts.map +1 -0
- package/dist/editor/ImageEditor.js +461 -0
- package/dist/editor/ImageEditor.js.map +1 -0
- package/dist/editor/ImageEditor.module.js +86 -0
- package/dist/editor/ImageEditor.module.js.map +1 -0
- package/dist/editor/draw.d.ts +37 -0
- package/dist/editor/draw.d.ts.map +1 -0
- package/dist/editor/draw.js +93 -0
- package/dist/editor/draw.js.map +1 -0
- package/dist/editor/geometry.d.ts +54 -0
- package/dist/editor/geometry.d.ts.map +1 -0
- package/dist/editor/geometry.js +227 -0
- package/dist/editor/geometry.js.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +3 -0
- package/dist/editor/tools.d.ts +11 -0
- package/dist/editor/tools.d.ts.map +1 -0
- package/dist/editor/tools.js +1199 -0
- package/dist/editor/tools.js.map +1 -0
- package/dist/editor/types.d.ts +111 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/picker/MediaDetails.d.ts +22 -0
- package/dist/picker/MediaDetails.d.ts.map +1 -0
- package/dist/picker/MediaDetails.js +368 -0
- package/dist/picker/MediaDetails.js.map +1 -0
- package/dist/picker/MediaGrid.d.ts +30 -0
- package/dist/picker/MediaGrid.d.ts.map +1 -0
- package/dist/picker/MediaGrid.js +260 -0
- package/dist/picker/MediaGrid.js.map +1 -0
- package/dist/picker/MediaPicker.css +642 -0
- package/dist/picker/MediaPicker.d.ts +9 -0
- package/dist/picker/MediaPicker.d.ts.map +1 -0
- package/dist/picker/MediaPicker.js +601 -0
- package/dist/picker/MediaPicker.js.map +1 -0
- package/dist/picker/MediaPicker.module.js +132 -0
- package/dist/picker/MediaPicker.module.js.map +1 -0
- package/dist/picker/PickerToolbar.d.ts +19 -0
- package/dist/picker/PickerToolbar.d.ts.map +1 -0
- package/dist/picker/PickerToolbar.js +266 -0
- package/dist/picker/PickerToolbar.js.map +1 -0
- package/dist/picker/UploadPanel.d.ts +22 -0
- package/dist/picker/UploadPanel.d.ts.map +1 -0
- package/dist/picker/UploadPanel.js +186 -0
- package/dist/picker/UploadPanel.js.map +1 -0
- package/dist/picker/format.d.ts +18 -0
- package/dist/picker/format.d.ts.map +1 -0
- package/dist/picker/format.js +64 -0
- package/dist/picker/format.js.map +1 -0
- package/dist/picker/index.d.ts +3 -0
- package/dist/picker/index.d.ts.map +1 -0
- package/dist/picker/index.js +1 -0
- package/dist/picker/types.d.ts +119 -0
- package/dist/picker/types.d.ts.map +1 -0
- package/dist/picker/useMediaBrowser.d.ts +50 -0
- package/dist/picker/useMediaBrowser.d.ts.map +1 -0
- package/dist/picker/useMediaBrowser.js +314 -0
- package/dist/picker/useMediaBrowser.js.map +1 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +5 -2
- package/dist/plugin.js.map +1 -1
- package/dist/resourceSource.d.ts +21 -0
- package/dist/resourceSource.d.ts.map +1 -0
- package/dist/resourceSource.js +99 -0
- package/dist/resourceSource.js.map +1 -0
- package/package.json +18 -7
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
import { cropAround, cropInView, focalFromView, focalInView, handlePoint, moveRect, rectFromView, resizeRect, viewSize } from "./geometry.js";
|
|
2
|
+
import ImageEditor_module_default from "./ImageEditor.module.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Crop, FlipHorizontal2, FlipVertical2, Focus, RotateCcw, RotateCw } from "lucide-react";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
import { mediaMessages } from "@panneau/intl";
|
|
7
|
+
import { matchesRatio, parseRatio } from "@panneau/protocol/runtime";
|
|
8
|
+
import { Badge, Button, NumberInput, Text, usePanneauIntl } from "@panneau/ui";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Label, Radio, RadioGroup } from "react-aria-components";
|
|
11
|
+
//#region src/editor/tools.tsx
|
|
12
|
+
/** The ratios offered when the field gives none. */
|
|
13
|
+
var COMMON_RATIOS = [
|
|
14
|
+
"16:9",
|
|
15
|
+
"4:3",
|
|
16
|
+
"1:1",
|
|
17
|
+
"3:4",
|
|
18
|
+
"9:16"
|
|
19
|
+
];
|
|
20
|
+
var CORNERS = [
|
|
21
|
+
"nw",
|
|
22
|
+
"ne",
|
|
23
|
+
"se",
|
|
24
|
+
"sw"
|
|
25
|
+
];
|
|
26
|
+
var EDGES = [
|
|
27
|
+
"n",
|
|
28
|
+
"e",
|
|
29
|
+
"s",
|
|
30
|
+
"w"
|
|
31
|
+
];
|
|
32
|
+
/** The ratios of the automatic crops the focal point shows. */
|
|
33
|
+
var PREVIEW_RATIOS = [
|
|
34
|
+
"1:1",
|
|
35
|
+
"4:5",
|
|
36
|
+
"16:9"
|
|
37
|
+
];
|
|
38
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
39
|
+
var center = (rect) => ({
|
|
40
|
+
x: rect.x + rect.width / 2,
|
|
41
|
+
y: rect.y + rect.height / 2
|
|
42
|
+
});
|
|
43
|
+
/** The ratios the crop tool offers, the one chosen, and the ratio the frame keeps. */
|
|
44
|
+
function cropRatios(context) {
|
|
45
|
+
const { ratios, enforceRatios, transform, crop, view } = context;
|
|
46
|
+
const offered = enforceRatios ? [...ratios] : [
|
|
47
|
+
"free",
|
|
48
|
+
"original",
|
|
49
|
+
...ratios.length > 0 ? ratios : COMMON_RATIOS
|
|
50
|
+
];
|
|
51
|
+
const valueOf = (id) => id === "free" ? null : id === "original" ? view.width / view.height : parseRatio(id);
|
|
52
|
+
const chosen = context.state?.ratio;
|
|
53
|
+
const matching = transform.crop !== void 0 ? offered.find((id) => {
|
|
54
|
+
const value = valueOf(id);
|
|
55
|
+
return value !== null && matchesRatio(crop.width, crop.height, value);
|
|
56
|
+
}) : void 0;
|
|
57
|
+
const selected = chosen !== void 0 && offered.includes(chosen) ? chosen : matching ?? (enforceRatios ? offered[0] ?? "free" : "free");
|
|
58
|
+
return {
|
|
59
|
+
offered,
|
|
60
|
+
selected,
|
|
61
|
+
locked: valueOf(selected),
|
|
62
|
+
valueOf
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function setCropInView(context, rect) {
|
|
66
|
+
const { size } = context;
|
|
67
|
+
context.setTransform((current) => ({
|
|
68
|
+
...current,
|
|
69
|
+
crop: rectFromView(rect, size, current)
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
function arrows(event, step) {
|
|
73
|
+
const dx = event.key === "ArrowRight" ? step : event.key === "ArrowLeft" ? -step : 0;
|
|
74
|
+
const dy = event.key === "ArrowDown" ? step : event.key === "ArrowUp" ? -step : 0;
|
|
75
|
+
return dx === 0 && dy === 0 ? null : {
|
|
76
|
+
dx,
|
|
77
|
+
dy
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** The ratios, as tiles of their shape, and the crop in numbers. */
|
|
81
|
+
function CropPanel(context) {
|
|
82
|
+
const $ = c(50);
|
|
83
|
+
const intl = usePanneauIntl();
|
|
84
|
+
const { crop, view, enforceRatios } = context;
|
|
85
|
+
let T0;
|
|
86
|
+
let locked;
|
|
87
|
+
let t0;
|
|
88
|
+
let t1;
|
|
89
|
+
let t2;
|
|
90
|
+
let t3;
|
|
91
|
+
let t4;
|
|
92
|
+
let t5;
|
|
93
|
+
if ($[0] !== context || $[1] !== crop || $[2] !== enforceRatios || $[3] !== intl || $[4] !== view) {
|
|
94
|
+
const { offered, selected, locked: t6, valueOf } = cropRatios(context);
|
|
95
|
+
locked = t6;
|
|
96
|
+
let t7;
|
|
97
|
+
if ($[13] !== intl) {
|
|
98
|
+
t7 = (id) => id === "free" ? intl.formatMessage(mediaMessages.editorRatioFree) : id === "original" ? intl.formatMessage(mediaMessages.editorRatioOriginal) : id;
|
|
99
|
+
$[13] = intl;
|
|
100
|
+
$[14] = t7;
|
|
101
|
+
} else t7 = $[14];
|
|
102
|
+
const label = t7;
|
|
103
|
+
t5 = ImageEditor_module_default.panel;
|
|
104
|
+
T0 = RadioGroup;
|
|
105
|
+
t2 = selected;
|
|
106
|
+
t3 = (id_0) => {
|
|
107
|
+
context.setState({ ratio: id_0 });
|
|
108
|
+
const value = valueOf(id_0);
|
|
109
|
+
if (value !== null) setCropInView(context, cropAround({
|
|
110
|
+
x: 0,
|
|
111
|
+
y: 0,
|
|
112
|
+
...view
|
|
113
|
+
}, value, center(crop)));
|
|
114
|
+
};
|
|
115
|
+
let t8;
|
|
116
|
+
if ($[15] !== intl) {
|
|
117
|
+
t8 = intl.formatMessage(mediaMessages.editorRatio);
|
|
118
|
+
$[15] = intl;
|
|
119
|
+
$[16] = t8;
|
|
120
|
+
} else t8 = $[16];
|
|
121
|
+
let t9;
|
|
122
|
+
if ($[17] !== enforceRatios || $[18] !== intl) {
|
|
123
|
+
t9 = enforceRatios ? /* @__PURE__ */ jsx(Badge, { children: intl.formatMessage(mediaMessages.editorRatioRequired) }) : null;
|
|
124
|
+
$[17] = enforceRatios;
|
|
125
|
+
$[18] = intl;
|
|
126
|
+
$[19] = t9;
|
|
127
|
+
} else t9 = $[19];
|
|
128
|
+
if ($[20] !== t8 || $[21] !== t9) {
|
|
129
|
+
t4 = /* @__PURE__ */ jsxs(Label, {
|
|
130
|
+
className: ImageEditor_module_default.panelLabel,
|
|
131
|
+
children: [t8, t9]
|
|
132
|
+
});
|
|
133
|
+
$[20] = t8;
|
|
134
|
+
$[21] = t9;
|
|
135
|
+
$[22] = t4;
|
|
136
|
+
} else t4 = $[22];
|
|
137
|
+
t0 = ImageEditor_module_default.ratios;
|
|
138
|
+
t1 = offered.map((id_1) => {
|
|
139
|
+
const value_0 = valueOf(id_1);
|
|
140
|
+
const shape = value_0 === null ? {
|
|
141
|
+
width: 22,
|
|
142
|
+
height: 16
|
|
143
|
+
} : value_0 >= 1 ? {
|
|
144
|
+
width: 24,
|
|
145
|
+
height: 24 / value_0
|
|
146
|
+
} : {
|
|
147
|
+
width: 24 * value_0,
|
|
148
|
+
height: 24
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ jsxs(Radio, {
|
|
151
|
+
value: id_1,
|
|
152
|
+
className: ImageEditor_module_default.ratio,
|
|
153
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
154
|
+
"aria-hidden": true,
|
|
155
|
+
className: value_0 === null ? ImageEditor_module_default.ratioFree : ImageEditor_module_default.ratioShape,
|
|
156
|
+
style: shape
|
|
157
|
+
}), label(id_1)]
|
|
158
|
+
}, id_1);
|
|
159
|
+
});
|
|
160
|
+
$[0] = context;
|
|
161
|
+
$[1] = crop;
|
|
162
|
+
$[2] = enforceRatios;
|
|
163
|
+
$[3] = intl;
|
|
164
|
+
$[4] = view;
|
|
165
|
+
$[5] = T0;
|
|
166
|
+
$[6] = locked;
|
|
167
|
+
$[7] = t0;
|
|
168
|
+
$[8] = t1;
|
|
169
|
+
$[9] = t2;
|
|
170
|
+
$[10] = t3;
|
|
171
|
+
$[11] = t4;
|
|
172
|
+
$[12] = t5;
|
|
173
|
+
} else {
|
|
174
|
+
T0 = $[5];
|
|
175
|
+
locked = $[6];
|
|
176
|
+
t0 = $[7];
|
|
177
|
+
t1 = $[8];
|
|
178
|
+
t2 = $[9];
|
|
179
|
+
t3 = $[10];
|
|
180
|
+
t4 = $[11];
|
|
181
|
+
t5 = $[12];
|
|
182
|
+
}
|
|
183
|
+
let t6;
|
|
184
|
+
if ($[23] !== t0 || $[24] !== t1) {
|
|
185
|
+
t6 = /* @__PURE__ */ jsx("div", {
|
|
186
|
+
className: t0,
|
|
187
|
+
children: t1
|
|
188
|
+
});
|
|
189
|
+
$[23] = t0;
|
|
190
|
+
$[24] = t1;
|
|
191
|
+
$[25] = t6;
|
|
192
|
+
} else t6 = $[25];
|
|
193
|
+
let t7;
|
|
194
|
+
if ($[26] !== T0 || $[27] !== t2 || $[28] !== t3 || $[29] !== t4 || $[30] !== t6) {
|
|
195
|
+
t7 = /* @__PURE__ */ jsxs(T0, {
|
|
196
|
+
value: t2,
|
|
197
|
+
onChange: t3,
|
|
198
|
+
children: [t4, t6]
|
|
199
|
+
});
|
|
200
|
+
$[26] = T0;
|
|
201
|
+
$[27] = t2;
|
|
202
|
+
$[28] = t3;
|
|
203
|
+
$[29] = t4;
|
|
204
|
+
$[30] = t6;
|
|
205
|
+
$[31] = t7;
|
|
206
|
+
} else t7 = $[31];
|
|
207
|
+
let t8;
|
|
208
|
+
if ($[32] !== context || $[33] !== crop || $[34] !== intl || $[35] !== locked || $[36] !== view.height || $[37] !== view.width) {
|
|
209
|
+
t8 = /* @__PURE__ */ jsx("div", {
|
|
210
|
+
className: ImageEditor_module_default.numbers,
|
|
211
|
+
children: [
|
|
212
|
+
["x", mediaMessages.editorCropX],
|
|
213
|
+
["y", mediaMessages.editorCropY],
|
|
214
|
+
["width", mediaMessages.editorCropWidth],
|
|
215
|
+
["height", mediaMessages.editorCropHeight]
|
|
216
|
+
].map((t9) => {
|
|
217
|
+
const [key, message] = t9;
|
|
218
|
+
return /* @__PURE__ */ jsx(NumberInput, {
|
|
219
|
+
label: intl.formatMessage(message),
|
|
220
|
+
suffix: "px",
|
|
221
|
+
minValue: 0,
|
|
222
|
+
value: Math.round(crop[key]),
|
|
223
|
+
isDisabled: locked !== null && key === "height",
|
|
224
|
+
onChange: (value_1) => {
|
|
225
|
+
if (value_1 === null) return;
|
|
226
|
+
const next = {
|
|
227
|
+
...crop,
|
|
228
|
+
[key]: value_1
|
|
229
|
+
};
|
|
230
|
+
if (locked !== null && key === "width") next.height = value_1 / locked;
|
|
231
|
+
const x = clamp(next.x, 0, view.width - 1);
|
|
232
|
+
const y = clamp(next.y, 0, view.height - 1);
|
|
233
|
+
setCropInView(context, {
|
|
234
|
+
x,
|
|
235
|
+
y,
|
|
236
|
+
width: clamp(next.width, 1, view.width - x),
|
|
237
|
+
height: clamp(next.height, 1, view.height - y)
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}, key);
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
$[32] = context;
|
|
244
|
+
$[33] = crop;
|
|
245
|
+
$[34] = intl;
|
|
246
|
+
$[35] = locked;
|
|
247
|
+
$[36] = view.height;
|
|
248
|
+
$[37] = view.width;
|
|
249
|
+
$[38] = t8;
|
|
250
|
+
} else t8 = $[38];
|
|
251
|
+
let t9;
|
|
252
|
+
if ($[39] !== intl || $[40] !== view.height || $[41] !== view.width) {
|
|
253
|
+
t9 = intl.formatMessage(mediaMessages.editorCropPixels, {
|
|
254
|
+
width: Math.round(view.width),
|
|
255
|
+
height: Math.round(view.height)
|
|
256
|
+
});
|
|
257
|
+
$[39] = intl;
|
|
258
|
+
$[40] = view.height;
|
|
259
|
+
$[41] = view.width;
|
|
260
|
+
$[42] = t9;
|
|
261
|
+
} else t9 = $[42];
|
|
262
|
+
let t10;
|
|
263
|
+
if ($[43] !== t9) {
|
|
264
|
+
t10 = /* @__PURE__ */ jsx(Text, {
|
|
265
|
+
size: "sm",
|
|
266
|
+
muted: true,
|
|
267
|
+
children: t9
|
|
268
|
+
});
|
|
269
|
+
$[43] = t9;
|
|
270
|
+
$[44] = t10;
|
|
271
|
+
} else t10 = $[44];
|
|
272
|
+
let t11;
|
|
273
|
+
if ($[45] !== t10 || $[46] !== t5 || $[47] !== t7 || $[48] !== t8) {
|
|
274
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
275
|
+
className: t5,
|
|
276
|
+
children: [
|
|
277
|
+
t7,
|
|
278
|
+
t8,
|
|
279
|
+
t10
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
$[45] = t10;
|
|
283
|
+
$[46] = t5;
|
|
284
|
+
$[47] = t7;
|
|
285
|
+
$[48] = t8;
|
|
286
|
+
$[49] = t11;
|
|
287
|
+
} else t11 = $[49];
|
|
288
|
+
return t11;
|
|
289
|
+
}
|
|
290
|
+
/** The crop frame: moved by dragging it, resized by its handles, or with the keyboard. */
|
|
291
|
+
function CropOverlay(context) {
|
|
292
|
+
const $ = c(52);
|
|
293
|
+
const intl = usePanneauIntl();
|
|
294
|
+
const { crop, view, unit } = context;
|
|
295
|
+
let t0;
|
|
296
|
+
if ($[0] !== context) {
|
|
297
|
+
t0 = cropRatios(context);
|
|
298
|
+
$[0] = context;
|
|
299
|
+
$[1] = t0;
|
|
300
|
+
} else t0 = $[1];
|
|
301
|
+
const { locked } = t0;
|
|
302
|
+
const drag = useRef(null);
|
|
303
|
+
let t1;
|
|
304
|
+
if ($[2] !== context || $[3] !== crop) {
|
|
305
|
+
t1 = (handle, event) => {
|
|
306
|
+
event.stopPropagation();
|
|
307
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
308
|
+
drag.current = {
|
|
309
|
+
handle,
|
|
310
|
+
from: context.pointToView(event),
|
|
311
|
+
rect: crop
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
$[2] = context;
|
|
315
|
+
$[3] = crop;
|
|
316
|
+
$[4] = t1;
|
|
317
|
+
} else t1 = $[4];
|
|
318
|
+
const start = t1;
|
|
319
|
+
let t2;
|
|
320
|
+
if ($[5] !== context || $[6] !== locked || $[7] !== view) {
|
|
321
|
+
t2 = (event_0) => {
|
|
322
|
+
const current = drag.current;
|
|
323
|
+
if (current === null) return;
|
|
324
|
+
const point = context.pointToView(event_0);
|
|
325
|
+
const dx = point.x - current.from.x;
|
|
326
|
+
const dy = point.y - current.from.y;
|
|
327
|
+
setCropInView(context, current.handle === "move" ? moveRect(current.rect, dx, dy, view) : resizeRect(current.rect, current.handle, dx, dy, locked, view));
|
|
328
|
+
};
|
|
329
|
+
$[5] = context;
|
|
330
|
+
$[6] = locked;
|
|
331
|
+
$[7] = view;
|
|
332
|
+
$[8] = t2;
|
|
333
|
+
} else t2 = $[8];
|
|
334
|
+
const move = t2;
|
|
335
|
+
let t3;
|
|
336
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
337
|
+
t3 = () => {
|
|
338
|
+
drag.current = null;
|
|
339
|
+
};
|
|
340
|
+
$[9] = t3;
|
|
341
|
+
} else t3 = $[9];
|
|
342
|
+
const end = t3;
|
|
343
|
+
const step = Math.max(view.width, view.height) / 100;
|
|
344
|
+
const handleSize = 14 * unit;
|
|
345
|
+
let t4;
|
|
346
|
+
if ($[10] !== intl) {
|
|
347
|
+
t4 = intl.formatMessage(mediaMessages.editorCropFrameRole);
|
|
348
|
+
$[10] = intl;
|
|
349
|
+
$[11] = t4;
|
|
350
|
+
} else t4 = $[11];
|
|
351
|
+
let t5;
|
|
352
|
+
if ($[12] !== crop.height || $[13] !== crop.width || $[14] !== intl) {
|
|
353
|
+
t5 = intl.formatMessage(mediaMessages.editorCropFrame, {
|
|
354
|
+
width: Math.round(crop.width),
|
|
355
|
+
height: Math.round(crop.height)
|
|
356
|
+
});
|
|
357
|
+
$[12] = crop.height;
|
|
358
|
+
$[13] = crop.width;
|
|
359
|
+
$[14] = intl;
|
|
360
|
+
$[15] = t5;
|
|
361
|
+
} else t5 = $[15];
|
|
362
|
+
const t6 = context.hintId;
|
|
363
|
+
let t7;
|
|
364
|
+
if ($[16] !== context || $[17] !== crop || $[18] !== locked || $[19] !== step || $[20] !== view) {
|
|
365
|
+
t7 = (event_1) => {
|
|
366
|
+
const delta = arrows(event_1, step);
|
|
367
|
+
if (delta === null) return;
|
|
368
|
+
event_1.preventDefault();
|
|
369
|
+
setCropInView(context, event_1.shiftKey ? resizeRect(crop, "se", locked !== null ? delta.dx + delta.dy : delta.dx, delta.dy, locked, view) : moveRect(crop, delta.dx, delta.dy, view));
|
|
370
|
+
};
|
|
371
|
+
$[16] = context;
|
|
372
|
+
$[17] = crop;
|
|
373
|
+
$[18] = locked;
|
|
374
|
+
$[19] = step;
|
|
375
|
+
$[20] = view;
|
|
376
|
+
$[21] = t7;
|
|
377
|
+
} else t7 = $[21];
|
|
378
|
+
let t8;
|
|
379
|
+
if ($[22] !== start) {
|
|
380
|
+
t8 = (event_2) => start("move", event_2);
|
|
381
|
+
$[22] = start;
|
|
382
|
+
$[23] = t8;
|
|
383
|
+
} else t8 = $[23];
|
|
384
|
+
let t9;
|
|
385
|
+
if ($[24] !== crop.height || $[25] !== crop.width || $[26] !== crop.x || $[27] !== crop.y || $[28] !== t8) {
|
|
386
|
+
t9 = /* @__PURE__ */ jsx("rect", {
|
|
387
|
+
x: crop.x,
|
|
388
|
+
y: crop.y,
|
|
389
|
+
width: crop.width,
|
|
390
|
+
height: crop.height,
|
|
391
|
+
className: ImageEditor_module_default.frameArea,
|
|
392
|
+
onPointerDown: t8
|
|
393
|
+
});
|
|
394
|
+
$[24] = crop.height;
|
|
395
|
+
$[25] = crop.width;
|
|
396
|
+
$[26] = crop.x;
|
|
397
|
+
$[27] = crop.y;
|
|
398
|
+
$[28] = t8;
|
|
399
|
+
$[29] = t9;
|
|
400
|
+
} else t9 = $[29];
|
|
401
|
+
let t10;
|
|
402
|
+
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
403
|
+
t10 = [1, 2];
|
|
404
|
+
$[30] = t10;
|
|
405
|
+
} else t10 = $[30];
|
|
406
|
+
let t11;
|
|
407
|
+
let t12;
|
|
408
|
+
if ($[31] !== crop.height || $[32] !== crop.width || $[33] !== crop.x || $[34] !== crop.y) {
|
|
409
|
+
t11 = t10.map((third) => /* @__PURE__ */ jsxs("g", {
|
|
410
|
+
className: ImageEditor_module_default.thirds,
|
|
411
|
+
children: [/* @__PURE__ */ jsx("line", {
|
|
412
|
+
x1: crop.x + crop.width * third / 3,
|
|
413
|
+
x2: crop.x + crop.width * third / 3,
|
|
414
|
+
y1: crop.y,
|
|
415
|
+
y2: crop.y + crop.height
|
|
416
|
+
}), /* @__PURE__ */ jsx("line", {
|
|
417
|
+
y1: crop.y + crop.height * third / 3,
|
|
418
|
+
y2: crop.y + crop.height * third / 3,
|
|
419
|
+
x1: crop.x,
|
|
420
|
+
x2: crop.x + crop.width
|
|
421
|
+
})]
|
|
422
|
+
}, third));
|
|
423
|
+
t12 = /* @__PURE__ */ jsx("rect", {
|
|
424
|
+
x: crop.x,
|
|
425
|
+
y: crop.y,
|
|
426
|
+
width: crop.width,
|
|
427
|
+
height: crop.height,
|
|
428
|
+
className: ImageEditor_module_default.frameBorder
|
|
429
|
+
});
|
|
430
|
+
$[31] = crop.height;
|
|
431
|
+
$[32] = crop.width;
|
|
432
|
+
$[33] = crop.x;
|
|
433
|
+
$[34] = crop.y;
|
|
434
|
+
$[35] = t11;
|
|
435
|
+
$[36] = t12;
|
|
436
|
+
} else {
|
|
437
|
+
t11 = $[35];
|
|
438
|
+
t12 = $[36];
|
|
439
|
+
}
|
|
440
|
+
let t13;
|
|
441
|
+
if ($[37] !== crop || $[38] !== handleSize || $[39] !== locked || $[40] !== start) {
|
|
442
|
+
t13 = [...CORNERS, ...locked === null ? EDGES : []].map((handle_0) => {
|
|
443
|
+
const at = handlePoint(crop, handle_0);
|
|
444
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
445
|
+
x: at.x - handleSize / 2,
|
|
446
|
+
y: at.y - handleSize / 2,
|
|
447
|
+
width: handleSize,
|
|
448
|
+
height: handleSize,
|
|
449
|
+
rx: handleSize / 4,
|
|
450
|
+
className: ImageEditor_module_default.handle,
|
|
451
|
+
"data-handle": handle_0,
|
|
452
|
+
onPointerDown: (event_3) => start(handle_0, event_3)
|
|
453
|
+
}, handle_0);
|
|
454
|
+
});
|
|
455
|
+
$[37] = crop;
|
|
456
|
+
$[38] = handleSize;
|
|
457
|
+
$[39] = locked;
|
|
458
|
+
$[40] = start;
|
|
459
|
+
$[41] = t13;
|
|
460
|
+
} else t13 = $[41];
|
|
461
|
+
let t14;
|
|
462
|
+
if ($[42] !== context.hintId || $[43] !== move || $[44] !== t11 || $[45] !== t12 || $[46] !== t13 || $[47] !== t4 || $[48] !== t5 || $[49] !== t7 || $[50] !== t9) {
|
|
463
|
+
t14 = /* @__PURE__ */ jsxs("g", {
|
|
464
|
+
tabIndex: 0,
|
|
465
|
+
role: "group",
|
|
466
|
+
"aria-roledescription": t4,
|
|
467
|
+
"aria-label": t5,
|
|
468
|
+
"aria-describedby": t6,
|
|
469
|
+
className: ImageEditor_module_default.frame,
|
|
470
|
+
onKeyDown: t7,
|
|
471
|
+
onPointerMove: move,
|
|
472
|
+
onPointerUp: end,
|
|
473
|
+
onPointerCancel: end,
|
|
474
|
+
children: [
|
|
475
|
+
t9,
|
|
476
|
+
t11,
|
|
477
|
+
t12,
|
|
478
|
+
t13
|
|
479
|
+
]
|
|
480
|
+
});
|
|
481
|
+
$[42] = context.hintId;
|
|
482
|
+
$[43] = move;
|
|
483
|
+
$[44] = t11;
|
|
484
|
+
$[45] = t12;
|
|
485
|
+
$[46] = t13;
|
|
486
|
+
$[47] = t4;
|
|
487
|
+
$[48] = t5;
|
|
488
|
+
$[49] = t7;
|
|
489
|
+
$[50] = t9;
|
|
490
|
+
$[51] = t14;
|
|
491
|
+
} else t14 = $[51];
|
|
492
|
+
return t14;
|
|
493
|
+
}
|
|
494
|
+
/** Turns the image a quarter. A crop of the field's ratios keeps its ratio. */
|
|
495
|
+
function turn(context, by) {
|
|
496
|
+
const { size, ratios, crop } = context;
|
|
497
|
+
const kept = ratios.map((ratio) => parseRatio(ratio)).find((value) => value !== null && matchesRatio(crop.width, crop.height, value));
|
|
498
|
+
context.setTransform((current) => {
|
|
499
|
+
const rotate = ((current.rotate ?? 0) + by + 360) % 360;
|
|
500
|
+
const next = {
|
|
501
|
+
...current,
|
|
502
|
+
rotate
|
|
503
|
+
};
|
|
504
|
+
if (kept === void 0 || kept === null || current.crop === void 0) return next;
|
|
505
|
+
const turned = viewSize(size, rotate);
|
|
506
|
+
const fitted = cropAround({
|
|
507
|
+
x: 0,
|
|
508
|
+
y: 0,
|
|
509
|
+
...turned
|
|
510
|
+
}, kept, center(cropInView(size, next)));
|
|
511
|
+
return {
|
|
512
|
+
...next,
|
|
513
|
+
crop: rectFromView(fitted, size, next)
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function RotatePanel(context) {
|
|
518
|
+
const $ = c(68);
|
|
519
|
+
const intl = usePanneauIntl();
|
|
520
|
+
const { transform, ratios, crop } = context;
|
|
521
|
+
let t0;
|
|
522
|
+
if ($[0] !== context) {
|
|
523
|
+
t0 = (key) => context.setTransform((current) => ({
|
|
524
|
+
...current,
|
|
525
|
+
[key]: current[key] !== true
|
|
526
|
+
}));
|
|
527
|
+
$[0] = context;
|
|
528
|
+
$[1] = t0;
|
|
529
|
+
} else t0 = $[1];
|
|
530
|
+
const flip = t0;
|
|
531
|
+
let T0;
|
|
532
|
+
let t1;
|
|
533
|
+
let t2;
|
|
534
|
+
let t3;
|
|
535
|
+
let t4;
|
|
536
|
+
let t5;
|
|
537
|
+
let t6;
|
|
538
|
+
if ($[2] !== context || $[3] !== crop || $[4] !== flip || $[5] !== intl || $[6] !== ratios || $[7] !== transform.crop || $[8] !== transform.flipX || $[9] !== transform.flipY || $[10] !== transform.rotate) {
|
|
539
|
+
let t7;
|
|
540
|
+
if ($[18] !== crop) {
|
|
541
|
+
t7 = (ratio) => matchesRatio(crop.width, crop.height, ratio);
|
|
542
|
+
$[18] = crop;
|
|
543
|
+
$[19] = t7;
|
|
544
|
+
} else t7 = $[19];
|
|
545
|
+
const kept = ratios.find(t7);
|
|
546
|
+
t5 = ImageEditor_module_default.panel;
|
|
547
|
+
let t8;
|
|
548
|
+
if ($[20] !== context) {
|
|
549
|
+
t8 = () => turn(context, -90);
|
|
550
|
+
$[20] = context;
|
|
551
|
+
$[21] = t8;
|
|
552
|
+
} else t8 = $[21];
|
|
553
|
+
let t9;
|
|
554
|
+
if ($[22] !== intl) {
|
|
555
|
+
t9 = intl.formatMessage(mediaMessages.editorRotateLeft);
|
|
556
|
+
$[22] = intl;
|
|
557
|
+
$[23] = t9;
|
|
558
|
+
} else t9 = $[23];
|
|
559
|
+
let t10;
|
|
560
|
+
if ($[24] !== t8 || $[25] !== t9) {
|
|
561
|
+
t10 = /* @__PURE__ */ jsx(Button, {
|
|
562
|
+
icon: RotateCcw,
|
|
563
|
+
onPress: t8,
|
|
564
|
+
children: t9
|
|
565
|
+
});
|
|
566
|
+
$[24] = t8;
|
|
567
|
+
$[25] = t9;
|
|
568
|
+
$[26] = t10;
|
|
569
|
+
} else t10 = $[26];
|
|
570
|
+
let t11;
|
|
571
|
+
if ($[27] !== context) {
|
|
572
|
+
t11 = () => turn(context, 90);
|
|
573
|
+
$[27] = context;
|
|
574
|
+
$[28] = t11;
|
|
575
|
+
} else t11 = $[28];
|
|
576
|
+
let t12;
|
|
577
|
+
if ($[29] !== intl) {
|
|
578
|
+
t12 = intl.formatMessage(mediaMessages.editorRotateRight);
|
|
579
|
+
$[29] = intl;
|
|
580
|
+
$[30] = t12;
|
|
581
|
+
} else t12 = $[30];
|
|
582
|
+
let t13;
|
|
583
|
+
if ($[31] !== t11 || $[32] !== t12) {
|
|
584
|
+
t13 = /* @__PURE__ */ jsx(Button, {
|
|
585
|
+
icon: RotateCw,
|
|
586
|
+
onPress: t11,
|
|
587
|
+
children: t12
|
|
588
|
+
});
|
|
589
|
+
$[31] = t11;
|
|
590
|
+
$[32] = t12;
|
|
591
|
+
$[33] = t13;
|
|
592
|
+
} else t13 = $[33];
|
|
593
|
+
const t14 = transform.flipX === true;
|
|
594
|
+
let t15;
|
|
595
|
+
if ($[34] !== flip) {
|
|
596
|
+
t15 = () => flip("flipX");
|
|
597
|
+
$[34] = flip;
|
|
598
|
+
$[35] = t15;
|
|
599
|
+
} else t15 = $[35];
|
|
600
|
+
let t16;
|
|
601
|
+
if ($[36] !== intl) {
|
|
602
|
+
t16 = intl.formatMessage(mediaMessages.editorFlipHorizontal);
|
|
603
|
+
$[36] = intl;
|
|
604
|
+
$[37] = t16;
|
|
605
|
+
} else t16 = $[37];
|
|
606
|
+
let t17;
|
|
607
|
+
if ($[38] !== t14 || $[39] !== t15 || $[40] !== t16) {
|
|
608
|
+
t17 = /* @__PURE__ */ jsx(Button, {
|
|
609
|
+
icon: FlipHorizontal2,
|
|
610
|
+
"aria-pressed": t14,
|
|
611
|
+
onPress: t15,
|
|
612
|
+
children: t16
|
|
613
|
+
});
|
|
614
|
+
$[38] = t14;
|
|
615
|
+
$[39] = t15;
|
|
616
|
+
$[40] = t16;
|
|
617
|
+
$[41] = t17;
|
|
618
|
+
} else t17 = $[41];
|
|
619
|
+
const t18 = transform.flipY === true;
|
|
620
|
+
let t19;
|
|
621
|
+
if ($[42] !== flip) {
|
|
622
|
+
t19 = () => flip("flipY");
|
|
623
|
+
$[42] = flip;
|
|
624
|
+
$[43] = t19;
|
|
625
|
+
} else t19 = $[43];
|
|
626
|
+
let t20;
|
|
627
|
+
if ($[44] !== intl) {
|
|
628
|
+
t20 = intl.formatMessage(mediaMessages.editorFlipVertical);
|
|
629
|
+
$[44] = intl;
|
|
630
|
+
$[45] = t20;
|
|
631
|
+
} else t20 = $[45];
|
|
632
|
+
let t21;
|
|
633
|
+
if ($[46] !== t18 || $[47] !== t19 || $[48] !== t20) {
|
|
634
|
+
t21 = /* @__PURE__ */ jsx(Button, {
|
|
635
|
+
icon: FlipVertical2,
|
|
636
|
+
"aria-pressed": t18,
|
|
637
|
+
onPress: t19,
|
|
638
|
+
children: t20
|
|
639
|
+
});
|
|
640
|
+
$[46] = t18;
|
|
641
|
+
$[47] = t19;
|
|
642
|
+
$[48] = t20;
|
|
643
|
+
$[49] = t21;
|
|
644
|
+
} else t21 = $[49];
|
|
645
|
+
if ($[50] !== t10 || $[51] !== t13 || $[52] !== t17 || $[53] !== t21) {
|
|
646
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
647
|
+
className: ImageEditor_module_default.buttons,
|
|
648
|
+
children: [
|
|
649
|
+
t10,
|
|
650
|
+
t13,
|
|
651
|
+
t17,
|
|
652
|
+
t21
|
|
653
|
+
]
|
|
654
|
+
});
|
|
655
|
+
$[50] = t10;
|
|
656
|
+
$[51] = t13;
|
|
657
|
+
$[52] = t17;
|
|
658
|
+
$[53] = t21;
|
|
659
|
+
$[54] = t6;
|
|
660
|
+
} else t6 = $[54];
|
|
661
|
+
T0 = Text;
|
|
662
|
+
t1 = "sm";
|
|
663
|
+
t2 = true;
|
|
664
|
+
if ($[55] !== intl || $[56] !== transform.rotate) {
|
|
665
|
+
t3 = intl.formatMessage(mediaMessages.editorRotated, { degrees: transform.rotate ?? 0 });
|
|
666
|
+
$[55] = intl;
|
|
667
|
+
$[56] = transform.rotate;
|
|
668
|
+
$[57] = t3;
|
|
669
|
+
} else t3 = $[57];
|
|
670
|
+
t4 = kept !== void 0 && transform.crop !== void 0 ? ` ${intl.formatMessage(mediaMessages.editorRotateKeepsRatio, { ratio: kept })}` : null;
|
|
671
|
+
$[2] = context;
|
|
672
|
+
$[3] = crop;
|
|
673
|
+
$[4] = flip;
|
|
674
|
+
$[5] = intl;
|
|
675
|
+
$[6] = ratios;
|
|
676
|
+
$[7] = transform.crop;
|
|
677
|
+
$[8] = transform.flipX;
|
|
678
|
+
$[9] = transform.flipY;
|
|
679
|
+
$[10] = transform.rotate;
|
|
680
|
+
$[11] = T0;
|
|
681
|
+
$[12] = t1;
|
|
682
|
+
$[13] = t2;
|
|
683
|
+
$[14] = t3;
|
|
684
|
+
$[15] = t4;
|
|
685
|
+
$[16] = t5;
|
|
686
|
+
$[17] = t6;
|
|
687
|
+
} else {
|
|
688
|
+
T0 = $[11];
|
|
689
|
+
t1 = $[12];
|
|
690
|
+
t2 = $[13];
|
|
691
|
+
t3 = $[14];
|
|
692
|
+
t4 = $[15];
|
|
693
|
+
t5 = $[16];
|
|
694
|
+
t6 = $[17];
|
|
695
|
+
}
|
|
696
|
+
let t7;
|
|
697
|
+
if ($[58] !== T0 || $[59] !== t1 || $[60] !== t2 || $[61] !== t3 || $[62] !== t4) {
|
|
698
|
+
t7 = /* @__PURE__ */ jsxs(T0, {
|
|
699
|
+
size: t1,
|
|
700
|
+
muted: t2,
|
|
701
|
+
children: [t3, t4]
|
|
702
|
+
});
|
|
703
|
+
$[58] = T0;
|
|
704
|
+
$[59] = t1;
|
|
705
|
+
$[60] = t2;
|
|
706
|
+
$[61] = t3;
|
|
707
|
+
$[62] = t4;
|
|
708
|
+
$[63] = t7;
|
|
709
|
+
} else t7 = $[63];
|
|
710
|
+
let t8;
|
|
711
|
+
if ($[64] !== t5 || $[65] !== t6 || $[66] !== t7) {
|
|
712
|
+
t8 = /* @__PURE__ */ jsxs("div", {
|
|
713
|
+
className: t5,
|
|
714
|
+
children: [t6, t7]
|
|
715
|
+
});
|
|
716
|
+
$[64] = t5;
|
|
717
|
+
$[65] = t6;
|
|
718
|
+
$[66] = t7;
|
|
719
|
+
$[67] = t8;
|
|
720
|
+
} else t8 = $[67];
|
|
721
|
+
return t8;
|
|
722
|
+
}
|
|
723
|
+
function setFocal(context, point) {
|
|
724
|
+
const { size, crop } = context;
|
|
725
|
+
const inside = {
|
|
726
|
+
x: clamp(point.x, crop.x, crop.x + crop.width),
|
|
727
|
+
y: clamp(point.y, crop.y, crop.y + crop.height)
|
|
728
|
+
};
|
|
729
|
+
context.setTransform((current) => ({
|
|
730
|
+
...current,
|
|
731
|
+
focalPoint: focalFromView(inside, size, current)
|
|
732
|
+
}));
|
|
733
|
+
}
|
|
734
|
+
/** The automatic crops the focal point gives, and the point in numbers. */
|
|
735
|
+
function FocalPanel(context) {
|
|
736
|
+
const $ = c(50);
|
|
737
|
+
const intl = usePanneauIntl();
|
|
738
|
+
const { transform, size, crop } = context;
|
|
739
|
+
let percent;
|
|
740
|
+
let setPercent;
|
|
741
|
+
let t0;
|
|
742
|
+
let t1;
|
|
743
|
+
let t2;
|
|
744
|
+
let t3;
|
|
745
|
+
if ($[0] !== context || $[1] !== crop || $[2] !== intl || $[3] !== size || $[4] !== transform) {
|
|
746
|
+
const focal = focalInView(size, transform);
|
|
747
|
+
percent = _temp;
|
|
748
|
+
let t4;
|
|
749
|
+
if ($[11] !== context) {
|
|
750
|
+
t4 = (key, value_0) => {
|
|
751
|
+
if (value_0 === null) return;
|
|
752
|
+
context.setTransform((current) => ({
|
|
753
|
+
...current,
|
|
754
|
+
focalPoint: {
|
|
755
|
+
x: current.focalPoint?.x ?? .5,
|
|
756
|
+
y: current.focalPoint?.y ?? .5,
|
|
757
|
+
[key]: clamp(value_0, 0, 100) / 100
|
|
758
|
+
}
|
|
759
|
+
}));
|
|
760
|
+
};
|
|
761
|
+
$[11] = context;
|
|
762
|
+
$[12] = t4;
|
|
763
|
+
} else t4 = $[12];
|
|
764
|
+
setPercent = t4;
|
|
765
|
+
t2 = ImageEditor_module_default.panel;
|
|
766
|
+
let t5;
|
|
767
|
+
if ($[13] !== intl) {
|
|
768
|
+
t5 = intl.formatMessage(mediaMessages.editorFocalIntro);
|
|
769
|
+
$[13] = intl;
|
|
770
|
+
$[14] = t5;
|
|
771
|
+
} else t5 = $[14];
|
|
772
|
+
if ($[15] !== t5) {
|
|
773
|
+
t3 = /* @__PURE__ */ jsx(Text, {
|
|
774
|
+
size: "sm",
|
|
775
|
+
children: t5
|
|
776
|
+
});
|
|
777
|
+
$[15] = t5;
|
|
778
|
+
$[16] = t3;
|
|
779
|
+
} else t3 = $[16];
|
|
780
|
+
t0 = ImageEditor_module_default.focalPreviews;
|
|
781
|
+
t1 = PREVIEW_RATIOS.map((id) => {
|
|
782
|
+
const region = cropAround(crop, parseRatio(id) ?? 1, focal);
|
|
783
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
784
|
+
className: ImageEditor_module_default.focalPreview,
|
|
785
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
786
|
+
role: "img",
|
|
787
|
+
"aria-label": intl.formatMessage(mediaMessages.editorFocalPreview, { ratio: id }),
|
|
788
|
+
viewBox: `${String(region.x)} ${String(region.y)} ${String(region.width)} ${String(region.height)}`,
|
|
789
|
+
className: ImageEditor_module_default.focalPreviewImage,
|
|
790
|
+
children: context.drawing
|
|
791
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: id })]
|
|
792
|
+
}, id);
|
|
793
|
+
});
|
|
794
|
+
$[0] = context;
|
|
795
|
+
$[1] = crop;
|
|
796
|
+
$[2] = intl;
|
|
797
|
+
$[3] = size;
|
|
798
|
+
$[4] = transform;
|
|
799
|
+
$[5] = percent;
|
|
800
|
+
$[6] = setPercent;
|
|
801
|
+
$[7] = t0;
|
|
802
|
+
$[8] = t1;
|
|
803
|
+
$[9] = t2;
|
|
804
|
+
$[10] = t3;
|
|
805
|
+
} else {
|
|
806
|
+
percent = $[5];
|
|
807
|
+
setPercent = $[6];
|
|
808
|
+
t0 = $[7];
|
|
809
|
+
t1 = $[8];
|
|
810
|
+
t2 = $[9];
|
|
811
|
+
t3 = $[10];
|
|
812
|
+
}
|
|
813
|
+
let t4;
|
|
814
|
+
if ($[17] !== t0 || $[18] !== t1) {
|
|
815
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
816
|
+
className: t0,
|
|
817
|
+
children: t1
|
|
818
|
+
});
|
|
819
|
+
$[17] = t0;
|
|
820
|
+
$[18] = t1;
|
|
821
|
+
$[19] = t4;
|
|
822
|
+
} else t4 = $[19];
|
|
823
|
+
let t5;
|
|
824
|
+
if ($[20] !== intl) {
|
|
825
|
+
t5 = intl.formatMessage(mediaMessages.editorFocalLeft);
|
|
826
|
+
$[20] = intl;
|
|
827
|
+
$[21] = t5;
|
|
828
|
+
} else t5 = $[21];
|
|
829
|
+
const t6 = transform.focalPoint?.x;
|
|
830
|
+
let t7;
|
|
831
|
+
if ($[22] !== percent || $[23] !== t6) {
|
|
832
|
+
t7 = percent(t6);
|
|
833
|
+
$[22] = percent;
|
|
834
|
+
$[23] = t6;
|
|
835
|
+
$[24] = t7;
|
|
836
|
+
} else t7 = $[24];
|
|
837
|
+
let t8;
|
|
838
|
+
if ($[25] !== setPercent) {
|
|
839
|
+
t8 = (value_1) => setPercent("x", value_1);
|
|
840
|
+
$[25] = setPercent;
|
|
841
|
+
$[26] = t8;
|
|
842
|
+
} else t8 = $[26];
|
|
843
|
+
let t9;
|
|
844
|
+
if ($[27] !== t5 || $[28] !== t7 || $[29] !== t8) {
|
|
845
|
+
t9 = /* @__PURE__ */ jsx(NumberInput, {
|
|
846
|
+
label: t5,
|
|
847
|
+
suffix: "%",
|
|
848
|
+
minValue: 0,
|
|
849
|
+
maxValue: 100,
|
|
850
|
+
value: t7,
|
|
851
|
+
onChange: t8
|
|
852
|
+
});
|
|
853
|
+
$[27] = t5;
|
|
854
|
+
$[28] = t7;
|
|
855
|
+
$[29] = t8;
|
|
856
|
+
$[30] = t9;
|
|
857
|
+
} else t9 = $[30];
|
|
858
|
+
let t10;
|
|
859
|
+
if ($[31] !== intl) {
|
|
860
|
+
t10 = intl.formatMessage(mediaMessages.editorFocalTop);
|
|
861
|
+
$[31] = intl;
|
|
862
|
+
$[32] = t10;
|
|
863
|
+
} else t10 = $[32];
|
|
864
|
+
const t11 = transform.focalPoint?.y;
|
|
865
|
+
let t12;
|
|
866
|
+
if ($[33] !== percent || $[34] !== t11) {
|
|
867
|
+
t12 = percent(t11);
|
|
868
|
+
$[33] = percent;
|
|
869
|
+
$[34] = t11;
|
|
870
|
+
$[35] = t12;
|
|
871
|
+
} else t12 = $[35];
|
|
872
|
+
let t13;
|
|
873
|
+
if ($[36] !== setPercent) {
|
|
874
|
+
t13 = (value_2) => setPercent("y", value_2);
|
|
875
|
+
$[36] = setPercent;
|
|
876
|
+
$[37] = t13;
|
|
877
|
+
} else t13 = $[37];
|
|
878
|
+
let t14;
|
|
879
|
+
if ($[38] !== t10 || $[39] !== t12 || $[40] !== t13) {
|
|
880
|
+
t14 = /* @__PURE__ */ jsx(NumberInput, {
|
|
881
|
+
label: t10,
|
|
882
|
+
suffix: "%",
|
|
883
|
+
minValue: 0,
|
|
884
|
+
maxValue: 100,
|
|
885
|
+
value: t12,
|
|
886
|
+
onChange: t13
|
|
887
|
+
});
|
|
888
|
+
$[38] = t10;
|
|
889
|
+
$[39] = t12;
|
|
890
|
+
$[40] = t13;
|
|
891
|
+
$[41] = t14;
|
|
892
|
+
} else t14 = $[41];
|
|
893
|
+
let t15;
|
|
894
|
+
if ($[42] !== t14 || $[43] !== t9) {
|
|
895
|
+
t15 = /* @__PURE__ */ jsxs("div", {
|
|
896
|
+
className: ImageEditor_module_default.numbers,
|
|
897
|
+
children: [t9, t14]
|
|
898
|
+
});
|
|
899
|
+
$[42] = t14;
|
|
900
|
+
$[43] = t9;
|
|
901
|
+
$[44] = t15;
|
|
902
|
+
} else t15 = $[44];
|
|
903
|
+
let t16;
|
|
904
|
+
if ($[45] !== t15 || $[46] !== t2 || $[47] !== t3 || $[48] !== t4) {
|
|
905
|
+
t16 = /* @__PURE__ */ jsxs("div", {
|
|
906
|
+
className: t2,
|
|
907
|
+
children: [
|
|
908
|
+
t3,
|
|
909
|
+
t4,
|
|
910
|
+
t15
|
|
911
|
+
]
|
|
912
|
+
});
|
|
913
|
+
$[45] = t15;
|
|
914
|
+
$[46] = t2;
|
|
915
|
+
$[47] = t3;
|
|
916
|
+
$[48] = t4;
|
|
917
|
+
$[49] = t16;
|
|
918
|
+
} else t16 = $[49];
|
|
919
|
+
return t16;
|
|
920
|
+
}
|
|
921
|
+
/** The focal point: set by a click or a drag on the image, or with the keyboard. */
|
|
922
|
+
function _temp(value) {
|
|
923
|
+
return Math.round((value ?? .5) * 100);
|
|
924
|
+
}
|
|
925
|
+
function FocalOverlay(context) {
|
|
926
|
+
const $ = c(42);
|
|
927
|
+
const intl = usePanneauIntl();
|
|
928
|
+
const { transform, size, view, unit } = context;
|
|
929
|
+
let t0;
|
|
930
|
+
if ($[0] !== size || $[1] !== transform) {
|
|
931
|
+
t0 = focalInView(size, transform);
|
|
932
|
+
$[0] = size;
|
|
933
|
+
$[1] = transform;
|
|
934
|
+
$[2] = t0;
|
|
935
|
+
} else t0 = $[2];
|
|
936
|
+
const focal = t0;
|
|
937
|
+
const dragging = useRef(false);
|
|
938
|
+
const step = Math.max(view.width, view.height) / 100;
|
|
939
|
+
let t1;
|
|
940
|
+
let t2;
|
|
941
|
+
if ($[3] !== context) {
|
|
942
|
+
t1 = (event) => {
|
|
943
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
944
|
+
dragging.current = true;
|
|
945
|
+
setFocal(context, context.pointToView(event));
|
|
946
|
+
};
|
|
947
|
+
t2 = (event_0) => {
|
|
948
|
+
if (dragging.current) setFocal(context, context.pointToView(event_0));
|
|
949
|
+
};
|
|
950
|
+
$[3] = context;
|
|
951
|
+
$[4] = t1;
|
|
952
|
+
$[5] = t2;
|
|
953
|
+
} else {
|
|
954
|
+
t1 = $[4];
|
|
955
|
+
t2 = $[5];
|
|
956
|
+
}
|
|
957
|
+
let t3;
|
|
958
|
+
let t4;
|
|
959
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
960
|
+
t3 = () => {
|
|
961
|
+
dragging.current = false;
|
|
962
|
+
};
|
|
963
|
+
t4 = () => {
|
|
964
|
+
dragging.current = false;
|
|
965
|
+
};
|
|
966
|
+
$[6] = t3;
|
|
967
|
+
$[7] = t4;
|
|
968
|
+
} else {
|
|
969
|
+
t3 = $[6];
|
|
970
|
+
t4 = $[7];
|
|
971
|
+
}
|
|
972
|
+
let t5;
|
|
973
|
+
if ($[8] !== view.height || $[9] !== view.width) {
|
|
974
|
+
t5 = /* @__PURE__ */ jsx("rect", {
|
|
975
|
+
width: view.width,
|
|
976
|
+
height: view.height,
|
|
977
|
+
className: ImageEditor_module_default.focalArea
|
|
978
|
+
});
|
|
979
|
+
$[8] = view.height;
|
|
980
|
+
$[9] = view.width;
|
|
981
|
+
$[10] = t5;
|
|
982
|
+
} else t5 = $[10];
|
|
983
|
+
let t6;
|
|
984
|
+
if ($[11] !== intl) {
|
|
985
|
+
t6 = intl.formatMessage(mediaMessages.editorFocalRole);
|
|
986
|
+
$[11] = intl;
|
|
987
|
+
$[12] = t6;
|
|
988
|
+
} else t6 = $[12];
|
|
989
|
+
let t7;
|
|
990
|
+
if ($[13] !== intl || $[14] !== transform.focalPoint?.x || $[15] !== transform.focalPoint?.y) {
|
|
991
|
+
t7 = intl.formatMessage(mediaMessages.editorFocalPoint, {
|
|
992
|
+
x: Math.round((transform.focalPoint?.x ?? .5) * 100),
|
|
993
|
+
y: Math.round((transform.focalPoint?.y ?? .5) * 100)
|
|
994
|
+
});
|
|
995
|
+
$[13] = intl;
|
|
996
|
+
$[14] = transform.focalPoint?.x;
|
|
997
|
+
$[15] = transform.focalPoint?.y;
|
|
998
|
+
$[16] = t7;
|
|
999
|
+
} else t7 = $[16];
|
|
1000
|
+
let t8;
|
|
1001
|
+
if ($[17] !== context || $[18] !== focal.x || $[19] !== focal.y || $[20] !== step) {
|
|
1002
|
+
t8 = (event_1) => {
|
|
1003
|
+
const delta = arrows(event_1, step);
|
|
1004
|
+
if (delta !== null) {
|
|
1005
|
+
event_1.preventDefault();
|
|
1006
|
+
setFocal(context, {
|
|
1007
|
+
x: focal.x + delta.dx,
|
|
1008
|
+
y: focal.y + delta.dy
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
$[17] = context;
|
|
1013
|
+
$[18] = focal.x;
|
|
1014
|
+
$[19] = focal.y;
|
|
1015
|
+
$[20] = step;
|
|
1016
|
+
$[21] = t8;
|
|
1017
|
+
} else t8 = $[21];
|
|
1018
|
+
const t9 = 18 * unit;
|
|
1019
|
+
let t10;
|
|
1020
|
+
if ($[22] !== focal.x || $[23] !== focal.y || $[24] !== t9) {
|
|
1021
|
+
t10 = /* @__PURE__ */ jsx("circle", {
|
|
1022
|
+
cx: focal.x,
|
|
1023
|
+
cy: focal.y,
|
|
1024
|
+
r: t9,
|
|
1025
|
+
className: ImageEditor_module_default.focalRing
|
|
1026
|
+
});
|
|
1027
|
+
$[22] = focal.x;
|
|
1028
|
+
$[23] = focal.y;
|
|
1029
|
+
$[24] = t9;
|
|
1030
|
+
$[25] = t10;
|
|
1031
|
+
} else t10 = $[25];
|
|
1032
|
+
const t11 = 4 * unit;
|
|
1033
|
+
let t12;
|
|
1034
|
+
if ($[26] !== focal.x || $[27] !== focal.y || $[28] !== t11) {
|
|
1035
|
+
t12 = /* @__PURE__ */ jsx("circle", {
|
|
1036
|
+
cx: focal.x,
|
|
1037
|
+
cy: focal.y,
|
|
1038
|
+
r: t11,
|
|
1039
|
+
className: ImageEditor_module_default.focalDot
|
|
1040
|
+
});
|
|
1041
|
+
$[26] = focal.x;
|
|
1042
|
+
$[27] = focal.y;
|
|
1043
|
+
$[28] = t11;
|
|
1044
|
+
$[29] = t12;
|
|
1045
|
+
} else t12 = $[29];
|
|
1046
|
+
let t13;
|
|
1047
|
+
if ($[30] !== context.hintId || $[31] !== t10 || $[32] !== t12 || $[33] !== t6 || $[34] !== t7 || $[35] !== t8) {
|
|
1048
|
+
t13 = /* @__PURE__ */ jsxs("g", {
|
|
1049
|
+
tabIndex: 0,
|
|
1050
|
+
role: "group",
|
|
1051
|
+
"aria-roledescription": t6,
|
|
1052
|
+
"aria-label": t7,
|
|
1053
|
+
"aria-describedby": context.hintId,
|
|
1054
|
+
className: ImageEditor_module_default.focal,
|
|
1055
|
+
onKeyDown: t8,
|
|
1056
|
+
children: [t10, t12]
|
|
1057
|
+
});
|
|
1058
|
+
$[30] = context.hintId;
|
|
1059
|
+
$[31] = t10;
|
|
1060
|
+
$[32] = t12;
|
|
1061
|
+
$[33] = t6;
|
|
1062
|
+
$[34] = t7;
|
|
1063
|
+
$[35] = t8;
|
|
1064
|
+
$[36] = t13;
|
|
1065
|
+
} else t13 = $[36];
|
|
1066
|
+
let t14;
|
|
1067
|
+
if ($[37] !== t1 || $[38] !== t13 || $[39] !== t2 || $[40] !== t5) {
|
|
1068
|
+
t14 = /* @__PURE__ */ jsxs("g", {
|
|
1069
|
+
onPointerDown: t1,
|
|
1070
|
+
onPointerMove: t2,
|
|
1071
|
+
onPointerUp: t3,
|
|
1072
|
+
onPointerCancel: t4,
|
|
1073
|
+
children: [t5, t13]
|
|
1074
|
+
});
|
|
1075
|
+
$[37] = t1;
|
|
1076
|
+
$[38] = t13;
|
|
1077
|
+
$[39] = t2;
|
|
1078
|
+
$[40] = t5;
|
|
1079
|
+
$[41] = t14;
|
|
1080
|
+
} else t14 = $[41];
|
|
1081
|
+
return t14;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* The tools of the editor by default: crop, rotate (with flips) and focal point. A product passes
|
|
1085
|
+
* them to `ImageEditor`'s `tools` with its own, or without the ones a field doesn't offer.
|
|
1086
|
+
*/
|
|
1087
|
+
function useImageEditorTools() {
|
|
1088
|
+
const $ = c(25);
|
|
1089
|
+
const intl = usePanneauIntl();
|
|
1090
|
+
let t0;
|
|
1091
|
+
if ($[0] !== intl) {
|
|
1092
|
+
t0 = intl.formatMessage(mediaMessages.editorToolCrop);
|
|
1093
|
+
$[0] = intl;
|
|
1094
|
+
$[1] = t0;
|
|
1095
|
+
} else t0 = $[1];
|
|
1096
|
+
let t1;
|
|
1097
|
+
if ($[2] !== intl) {
|
|
1098
|
+
t1 = intl.formatMessage(mediaMessages.editorCropHint);
|
|
1099
|
+
$[2] = intl;
|
|
1100
|
+
$[3] = t1;
|
|
1101
|
+
} else t1 = $[3];
|
|
1102
|
+
let t2;
|
|
1103
|
+
if ($[4] !== t0 || $[5] !== t1) {
|
|
1104
|
+
t2 = {
|
|
1105
|
+
id: "crop",
|
|
1106
|
+
label: t0,
|
|
1107
|
+
icon: Crop,
|
|
1108
|
+
hint: t1,
|
|
1109
|
+
renderPanel: _temp2,
|
|
1110
|
+
renderOverlay: _temp3
|
|
1111
|
+
};
|
|
1112
|
+
$[4] = t0;
|
|
1113
|
+
$[5] = t1;
|
|
1114
|
+
$[6] = t2;
|
|
1115
|
+
} else t2 = $[6];
|
|
1116
|
+
let t3;
|
|
1117
|
+
if ($[7] !== intl) {
|
|
1118
|
+
t3 = intl.formatMessage(mediaMessages.editorToolRotate);
|
|
1119
|
+
$[7] = intl;
|
|
1120
|
+
$[8] = t3;
|
|
1121
|
+
} else t3 = $[8];
|
|
1122
|
+
let t4;
|
|
1123
|
+
if ($[9] !== intl) {
|
|
1124
|
+
t4 = intl.formatMessage(mediaMessages.editorRotateHint);
|
|
1125
|
+
$[9] = intl;
|
|
1126
|
+
$[10] = t4;
|
|
1127
|
+
} else t4 = $[10];
|
|
1128
|
+
let t5;
|
|
1129
|
+
if ($[11] !== t3 || $[12] !== t4) {
|
|
1130
|
+
t5 = {
|
|
1131
|
+
id: "rotate",
|
|
1132
|
+
label: t3,
|
|
1133
|
+
icon: RotateCw,
|
|
1134
|
+
hint: t4,
|
|
1135
|
+
renderPanel: _temp4
|
|
1136
|
+
};
|
|
1137
|
+
$[11] = t3;
|
|
1138
|
+
$[12] = t4;
|
|
1139
|
+
$[13] = t5;
|
|
1140
|
+
} else t5 = $[13];
|
|
1141
|
+
let t6;
|
|
1142
|
+
if ($[14] !== intl) {
|
|
1143
|
+
t6 = intl.formatMessage(mediaMessages.editorToolFocalPoint);
|
|
1144
|
+
$[14] = intl;
|
|
1145
|
+
$[15] = t6;
|
|
1146
|
+
} else t6 = $[15];
|
|
1147
|
+
let t7;
|
|
1148
|
+
if ($[16] !== intl) {
|
|
1149
|
+
t7 = intl.formatMessage(mediaMessages.editorFocalHint);
|
|
1150
|
+
$[16] = intl;
|
|
1151
|
+
$[17] = t7;
|
|
1152
|
+
} else t7 = $[17];
|
|
1153
|
+
let t8;
|
|
1154
|
+
if ($[18] !== t6 || $[19] !== t7) {
|
|
1155
|
+
t8 = {
|
|
1156
|
+
id: "focalPoint",
|
|
1157
|
+
label: t6,
|
|
1158
|
+
icon: Focus,
|
|
1159
|
+
hint: t7,
|
|
1160
|
+
renderPanel: _temp5,
|
|
1161
|
+
renderOverlay: _temp6
|
|
1162
|
+
};
|
|
1163
|
+
$[18] = t6;
|
|
1164
|
+
$[19] = t7;
|
|
1165
|
+
$[20] = t8;
|
|
1166
|
+
} else t8 = $[20];
|
|
1167
|
+
let t9;
|
|
1168
|
+
if ($[21] !== t2 || $[22] !== t5 || $[23] !== t8) {
|
|
1169
|
+
t9 = {
|
|
1170
|
+
crop: t2,
|
|
1171
|
+
rotate: t5,
|
|
1172
|
+
focalPoint: t8
|
|
1173
|
+
};
|
|
1174
|
+
$[21] = t2;
|
|
1175
|
+
$[22] = t5;
|
|
1176
|
+
$[23] = t8;
|
|
1177
|
+
$[24] = t9;
|
|
1178
|
+
} else t9 = $[24];
|
|
1179
|
+
return t9;
|
|
1180
|
+
}
|
|
1181
|
+
function _temp6(context_3) {
|
|
1182
|
+
return /* @__PURE__ */ jsx(FocalOverlay, { ...context_3 });
|
|
1183
|
+
}
|
|
1184
|
+
function _temp5(context_2) {
|
|
1185
|
+
return /* @__PURE__ */ jsx(FocalPanel, { ...context_2 });
|
|
1186
|
+
}
|
|
1187
|
+
function _temp4(context_1) {
|
|
1188
|
+
return /* @__PURE__ */ jsx(RotatePanel, { ...context_1 });
|
|
1189
|
+
}
|
|
1190
|
+
function _temp3(context_0) {
|
|
1191
|
+
return /* @__PURE__ */ jsx(CropOverlay, { ...context_0 });
|
|
1192
|
+
}
|
|
1193
|
+
function _temp2(context) {
|
|
1194
|
+
return /* @__PURE__ */ jsx(CropPanel, { ...context });
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
export { useImageEditorTools };
|
|
1198
|
+
|
|
1199
|
+
//# sourceMappingURL=tools.js.map
|