@anzusystems/common-admin 2.0.0-rc.28 → 2.0.0-rc.29
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/domains/dam/api/damAssetApi.d.ts +12 -1
- package/dist/domains/dam/api/damAssetApi.js +151 -95
- package/dist/domains/dam/api/damAssetApi.js.map +1 -1
- package/dist/domains/dam/api/damMetadataOnServer.d.ts +35 -0
- package/dist/domains/dam/api/damMetadataOnServer.js +28 -0
- package/dist/domains/dam/api/damMetadataOnServer.js.map +1 -0
- package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue.js +26 -25
- package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue.js.map +1 -1
- package/dist/domains/dam/assetDetail/store/assetDetailStore.js +40 -39
- package/dist/domains/dam/assetDetail/store/assetDetailStore.js.map +1 -1
- package/dist/domains/dam/cropper/components/ACropper.vue.d.ts +1 -1
- package/dist/domains/dam/cropper/components/ACropper.vue.js +153 -136
- package/dist/domains/dam/cropper/components/ACropper.vue.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/AImageMediaWidget.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/AImagePublicInput.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/AImageWidget.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/AImageWidgetMultiple.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue.d.ts +1 -1
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue.d.ts +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue.js +106 -106
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue.js +13 -13
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue.js.map +1 -1
- package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js +115 -114
- package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js.map +1 -1
- package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js +147 -143
- package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js.map +1 -1
- package/dist/domains/filters/components/FiltersSelected.vue.js +5 -5
- package/dist/domains/filters/components/FiltersSelected.vue.js.map +1 -1
- package/dist/domains/filters/composables/filterFactory.js +41 -38
- package/dist/domains/filters/composables/filterFactory.js.map +1 -1
- package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocomplete.vue.js +46 -38
- package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocomplete.vue.js.map +1 -1
- package/dist/domains/system/composables/alerts.js +8 -2
- package/dist/domains/system/composables/alerts.js.map +1 -1
- package/dist/domains/system/systemBar/utils/appReload.d.ts +9 -1
- package/dist/domains/system/systemBar/utils/appReload.js +3 -3
- package/dist/domains/system/systemBar/utils/appReload.js.map +1 -1
- package/dist/lib.d.ts +2 -2
- package/package.json +2 -2
|
@@ -6,15 +6,15 @@ import i from "../../../../vendor/@cropper/element-selection/dist/element-select
|
|
|
6
6
|
import a from "../../../../vendor/@cropper/element-grid/dist/element-grid.esm.raw.js";
|
|
7
7
|
import o from "../../../../vendor/@cropper/element-crosshair/dist/element-crosshair.esm.raw.js";
|
|
8
8
|
import { createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, normalizeStyle as f, onBeforeUnmount as ee, onMounted as te, openBlock as p, ref as ne, useTemplateRef as re, watch as m } from "vue";
|
|
9
|
-
import {
|
|
9
|
+
import { useEventListener as ie, useResizeObserver as ae } from "@vueuse/core";
|
|
10
10
|
import "../../../../vendor/cropperjs/dist/cropper.esm.raw.js";
|
|
11
|
-
import { RESIZE_ANCHORS as
|
|
11
|
+
import { RESIZE_ANCHORS as oe, canvasSizeFor as h, clampRectInside as g, initialSelectionRect as se, isUsableAspectRatio as ce, rectsAreClose as _ } from "../utils/cropperGeometry.js";
|
|
12
12
|
import { VProgressCircular as le } from "vuetify/components/VProgressCircular";
|
|
13
13
|
// src/domains/dam/cropper/components/ACropper.vue?vue&type=script&setup=true&lang.ts
|
|
14
14
|
var ue = { class: "a-cropper d-flex flex-column" }, de = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "d-flex w-100 align-center justify-center"
|
|
17
|
-
}, fe = .8, pe = 200,
|
|
17
|
+
}, fe = .8, pe = 200, v = 100, me = 20, y = "rgba(51, 153, 255, 0.75)", he = "rgba(255, 255, 255, 0.1)", ge = "rgba(238, 238, 238, 0.5)", _e = "rgba(238, 238, 238, 0.75)", b = /*@__PURE__*/ d({
|
|
18
18
|
__name: "ACropper",
|
|
19
19
|
props: {
|
|
20
20
|
src: { default: "" },
|
|
@@ -28,8 +28,8 @@ var ue = { class: "a-cropper d-flex flex-column" }, de = {
|
|
|
28
28
|
"commit",
|
|
29
29
|
"ready"
|
|
30
30
|
],
|
|
31
|
-
setup(d, { emit:
|
|
32
|
-
let
|
|
31
|
+
setup(d, { emit: b }) {
|
|
32
|
+
let x = d, S = b;
|
|
33
33
|
for (let s of [
|
|
34
34
|
e,
|
|
35
35
|
o,
|
|
@@ -39,7 +39,7 @@ var ue = { class: "a-cropper d-flex flex-column" }, de = {
|
|
|
39
39
|
i,
|
|
40
40
|
n
|
|
41
41
|
]) s.$define();
|
|
42
|
-
let
|
|
42
|
+
let ve = [
|
|
43
43
|
"n-resize",
|
|
44
44
|
"e-resize",
|
|
45
45
|
"s-resize",
|
|
@@ -48,243 +48,260 @@ var ue = { class: "a-cropper d-flex flex-column" }, de = {
|
|
|
48
48
|
"nw-resize",
|
|
49
49
|
"se-resize",
|
|
50
50
|
"sw-resize"
|
|
51
|
-
],
|
|
51
|
+
], C = re("hostEl"), w = ne(!0), T = null, E = {
|
|
52
52
|
width: 0,
|
|
53
53
|
height: 0
|
|
54
|
-
},
|
|
54
|
+
}, D = null, O = !1, k = !1, A = 0, j = {
|
|
55
55
|
width: 0,
|
|
56
56
|
height: 0
|
|
57
|
-
},
|
|
58
|
-
if (!
|
|
57
|
+
}, M = null, N = null, P = null, F = null, I = (e) => document.createElement(e), L = () => {
|
|
58
|
+
if (!T) return {
|
|
59
59
|
x: 0,
|
|
60
60
|
y: 0,
|
|
61
61
|
width: 0,
|
|
62
62
|
height: 0
|
|
63
63
|
};
|
|
64
|
-
let e =
|
|
64
|
+
let e = T.canvas.getBoundingClientRect(), t = T.image.getBoundingClientRect();
|
|
65
65
|
return {
|
|
66
66
|
x: t.left - e.left,
|
|
67
67
|
y: t.top - e.top,
|
|
68
68
|
width: t.width,
|
|
69
69
|
height: t.height
|
|
70
70
|
};
|
|
71
|
-
},
|
|
72
|
-
if (!
|
|
71
|
+
}, R = () => {
|
|
72
|
+
if (!T) return {
|
|
73
73
|
x: 0,
|
|
74
74
|
y: 0,
|
|
75
75
|
width: 0,
|
|
76
76
|
height: 0
|
|
77
77
|
};
|
|
78
|
-
let e =
|
|
78
|
+
let e = L(), t = T.canvas.getBoundingClientRect(), n = Math.max(e.x, 0), r = Math.max(e.y, 0), i = Math.min(e.x + e.width, t.width), a = Math.min(e.y + e.height, t.height);
|
|
79
79
|
return {
|
|
80
80
|
x: n,
|
|
81
81
|
y: r,
|
|
82
82
|
width: Math.max(0, i - n),
|
|
83
83
|
height: Math.max(0, a - r)
|
|
84
84
|
};
|
|
85
|
-
},
|
|
86
|
-
if (!
|
|
85
|
+
}, z = () => {
|
|
86
|
+
if (!T) return {
|
|
87
87
|
x: 0,
|
|
88
88
|
y: 0,
|
|
89
89
|
width: 0,
|
|
90
90
|
height: 0
|
|
91
91
|
};
|
|
92
|
-
let { x: e, y: t, width: n, height: r } =
|
|
92
|
+
let { x: e, y: t, width: n, height: r } = T.selection;
|
|
93
93
|
return {
|
|
94
94
|
x: e,
|
|
95
95
|
y: t,
|
|
96
96
|
width: n,
|
|
97
97
|
height: r
|
|
98
98
|
};
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
if (!
|
|
103
|
-
let { image: e } =
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
if (!
|
|
107
|
-
let e =
|
|
99
|
+
}, B = (e) => {
|
|
100
|
+
T && (O = !0, T.selection.$change(e.x, e.y, e.width, e.height, x.aspectRatio, !0), O = !1);
|
|
101
|
+
}, V = () => {
|
|
102
|
+
if (!T) return;
|
|
103
|
+
let { image: e } = T, { scalable: t, translatable: n } = e;
|
|
104
|
+
k = !0, e.scalable = !0, e.translatable = !0, e.$center("contain"), e.scalable = t, e.translatable = n, k = !1;
|
|
105
|
+
}, ye = () => {
|
|
106
|
+
if (!T) return;
|
|
107
|
+
let e = L();
|
|
108
108
|
if (e.width <= 0 || e.height <= 0) return;
|
|
109
|
-
let t = se(e,
|
|
110
|
-
|
|
109
|
+
let t = se(e, x.aspectRatio, fe);
|
|
110
|
+
B({
|
|
111
111
|
...t,
|
|
112
112
|
x: t.x + e.x,
|
|
113
113
|
y: t.y + e.y
|
|
114
114
|
});
|
|
115
|
-
},
|
|
116
|
-
let e =
|
|
117
|
-
e && e.width > 0 && e.height > 0 ?
|
|
118
|
-
},
|
|
119
|
-
if (!
|
|
120
|
-
let e =
|
|
115
|
+
}, H = () => {
|
|
116
|
+
let e = x.modelValue;
|
|
117
|
+
e && e.width > 0 && e.height > 0 ? J(e) : ye(), X();
|
|
118
|
+
}, be = () => {
|
|
119
|
+
if (!T || k) return;
|
|
120
|
+
let e = z();
|
|
121
121
|
if (e.width <= 0 || e.height <= 0) return;
|
|
122
|
-
let t =
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
if (
|
|
122
|
+
let t = g(e, R(), x.aspectRatio);
|
|
123
|
+
_(e, t) || B(t);
|
|
124
|
+
}, U = (e) => {
|
|
125
|
+
if (O || !T) return;
|
|
126
126
|
let t = e.detail;
|
|
127
127
|
if (!t) return;
|
|
128
|
-
let n =
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
},
|
|
128
|
+
let n = T.canvas.$action, r = typeof n == "string" && n ? n : D, i = r ? oe[r] : void 0, a = g(t, R(), x.aspectRatio, i);
|
|
129
|
+
_(t, a) || (e.preventDefault(), B(a));
|
|
130
|
+
}, W = (e) => {
|
|
131
|
+
D = e.detail?.action ?? null, P || (P = q(), F = D === "select" ? z() : null);
|
|
132
|
+
}, G = (e) => {
|
|
133
133
|
let t = e.detail?.action;
|
|
134
|
-
t && (
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
t && (D = t);
|
|
135
|
+
}, xe = (e) => {
|
|
136
|
+
let t = R(), n = Math.min(me, Math.min(t.width, t.height) / 4);
|
|
137
|
+
return Math.max(e.width, e.height) < n;
|
|
138
|
+
}, Se = (e) => {
|
|
139
|
+
let t = T?.canvas?.$pointers, n = e.detail?.relatedEvent;
|
|
140
|
+
if (!(t instanceof Map) || !n) return !1;
|
|
141
|
+
let r = "changedTouches" in n ? Array.from(n.changedTouches, (e) => e.identifier) : [n.pointerId ?? 0];
|
|
142
|
+
return [...t.keys()].some((e) => !r.includes(e));
|
|
143
|
+
}, Ce = (e) => {
|
|
144
|
+
if (Se(e)) return;
|
|
145
|
+
D = null;
|
|
146
|
+
let t = P, n = F;
|
|
147
|
+
P = null, F = null, t && (n && xe(z()) && B(g(n, R(), x.aspectRatio)), Y(q(), t) || X(!0));
|
|
148
|
+
}, we = (e) => {
|
|
138
149
|
e.stopPropagation();
|
|
139
|
-
},
|
|
140
|
-
if (
|
|
141
|
-
let { canvas: e, image: t, selection: n } =
|
|
142
|
-
n.removeEventListener("change",
|
|
150
|
+
}, Te = () => queueMicrotask(be), Ee = () => {
|
|
151
|
+
if (T) {
|
|
152
|
+
let { canvas: e, image: t, selection: n } = T;
|
|
153
|
+
n.removeEventListener("change", U), e.removeEventListener("actionstart", W), e.removeEventListener("action", G), e.removeEventListener("actionend", Ce), t.removeEventListener("transform", Te);
|
|
143
154
|
}
|
|
144
|
-
|
|
155
|
+
C.value?.querySelectorAll(e.$name).forEach((e) => {
|
|
145
156
|
e.querySelectorAll(t.$name).forEach((e) => {
|
|
146
157
|
e.$image && (e.$image.src = "");
|
|
147
158
|
}), e.remove();
|
|
148
|
-
}),
|
|
159
|
+
}), N?.disconnect(), N = null, T = null, E = {
|
|
149
160
|
width: 0,
|
|
150
161
|
height: 0
|
|
151
|
-
},
|
|
162
|
+
}, j = {
|
|
152
163
|
width: 0,
|
|
153
164
|
height: 0
|
|
154
|
-
},
|
|
155
|
-
},
|
|
165
|
+
}, D = null, P = null, F = null;
|
|
166
|
+
}, De = (e) => {
|
|
156
167
|
let t = [], n = e.parentElement;
|
|
157
168
|
for (; n && n !== document.body && n !== document.documentElement;) {
|
|
158
169
|
let { overflowY: e } = window.getComputedStyle(n);
|
|
159
170
|
(e === "hidden" || e === "clip") && t.push(n), n = n.parentElement;
|
|
160
171
|
}
|
|
161
172
|
return t;
|
|
162
|
-
},
|
|
163
|
-
let
|
|
164
|
-
return
|
|
165
|
-
let
|
|
166
|
-
i > 0 && (
|
|
167
|
-
}),
|
|
168
|
-
},
|
|
169
|
-
let
|
|
173
|
+
}, Oe = (e, t) => {
|
|
174
|
+
let n = t, r = e.getBoundingClientRect().top;
|
|
175
|
+
return De(e).forEach((e) => {
|
|
176
|
+
let t = e.getBoundingClientRect(), i = t.bottom - Math.max(t.top, r);
|
|
177
|
+
i > 0 && (n = Math.min(n, i));
|
|
178
|
+
}), n;
|
|
179
|
+
}, ke = (e) => Oe(e, e.clientHeight), Ae = (e) => {
|
|
180
|
+
let t = window.getComputedStyle(e).maxHeight;
|
|
181
|
+
return t.endsWith("px") ? parseFloat(t) : 1e400;
|
|
182
|
+
}, K = (e, t, n) => {
|
|
183
|
+
let r = h(E, n, pe, v);
|
|
170
184
|
e.style.width = `${r.width}px`, e.style.height = `${r.height}px`;
|
|
171
|
-
let i =
|
|
172
|
-
return i > 0 && i < r.height && (r.height = Math.max(i,
|
|
173
|
-
},
|
|
174
|
-
let t =
|
|
175
|
-
t.rows = 3, t.columns = 3, t.covered = !0, t.themeColor =
|
|
176
|
-
let n =
|
|
177
|
-
n.centered = !0, n.themeColor =
|
|
178
|
-
let i =
|
|
179
|
-
i.action = "move", i.themeColor =
|
|
180
|
-
let n =
|
|
181
|
-
n.action = t, n.themeColor =
|
|
185
|
+
let i = ke(t);
|
|
186
|
+
return i > 0 && i < r.height && (r.height = Math.max(i, v), e.style.height = `${r.height}px`), r;
|
|
187
|
+
}, je = (e) => {
|
|
188
|
+
let t = I(a.$name);
|
|
189
|
+
t.rows = 3, t.columns = 3, t.covered = !0, t.themeColor = ge, t.setAttribute("role", "grid"), e.appendChild(t);
|
|
190
|
+
let n = I(o.$name);
|
|
191
|
+
n.centered = !0, n.themeColor = _e, e.appendChild(n);
|
|
192
|
+
let i = I(r.$name);
|
|
193
|
+
i.action = "move", i.themeColor = he, e.appendChild(i), ve.forEach((t) => {
|
|
194
|
+
let n = I(r.$name);
|
|
195
|
+
n.action = t, n.themeColor = y, e.appendChild(n);
|
|
182
196
|
});
|
|
183
|
-
},
|
|
184
|
-
let a = ++
|
|
185
|
-
|
|
186
|
-
let o =
|
|
187
|
-
if (!o || !
|
|
188
|
-
|
|
197
|
+
}, Me = async () => {
|
|
198
|
+
let a = ++A;
|
|
199
|
+
Ee(), w.value = !0;
|
|
200
|
+
let o = C.value;
|
|
201
|
+
if (!o || !x.src) {
|
|
202
|
+
w.value = !1;
|
|
189
203
|
return;
|
|
190
204
|
}
|
|
191
|
-
let s =
|
|
192
|
-
s.background = !1, s.themeColor =
|
|
193
|
-
let c =
|
|
194
|
-
c.alt = "", c.initialFit = "contain", c.rotatable = !1, c.skewable = !1, c.translatable = !1, c.scalable = !0, c.src =
|
|
195
|
-
let l =
|
|
196
|
-
l.themeColor =
|
|
197
|
-
let u =
|
|
205
|
+
let s = I(e.$name);
|
|
206
|
+
s.background = !1, s.themeColor = y, s.style.display = "block", K(s, o, o.clientWidth);
|
|
207
|
+
let c = I(t.$name);
|
|
208
|
+
c.alt = "", c.initialFit = "contain", c.rotatable = !1, c.skewable = !1, c.translatable = !1, c.scalable = !0, c.src = x.src;
|
|
209
|
+
let l = I(n.$name);
|
|
210
|
+
l.themeColor = x.shadeColor, l.hidden = !0;
|
|
211
|
+
let u = I(r.$name);
|
|
198
212
|
u.action = "select", u.plain = !0;
|
|
199
|
-
let d =
|
|
200
|
-
d.themeColor =
|
|
213
|
+
let d = I(i.$name);
|
|
214
|
+
d.themeColor = y, d.movable = !0, d.resizable = !0, d.outlined = !0, d.precise = !0, d.aspectRatio = x.aspectRatio, je(d), s.addEventListener("actionstart", W), s.addEventListener("action", G), s.addEventListener("actionend", Ce), c.addEventListener("transform", Te), d.addEventListener("change", U), s.append(c, l, u, d), o.appendChild(s), K(s, o, o.clientWidth);
|
|
201
215
|
let f;
|
|
202
216
|
try {
|
|
203
217
|
f = await c.$ready();
|
|
204
218
|
} catch {
|
|
205
|
-
s.remove(), a ===
|
|
219
|
+
s.remove(), a === A && (w.value = !1);
|
|
206
220
|
return;
|
|
207
221
|
}
|
|
208
|
-
a ===
|
|
222
|
+
a === A ? (T = {
|
|
209
223
|
canvas: s,
|
|
210
224
|
image: c,
|
|
211
225
|
selection: d
|
|
212
|
-
},
|
|
226
|
+
}, E = {
|
|
213
227
|
width: f.naturalWidth,
|
|
214
228
|
height: f.naturalHeight
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
if (!
|
|
218
|
-
let e =
|
|
229
|
+
}, K(s, o, o.clientWidth), l.themeColor = x.shadeColor, d.aspectRatio = x.aspectRatio, V(), j = Z(o), $(o), H(), w.value = !1, S("ready")) : s.remove();
|
|
230
|
+
}, q = () => {
|
|
231
|
+
if (!T) return null;
|
|
232
|
+
let e = L();
|
|
219
233
|
if (e.width <= 0 || e.height <= 0) return null;
|
|
220
|
-
let t =
|
|
234
|
+
let t = z();
|
|
221
235
|
return {
|
|
222
236
|
x: (t.x - e.x) / e.width,
|
|
223
237
|
y: (t.y - e.y) / e.height,
|
|
224
238
|
width: t.width / e.width,
|
|
225
239
|
height: t.height / e.height
|
|
226
240
|
};
|
|
227
|
-
},
|
|
228
|
-
let t =
|
|
229
|
-
!
|
|
241
|
+
}, J = (e) => {
|
|
242
|
+
let t = L();
|
|
243
|
+
!T || t.width <= 0 || t.height <= 0 || B(g({
|
|
230
244
|
x: t.x + e.x * t.width,
|
|
231
245
|
y: t.y + e.y * t.height,
|
|
232
246
|
width: e.width * t.width,
|
|
233
247
|
height: e.height * t.height
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
let t =
|
|
237
|
-
t && ((e || !
|
|
238
|
-
}, Z = (e) =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
}, R(), x.aspectRatio));
|
|
249
|
+
}, Y = (e, t) => e !== null && t !== null && Math.abs(e.x - t.x) < 5e-4 && Math.abs(e.y - t.y) < 5e-4 && Math.abs(e.width - t.width) < 5e-4 && Math.abs(e.height - t.height) < 5e-4, X = (e = !1) => {
|
|
250
|
+
let t = q();
|
|
251
|
+
t && ((e || !Y(t, M)) && (M = t, S("update:modelValue", t)), e && S("commit", t));
|
|
252
|
+
}, Z = (e) => {
|
|
253
|
+
let t = e.clientWidth, n = h(E, t, pe, v).height;
|
|
254
|
+
return {
|
|
255
|
+
width: t,
|
|
256
|
+
height: Math.min(n, Oe(e, Ae(e)))
|
|
257
|
+
};
|
|
258
|
+
}, Ne = () => {
|
|
259
|
+
let e = C.value;
|
|
260
|
+
if (!T || !e) return;
|
|
261
|
+
let t = q() ?? x.modelValue, n = K(T.canvas, e, e.clientWidth);
|
|
262
|
+
j = Z(e), $(e), V(), n.width <= 0 || n.height <= 0 || (t && t.width > 0 ? J(t) : H(), X());
|
|
246
263
|
}, Q = () => {
|
|
247
|
-
let e =
|
|
264
|
+
let e = C.value;
|
|
248
265
|
if (!e) return;
|
|
249
266
|
let t = Z(e);
|
|
250
|
-
t.width <= 0 || t.height <= 0 || (t.width !==
|
|
267
|
+
t.width <= 0 || t.height <= 0 || (t.width !== j.width || t.height !== j.height) && T && requestAnimationFrame(() => Ne());
|
|
251
268
|
};
|
|
252
|
-
ie(
|
|
269
|
+
ae(C, Q), ie(window, "resize", Q, { passive: !0 });
|
|
253
270
|
let $ = (e) => {
|
|
254
|
-
|
|
255
|
-
let t =
|
|
256
|
-
t.length === 0 ?
|
|
271
|
+
N?.disconnect();
|
|
272
|
+
let t = De(e);
|
|
273
|
+
t.length === 0 ? N = null : (N = new ResizeObserver(Q), t.forEach((e) => N?.observe(e)));
|
|
257
274
|
};
|
|
258
|
-
return m(() =>
|
|
259
|
-
|
|
260
|
-
}), m(() =>
|
|
261
|
-
|
|
262
|
-
}, { deep: !0 }), m(() =>
|
|
263
|
-
let t =
|
|
275
|
+
return m(() => x.src, () => {
|
|
276
|
+
Me();
|
|
277
|
+
}), m(() => x.modelValue, (e) => {
|
|
278
|
+
T && e && !Y(e, M) && (J(e), X());
|
|
279
|
+
}, { deep: !0 }), m(() => x.shadeColor, (e) => {
|
|
280
|
+
let t = T?.canvas.querySelector(n.$name);
|
|
264
281
|
t && (t.themeColor = e);
|
|
265
|
-
}), m(() =>
|
|
266
|
-
if (!
|
|
267
|
-
let t =
|
|
268
|
-
|
|
282
|
+
}), m(() => x.aspectRatio, (e) => {
|
|
283
|
+
if (!T || (T.selection.aspectRatio = e, !ce(e))) return;
|
|
284
|
+
let t = z();
|
|
285
|
+
B(g({
|
|
269
286
|
...t,
|
|
270
287
|
height: t.width / e
|
|
271
|
-
},
|
|
288
|
+
}, R(), e));
|
|
272
289
|
}), te(() => {
|
|
273
|
-
|
|
290
|
+
Me();
|
|
274
291
|
}), ee(() => {
|
|
275
|
-
|
|
276
|
-
}), (e, t) => (p(), c("div", ue, [
|
|
292
|
+
A += 1, Ee();
|
|
293
|
+
}), (e, t) => (p(), c("div", ue, [w.value ? (p(), c("div", de, [u(le, {
|
|
277
294
|
class: "position-absolute",
|
|
278
295
|
indeterminate: ""
|
|
279
296
|
})])) : s("", !0), l("div", {
|
|
280
297
|
ref_key: "hostEl",
|
|
281
|
-
ref:
|
|
298
|
+
ref: C,
|
|
282
299
|
class: "a-cropper__container",
|
|
283
300
|
style: f(d.containerStyle),
|
|
284
|
-
onWheelCapture:
|
|
301
|
+
onWheelCapture: we
|
|
285
302
|
}, null, 36)]));
|
|
286
303
|
}
|
|
287
304
|
});
|
|
288
|
-
export {
|
|
305
|
+
export { b as default };
|
|
289
306
|
|
|
290
307
|
//# sourceMappingURL=ACropper.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ACropper.vue.js","names":["_openBlock","_createElementBlock","_createVNode","_component_VProgressCircular","_createElementVNode","_normalizeStyle","CropperCanvas","CropperImage","CropperShade","CropperHandle","CropperSelection","CropperGrid","CropperCrosshair","createCommentVNode","createElementBlock","createElementVNode","createVNode","defineComponent","normalizeStyle","onBeforeUnmount","onMounted","openBlock","ref","useTemplateRef","watch","useResizeObserver","RESIZE_ANCHORS","canvasSizeFor","clampRectInside","initialSelectionRect","isUsableAspectRatio","rectsAreClose","VProgressCircular","_hoisted_1","_hoisted_2","AUTO_CROP_AREA","MIN_CONTAINER_WIDTH","MIN_CONTAINER_HEIGHT","SELECTION_COLOR","FACE_COLOR","GRID_COLOR","CROSSHAIR_COLOR","ACropper_vue_vue_type_script_setup_true_lang_default","__props","__emit","props","emit","element","RESIZE_ACTIONS","hostEl","loading","parts","natural","currentAction","clamping","centring","buildToken","laidOut","lastEmitted","ancestorObserver","create","name","imageBounds","canvasRect","imageRect","constraintBounds","image","canvas","left","top","right","bottom","selectionRect","x","y","width","height","applyRect","rect","centerImage","scalable","translatable","seedInitialCrop","bounds","initial","applyModelOrSeed","model","applyCrop","emitCrop","refit","current","fitted","onSelectionChange","event","detail","liveAction","action","anchor","clamped","onActionStart","onAction","onActionEnd","onWheelCapture","onImageTransform","teardown","selection","clippingAncestorsOf","host","found","ancestor","overflowY","visibleHeightOf","available","hostTop","room","sizeCanvas","availableWidth","size","visibleHeight","buildSelectionChildren","grid","crosshair","face","handle","build","token","shade","selectHandle","loaded","hostBox","observeAncestors","currentCrop","crop","cropsAreClose","a","b","alsoCommit","relayout","wanted","onHostBoxChanged","box","ancestors","shadeColor","aspectRatio","_ctx","_cache"],"sources":["../../../../../src/domains/dam/cropper/components/ACropper.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\nimport { useResizeObserver } from '@vueuse/core'\nimport {\n CropperCanvas,\n CropperCrosshair,\n CropperGrid,\n CropperHandle,\n CropperImage,\n CropperSelection,\n CropperShade,\n} from 'cropperjs'\nimport {\n canvasSizeFor,\n clampRectInside,\n initialSelectionRect,\n isUsableAspectRatio,\n RESIZE_ANCHORS,\n rectsAreClose,\n type Rect,\n type Size,\n} from '@/domains/dam/cropper/utils/cropperGeometry'\nimport type { CropRect } from '@/domains/dam/cropper/utils/cropperTypes'\n\n/**\n * Image cropper built on cropper.js v2 custom elements. Replaces the v1-based `ACropperjs`.\n * Not exported. Its only user is `DamAssetImageRoiSelect`, and it is shaped to that one need.\n * The crop is bound via `v-model` as fractions of the image.\n * `commit` signals that a gesture ended. There is no imperative API.\n * Elements are built in script, not the template. Consumers do not configure `isCustomElement`,\n * and setting properties avoids attribute coercion issues (`NaN`, booleans, fractions).\n */\n\nconst props = withDefaults(\n defineProps<{\n src?: string\n /** The crop as fractions of the image. Null starts from the default box. */\n modelValue?: CropRect | null\n /** `NaN` (the default) leaves the crop free-form. */\n aspectRatio?: number\n containerStyle?: { [key: string]: string } | undefined\n /** Colour over everything outside the crop. Replaces overriding `.cropper-modal`. */\n shadeColor?: string\n }>(),\n {\n src: '',\n modelValue: null,\n aspectRatio: NaN,\n containerStyle: undefined,\n shadeColor: 'rgba(0, 0, 0, 0.5)',\n }\n)\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', crop: CropRect): void\n /** The user finished a gesture. The crop is worth saving. */\n (event: 'commit', crop: CropRect): void\n (event: 'ready'): void\n}>()\n\n// cropper.js registers its elements as a side effect of its entry module. Our `sideEffects`\n// setting lets the consumer's bundler drop that module, so register them here.\n// `$define` is a no-op for an already registered element.\nfor (const element of [\n CropperCanvas,\n CropperCrosshair,\n CropperGrid,\n CropperHandle,\n CropperImage,\n CropperSelection,\n CropperShade,\n]) {\n element.$define()\n}\n\n/**\n * Settings the only caller never varies. Each is behaviour: no checkerboard behind a photo, wheel left\n * to the page, pinch zoom kept for tablets, and the minimum canvas size from cropper.js' stylesheet.\n */\nconst AUTO_CROP_AREA = 0.8\nconst MIN_CONTAINER_WIDTH = 200\nconst MIN_CONTAINER_HEIGHT = 100\n\n// Matches cropper.js v1's stylesheet so both components look the same.\nconst SELECTION_COLOR = 'rgba(51, 153, 255, 0.75)'\nconst FACE_COLOR = 'rgba(255, 255, 255, 0.1)'\nconst GRID_COLOR = 'rgba(238, 238, 238, 0.5)'\nconst CROSSHAIR_COLOR = 'rgba(238, 238, 238, 0.75)'\nconst RESIZE_ACTIONS = [\n 'n-resize',\n 'e-resize',\n 's-resize',\n 'w-resize',\n 'ne-resize',\n 'nw-resize',\n 'se-resize',\n 'sw-resize',\n]\n\ninterface CropperParts {\n canvas: CropperCanvas\n image: CropperImage\n selection: CropperSelection\n}\n\nconst hostEl = useTemplateRef<HTMLDivElement>('hostEl')\nconst loading = ref(true)\n\nlet parts: CropperParts | null = null\nlet natural: Size = { width: 0, height: 0 }\n/** The action cropper.js is performing, so a clamp knows which edge to hold still. */\nlet currentAction: string | null = null\n/** Guards the re-entrant `$change` a clamp performs from being clamped again. */\nlet clamping = false\n/** Ignores the half-applied transforms `$center` emits between its move and its scale. */\nlet centring = false\n/** Invalidates an in-flight build when `src` changes or the component goes away mid-load. */\nlet buildToken = 0\n/** The host box the current layout was computed for, not the last one observed. */\nlet laidOut: Size = { width: 0, height: 0 }\n/** The last emitted crop, so a model written straight back is not treated as new. */\nlet lastEmitted: CropRect | null = null\n/** Watches ancestors that clip the host. Their height limits the available room. */\nlet ancestorObserver: ResizeObserver | null = null\n\nconst create = <T extends HTMLElement>(name: string): T => document.createElement(name) as T\n\n/** The image box in canvas coordinates. Read from layout so panning and zooming are included. */\nconst imageBounds = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const canvasRect = parts.canvas.getBoundingClientRect()\n const imageRect = parts.image.getBoundingClientRect()\n return {\n x: imageRect.left - canvasRect.left,\n y: imageRect.top - canvasRect.top,\n width: imageRect.width,\n height: imageRect.height,\n }\n}\n\n/**\n * Where the crop may be: the image, but never outside the visible canvas.\n * They differ only when the image is zoomed past its frame. Then the frame wins, as in cropper.js v1.\n */\nconst constraintBounds = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const image = imageBounds()\n const canvas = parts.canvas.getBoundingClientRect()\n const left = Math.max(image.x, 0)\n const top = Math.max(image.y, 0)\n const right = Math.min(image.x + image.width, canvas.width)\n const bottom = Math.min(image.y + image.height, canvas.height)\n return { x: left, y: top, width: Math.max(0, right - left), height: Math.max(0, bottom - top) }\n}\n\nconst selectionRect = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const { x, y, width, height } = parts.selection\n return { x, y, width, height }\n}\n\nconst applyRect = (rect: Rect) => {\n if (!parts) return\n clamping = true\n parts.selection.$change(rect.x, rect.y, rect.width, rect.height, props.aspectRatio, true)\n clamping = false\n}\n\n/**\n * Re-fits the image to the canvas.\n * `$center` only scales and moves an image marked scalable and translatable. cropper.js allows\n * this itself only while loading, so the flags are set for the call and restored after.\n */\nconst centerImage = () => {\n if (!parts) return\n const { image } = parts\n const { scalable, translatable } = image\n centring = true\n image.scalable = true\n image.translatable = true\n image.$center('contain')\n image.scalable = scalable\n image.translatable = translatable\n centring = false\n}\n\n/**\n * The initial crop of a new picture. Not using cropper.js' `initialCoverage`,\n * because its deferred init runs after a `ready` handler has positioned the crop.\n * Measured against the image, not the canvas. They differ when the image is centred between margins.\n */\nconst seedInitialCrop = () => {\n if (!parts) return\n const bounds = imageBounds()\n if (bounds.width <= 0 || bounds.height <= 0) return\n const initial = initialSelectionRect(bounds, props.aspectRatio, AUTO_CROP_AREA)\n applyRect({ ...initial, x: initial.x + bounds.x, y: initial.y + bounds.y })\n}\n\nconst applyModelOrSeed = () => {\n const model = props.modelValue\n if (model && model.width > 0 && model.height > 0) applyCrop(model)\n else seedInitialCrop()\n emitCrop()\n}\n\n/** Pulls the selection back inside the image after the image moved. */\nconst refit = () => {\n if (!parts || centring) return\n const current = selectionRect()\n if (current.width <= 0 || current.height <= 0) return\n const fitted = clampRectInside(current, constraintBounds(), props.aspectRatio)\n if (!rectsAreClose(current, fitted)) applyRect(fitted)\n}\n\nconst onSelectionChange = (event: Event) => {\n if (clamping || !parts) return\n const detail = (event as CustomEvent<Rect>).detail\n if (!detail) return\n // cropper.js reverses the action when a grip is dragged past the opposite edge. It records\n // this on the canvas before emitting this event, one move ahead of the `action` event.\n // Prefer that value, and fall back in case a future version stops setting it.\n const liveAction = (parts.canvas as unknown as { $action?: unknown }).$action\n const action = typeof liveAction === 'string' && liveAction ? liveAction : currentAction\n const anchor = action ? RESIZE_ANCHORS[action] : undefined\n const clamped = clampRectInside(detail, constraintBounds(), props.aspectRatio, anchor)\n if (rectsAreClose(detail, clamped)) return\n // Rejecting the change and applying the clamped one keeps the crop sliding along the border instead of freezing.\n // The shade reads `defaultPrevented` and follows the new values.\n event.preventDefault()\n applyRect(clamped)\n}\n\nconst onActionStart = (event: Event) => {\n currentAction = (event as CustomEvent<{ action?: string }>).detail?.action ?? null\n}\n\nconst onAction = (event: Event) => {\n const action = (event as CustomEvent<{ action?: string }>).detail?.action\n // cropper.js turns a new \"select\" drag into a corner resize once the direction is known.\n // It reports the new action on the next move. Follow it so the anchor stays correct.\n if (action) currentAction = action\n}\n\nconst onActionEnd = () => {\n currentAction = null\n emitCrop(true)\n}\n\n/**\n * The canvas must never see a wheel event. Its handler always calls\n * `preventDefault()`, which would block page scrolling over the picture.\n * Pinch zoom still works because it arrives as pointer events.\n */\nconst onWheelCapture = (event: WheelEvent) => {\n event.stopPropagation()\n}\n\n/**\n * cropper.js emits `transform` before it writes the new matrix to the element style.\n * Re-fitting at once would measure the old image. After a zoom out the crop would hang over the edge of the new one.\n */\nconst onImageTransform = () => queueMicrotask(refit)\n\nconst teardown = () => {\n if (parts) {\n const { canvas, image, selection } = parts\n selection.removeEventListener('change', onSelectionChange)\n canvas.removeEventListener('actionstart', onActionStart)\n canvas.removeEventListener('action', onAction)\n canvas.removeEventListener('actionend', onActionEnd)\n image.removeEventListener('transform', onImageTransform)\n }\n // Every canvas, not only the one on `parts`. A superseded build still waiting\n // on its image has already added one to the DOM, and nothing tracks it.\n hostEl.value?.querySelectorAll(CropperCanvas.$name).forEach((canvas) => {\n // Disconnecting a `cropper-image` drops its listeners but keeps its request running.\n // The pending `$ready()` promise keeps this component alive until the server answers.\n canvas.querySelectorAll<CropperImage>(CropperImage.$name).forEach((image) => {\n if (image.$image) image.$image.src = ''\n })\n canvas.remove()\n })\n ancestorObserver?.disconnect()\n ancestorObserver = null\n parts = null\n natural = { width: 0, height: 0 }\n laidOut = { width: 0, height: 0 }\n currentAction = null\n}\n\n/**\n * How much of the host's height is actually shown.\n * Usually the host's own `max-height`, which `DamAssetImageRoiSelect` relies on. Ancestors\n * with `overflow: hidden` count too, because what they cut off cannot be scrolled into view.\n * Scrolling ancestors are ignored. There the rest is reachable by scrolling.\n */\nconst clippingAncestorsOf = (host: HTMLElement): HTMLElement[] => {\n const found: HTMLElement[] = []\n let ancestor = host.parentElement\n while (ancestor && ancestor !== document.body && ancestor !== document.documentElement) {\n const { overflowY } = window.getComputedStyle(ancestor)\n if (overflowY === 'hidden' || overflowY === 'clip') found.push(ancestor)\n ancestor = ancestor.parentElement\n }\n return found\n}\n\nconst visibleHeightOf = (host: HTMLElement): number => {\n let available = host.clientHeight\n const hostTop = host.getBoundingClientRect().top\n\n clippingAncestorsOf(host).forEach((ancestor) => {\n const rect = ancestor.getBoundingClientRect()\n // From where the host becomes visible to where the ancestor stops showing content.\n // The ancestor's top matters when the host starts above it.\n // Content off the top is as unreachable as content off the bottom.\n const room = rect.bottom - Math.max(rect.top, hostTop)\n if (room > 0) available = Math.min(available, room)\n })\n\n return available\n}\n\n/**\n * Sizes the canvas to the room the host gives it, in two passes.\n * The picture's height follows from its width, but a frame with\n * `max-height` only shows how much it reveals once it has content.\n * This keeps a tall picture in a short frame scaled to fit, as in v1. A\n * part cut off by `overflow: hidden` could not be reached by the crop.\n */\nconst sizeCanvas = (canvas: CropperCanvas, host: HTMLElement, availableWidth: number): Size => {\n const size = canvasSizeFor(natural, availableWidth, MIN_CONTAINER_WIDTH, MIN_CONTAINER_HEIGHT)\n canvas.style.width = `${size.width}px`\n canvas.style.height = `${size.height}px`\n\n const visibleHeight = visibleHeightOf(host)\n if (visibleHeight > 0 && visibleHeight < size.height) {\n size.height = Math.max(visibleHeight, MIN_CONTAINER_HEIGHT)\n canvas.style.height = `${size.height}px`\n }\n return size\n}\n\nconst buildSelectionChildren = (selection: CropperSelection) => {\n const grid = create<CropperGrid>(CropperGrid.$name)\n grid.rows = 3\n grid.columns = 3\n grid.covered = true\n grid.themeColor = GRID_COLOR\n grid.setAttribute('role', 'grid')\n selection.appendChild(grid)\n\n const crosshair = create<CropperCrosshair>(CropperCrosshair.$name)\n crosshair.centered = true\n crosshair.themeColor = CROSSHAIR_COLOR\n selection.appendChild(crosshair)\n\n const face = create<CropperHandle>(CropperHandle.$name)\n face.action = 'move'\n face.themeColor = FACE_COLOR\n selection.appendChild(face)\n\n RESIZE_ACTIONS.forEach((action) => {\n const handle = create<CropperHandle>(CropperHandle.$name)\n handle.action = action\n handle.themeColor = SELECTION_COLOR\n selection.appendChild(handle)\n })\n}\n\nconst build = async () => {\n const token = ++buildToken\n teardown()\n loading.value = true\n\n const host = hostEl.value\n if (!host || !props.src) {\n // Nothing to load. A visible spinner would make an empty cropper look stuck.\n loading.value = false\n return\n }\n\n const canvas = create<CropperCanvas>(CropperCanvas.$name)\n canvas.background = false\n canvas.themeColor = SELECTION_COLOR\n canvas.style.display = 'block'\n sizeCanvas(canvas, host, host.clientWidth)\n\n const image = create<CropperImage>(CropperImage.$name)\n image.alt = ''\n image.initialFit = 'contain'\n image.rotatable = false\n image.skewable = false\n image.translatable = false\n image.scalable = true\n image.src = props.src\n\n const shade = create<CropperShade>(CropperShade.$name)\n shade.themeColor = props.shadeColor\n // Hidden until the first crop box exists, or it would flash across the whole canvas.\n shade.hidden = true\n\n const selectHandle = create<CropperHandle>(CropperHandle.$name)\n selectHandle.action = 'select'\n selectHandle.plain = true\n\n const selection = create<CropperSelection>(CropperSelection.$name)\n selection.themeColor = SELECTION_COLOR\n selection.movable = true\n selection.resizable = true\n selection.outlined = true\n // Keep sub-pixel values. Rounding would drift the natural-pixel crop data that callers persist.\n selection.precise = true\n selection.aspectRatio = props.aspectRatio\n buildSelectionChildren(selection)\n\n // Listeners are added before anything is connected, so the current\n // action is known before the elements' own handlers react.\n canvas.addEventListener('actionstart', onActionStart)\n canvas.addEventListener('action', onAction)\n canvas.addEventListener('actionend', onActionEnd)\n image.addEventListener('transform', onImageTransform)\n selection.addEventListener('change', onSelectionChange)\n\n canvas.append(image, shade, selectHandle, selection)\n // Attach the whole tree at once. Each element links to its\n // siblings on connect, and the shade looks for the selection.\n // Appending children one by one leaves the shade on an empty canvas, and it never follows the crop.\n host.appendChild(canvas)\n // Second pass, now that the host has content for its constraints to act on.\n sizeCanvas(canvas, host, host.clientWidth)\n\n let loaded: HTMLImageElement\n try {\n // The element makes the only request. Its promise returns the loaded picture.\n loaded = await image.$ready()\n } catch {\n // Matches cropper.js v1, which never became ready on a broken source.\n canvas.remove()\n if (token === buildToken) loading.value = false\n return\n }\n if (token !== buildToken) {\n canvas.remove()\n return\n }\n\n parts = { canvas, image, selection }\n // The natural size is known only now. Sizing here avoids a separate request just to measure the image.\n natural = { width: loaded.naturalWidth, height: loaded.naturalHeight }\n sizeCanvas(canvas, host, host.clientWidth)\n\n // A prop changed during loading found no elements for the watchers to\n // update. Re-apply the two variable props. This is idempotent otherwise.\n shade.themeColor = props.shadeColor\n selection.aspectRatio = props.aspectRatio\n\n centerImage()\n\n laidOut = hostBox(host)\n observeAncestors(host)\n applyModelOrSeed()\n\n loading.value = false\n emit('ready')\n}\n\nconst currentCrop = (): CropRect | null => {\n if (!parts) return null\n const bounds = imageBounds()\n if (bounds.width <= 0 || bounds.height <= 0) return null\n const rect = selectionRect()\n return {\n x: (rect.x - bounds.x) / bounds.width,\n y: (rect.y - bounds.y) / bounds.height,\n width: rect.width / bounds.width,\n height: rect.height / bounds.height,\n }\n}\n\n/** Applies a crop given in fractions to the canvas, clamped to the picture. */\nconst applyCrop = (crop: CropRect) => {\n const bounds = imageBounds()\n if (!parts || bounds.width <= 0 || bounds.height <= 0) return\n applyRect(\n clampRectInside(\n {\n x: bounds.x + crop.x * bounds.width,\n y: bounds.y + crop.y * bounds.height,\n width: crop.width * bounds.width,\n height: crop.height * bounds.height,\n },\n constraintBounds(),\n props.aspectRatio\n )\n )\n}\n\nconst cropsAreClose = (a: CropRect | null, b: CropRect | null): boolean =>\n a !== null &&\n b !== null &&\n Math.abs(a.x - b.x) < 0.0005 &&\n Math.abs(a.y - b.y) < 0.0005 &&\n Math.abs(a.width - b.width) < 0.0005 &&\n Math.abs(a.height - b.height) < 0.0005\n\n/**\n * Emits the crop. Also called after the component adjusts the crop itself. A stored region\n * rarely matches the configured ratio, and the binding should show the actual crop.\n */\nconst emitCrop = (alsoCommit = false) => {\n const crop = currentCrop()\n if (!crop) return\n if (alsoCommit || !cropsAreClose(crop, lastEmitted)) {\n lastEmitted = crop\n emit('update:modelValue', crop)\n }\n if (alsoCommit) emit('commit', crop)\n}\n\n/** The host's room: its width and the height that is actually shown. */\nconst hostBox = (host: HTMLElement): Size => ({ width: host.clientWidth, height: visibleHeightOf(host) })\n\n/** Re-fits the image to the new container and keeps the user's crop. */\nconst relayout = () => {\n const host = hostEl.value\n if (!parts || !host) return\n // No crop means the last layout had no size. Fall back to the bound\n // crop, which a cropper built inside a closed panel has held all along.\n const wanted = currentCrop() ?? props.modelValue\n\n const size = sizeCanvas(parts.canvas, host, host.clientWidth)\n laidOut = hostBox(host)\n // Re-read the ancestors too. A cropper can move between frames,\n // and the current clipping ancestor is the one that matters.\n observeAncestors(host)\n centerImage()\n if (size.width <= 0 || size.height <= 0) return\n\n if (wanted && wanted.width > 0) applyCrop(wanted)\n else applyModelOrSeed()\n emitCrop()\n}\n\nconst onHostBoxChanged = () => {\n const host = hostEl.value\n if (!host) return\n const box = hostBox(host)\n if (box.width <= 0 || box.height <= 0) return\n // Compare with the box the current layout was built for, so a\n // size seen during loading is not treated as already laid out.\n if (box.width === laidOut.width && box.height === laidOut.height) return\n if (!parts) return\n // Deferred a frame. Resizing the canvas inside the observer\n // callback makes Chromium report an undelivered-notification loop.\n requestAnimationFrame(() => relayout())\n}\n\n// Height matters as much as width. The DAM sizes the cropper with `calc(100vh\n// - 160px)`, so a shorter window shrinks the frame without changing its width.\nuseResizeObserver(hostEl, onHostBoxChanged)\n\n/** A clipping ancestor can change how much it shows without the host box changing. */\nconst observeAncestors = (host: HTMLElement) => {\n ancestorObserver?.disconnect()\n const ancestors = clippingAncestorsOf(host)\n if (ancestors.length === 0) {\n ancestorObserver = null\n return\n }\n ancestorObserver = new ResizeObserver(onHostBoxChanged)\n ancestors.forEach((ancestor) => ancestorObserver?.observe(ancestor))\n}\n\nwatch(\n () => props.src,\n () => {\n build()\n }\n)\n\nwatch(\n () => props.modelValue,\n (model) => {\n // Ignore the echo of the crop just emitted. Otherwise parent and component would keep writing to each other.\n if (!parts || !model || cropsAreClose(model, lastEmitted)) return\n applyCrop(model)\n emitCrop()\n },\n { deep: true }\n)\n\nwatch(\n () => props.shadeColor,\n (shadeColor) => {\n const shade = parts?.canvas.querySelector<CropperShade>(CropperShade.$name)\n if (shade) shade.themeColor = shadeColor\n }\n)\n\nwatch(\n () => props.aspectRatio,\n (aspectRatio) => {\n if (!parts) return\n parts.selection.aspectRatio = aspectRatio\n if (!isUsableAspectRatio(aspectRatio)) return\n const current = selectionRect()\n applyRect(clampRectInside({ ...current, height: current.width / aspectRatio }, constraintBounds(), aspectRatio))\n }\n)\n\nonMounted(() => {\n build()\n})\n\nonBeforeUnmount(() => {\n buildToken += 1\n teardown()\n})\n</script>\n\n<template>\n <div class=\"a-cropper d-flex flex-column\">\n <div\n v-if=\"loading\"\n class=\"d-flex w-100 align-center justify-center\"\n >\n <VProgressCircular\n class=\"position-absolute\"\n indeterminate\n />\n </div>\n\n <div\n ref=\"hostEl\"\n class=\"a-cropper__container\"\n :style=\"containerStyle\"\n @wheel.capture=\"onWheelCapture\"\n />\n </div>\n</template>\n\n<style lang=\"scss\">\n// Full width even as a flex item, such as in the asset detail dialog. The canvas is sized from the\n// host's width, and a shrink-wrapped root has none to give, so every picture got the 200px minimum.\n.a-cropper {\n width: 100%;\n}\n\n// `cropper-crosshair` is sized in `em`. Without its own size the centre marker would scale with the admin's font.\n// 7px matches the plus sign of v1's `.cropper-center`.\n.a-cropper cropper-crosshair {\n font-size: 7px;\n}\n\n// Recreates v1's `.cropper-line` on each crop edge: a 5px band of the selection colour at 10%\n// opacity, 3px outside and 2px inside the border. It makes the outline read as a grabbable edge.\n// Drawn as two shadows, so it does not depend on the v2 grip sizes.\n.a-cropper cropper-selection[outlined] {\n box-shadow:\n inset 0 0 0 2px rgb(51 153 255 / 10%),\n 0 0 0 3px rgb(51 153 255 / 10%);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;A,GA+EMmC,KAAiB,IACjBC,KAAsB,KACtBC,IAAuB,KAGvBC,IAAkB,4BAClBC,KAAa,4BACbC,KAAa,4BACbC,KAAkB,6B;;;;;;;;;;;;;;;EAtDxB,IAAMI,IAAQF,GAoBRG,IAAOF;EAUb,KAAK,IAAMG,KAAW;GACpBzC;GACAM;GACAD;G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GAAG9E,EAAiB,GAAG8E,CAAW,CAAC;EACjH,CACF,GAEA3H,SAAgB;GACdwG,GAAM;EACR,CAAC,GAEDzG,SAAsB;GACpBqC,KAAc,GACdgD,EAAS;EACX,CAAC,I,UAICxG,EAAA,GAAAC,EAiBM,OAjBNgC,IAiBM,CAfIiB,EAAA,SADRlD,EAAA,GAAAC,EAQM,OARNiC,IAQM,CAJJhC,EAGEC,IAAA;GAFA,OAAM;GACN,eAAA;E,mBAIJC,EAKE,OAAA;GAJI,SAAA;GAAJ,KAAI6C;GACJ,OAAM;GACL,OAAK5C,EAAEsC,EAAA,cAAc;GACN2D"}
|
|
1
|
+
{"version":3,"file":"ACropper.vue.js","names":["_openBlock","_createElementBlock","_createVNode","_component_VProgressCircular","_createElementVNode","_normalizeStyle","CropperCanvas","CropperImage","CropperShade","CropperHandle","CropperSelection","CropperGrid","CropperCrosshair","createCommentVNode","createElementBlock","createElementVNode","createVNode","defineComponent","normalizeStyle","onBeforeUnmount","onMounted","openBlock","ref","useTemplateRef","watch","useEventListener","useResizeObserver","RESIZE_ANCHORS","canvasSizeFor","clampRectInside","initialSelectionRect","isUsableAspectRatio","rectsAreClose","VProgressCircular","_hoisted_1","_hoisted_2","AUTO_CROP_AREA","MIN_CONTAINER_WIDTH","MIN_CONTAINER_HEIGHT","MIN_DRAWN_BOX","SELECTION_COLOR","FACE_COLOR","GRID_COLOR","CROSSHAIR_COLOR","ACropper_vue_vue_type_script_setup_true_lang_default","__props","__emit","props","emit","element","RESIZE_ACTIONS","hostEl","loading","parts","natural","currentAction","clamping","centring","buildToken","laidOut","lastEmitted","ancestorObserver","cropAtStart","boxBeforeDrawing","create","name","imageBounds","canvasRect","imageRect","constraintBounds","image","canvas","left","top","right","bottom","selectionRect","x","y","width","height","applyRect","rect","centerImage","scalable","translatable","seedInitialCrop","bounds","initial","applyModelOrSeed","model","applyCrop","emitCrop","refit","current","fitted","onSelectionChange","event","detail","liveAction","action","anchor","clamped","onActionStart","currentCrop","onAction","isSlip","box","minimum","gestureGoesOn","pointers","lifted","ids","touch","id","onActionEnd","before","drawnOver","cropsAreClose","onWheelCapture","onImageTransform","teardown","selection","clippingAncestorsOf","host","found","ancestor","overflowY","clippedHeightOf","available","hostTop","room","visibleHeightOf","maxHeightOf","maxHeight","sizeCanvas","availableWidth","size","visibleHeight","buildSelectionChildren","grid","crosshair","face","handle","build","token","shade","selectHandle","loaded","hostBox","observeAncestors","crop","a","b","alsoCommit","wanted","relayout","onHostBoxChanged","ancestors","shadeColor","aspectRatio","_ctx","_cache"],"sources":["../../../../../src/domains/dam/cropper/components/ACropper.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\nimport { useEventListener, useResizeObserver } from '@vueuse/core'\nimport {\n CropperCanvas,\n CropperCrosshair,\n CropperGrid,\n CropperHandle,\n CropperImage,\n CropperSelection,\n CropperShade,\n} from 'cropperjs'\nimport {\n canvasSizeFor,\n clampRectInside,\n initialSelectionRect,\n isUsableAspectRatio,\n RESIZE_ANCHORS,\n rectsAreClose,\n type Rect,\n type Size,\n} from '@/domains/dam/cropper/utils/cropperGeometry'\nimport type { CropRect } from '@/domains/dam/cropper/utils/cropperTypes'\n\n/**\n * Image cropper built on cropper.js v2 custom elements. Replaces the v1-based `ACropperjs`.\n * Not exported. Its only user is `DamAssetImageRoiSelect`, and it is shaped to that one need.\n * The crop is bound via `v-model` as fractions of the image.\n * `commit` signals that a gesture ended with a changed crop. There is no imperative API.\n * Elements are built in script, not the template. Consumers do not configure `isCustomElement`,\n * and setting properties avoids attribute coercion issues (`NaN`, booleans, fractions).\n */\n\nconst props = withDefaults(\n defineProps<{\n src?: string\n /** The crop as fractions of the image. Null starts from the default box. */\n modelValue?: CropRect | null\n /** `NaN` (the default) leaves the crop free-form. */\n aspectRatio?: number\n containerStyle?: { [key: string]: string } | undefined\n /** Colour over everything outside the crop. Replaces overriding `.cropper-modal`. */\n shadeColor?: string\n }>(),\n {\n src: '',\n modelValue: null,\n aspectRatio: NaN,\n containerStyle: undefined,\n shadeColor: 'rgba(0, 0, 0, 0.5)',\n }\n)\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', crop: CropRect): void\n /** The user finished a gesture that changed the crop. The crop is worth saving. */\n (event: 'commit', crop: CropRect): void\n (event: 'ready'): void\n}>()\n\n// cropper.js registers its elements as a side effect of its entry module. Our `sideEffects`\n// setting lets the consumer's bundler drop that module, so register them here.\n// `$define` is a no-op for an already registered element.\nfor (const element of [\n CropperCanvas,\n CropperCrosshair,\n CropperGrid,\n CropperHandle,\n CropperImage,\n CropperSelection,\n CropperShade,\n]) {\n element.$define()\n}\n\n/**\n * Settings the only caller never varies. Each is behaviour: no checkerboard behind a photo, wheel left\n * to the page, pinch zoom kept for tablets, and the minimum canvas size from cropper.js' stylesheet.\n */\nconst AUTO_CROP_AREA = 0.8\nconst MIN_CONTAINER_WIDTH = 200\nconst MIN_CONTAINER_HEIGHT = 100\n/** A box drawn anew that stays under this many screen pixels on its longer side is a slip of the mouse, not a crop. */\nconst MIN_DRAWN_BOX = 20\n\n// Matches cropper.js v1's stylesheet so both components look the same.\nconst SELECTION_COLOR = 'rgba(51, 153, 255, 0.75)'\nconst FACE_COLOR = 'rgba(255, 255, 255, 0.1)'\nconst GRID_COLOR = 'rgba(238, 238, 238, 0.5)'\nconst CROSSHAIR_COLOR = 'rgba(238, 238, 238, 0.75)'\nconst RESIZE_ACTIONS = [\n 'n-resize',\n 'e-resize',\n 's-resize',\n 'w-resize',\n 'ne-resize',\n 'nw-resize',\n 'se-resize',\n 'sw-resize',\n]\n\ninterface CropperParts {\n canvas: CropperCanvas\n image: CropperImage\n selection: CropperSelection\n}\n\nconst hostEl = useTemplateRef<HTMLDivElement>('hostEl')\nconst loading = ref(true)\n\nlet parts: CropperParts | null = null\nlet natural: Size = { width: 0, height: 0 }\n/** The action cropper.js is performing, so a clamp knows which edge to hold still. */\nlet currentAction: string | null = null\n/** Guards the re-entrant `$change` a clamp performs from being clamped again. */\nlet clamping = false\n/** Ignores the half-applied transforms `$center` emits between its move and its scale. */\nlet centring = false\n/** Invalidates an in-flight build when `src` changes or the component goes away mid-load. */\nlet buildToken = 0\n/** The host box the current layout was computed for, not the last one observed. */\nlet laidOut: Size = { width: 0, height: 0 }\n/** The last emitted crop, so a model written straight back is not treated as new. */\nlet lastEmitted: CropRect | null = null\n/** Watches ancestors that clip the host. Their height limits the available room. */\nlet ancestorObserver: ResizeObserver | null = null\n/** The crop when the running gesture began. Null between gestures. */\nlet cropAtStart: CropRect | null = null\n/** The crop box before the running gesture began to draw a new one. */\nlet boxBeforeDrawing: Rect | null = null\n\nconst create = <T extends HTMLElement>(name: string): T => document.createElement(name) as T\n\n/** The image box in canvas coordinates. Read from layout so panning and zooming are included. */\nconst imageBounds = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const canvasRect = parts.canvas.getBoundingClientRect()\n const imageRect = parts.image.getBoundingClientRect()\n return {\n x: imageRect.left - canvasRect.left,\n y: imageRect.top - canvasRect.top,\n width: imageRect.width,\n height: imageRect.height,\n }\n}\n\n/**\n * Where the crop may be: the image, but never outside the visible canvas.\n * They differ only when the image is zoomed past its frame. Then the frame wins, as in cropper.js v1.\n */\nconst constraintBounds = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const image = imageBounds()\n const canvas = parts.canvas.getBoundingClientRect()\n const left = Math.max(image.x, 0)\n const top = Math.max(image.y, 0)\n const right = Math.min(image.x + image.width, canvas.width)\n const bottom = Math.min(image.y + image.height, canvas.height)\n return { x: left, y: top, width: Math.max(0, right - left), height: Math.max(0, bottom - top) }\n}\n\nconst selectionRect = (): Rect => {\n if (!parts) return { x: 0, y: 0, width: 0, height: 0 }\n const { x, y, width, height } = parts.selection\n return { x, y, width, height }\n}\n\nconst applyRect = (rect: Rect) => {\n if (!parts) return\n clamping = true\n parts.selection.$change(rect.x, rect.y, rect.width, rect.height, props.aspectRatio, true)\n clamping = false\n}\n\n/**\n * Re-fits the image to the canvas.\n * `$center` only scales and moves an image marked scalable and translatable. cropper.js allows\n * this itself only while loading, so the flags are set for the call and restored after.\n */\nconst centerImage = () => {\n if (!parts) return\n const { image } = parts\n const { scalable, translatable } = image\n centring = true\n image.scalable = true\n image.translatable = true\n image.$center('contain')\n image.scalable = scalable\n image.translatable = translatable\n centring = false\n}\n\n/**\n * The initial crop of a new picture. Not using cropper.js' `initialCoverage`,\n * because its deferred init runs after a `ready` handler has positioned the crop.\n * Measured against the image, not the canvas. They differ when the image is centred between margins.\n */\nconst seedInitialCrop = () => {\n if (!parts) return\n const bounds = imageBounds()\n if (bounds.width <= 0 || bounds.height <= 0) return\n const initial = initialSelectionRect(bounds, props.aspectRatio, AUTO_CROP_AREA)\n applyRect({ ...initial, x: initial.x + bounds.x, y: initial.y + bounds.y })\n}\n\nconst applyModelOrSeed = () => {\n const model = props.modelValue\n if (model && model.width > 0 && model.height > 0) applyCrop(model)\n else seedInitialCrop()\n emitCrop()\n}\n\n/** Pulls the selection back inside the image after the image moved. */\nconst refit = () => {\n if (!parts || centring) return\n const current = selectionRect()\n if (current.width <= 0 || current.height <= 0) return\n const fitted = clampRectInside(current, constraintBounds(), props.aspectRatio)\n if (!rectsAreClose(current, fitted)) applyRect(fitted)\n}\n\nconst onSelectionChange = (event: Event) => {\n if (clamping || !parts) return\n const detail = (event as CustomEvent<Rect>).detail\n if (!detail) return\n // cropper.js reverses the action when a grip is dragged past the opposite edge. It records\n // this on the canvas before emitting this event, one move ahead of the `action` event.\n // Prefer that value, and fall back in case a future version stops setting it.\n const liveAction = (parts.canvas as unknown as { $action?: unknown }).$action\n const action = typeof liveAction === 'string' && liveAction ? liveAction : currentAction\n const anchor = action ? RESIZE_ANCHORS[action] : undefined\n const clamped = clampRectInside(detail, constraintBounds(), props.aspectRatio, anchor)\n if (rectsAreClose(detail, clamped)) return\n // Rejecting the change and applying the clamped one keeps the crop sliding along the border instead of freezing.\n // The shade reads `defaultPrevented` and follows the new values.\n event.preventDefault()\n applyRect(clamped)\n}\n\nconst onActionStart = (event: Event) => {\n currentAction = (event as CustomEvent<{ action?: string }>).detail?.action ?? null\n // A second finger joins the gesture already running and turns it into a pinch. The gesture keeps the crop and box it\n // began with: the first finger may have slipped before the second one landed, and cropper.js drew a box of that size.\n if (cropAtStart) return\n cropAtStart = currentCrop()\n boxBeforeDrawing = currentAction === 'select' ? selectionRect() : null\n}\n\nconst onAction = (event: Event) => {\n const action = (event as CustomEvent<{ action?: string }>).detail?.action\n // cropper.js turns a new \"select\" drag into a corner resize once the direction is known.\n // It reports the new action on the next move. Follow it so the anchor stays correct.\n if (action) currentAction = action\n}\n\nconst isSlip = (box: Rect): boolean => {\n const bounds = constraintBounds()\n // A tiny picture still lets a box of a quarter of its shorter side through.\n const minimum = Math.min(MIN_DRAWN_BOX, Math.min(bounds.width, bounds.height) / 4)\n return Math.max(box.width, box.height) < minimum\n}\n\n/**\n * Whether a pointer stays down after the one of this `actionend` lifts, so the gesture goes on.\n * cropper.js ends its action for every pointer lifted, also one finger of a pinch or a palm that touched outside the\n * canvas during a resize, but stops acting only when no pointer is left. It still holds the lifted one at this point.\n * Without its pointers to read, every end ends the gesture.\n */\nconst gestureGoesOn = (event: Event): boolean => {\n const pointers = (parts?.canvas as unknown as { $pointers?: unknown } | undefined)?.$pointers\n const lifted = (event as CustomEvent<{ relatedEvent?: Event }>).detail?.relatedEvent\n if (!(pointers instanceof Map) || !lifted) return false\n // cropper.js keys a touch by its identifier and a pointer by its id, a mouse without one as 0.\n const ids: unknown[] =\n 'changedTouches' in lifted\n ? Array.from((lifted as TouchEvent).changedTouches, (touch) => touch.identifier)\n : [(lifted as Partial<PointerEvent>).pointerId ?? 0]\n return [...pointers.keys()].some((id) => !ids.includes(id))\n}\n\n/**\n * Commits only a gesture that changed the crop, when its last pointer lifts, so with the crop it ends with. A click,\n * or a slip off the crop box that drew a box of a few pixels (put back as it was), sends nothing. The DAM saved\n * either, and the slip replaced the region with a point.\n */\nconst onActionEnd = (event: Event) => {\n if (gestureGoesOn(event)) return\n currentAction = null\n const before = cropAtStart\n const drawnOver = boxBeforeDrawing\n cropAtStart = null\n boxBeforeDrawing = null\n if (!before) return\n // Where it was on the screen, as after any pinch, which may have zoomed the picture out from under it.\n if (drawnOver && isSlip(selectionRect())) {\n applyRect(clampRectInside(drawnOver, constraintBounds(), props.aspectRatio))\n }\n if (cropsAreClose(currentCrop(), before)) return\n emitCrop(true)\n}\n\n/**\n * The canvas must never see a wheel event. Its handler always calls\n * `preventDefault()`, which would block page scrolling over the picture.\n * Pinch zoom still works because it arrives as pointer events.\n */\nconst onWheelCapture = (event: WheelEvent) => {\n event.stopPropagation()\n}\n\n/**\n * cropper.js emits `transform` before it writes the new matrix to the element style.\n * Re-fitting at once would measure the old image. After a zoom out the crop would hang over the edge of the new one.\n */\nconst onImageTransform = () => queueMicrotask(refit)\n\nconst teardown = () => {\n if (parts) {\n const { canvas, image, selection } = parts\n selection.removeEventListener('change', onSelectionChange)\n canvas.removeEventListener('actionstart', onActionStart)\n canvas.removeEventListener('action', onAction)\n canvas.removeEventListener('actionend', onActionEnd)\n image.removeEventListener('transform', onImageTransform)\n }\n // Every canvas, not only the one on `parts`. A superseded build still waiting\n // on its image has already added one to the DOM, and nothing tracks it.\n hostEl.value?.querySelectorAll(CropperCanvas.$name).forEach((canvas) => {\n // Disconnecting a `cropper-image` drops its listeners but keeps its request running.\n // The pending `$ready()` promise keeps this component alive until the server answers.\n canvas.querySelectorAll<CropperImage>(CropperImage.$name).forEach((image) => {\n if (image.$image) image.$image.src = ''\n })\n canvas.remove()\n })\n ancestorObserver?.disconnect()\n ancestorObserver = null\n parts = null\n natural = { width: 0, height: 0 }\n laidOut = { width: 0, height: 0 }\n currentAction = null\n cropAtStart = null\n boxBeforeDrawing = null\n}\n\n/**\n * How much of the host's height is actually shown.\n * Usually the host's own `max-height`, which `DamAssetImageRoiSelect` relies on. Ancestors\n * with `overflow: hidden` count too, because what they cut off cannot be scrolled into view.\n * Scrolling ancestors are ignored. There the rest is reachable by scrolling.\n */\nconst clippingAncestorsOf = (host: HTMLElement): HTMLElement[] => {\n const found: HTMLElement[] = []\n let ancestor = host.parentElement\n while (ancestor && ancestor !== document.body && ancestor !== document.documentElement) {\n const { overflowY } = window.getComputedStyle(ancestor)\n if (overflowY === 'hidden' || overflowY === 'clip') found.push(ancestor)\n ancestor = ancestor.parentElement\n }\n return found\n}\n\nconst clippedHeightOf = (host: HTMLElement, height: number): number => {\n let available = height\n const hostTop = host.getBoundingClientRect().top\n\n clippingAncestorsOf(host).forEach((ancestor) => {\n const rect = ancestor.getBoundingClientRect()\n // From where the host becomes visible to where the ancestor stops showing content.\n // The ancestor's top matters when the host starts above it.\n // Content off the top is as unreachable as content off the bottom.\n const room = rect.bottom - Math.max(rect.top, hostTop)\n if (room > 0) available = Math.min(available, room)\n })\n\n return available\n}\n\nconst visibleHeightOf = (host: HTMLElement): number => clippedHeightOf(host, host.clientHeight)\n\n/** The host's own `max-height` in pixels. Infinity without one, or with one not resolved to pixels (a percentage). */\nconst maxHeightOf = (host: HTMLElement): number => {\n const maxHeight = window.getComputedStyle(host).maxHeight\n return maxHeight.endsWith('px') ? parseFloat(maxHeight) : Infinity\n}\n\n/**\n * Sizes the canvas to the room the host gives it, in two passes.\n * The picture's height follows from its width, but a frame with\n * `max-height` only shows how much it reveals once it has content.\n * This keeps a tall picture in a short frame scaled to fit, as in v1. A\n * part cut off by `overflow: hidden` could not be reached by the crop.\n */\nconst sizeCanvas = (canvas: CropperCanvas, host: HTMLElement, availableWidth: number): Size => {\n const size = canvasSizeFor(natural, availableWidth, MIN_CONTAINER_WIDTH, MIN_CONTAINER_HEIGHT)\n canvas.style.width = `${size.width}px`\n canvas.style.height = `${size.height}px`\n\n const visibleHeight = visibleHeightOf(host)\n if (visibleHeight > 0 && visibleHeight < size.height) {\n size.height = Math.max(visibleHeight, MIN_CONTAINER_HEIGHT)\n canvas.style.height = `${size.height}px`\n }\n return size\n}\n\nconst buildSelectionChildren = (selection: CropperSelection) => {\n const grid = create<CropperGrid>(CropperGrid.$name)\n grid.rows = 3\n grid.columns = 3\n grid.covered = true\n grid.themeColor = GRID_COLOR\n grid.setAttribute('role', 'grid')\n selection.appendChild(grid)\n\n const crosshair = create<CropperCrosshair>(CropperCrosshair.$name)\n crosshair.centered = true\n crosshair.themeColor = CROSSHAIR_COLOR\n selection.appendChild(crosshair)\n\n const face = create<CropperHandle>(CropperHandle.$name)\n face.action = 'move'\n face.themeColor = FACE_COLOR\n selection.appendChild(face)\n\n RESIZE_ACTIONS.forEach((action) => {\n const handle = create<CropperHandle>(CropperHandle.$name)\n handle.action = action\n handle.themeColor = SELECTION_COLOR\n selection.appendChild(handle)\n })\n}\n\nconst build = async () => {\n const token = ++buildToken\n teardown()\n loading.value = true\n\n const host = hostEl.value\n if (!host || !props.src) {\n // Nothing to load. A visible spinner would make an empty cropper look stuck.\n loading.value = false\n return\n }\n\n const canvas = create<CropperCanvas>(CropperCanvas.$name)\n canvas.background = false\n canvas.themeColor = SELECTION_COLOR\n canvas.style.display = 'block'\n sizeCanvas(canvas, host, host.clientWidth)\n\n const image = create<CropperImage>(CropperImage.$name)\n image.alt = ''\n image.initialFit = 'contain'\n image.rotatable = false\n image.skewable = false\n image.translatable = false\n image.scalable = true\n image.src = props.src\n\n const shade = create<CropperShade>(CropperShade.$name)\n shade.themeColor = props.shadeColor\n // Hidden until the first crop box exists, or it would flash across the whole canvas.\n shade.hidden = true\n\n const selectHandle = create<CropperHandle>(CropperHandle.$name)\n selectHandle.action = 'select'\n selectHandle.plain = true\n\n const selection = create<CropperSelection>(CropperSelection.$name)\n selection.themeColor = SELECTION_COLOR\n selection.movable = true\n selection.resizable = true\n selection.outlined = true\n // Keep sub-pixel values. Rounding would drift the natural-pixel crop data that callers persist.\n selection.precise = true\n selection.aspectRatio = props.aspectRatio\n buildSelectionChildren(selection)\n\n // Listeners are added before anything is connected, so the current\n // action is known before the elements' own handlers react.\n canvas.addEventListener('actionstart', onActionStart)\n canvas.addEventListener('action', onAction)\n canvas.addEventListener('actionend', onActionEnd)\n image.addEventListener('transform', onImageTransform)\n selection.addEventListener('change', onSelectionChange)\n\n canvas.append(image, shade, selectHandle, selection)\n // Attach the whole tree at once. Each element links to its\n // siblings on connect, and the shade looks for the selection.\n // Appending children one by one leaves the shade on an empty canvas, and it never follows the crop.\n host.appendChild(canvas)\n // Second pass, now that the host has content for its constraints to act on.\n sizeCanvas(canvas, host, host.clientWidth)\n\n let loaded: HTMLImageElement\n try {\n // The element makes the only request. Its promise returns the loaded picture.\n loaded = await image.$ready()\n } catch {\n // Matches cropper.js v1, which never became ready on a broken source.\n canvas.remove()\n if (token === buildToken) loading.value = false\n return\n }\n if (token !== buildToken) {\n canvas.remove()\n return\n }\n\n parts = { canvas, image, selection }\n // The natural size is known only now. Sizing here avoids a separate request just to measure the image.\n natural = { width: loaded.naturalWidth, height: loaded.naturalHeight }\n sizeCanvas(canvas, host, host.clientWidth)\n\n // A prop changed during loading found no elements for the watchers to\n // update. Re-apply the two variable props. This is idempotent otherwise.\n shade.themeColor = props.shadeColor\n selection.aspectRatio = props.aspectRatio\n\n centerImage()\n\n laidOut = hostBox(host)\n observeAncestors(host)\n applyModelOrSeed()\n\n loading.value = false\n emit('ready')\n}\n\nconst currentCrop = (): CropRect | null => {\n if (!parts) return null\n const bounds = imageBounds()\n if (bounds.width <= 0 || bounds.height <= 0) return null\n const rect = selectionRect()\n return {\n x: (rect.x - bounds.x) / bounds.width,\n y: (rect.y - bounds.y) / bounds.height,\n width: rect.width / bounds.width,\n height: rect.height / bounds.height,\n }\n}\n\n/** Applies a crop given in fractions to the canvas, clamped to the picture. */\nconst applyCrop = (crop: CropRect) => {\n const bounds = imageBounds()\n if (!parts || bounds.width <= 0 || bounds.height <= 0) return\n applyRect(\n clampRectInside(\n {\n x: bounds.x + crop.x * bounds.width,\n y: bounds.y + crop.y * bounds.height,\n width: crop.width * bounds.width,\n height: crop.height * bounds.height,\n },\n constraintBounds(),\n props.aspectRatio\n )\n )\n}\n\nconst cropsAreClose = (a: CropRect | null, b: CropRect | null): boolean =>\n a !== null &&\n b !== null &&\n Math.abs(a.x - b.x) < 0.0005 &&\n Math.abs(a.y - b.y) < 0.0005 &&\n Math.abs(a.width - b.width) < 0.0005 &&\n Math.abs(a.height - b.height) < 0.0005\n\n/**\n * Emits the crop. Also called after the component adjusts the crop itself. A stored region\n * rarely matches the configured ratio, and the binding should show the actual crop.\n */\nconst emitCrop = (alsoCommit = false) => {\n const crop = currentCrop()\n if (!crop) return\n if (alsoCommit || !cropsAreClose(crop, lastEmitted)) {\n lastEmitted = crop\n emit('update:modelValue', crop)\n }\n if (alsoCommit) emit('commit', crop)\n}\n\n/**\n * The host's room: its width and the height the canvas may take there.\n * Measured without the canvas. The host is as tall as the canvas, so its own height only shows the room of the last\n * layout: a frame that grew again (a taller window, a panel ending its open transition) went unnoticed, and the\n * cropper stayed small. Capped at the height the picture wants, so growing past it does not lay it out again.\n */\nconst hostBox = (host: HTMLElement): Size => {\n const width = host.clientWidth\n const wanted = canvasSizeFor(natural, width, MIN_CONTAINER_WIDTH, MIN_CONTAINER_HEIGHT).height\n return { width, height: Math.min(wanted, clippedHeightOf(host, maxHeightOf(host))) }\n}\n\n/** Re-fits the image to the new container and keeps the user's crop. */\nconst relayout = () => {\n const host = hostEl.value\n if (!parts || !host) return\n // No crop means the last layout had no size. Fall back to the bound\n // crop, which a cropper built inside a closed panel has held all along.\n const wanted = currentCrop() ?? props.modelValue\n\n const size = sizeCanvas(parts.canvas, host, host.clientWidth)\n laidOut = hostBox(host)\n // Re-read the ancestors too. A cropper can move between frames,\n // and the current clipping ancestor is the one that matters.\n observeAncestors(host)\n centerImage()\n if (size.width <= 0 || size.height <= 0) return\n\n if (wanted && wanted.width > 0) applyCrop(wanted)\n else applyModelOrSeed()\n emitCrop()\n}\n\nconst onHostBoxChanged = () => {\n const host = hostEl.value\n if (!host) return\n const box = hostBox(host)\n if (box.width <= 0 || box.height <= 0) return\n // Compare with the box the current layout was built for, so a\n // size seen during loading is not treated as already laid out.\n if (box.width === laidOut.width && box.height === laidOut.height) return\n if (!parts) return\n // Deferred a frame. Resizing the canvas inside the observer\n // callback makes Chromium report an undelivered-notification loop.\n requestAnimationFrame(() => relayout())\n}\n\n// Height matters as much as width. The DAM sizes the cropper with `calc(100vh\n// - 160px)`, so a shorter window shrinks the frame without changing its width.\nuseResizeObserver(hostEl, onHostBoxChanged)\n// A taller window raises such a limit, and nothing the observers watch has to change size with it.\nuseEventListener(window, 'resize', onHostBoxChanged, { passive: true })\n\n/** A clipping ancestor can change how much it shows without the host box changing. */\nconst observeAncestors = (host: HTMLElement) => {\n ancestorObserver?.disconnect()\n const ancestors = clippingAncestorsOf(host)\n if (ancestors.length === 0) {\n ancestorObserver = null\n return\n }\n ancestorObserver = new ResizeObserver(onHostBoxChanged)\n ancestors.forEach((ancestor) => ancestorObserver?.observe(ancestor))\n}\n\nwatch(\n () => props.src,\n () => {\n build()\n }\n)\n\nwatch(\n () => props.modelValue,\n (model) => {\n // Ignore the echo of the crop just emitted. Otherwise parent and component would keep writing to each other.\n if (!parts || !model || cropsAreClose(model, lastEmitted)) return\n applyCrop(model)\n emitCrop()\n },\n { deep: true }\n)\n\nwatch(\n () => props.shadeColor,\n (shadeColor) => {\n const shade = parts?.canvas.querySelector<CropperShade>(CropperShade.$name)\n if (shade) shade.themeColor = shadeColor\n }\n)\n\nwatch(\n () => props.aspectRatio,\n (aspectRatio) => {\n if (!parts) return\n parts.selection.aspectRatio = aspectRatio\n if (!isUsableAspectRatio(aspectRatio)) return\n const current = selectionRect()\n applyRect(clampRectInside({ ...current, height: current.width / aspectRatio }, constraintBounds(), aspectRatio))\n }\n)\n\nonMounted(() => {\n build()\n})\n\nonBeforeUnmount(() => {\n buildToken += 1\n teardown()\n})\n</script>\n\n<template>\n <div class=\"a-cropper d-flex flex-column\">\n <div\n v-if=\"loading\"\n class=\"d-flex w-100 align-center justify-center\"\n >\n <VProgressCircular\n class=\"position-absolute\"\n indeterminate\n />\n </div>\n\n <div\n ref=\"hostEl\"\n class=\"a-cropper__container\"\n :style=\"containerStyle\"\n @wheel.capture=\"onWheelCapture\"\n />\n </div>\n</template>\n\n<style lang=\"scss\">\n// Full width even as a flex item, such as in the asset detail dialog. The canvas is sized from the\n// host's width, and a shrink-wrapped root has none to give, so every picture got the 200px minimum.\n.a-cropper {\n width: 100%;\n}\n\n// `cropper-crosshair` is sized in `em`. Without its own size the centre marker would scale with the admin's font.\n// 7px matches the plus sign of v1's `.cropper-center`.\n.a-cropper cropper-crosshair {\n font-size: 7px;\n}\n\n// Recreates v1's `.cropper-line` on each crop edge: a 5px band of the selection colour at 10%\n// opacity, 3px outside and 2px inside the border. It makes the outline read as a grabbable edge.\n// Drawn as two shadows, so it does not depend on the v2 grip sizes.\n.a-cropper cropper-selection[outlined] {\n box-shadow:\n inset 0 0 0 2px rgb(51 153 255 / 10%),\n 0 0 0 3px rgb(51 153 255 / 10%);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;A,GA+EMoC,KAAiB,IACjBC,KAAsB,KACtBC,IAAuB,KAEvBC,KAAgB,IAGhBC,IAAkB,4BAClBC,KAAa,4BACbC,KAAa,4BACbC,KAAkB,6B;;;;;;;;;;;;;;;EAxDxB,IAAMI,IAAQF,GAoBRG,IAAOF;EAUb,KAAK,IAAMG,KAAW;GACpB3C;GACAM;GACAD;GACAF;GACAF;GACAG;GACAF;EACF,GACEyC,EAAQ,QAAQ;EAkBlB,IAAMC,KAAiB;GACrB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,GAQMC,IAAS5B,GAA+B,QAAQ,GAChD6B,IAAU9B,GAAI,EAAI,GAEpB+B,IAA6B,MAC7BC,IAAgB;GAAE,OAAO;GAAG,QAAQ;EAAE,GAEtCC,IAA+B,MAE/BC,IAAW,IAEXC,IAAW,IAEXC,IAAa,GAEbC,IAAgB;GAAE,OAAO;GAAG,QAAQ;EAAE,GAEt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