vue-cropperjs2 0.0.1 → 0.0.3
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 +154 -3
- package/package.json +10 -10
- package/dist/index.d.ts +0 -145
- package/dist/index.js +0 -1633
- package/dist/index.umd.cjs +0 -1
- package/dist/vite.svg +0 -1
package/dist/index.js
DELETED
|
@@ -1,1633 +0,0 @@
|
|
|
1
|
-
import { defineComponent as D, useTemplateRef as ie, h as _, openBlock as W, createBlock as X, resolveDynamicComponent as H, unref as Y, withCtx as Ft, renderSlot as qt } from "vue";
|
|
2
|
-
const at = typeof window < "u" && typeof window.document < "u", R = at ? window : {}, bt = at ? "ontouchstart" in R.document.documentElement : !1, Ct = at ? "PointerEvent" in R : !1, B = "cropper", J = `${B}-canvas`, ne = `${B}-crosshair`, ae = `${B}-grid`, oe = `${B}-handle`, ot = `${B}-image`, z = `${B}-selection`, re = `${B}-shade`, he = `${B}-viewer`, st = "select", Vt = "move", Z = "scale", mt = "rotate", it = "transform", P = "none", yt = "n-resize", Et = "e-resize", wt = "s-resize", St = "w-resize", G = "ne-resize", F = "nw-resize", q = "se-resize", V = "sw-resize", ce = "action", le = bt ? "touchend touchcancel" : "mouseup", de = bt ? "touchmove" : "mousemove", ue = bt ? "touchstart" : "mousedown", At = Ct ? "pointerdown" : ue, Tt = Ct ? "pointermove" : de, kt = Ct ? "pointerup pointercancel" : le, xt = "error", Ot = "keydown", j = "load", Nt = "wheel", K = "action", L = "actionend", fe = "actionmove", U = "actionstart", M = "change", pt = "transform";
|
|
3
|
-
function $e(o) {
|
|
4
|
-
return typeof o == "string";
|
|
5
|
-
}
|
|
6
|
-
const Jt = Number.isNaN || R.isNaN;
|
|
7
|
-
function f(o) {
|
|
8
|
-
return typeof o == "number" && !Jt(o);
|
|
9
|
-
}
|
|
10
|
-
function T(o) {
|
|
11
|
-
return f(o) && o > 0 && o < 1 / 0;
|
|
12
|
-
}
|
|
13
|
-
function ge(o) {
|
|
14
|
-
return typeof o > "u";
|
|
15
|
-
}
|
|
16
|
-
function Qt(o) {
|
|
17
|
-
return typeof o == "object" && o !== null;
|
|
18
|
-
}
|
|
19
|
-
const { hasOwnProperty: me } = Object.prototype;
|
|
20
|
-
function nt(o) {
|
|
21
|
-
if (!Qt(o))
|
|
22
|
-
return !1;
|
|
23
|
-
try {
|
|
24
|
-
const { constructor: t } = o, { prototype: e } = t;
|
|
25
|
-
return t && e && me.call(e, "isPrototypeOf");
|
|
26
|
-
} catch {
|
|
27
|
-
return !1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function vt(o) {
|
|
31
|
-
return typeof o == "function";
|
|
32
|
-
}
|
|
33
|
-
function te(o) {
|
|
34
|
-
return typeof o == "object" && o !== null && o.nodeType === 1;
|
|
35
|
-
}
|
|
36
|
-
const pe = /([a-z\d])([A-Z])/g;
|
|
37
|
-
function Rt(o) {
|
|
38
|
-
return String(o).replace(pe, "$1-$2").toLowerCase();
|
|
39
|
-
}
|
|
40
|
-
const be = /-[A-z\d]/g;
|
|
41
|
-
function It(o) {
|
|
42
|
-
return o.replace(be, (t) => t.slice(1).toUpperCase());
|
|
43
|
-
}
|
|
44
|
-
const ee = /\s\s*/;
|
|
45
|
-
function v(o, t, e, s) {
|
|
46
|
-
t.trim().split(ee).forEach((i) => {
|
|
47
|
-
o.removeEventListener(i, e, s);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function y(o, t, e, s) {
|
|
51
|
-
t.trim().split(ee).forEach((i) => {
|
|
52
|
-
o.addEventListener(i, e, s);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function Pt(o, t, e, s) {
|
|
56
|
-
y(o, t, e, Object.assign(Object.assign({}, s), { once: !0 }));
|
|
57
|
-
}
|
|
58
|
-
const Ce = {
|
|
59
|
-
bubbles: !0,
|
|
60
|
-
cancelable: !0,
|
|
61
|
-
composed: !0
|
|
62
|
-
};
|
|
63
|
-
function ve(o, t, e, s) {
|
|
64
|
-
return o.dispatchEvent(new CustomEvent(t, Object.assign(Object.assign(Object.assign({}, Ce), { detail: e }), s)));
|
|
65
|
-
}
|
|
66
|
-
const zt = Promise.resolve();
|
|
67
|
-
function ye(o, t) {
|
|
68
|
-
return t ? zt.then(o ? t.bind(o) : t) : zt;
|
|
69
|
-
}
|
|
70
|
-
function Mt(o) {
|
|
71
|
-
const { documentElement: t } = o.ownerDocument, e = o.getBoundingClientRect();
|
|
72
|
-
return {
|
|
73
|
-
left: e.left + (R.pageXOffset - t.clientLeft),
|
|
74
|
-
top: e.top + (R.pageYOffset - t.clientTop)
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const Ee = /deg|g?rad|turn$/i;
|
|
78
|
-
function gt(o) {
|
|
79
|
-
const t = parseFloat(o) || 0;
|
|
80
|
-
if (t !== 0) {
|
|
81
|
-
const [e = "rad"] = String(o).match(Ee) || [];
|
|
82
|
-
switch (e.toLowerCase()) {
|
|
83
|
-
case "deg":
|
|
84
|
-
return t / 360 * (Math.PI * 2);
|
|
85
|
-
case "grad":
|
|
86
|
-
return t / 400 * (Math.PI * 2);
|
|
87
|
-
case "turn":
|
|
88
|
-
return t * (Math.PI * 2);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return t;
|
|
92
|
-
}
|
|
93
|
-
const Dt = "contain", we = "cover";
|
|
94
|
-
function et(o, t = Dt) {
|
|
95
|
-
const { aspectRatio: e } = o;
|
|
96
|
-
let { width: s, height: i } = o;
|
|
97
|
-
const n = T(s), r = T(i);
|
|
98
|
-
if (n && r) {
|
|
99
|
-
const a = i * e;
|
|
100
|
-
t === Dt && a > s || t === we && a < s ? i = s / e : s = i * e;
|
|
101
|
-
} else n ? i = s / e : r && (s = i * e);
|
|
102
|
-
return {
|
|
103
|
-
width: s,
|
|
104
|
-
height: i
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function se(o, ...t) {
|
|
108
|
-
if (t.length === 0)
|
|
109
|
-
return o;
|
|
110
|
-
const [e, s, i, n, r, a] = o, [l, c, h, u, $, g] = t[0];
|
|
111
|
-
return o = [
|
|
112
|
-
e * l + i * c,
|
|
113
|
-
s * l + n * c,
|
|
114
|
-
e * h + i * u,
|
|
115
|
-
s * h + n * u,
|
|
116
|
-
e * $ + i * g + r,
|
|
117
|
-
s * $ + n * g + a
|
|
118
|
-
], se(o, ...t.slice(1));
|
|
119
|
-
}
|
|
120
|
-
var Se = ":host([hidden]){display:none!important}";
|
|
121
|
-
const Ae = /left|top|width|height/i, _t = "open", Q = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ new Map(), Xt = R.document && Array.isArray(R.document.adoptedStyleSheets) && "replaceSync" in R.CSSStyleSheet.prototype;
|
|
122
|
-
class I extends HTMLElement {
|
|
123
|
-
get $sharedStyle() {
|
|
124
|
-
return `${this.themeColor ? `:host{--theme-color: ${this.themeColor};}` : ""}${Se}`;
|
|
125
|
-
}
|
|
126
|
-
constructor() {
|
|
127
|
-
var t, e;
|
|
128
|
-
super(), this.shadowRootMode = _t, this.slottable = !0;
|
|
129
|
-
const s = (e = (t = Object.getPrototypeOf(this)) === null || t === void 0 ? void 0 : t.constructor) === null || e === void 0 ? void 0 : e.$name;
|
|
130
|
-
s && Wt.set(s, this.tagName.toLowerCase());
|
|
131
|
-
}
|
|
132
|
-
static get observedAttributes() {
|
|
133
|
-
return [
|
|
134
|
-
"shadow-root-mode",
|
|
135
|
-
"slottable",
|
|
136
|
-
"theme-color"
|
|
137
|
-
];
|
|
138
|
-
}
|
|
139
|
-
// Convert attribute to property
|
|
140
|
-
attributeChangedCallback(t, e, s) {
|
|
141
|
-
if (Object.is(s, e))
|
|
142
|
-
return;
|
|
143
|
-
const i = It(t), n = this[i];
|
|
144
|
-
let r = s;
|
|
145
|
-
switch (typeof n) {
|
|
146
|
-
case "boolean":
|
|
147
|
-
r = s !== null && s !== "false";
|
|
148
|
-
break;
|
|
149
|
-
case "number":
|
|
150
|
-
r = Number(s);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
switch (this[i] = r, t) {
|
|
154
|
-
case "theme-color": {
|
|
155
|
-
const a = tt.get(this), l = this.$sharedStyle;
|
|
156
|
-
a && l && (Xt ? a.replaceSync(l) : a.textContent = l);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Convert property to attribute
|
|
162
|
-
$propertyChangedCallback(t, e, s) {
|
|
163
|
-
if (!Object.is(s, e))
|
|
164
|
-
switch (t = Rt(t), typeof s) {
|
|
165
|
-
case "boolean":
|
|
166
|
-
s === !0 ? this.hasAttribute(t) || this.setAttribute(t, "") : this.removeAttribute(t);
|
|
167
|
-
break;
|
|
168
|
-
case "number":
|
|
169
|
-
Jt(s) ? s = "" : s = String(s);
|
|
170
|
-
// Fall through
|
|
171
|
-
// case 'string':
|
|
172
|
-
// eslint-disable-next-line no-fallthrough
|
|
173
|
-
default:
|
|
174
|
-
s ? this.getAttribute(t) !== s && this.setAttribute(t, s) : this.removeAttribute(t);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
connectedCallback() {
|
|
178
|
-
Object.getPrototypeOf(this).constructor.observedAttributes.forEach((e) => {
|
|
179
|
-
const s = It(e);
|
|
180
|
-
let i = this[s];
|
|
181
|
-
ge(i) || this.$propertyChangedCallback(s, void 0, i), Object.defineProperty(this, s, {
|
|
182
|
-
enumerable: !0,
|
|
183
|
-
configurable: !0,
|
|
184
|
-
get() {
|
|
185
|
-
return i;
|
|
186
|
-
},
|
|
187
|
-
set(n) {
|
|
188
|
-
const r = i;
|
|
189
|
-
i = n, this.$propertyChangedCallback(s, r, n);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
const t = this.attachShadow({
|
|
194
|
-
mode: this.shadowRootMode || _t
|
|
195
|
-
});
|
|
196
|
-
if (this.shadowRoot || Q.set(this, t), tt.set(this, this.$addStyles(this.$sharedStyle)), this.$style && this.$addStyles(this.$style), this.$template) {
|
|
197
|
-
const e = document.createElement("template");
|
|
198
|
-
e.innerHTML = this.$template, t.appendChild(e.content);
|
|
199
|
-
}
|
|
200
|
-
if (this.slottable) {
|
|
201
|
-
const e = document.createElement("slot");
|
|
202
|
-
t.appendChild(e);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
disconnectedCallback() {
|
|
206
|
-
tt.has(this) && tt.delete(this), Q.has(this) && Q.delete(this);
|
|
207
|
-
}
|
|
208
|
-
// eslint-disable-next-line class-methods-use-this
|
|
209
|
-
$getTagNameOf(t) {
|
|
210
|
-
var e;
|
|
211
|
-
return (e = Wt.get(t)) !== null && e !== void 0 ? e : t;
|
|
212
|
-
}
|
|
213
|
-
$setStyles(t) {
|
|
214
|
-
return Object.keys(t).forEach((e) => {
|
|
215
|
-
let s = t[e];
|
|
216
|
-
f(s) && (s !== 0 && Ae.test(e) ? s = `${s}px` : s = String(s)), this.style[e] = s;
|
|
217
|
-
}), this;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Outputs the shadow root of the element.
|
|
221
|
-
* @returns {ShadowRoot} Returns the shadow root.
|
|
222
|
-
*/
|
|
223
|
-
$getShadowRoot() {
|
|
224
|
-
return this.shadowRoot || Q.get(this);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Adds styles to the shadow root.
|
|
228
|
-
* @param {string} styles The styles to add.
|
|
229
|
-
* @returns {CSSStyleSheet|HTMLStyleElement} Returns the generated style sheet.
|
|
230
|
-
*/
|
|
231
|
-
$addStyles(t) {
|
|
232
|
-
let e;
|
|
233
|
-
const s = this.$getShadowRoot();
|
|
234
|
-
return Xt ? (e = new CSSStyleSheet(), e.replaceSync(t), s.adoptedStyleSheets = s.adoptedStyleSheets.concat(e)) : (e = document.createElement("style"), e.textContent = t, s.appendChild(e)), e;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Dispatches an event at the element.
|
|
238
|
-
* @param {string} type The name of the event.
|
|
239
|
-
* @param {*} [detail] The data passed when initializing the event.
|
|
240
|
-
* @param {CustomEventInit} [options] The other event options.
|
|
241
|
-
* @returns {boolean} Returns the result value.
|
|
242
|
-
*/
|
|
243
|
-
$emit(t, e, s) {
|
|
244
|
-
return ve(this, t, e, s);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Defers the callback to be executed after the next DOM update cycle.
|
|
248
|
-
* @param {Function} [callback] The callback to execute after the next DOM update cycle.
|
|
249
|
-
* @returns {Promise} A promise that resolves to nothing.
|
|
250
|
-
*/
|
|
251
|
-
$nextTick(t) {
|
|
252
|
-
return ye(this, t);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Defines the constructor as a new custom element.
|
|
256
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define}
|
|
257
|
-
* @param {string|object} [name] The element name.
|
|
258
|
-
* @param {object} [options] The element definition options.
|
|
259
|
-
*/
|
|
260
|
-
static $define(t, e) {
|
|
261
|
-
Qt(t) && (e = t, t = ""), t || (t = this.$name || this.name), t = Rt(t), at && R.customElements && !R.customElements.get(t) && customElements.define(t, this, e);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
I.$version = "2.0.0-rc.2";
|
|
265
|
-
var Te = ':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}';
|
|
266
|
-
class rt extends I {
|
|
267
|
-
constructor() {
|
|
268
|
-
super(...arguments), this.$onPointerDown = null, this.$onPointerMove = null, this.$onPointerUp = null, this.$onWheel = null, this.$wheeling = !1, this.$pointers = /* @__PURE__ */ new Map(), this.$style = Te, this.$action = P, this.background = !1, this.disabled = !1, this.scaleStep = 0.1, this.themeColor = "#39f";
|
|
269
|
-
}
|
|
270
|
-
static get observedAttributes() {
|
|
271
|
-
return super.observedAttributes.concat([
|
|
272
|
-
"background",
|
|
273
|
-
"disabled",
|
|
274
|
-
"scale-step"
|
|
275
|
-
]);
|
|
276
|
-
}
|
|
277
|
-
connectedCallback() {
|
|
278
|
-
super.connectedCallback(), this.disabled || this.$bind();
|
|
279
|
-
}
|
|
280
|
-
disconnectedCallback() {
|
|
281
|
-
this.disabled || this.$unbind(), super.disconnectedCallback();
|
|
282
|
-
}
|
|
283
|
-
$propertyChangedCallback(t, e, s) {
|
|
284
|
-
if (!Object.is(s, e))
|
|
285
|
-
switch (super.$propertyChangedCallback(t, e, s), t) {
|
|
286
|
-
case "disabled":
|
|
287
|
-
s ? this.$unbind() : this.$bind();
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
$bind() {
|
|
292
|
-
this.$onPointerDown || (this.$onPointerDown = this.$handlePointerDown.bind(this), y(this, At, this.$onPointerDown)), this.$onPointerMove || (this.$onPointerMove = this.$handlePointerMove.bind(this), y(this.ownerDocument, Tt, this.$onPointerMove)), this.$onPointerUp || (this.$onPointerUp = this.$handlePointerUp.bind(this), y(this.ownerDocument, kt, this.$onPointerUp)), this.$onWheel || (this.$onWheel = this.$handleWheel.bind(this), y(this, Nt, this.$onWheel, {
|
|
293
|
-
passive: !1,
|
|
294
|
-
capture: !0
|
|
295
|
-
}));
|
|
296
|
-
}
|
|
297
|
-
$unbind() {
|
|
298
|
-
this.$onPointerDown && (v(this, At, this.$onPointerDown), this.$onPointerDown = null), this.$onPointerMove && (v(this.ownerDocument, Tt, this.$onPointerMove), this.$onPointerMove = null), this.$onPointerUp && (v(this.ownerDocument, kt, this.$onPointerUp), this.$onPointerUp = null), this.$onWheel && (v(this, Nt, this.$onWheel, {
|
|
299
|
-
capture: !0
|
|
300
|
-
}), this.$onWheel = null);
|
|
301
|
-
}
|
|
302
|
-
$handlePointerDown(t) {
|
|
303
|
-
const { buttons: e, button: s, type: i } = t;
|
|
304
|
-
if (this.disabled || // Handle pointer or mouse event, and ignore touch event
|
|
305
|
-
(i === "pointerdown" && t.pointerType === "mouse" || i === "mousedown") && // No primary button (Usually the left button)
|
|
306
|
-
(f(e) && e !== 1 || f(s) && s !== 0 || t.ctrlKey))
|
|
307
|
-
return;
|
|
308
|
-
const { $pointers: n } = this;
|
|
309
|
-
let r = "";
|
|
310
|
-
if (t.changedTouches)
|
|
311
|
-
Array.from(t.changedTouches).forEach(({ identifier: a, pageX: l, pageY: c }) => {
|
|
312
|
-
n.set(a, {
|
|
313
|
-
startX: l,
|
|
314
|
-
startY: c,
|
|
315
|
-
endX: l,
|
|
316
|
-
endY: c
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
else {
|
|
320
|
-
const { pointerId: a = 0, pageX: l, pageY: c } = t;
|
|
321
|
-
n.set(a, {
|
|
322
|
-
startX: l,
|
|
323
|
-
startY: c,
|
|
324
|
-
endX: l,
|
|
325
|
-
endY: c
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
n.size > 1 ? r = it : te(t.target) && (r = t.target.action || t.target.getAttribute(ce) || ""), this.$emit(U, {
|
|
329
|
-
action: r,
|
|
330
|
-
relatedEvent: t
|
|
331
|
-
}) !== !1 && (t.preventDefault(), this.$action = r, this.style.willChange = "transform");
|
|
332
|
-
}
|
|
333
|
-
$handlePointerMove(t) {
|
|
334
|
-
const { $action: e, $pointers: s } = this;
|
|
335
|
-
if (this.disabled || e === P || s.size === 0 || this.$emit(fe, {
|
|
336
|
-
action: e,
|
|
337
|
-
relatedEvent: t
|
|
338
|
-
}) === !1)
|
|
339
|
-
return;
|
|
340
|
-
if (t.preventDefault(), t.changedTouches)
|
|
341
|
-
Array.from(t.changedTouches).forEach(({ identifier: n, pageX: r, pageY: a }) => {
|
|
342
|
-
const l = s.get(n);
|
|
343
|
-
l && Object.assign(l, {
|
|
344
|
-
endX: r,
|
|
345
|
-
endY: a
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
else {
|
|
349
|
-
const { pointerId: n = 0, pageX: r, pageY: a } = t, l = s.get(n);
|
|
350
|
-
l && Object.assign(l, {
|
|
351
|
-
endX: r,
|
|
352
|
-
endY: a
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
const i = {
|
|
356
|
-
action: e,
|
|
357
|
-
relatedEvent: t
|
|
358
|
-
};
|
|
359
|
-
if (e === it) {
|
|
360
|
-
const n = new Map(s);
|
|
361
|
-
let r = 0, a = 0, l = 0, c = 0, h = t.pageX, u = t.pageY;
|
|
362
|
-
s.forEach((d, S) => {
|
|
363
|
-
n.delete(S), n.forEach((E) => {
|
|
364
|
-
let m = E.startX - d.startX, C = E.startY - d.startY, p = E.endX - d.endX, b = E.endY - d.endY, w = 0, A = 0, k = 0, x = 0;
|
|
365
|
-
if (m === 0 ? C < 0 ? k = Math.PI * 2 : C > 0 && (k = Math.PI) : m > 0 ? k = Math.PI / 2 + Math.atan(C / m) : m < 0 && (k = Math.PI * 1.5 + Math.atan(C / m)), p === 0 ? b < 0 ? x = Math.PI * 2 : b > 0 && (x = Math.PI) : p > 0 ? x = Math.PI / 2 + Math.atan(b / p) : p < 0 && (x = Math.PI * 1.5 + Math.atan(b / p)), x > 0 || k > 0) {
|
|
366
|
-
const O = x - k, N = Math.abs(O);
|
|
367
|
-
N > r && (r = N, l = O, h = (d.startX + E.startX) / 2, u = (d.startY + E.startY) / 2);
|
|
368
|
-
}
|
|
369
|
-
if (m = Math.abs(m), C = Math.abs(C), p = Math.abs(p), b = Math.abs(b), m > 0 && C > 0 ? w = Math.sqrt(m * m + C * C) : m > 0 ? w = m : C > 0 && (w = C), p > 0 && b > 0 ? A = Math.sqrt(p * p + b * b) : p > 0 ? A = p : b > 0 && (A = b), w > 0 && A > 0) {
|
|
370
|
-
const O = (A - w) / w, N = Math.abs(O);
|
|
371
|
-
N > a && (a = N, c = O, h = (d.startX + E.startX) / 2, u = (d.startY + E.startY) / 2);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
const $ = r > 0, g = a > 0;
|
|
376
|
-
$ && g ? (i.rotate = l, i.scale = c, i.centerX = h, i.centerY = u) : $ ? (i.action = mt, i.rotate = l, i.centerX = h, i.centerY = u) : g ? (i.action = Z, i.scale = c, i.centerX = h, i.centerY = u) : i.action = P;
|
|
377
|
-
} else {
|
|
378
|
-
const [n] = Array.from(s.values());
|
|
379
|
-
Object.assign(i, n);
|
|
380
|
-
}
|
|
381
|
-
s.forEach((n) => {
|
|
382
|
-
n.startX = n.endX, n.startY = n.endY;
|
|
383
|
-
}), i.action !== P && this.$emit(K, i, {
|
|
384
|
-
cancelable: !1
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
$handlePointerUp(t) {
|
|
388
|
-
const { $action: e, $pointers: s } = this;
|
|
389
|
-
if (!(this.disabled || e === P) && this.$emit(L, {
|
|
390
|
-
action: e,
|
|
391
|
-
relatedEvent: t
|
|
392
|
-
}) !== !1) {
|
|
393
|
-
if (t.preventDefault(), t.changedTouches)
|
|
394
|
-
Array.from(t.changedTouches).forEach(({ identifier: i }) => {
|
|
395
|
-
s.delete(i);
|
|
396
|
-
});
|
|
397
|
-
else {
|
|
398
|
-
const { pointerId: i = 0 } = t;
|
|
399
|
-
s.delete(i);
|
|
400
|
-
}
|
|
401
|
-
s.size === 0 && (this.style.willChange = "", this.$action = P);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
$handleWheel(t) {
|
|
405
|
-
if (this.disabled || (t.preventDefault(), this.$wheeling))
|
|
406
|
-
return;
|
|
407
|
-
this.$wheeling = !0, setTimeout(() => {
|
|
408
|
-
this.$wheeling = !1;
|
|
409
|
-
}, 50);
|
|
410
|
-
const s = (t.deltaY > 0 ? -1 : 1) * this.scaleStep;
|
|
411
|
-
this.$emit(K, {
|
|
412
|
-
action: Z,
|
|
413
|
-
scale: s,
|
|
414
|
-
relatedEvent: t
|
|
415
|
-
}, {
|
|
416
|
-
cancelable: !1
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Changes the current action to a new one.
|
|
421
|
-
* @param {string} action The new action.
|
|
422
|
-
* @returns {CropperCanvas} Returns `this` for chaining.
|
|
423
|
-
*/
|
|
424
|
-
$setAction(t) {
|
|
425
|
-
return $e(t) && (this.$action = t), this;
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Generates a real canvas element, with the image draw into if there is one.
|
|
429
|
-
* @param {object} [options] The available options.
|
|
430
|
-
* @param {number} [options.width] The width of the canvas.
|
|
431
|
-
* @param {number} [options.height] The height of the canvas.
|
|
432
|
-
* @param {Function} [options.beforeDraw] The function called before drawing the image onto the canvas.
|
|
433
|
-
* @returns {Promise} Returns a promise that resolves to the generated canvas element.
|
|
434
|
-
*/
|
|
435
|
-
$toCanvas(t) {
|
|
436
|
-
return new Promise((e, s) => {
|
|
437
|
-
if (!this.isConnected) {
|
|
438
|
-
s(new Error("The current element is not connected to the DOM."));
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
const i = document.createElement("canvas");
|
|
442
|
-
let n = this.offsetWidth, r = this.offsetHeight, a = 1;
|
|
443
|
-
nt(t) && (T(t.width) || T(t.height)) && ({ width: n, height: r } = et({
|
|
444
|
-
aspectRatio: n / r,
|
|
445
|
-
width: t.width,
|
|
446
|
-
height: t.height
|
|
447
|
-
}), a = n / this.offsetWidth), i.width = n, i.height = r;
|
|
448
|
-
const l = this.querySelector(this.$getTagNameOf(ot));
|
|
449
|
-
if (!l) {
|
|
450
|
-
e(i);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
l.$ready().then((c) => {
|
|
454
|
-
const h = i.getContext("2d");
|
|
455
|
-
if (h) {
|
|
456
|
-
const [u, $, g, d, S, E] = l.$getTransform();
|
|
457
|
-
let m = S, C = E, p = c.naturalWidth, b = c.naturalHeight;
|
|
458
|
-
a !== 1 && (m *= a, C *= a, p *= a, b *= a);
|
|
459
|
-
const w = p / 2, A = b / 2;
|
|
460
|
-
h.fillStyle = "transparent", h.fillRect(0, 0, n, r), nt(t) && vt(t.beforeDraw) && t.beforeDraw.call(this, h, i), h.save(), h.translate(w, A), h.transform(u, $, g, d, m, C), h.translate(-w, -A), h.drawImage(c, 0, 0, p, b), h.restore();
|
|
461
|
-
}
|
|
462
|
-
e(i);
|
|
463
|
-
}).catch(s);
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
rt.$name = J;
|
|
468
|
-
rt.$version = "2.0.0-rc.2";
|
|
469
|
-
var ke = ":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}";
|
|
470
|
-
const Ht = /* @__PURE__ */ new WeakMap(), Yt = [
|
|
471
|
-
"alt",
|
|
472
|
-
"crossorigin",
|
|
473
|
-
"decoding",
|
|
474
|
-
"importance",
|
|
475
|
-
"loading",
|
|
476
|
-
"referrerpolicy",
|
|
477
|
-
"sizes",
|
|
478
|
-
"src",
|
|
479
|
-
"srcset"
|
|
480
|
-
];
|
|
481
|
-
class ht extends I {
|
|
482
|
-
constructor() {
|
|
483
|
-
super(...arguments), this.$matrix = [1, 0, 0, 1, 0, 0], this.$onLoad = null, this.$onCanvasAction = null, this.$onCanvasActionEnd = null, this.$onCanvasActionStart = null, this.$actionStartTarget = null, this.$style = ke, this.$image = new Image(), this.initialCenterSize = "contain", this.rotatable = !1, this.scalable = !1, this.skewable = !1, this.slottable = !1, this.translatable = !1;
|
|
484
|
-
}
|
|
485
|
-
set $canvas(t) {
|
|
486
|
-
Ht.set(this, t);
|
|
487
|
-
}
|
|
488
|
-
get $canvas() {
|
|
489
|
-
return Ht.get(this);
|
|
490
|
-
}
|
|
491
|
-
static get observedAttributes() {
|
|
492
|
-
return super.observedAttributes.concat(Yt, [
|
|
493
|
-
"initial-center-size",
|
|
494
|
-
"rotatable",
|
|
495
|
-
"scalable",
|
|
496
|
-
"skewable",
|
|
497
|
-
"translatable"
|
|
498
|
-
]);
|
|
499
|
-
}
|
|
500
|
-
attributeChangedCallback(t, e, s) {
|
|
501
|
-
Object.is(s, e) || (super.attributeChangedCallback(t, e, s), Yt.includes(t) && this.$image.setAttribute(t, s));
|
|
502
|
-
}
|
|
503
|
-
$propertyChangedCallback(t, e, s) {
|
|
504
|
-
if (!Object.is(s, e))
|
|
505
|
-
switch (super.$propertyChangedCallback(t, e, s), t) {
|
|
506
|
-
case "initialCenterSize":
|
|
507
|
-
this.$nextTick(() => {
|
|
508
|
-
this.$center(s);
|
|
509
|
-
});
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
connectedCallback() {
|
|
514
|
-
super.connectedCallback();
|
|
515
|
-
const { $image: t } = this, e = this.closest(this.$getTagNameOf(J));
|
|
516
|
-
e && (this.$canvas = e, this.$setStyles({
|
|
517
|
-
// Make it a block element to avoid side effects (#1074).
|
|
518
|
-
display: "block",
|
|
519
|
-
position: "absolute"
|
|
520
|
-
}), this.$onCanvasActionStart = (s) => {
|
|
521
|
-
var i, n;
|
|
522
|
-
this.$actionStartTarget = (n = (i = s.detail) === null || i === void 0 ? void 0 : i.relatedEvent) === null || n === void 0 ? void 0 : n.target;
|
|
523
|
-
}, this.$onCanvasActionEnd = () => {
|
|
524
|
-
this.$actionStartTarget = null;
|
|
525
|
-
}, this.$onCanvasAction = this.$handleAction.bind(this), y(e, U, this.$onCanvasActionStart), y(e, L, this.$onCanvasActionEnd), y(e, K, this.$onCanvasAction)), this.$onLoad = this.$handleLoad.bind(this), y(t, j, this.$onLoad), this.$getShadowRoot().appendChild(t);
|
|
526
|
-
}
|
|
527
|
-
disconnectedCallback() {
|
|
528
|
-
const { $image: t, $canvas: e } = this;
|
|
529
|
-
e && (this.$onCanvasActionStart && (v(e, U, this.$onCanvasActionStart), this.$onCanvasActionStart = null), this.$onCanvasActionEnd && (v(e, L, this.$onCanvasActionEnd), this.$onCanvasActionEnd = null), this.$onCanvasAction && (v(e, K, this.$onCanvasAction), this.$onCanvasAction = null)), t && this.$onLoad && (v(t, j, this.$onLoad), this.$onLoad = null), this.$getShadowRoot().removeChild(t), super.disconnectedCallback();
|
|
530
|
-
}
|
|
531
|
-
$handleLoad() {
|
|
532
|
-
const { $image: t } = this;
|
|
533
|
-
this.$setStyles({
|
|
534
|
-
width: t.naturalWidth,
|
|
535
|
-
height: t.naturalHeight
|
|
536
|
-
}), this.$canvas && this.$center(this.initialCenterSize);
|
|
537
|
-
}
|
|
538
|
-
$handleAction(t) {
|
|
539
|
-
if (this.hidden || !(this.rotatable || this.scalable || this.translatable))
|
|
540
|
-
return;
|
|
541
|
-
const { $canvas: e } = this, { detail: s } = t;
|
|
542
|
-
if (s) {
|
|
543
|
-
const { relatedEvent: i } = s;
|
|
544
|
-
let { action: n } = s;
|
|
545
|
-
switch (n === it && (!this.rotatable || !this.scalable) && (this.rotatable ? n = mt : this.scalable ? n = Z : n = P), n) {
|
|
546
|
-
case Vt:
|
|
547
|
-
if (this.translatable) {
|
|
548
|
-
let r = null;
|
|
549
|
-
i && (r = i.target.closest(this.$getTagNameOf(z))), r || (r = e.querySelector(this.$getTagNameOf(z))), r && r.multiple && !r.active && (r = e.querySelector(`${this.$getTagNameOf(z)}[active]`)), (!r || r.hidden || !r.movable || r.dynamic || !(this.$actionStartTarget && r.contains(this.$actionStartTarget))) && this.$move(s.endX - s.startX, s.endY - s.startY);
|
|
550
|
-
}
|
|
551
|
-
break;
|
|
552
|
-
case mt:
|
|
553
|
-
if (this.rotatable)
|
|
554
|
-
if (i) {
|
|
555
|
-
const { x: r, y: a } = this.getBoundingClientRect();
|
|
556
|
-
this.$rotate(s.rotate, i.clientX - r, i.clientY - a);
|
|
557
|
-
} else
|
|
558
|
-
this.$rotate(s.rotate);
|
|
559
|
-
break;
|
|
560
|
-
case Z:
|
|
561
|
-
if (this.scalable)
|
|
562
|
-
if (i) {
|
|
563
|
-
const r = i.target.closest(this.$getTagNameOf(z));
|
|
564
|
-
if (!r || !r.zoomable || r.zoomable && r.dynamic) {
|
|
565
|
-
const { x: a, y: l } = this.getBoundingClientRect();
|
|
566
|
-
this.$zoom(s.scale, i.clientX - a, i.clientY - l);
|
|
567
|
-
}
|
|
568
|
-
} else
|
|
569
|
-
this.$zoom(s.scale);
|
|
570
|
-
break;
|
|
571
|
-
case it:
|
|
572
|
-
if (this.rotatable && this.scalable) {
|
|
573
|
-
const { rotate: r } = s;
|
|
574
|
-
let { scale: a } = s;
|
|
575
|
-
a < 0 ? a = 1 / (1 - a) : a += 1;
|
|
576
|
-
const l = Math.cos(r), c = Math.sin(r), [h, u, $, g] = [
|
|
577
|
-
l * a,
|
|
578
|
-
c * a,
|
|
579
|
-
-c * a,
|
|
580
|
-
l * a
|
|
581
|
-
];
|
|
582
|
-
if (i) {
|
|
583
|
-
const d = this.getBoundingClientRect(), S = i.clientX - d.x, E = i.clientY - d.y, [m, C, p, b] = this.$matrix, w = d.width / 2, A = d.height / 2, k = S - w, x = E - A, O = (k * b - p * x) / (m * b - p * C), N = (x * m - C * k) / (m * b - p * C);
|
|
584
|
-
this.$transform(h, u, $, g, O * (1 - h) + N * $, N * (1 - g) + O * u);
|
|
585
|
-
} else
|
|
586
|
-
this.$transform(h, u, $, g, 0, 0);
|
|
587
|
-
}
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Defers the callback to execute after successfully loading the image.
|
|
594
|
-
* @param {Function} [callback] The callback to execute after successfully loading the image.
|
|
595
|
-
* @returns {Promise} Returns a promise that resolves to the image element.
|
|
596
|
-
*/
|
|
597
|
-
$ready(t) {
|
|
598
|
-
const { $image: e } = this, s = new Promise((i, n) => {
|
|
599
|
-
const r = new Error("Failed to load the image source");
|
|
600
|
-
if (e.complete)
|
|
601
|
-
e.naturalWidth > 0 && e.naturalHeight > 0 ? i(e) : n(r);
|
|
602
|
-
else {
|
|
603
|
-
const a = () => {
|
|
604
|
-
v(e, xt, l), i(e);
|
|
605
|
-
}, l = () => {
|
|
606
|
-
v(e, j, a), n(r);
|
|
607
|
-
};
|
|
608
|
-
Pt(e, j, a), Pt(e, xt, l);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
return vt(t) && s.then((i) => (t(i), i)), s;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Aligns the image to the center of its parent element.
|
|
615
|
-
* @param {string} [size] The size of the image.
|
|
616
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
617
|
-
*/
|
|
618
|
-
$center(t) {
|
|
619
|
-
const { parentElement: e } = this;
|
|
620
|
-
if (!e)
|
|
621
|
-
return this;
|
|
622
|
-
const s = e.getBoundingClientRect(), i = s.width, n = s.height, { x: r, y: a, width: l, height: c } = this.getBoundingClientRect(), h = r + l / 2, u = a + c / 2, $ = s.x + i / 2, g = s.y + n / 2;
|
|
623
|
-
if (this.$move($ - h, g - u), t && (l !== i || c !== n)) {
|
|
624
|
-
const d = i / l, S = n / c;
|
|
625
|
-
switch (t) {
|
|
626
|
-
case "cover":
|
|
627
|
-
this.$scale(Math.max(d, S));
|
|
628
|
-
break;
|
|
629
|
-
case "contain":
|
|
630
|
-
this.$scale(Math.min(d, S));
|
|
631
|
-
break;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return this;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Moves the image.
|
|
638
|
-
* @param {number} x The moving distance in the horizontal direction.
|
|
639
|
-
* @param {number} [y] The moving distance in the vertical direction.
|
|
640
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
641
|
-
*/
|
|
642
|
-
$move(t, e = t) {
|
|
643
|
-
if (this.translatable && f(t) && f(e)) {
|
|
644
|
-
const [s, i, n, r] = this.$matrix, a = (t * r - n * e) / (s * r - n * i), l = (e * s - i * t) / (s * r - n * i);
|
|
645
|
-
this.$translate(a, l);
|
|
646
|
-
}
|
|
647
|
-
return this;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Moves the image to a specific position.
|
|
651
|
-
* @param {number} x The new position in the horizontal direction.
|
|
652
|
-
* @param {number} [y] The new position in the vertical direction.
|
|
653
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
654
|
-
*/
|
|
655
|
-
$moveTo(t, e = t) {
|
|
656
|
-
if (this.translatable && f(t) && f(e)) {
|
|
657
|
-
const [s, i, n, r] = this.$matrix, a = (t * r - n * e) / (s * r - n * i), l = (e * s - i * t) / (s * r - n * i);
|
|
658
|
-
this.$setTransform(s, i, n, r, a, l);
|
|
659
|
-
}
|
|
660
|
-
return this;
|
|
661
|
-
}
|
|
662
|
-
/**
|
|
663
|
-
* Rotates the image.
|
|
664
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate}
|
|
665
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rotate}
|
|
666
|
-
* @param {number|string} angle The rotation angle (in radians).
|
|
667
|
-
* @param {number} [x] The rotation origin in the horizontal, defaults to the center of the image.
|
|
668
|
-
* @param {number} [y] The rotation origin in the vertical, defaults to the center of the image.
|
|
669
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
670
|
-
*/
|
|
671
|
-
$rotate(t, e, s) {
|
|
672
|
-
if (this.rotatable) {
|
|
673
|
-
const i = gt(t), n = Math.cos(i), r = Math.sin(i), [a, l, c, h] = [n, r, -r, n];
|
|
674
|
-
if (f(e) && f(s)) {
|
|
675
|
-
const [u, $, g, d] = this.$matrix, { width: S, height: E } = this.getBoundingClientRect(), m = S / 2, C = E / 2, p = e - m, b = s - C, w = (p * d - g * b) / (u * d - g * $), A = (b * u - $ * p) / (u * d - g * $);
|
|
676
|
-
this.$transform(a, l, c, h, w * (1 - a) - A * c, A * (1 - h) - w * l);
|
|
677
|
-
} else
|
|
678
|
-
this.$transform(a, l, c, h, 0, 0);
|
|
679
|
-
}
|
|
680
|
-
return this;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Zooms the image.
|
|
684
|
-
* @param {number} scale The zoom factor. Positive numbers for zooming in, and negative numbers for zooming out.
|
|
685
|
-
* @param {number} [x] The zoom origin in the horizontal, defaults to the center of the image.
|
|
686
|
-
* @param {number} [y] The zoom origin in the vertical, defaults to the center of the image.
|
|
687
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
688
|
-
*/
|
|
689
|
-
$zoom(t, e, s) {
|
|
690
|
-
if (!this.scalable || t === 0)
|
|
691
|
-
return this;
|
|
692
|
-
if (t < 0 ? t = 1 / (1 - t) : t += 1, f(e) && f(s)) {
|
|
693
|
-
const [i, n, r, a] = this.$matrix, { width: l, height: c } = this.getBoundingClientRect(), h = l / 2, u = c / 2, $ = e - h, g = s - u, d = ($ * a - r * g) / (i * a - r * n), S = (g * i - n * $) / (i * a - r * n);
|
|
694
|
-
this.$transform(t, 0, 0, t, d * (1 - t), S * (1 - t));
|
|
695
|
-
} else
|
|
696
|
-
this.$scale(t);
|
|
697
|
-
return this;
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Scales the image.
|
|
701
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale}
|
|
702
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/scale}
|
|
703
|
-
* @param {number} x The scaling factor in the horizontal direction.
|
|
704
|
-
* @param {number} [y] The scaling factor in the vertical direction.
|
|
705
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
706
|
-
*/
|
|
707
|
-
$scale(t, e = t) {
|
|
708
|
-
return this.scalable && this.$transform(t, 0, 0, e, 0, 0), this;
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Skews the image.
|
|
712
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew}
|
|
713
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform}
|
|
714
|
-
* @param {number|string} x The skewing angle in the horizontal direction.
|
|
715
|
-
* @param {number|string} [y] The skewing angle in the vertical direction.
|
|
716
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
717
|
-
*/
|
|
718
|
-
$skew(t, e = 0) {
|
|
719
|
-
if (this.skewable) {
|
|
720
|
-
const s = gt(t), i = gt(e);
|
|
721
|
-
this.$transform(1, Math.tan(i), Math.tan(s), 1, 0, 0);
|
|
722
|
-
}
|
|
723
|
-
return this;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Translates the image.
|
|
727
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate}
|
|
728
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/translate}
|
|
729
|
-
* @param {number} x The translating distance in the horizontal direction.
|
|
730
|
-
* @param {number} [y] The translating distance in the vertical direction.
|
|
731
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
732
|
-
*/
|
|
733
|
-
$translate(t, e = t) {
|
|
734
|
-
return this.translatable && f(t) && f(e) && this.$transform(1, 0, 0, 1, t, e), this;
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Transforms the image.
|
|
738
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix}
|
|
739
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform}
|
|
740
|
-
* @param {number} a The scaling factor in the horizontal direction.
|
|
741
|
-
* @param {number} b The skewing angle in the vertical direction.
|
|
742
|
-
* @param {number} c The skewing angle in the horizontal direction.
|
|
743
|
-
* @param {number} d The scaling factor in the vertical direction.
|
|
744
|
-
* @param {number} e The translating distance in the horizontal direction.
|
|
745
|
-
* @param {number} f The translating distance in the vertical direction.
|
|
746
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
747
|
-
*/
|
|
748
|
-
$transform(t, e, s, i, n, r) {
|
|
749
|
-
return f(t) && f(e) && f(s) && f(i) && f(n) && f(r) ? this.$setTransform(se(this.$matrix, [t, e, s, i, n, r])) : this;
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Resets (overrides) the current transform to the specific identity matrix.
|
|
753
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform}
|
|
754
|
-
* @param {number|Array} a The scaling factor in the horizontal direction.
|
|
755
|
-
* @param {number} b The skewing angle in the vertical direction.
|
|
756
|
-
* @param {number} c The skewing angle in the horizontal direction.
|
|
757
|
-
* @param {number} d The scaling factor in the vertical direction.
|
|
758
|
-
* @param {number} e The translating distance in the horizontal direction.
|
|
759
|
-
* @param {number} f The translating distance in the vertical direction.
|
|
760
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
761
|
-
*/
|
|
762
|
-
$setTransform(t, e, s, i, n, r) {
|
|
763
|
-
if ((this.rotatable || this.scalable || this.skewable || this.translatable) && (Array.isArray(t) && ([t, e, s, i, n, r] = t), f(t) && f(e) && f(s) && f(i) && f(n) && f(r))) {
|
|
764
|
-
const a = [...this.$matrix], l = [t, e, s, i, n, r];
|
|
765
|
-
if (this.$emit(pt, {
|
|
766
|
-
matrix: l,
|
|
767
|
-
oldMatrix: a
|
|
768
|
-
}) === !1)
|
|
769
|
-
return this;
|
|
770
|
-
this.$matrix = l, this.style.transform = `matrix(${l.join(", ")})`;
|
|
771
|
-
}
|
|
772
|
-
return this;
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Retrieves the current transformation matrix being applied to the element.
|
|
776
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getTransform}
|
|
777
|
-
* @returns {Array} Returns the readonly transformation matrix.
|
|
778
|
-
*/
|
|
779
|
-
$getTransform() {
|
|
780
|
-
return this.$matrix.slice();
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Resets the current transform to the initial identity matrix.
|
|
784
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/resetTransform}
|
|
785
|
-
* @returns {CropperImage} Returns `this` for chaining.
|
|
786
|
-
*/
|
|
787
|
-
$resetTransform() {
|
|
788
|
-
return this.$setTransform([1, 0, 0, 1, 0, 0]);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
ht.$name = ot;
|
|
792
|
-
ht.$version = "2.0.0-rc.2";
|
|
793
|
-
var xe = ":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}";
|
|
794
|
-
const Bt = /* @__PURE__ */ new WeakMap();
|
|
795
|
-
class ct extends I {
|
|
796
|
-
constructor() {
|
|
797
|
-
super(...arguments), this.$onCanvasChange = null, this.$onCanvasActionEnd = null, this.$onCanvasActionStart = null, this.$style = xe, this.x = 0, this.y = 0, this.width = 0, this.height = 0, this.slottable = !1, this.themeColor = "rgba(0, 0, 0, 0.65)";
|
|
798
|
-
}
|
|
799
|
-
set $canvas(t) {
|
|
800
|
-
Bt.set(this, t);
|
|
801
|
-
}
|
|
802
|
-
get $canvas() {
|
|
803
|
-
return Bt.get(this);
|
|
804
|
-
}
|
|
805
|
-
static get observedAttributes() {
|
|
806
|
-
return super.observedAttributes.concat([
|
|
807
|
-
"height",
|
|
808
|
-
"width",
|
|
809
|
-
"x",
|
|
810
|
-
"y"
|
|
811
|
-
]);
|
|
812
|
-
}
|
|
813
|
-
connectedCallback() {
|
|
814
|
-
super.connectedCallback();
|
|
815
|
-
const t = this.closest(this.$getTagNameOf(J));
|
|
816
|
-
if (t) {
|
|
817
|
-
this.$canvas = t, this.style.position = "absolute";
|
|
818
|
-
const e = t.querySelector(this.$getTagNameOf(z));
|
|
819
|
-
e && (this.$onCanvasActionStart = (s) => {
|
|
820
|
-
e.hidden && s.detail.action === st && (this.hidden = !1);
|
|
821
|
-
}, this.$onCanvasActionEnd = (s) => {
|
|
822
|
-
e.hidden && s.detail.action === st && (this.hidden = !0);
|
|
823
|
-
}, this.$onCanvasChange = (s) => {
|
|
824
|
-
const { x: i, y: n, width: r, height: a } = s.detail;
|
|
825
|
-
this.$change(i, n, r, a), (e.hidden || i === 0 && n === 0 && r === 0 && a === 0) && (this.hidden = !0);
|
|
826
|
-
}, y(t, U, this.$onCanvasActionStart), y(t, L, this.$onCanvasActionEnd), y(t, M, this.$onCanvasChange));
|
|
827
|
-
}
|
|
828
|
-
this.$render();
|
|
829
|
-
}
|
|
830
|
-
disconnectedCallback() {
|
|
831
|
-
const { $canvas: t } = this;
|
|
832
|
-
t && (this.$onCanvasActionStart && (v(t, U, this.$onCanvasActionStart), this.$onCanvasActionStart = null), this.$onCanvasActionEnd && (v(t, L, this.$onCanvasActionEnd), this.$onCanvasActionEnd = null), this.$onCanvasChange && (v(t, M, this.$onCanvasChange), this.$onCanvasChange = null)), super.disconnectedCallback();
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Changes the position and/or size of the shade.
|
|
836
|
-
* @param {number} x The new position in the horizontal direction.
|
|
837
|
-
* @param {number} y The new position in the vertical direction.
|
|
838
|
-
* @param {number} [width] The new width.
|
|
839
|
-
* @param {number} [height] The new height.
|
|
840
|
-
* @returns {CropperShade} Returns `this` for chaining.
|
|
841
|
-
*/
|
|
842
|
-
$change(t, e, s = this.width, i = this.height) {
|
|
843
|
-
return !f(t) || !f(e) || !f(s) || !f(i) || t === this.x && e === this.y && s === this.width && i === this.height ? this : (this.hidden && (this.hidden = !1), this.x = t, this.y = e, this.width = s, this.height = i, this.$render());
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Resets the shade to its initial position and size.
|
|
847
|
-
* @returns {CropperShade} Returns `this` for chaining.
|
|
848
|
-
*/
|
|
849
|
-
$reset() {
|
|
850
|
-
return this.$change(0, 0, 0, 0);
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Refreshes the position or size of the shade.
|
|
854
|
-
* @returns {CropperShade} Returns `this` for chaining.
|
|
855
|
-
*/
|
|
856
|
-
$render() {
|
|
857
|
-
return this.$setStyles({
|
|
858
|
-
transform: `translate(${this.x}px, ${this.y}px)`,
|
|
859
|
-
width: this.width,
|
|
860
|
-
height: this.height,
|
|
861
|
-
outlineWidth: R.innerWidth
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
ct.$name = re;
|
|
866
|
-
ct.$version = "2.0.0-rc.2";
|
|
867
|
-
var Oe = ':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}';
|
|
868
|
-
class lt extends I {
|
|
869
|
-
constructor() {
|
|
870
|
-
super(...arguments), this.$onCanvasCropEnd = null, this.$onCanvasCropStart = null, this.$style = Oe, this.action = P, this.plain = !1, this.slottable = !1, this.themeColor = "rgba(51, 153, 255, 0.5)";
|
|
871
|
-
}
|
|
872
|
-
static get observedAttributes() {
|
|
873
|
-
return super.observedAttributes.concat([
|
|
874
|
-
"action",
|
|
875
|
-
"plain"
|
|
876
|
-
]);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
lt.$name = oe;
|
|
880
|
-
lt.$version = "2.0.0-rc.2";
|
|
881
|
-
var Ne = ':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}';
|
|
882
|
-
const Lt = /* @__PURE__ */ new WeakMap();
|
|
883
|
-
class dt extends I {
|
|
884
|
-
constructor() {
|
|
885
|
-
super(...arguments), this.$onCanvasAction = null, this.$onCanvasActionStart = null, this.$onCanvasActionEnd = null, this.$onDocumentKeyDown = null, this.$action = "", this.$actionStartTarget = null, this.$changing = !1, this.$style = Ne, this.$initialSelection = {
|
|
886
|
-
x: 0,
|
|
887
|
-
y: 0,
|
|
888
|
-
width: 0,
|
|
889
|
-
height: 0
|
|
890
|
-
}, this.x = 0, this.y = 0, this.width = 0, this.height = 0, this.aspectRatio = NaN, this.initialAspectRatio = NaN, this.initialCoverage = NaN, this.active = !1, this.linked = !1, this.dynamic = !1, this.movable = !1, this.resizable = !1, this.zoomable = !1, this.multiple = !1, this.keyboard = !1, this.outlined = !1, this.precise = !1;
|
|
891
|
-
}
|
|
892
|
-
set $canvas(t) {
|
|
893
|
-
Lt.set(this, t);
|
|
894
|
-
}
|
|
895
|
-
get $canvas() {
|
|
896
|
-
return Lt.get(this);
|
|
897
|
-
}
|
|
898
|
-
static get observedAttributes() {
|
|
899
|
-
return super.observedAttributes.concat([
|
|
900
|
-
"active",
|
|
901
|
-
"aspect-ratio",
|
|
902
|
-
"dynamic",
|
|
903
|
-
"height",
|
|
904
|
-
"initial-aspect-ratio",
|
|
905
|
-
"initial-coverage",
|
|
906
|
-
"keyboard",
|
|
907
|
-
"linked",
|
|
908
|
-
"movable",
|
|
909
|
-
"multiple",
|
|
910
|
-
"outlined",
|
|
911
|
-
"precise",
|
|
912
|
-
"resizable",
|
|
913
|
-
"width",
|
|
914
|
-
"x",
|
|
915
|
-
"y",
|
|
916
|
-
"zoomable"
|
|
917
|
-
]);
|
|
918
|
-
}
|
|
919
|
-
$propertyChangedCallback(t, e, s) {
|
|
920
|
-
if (!Object.is(s, e))
|
|
921
|
-
switch (super.$propertyChangedCallback(t, e, s), t) {
|
|
922
|
-
case "x":
|
|
923
|
-
case "y":
|
|
924
|
-
case "width":
|
|
925
|
-
case "height":
|
|
926
|
-
this.$changing || this.$nextTick(() => {
|
|
927
|
-
this.$change(this.x, this.y, this.width, this.height, this.aspectRatio, !0);
|
|
928
|
-
});
|
|
929
|
-
break;
|
|
930
|
-
case "aspectRatio":
|
|
931
|
-
case "initialAspectRatio":
|
|
932
|
-
this.$nextTick(() => {
|
|
933
|
-
this.$initSelection();
|
|
934
|
-
});
|
|
935
|
-
break;
|
|
936
|
-
case "initialCoverage":
|
|
937
|
-
this.$nextTick(() => {
|
|
938
|
-
T(s) && s <= 1 && this.$initSelection(!0, !0);
|
|
939
|
-
});
|
|
940
|
-
break;
|
|
941
|
-
case "keyboard":
|
|
942
|
-
this.$nextTick(() => {
|
|
943
|
-
this.$canvas && (s ? this.$onDocumentKeyDown || (this.$onDocumentKeyDown = this.$handleKeyDown.bind(this), y(this.ownerDocument, Ot, this.$onDocumentKeyDown)) : this.$onDocumentKeyDown && (v(this.ownerDocument, Ot, this.$onDocumentKeyDown), this.$onDocumentKeyDown = null));
|
|
944
|
-
});
|
|
945
|
-
break;
|
|
946
|
-
case "multiple":
|
|
947
|
-
this.$nextTick(() => {
|
|
948
|
-
if (this.$canvas) {
|
|
949
|
-
const i = this.$getSelections();
|
|
950
|
-
s ? (i.forEach((n) => {
|
|
951
|
-
n.active = !1;
|
|
952
|
-
}), this.active = !0, this.$emit(M, {
|
|
953
|
-
x: this.x,
|
|
954
|
-
y: this.y,
|
|
955
|
-
width: this.width,
|
|
956
|
-
height: this.height
|
|
957
|
-
})) : (this.active = !1, i.slice(1).forEach((n) => {
|
|
958
|
-
this.$removeSelection(n);
|
|
959
|
-
}));
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
break;
|
|
963
|
-
case "precise":
|
|
964
|
-
this.$nextTick(() => {
|
|
965
|
-
this.$change(this.x, this.y);
|
|
966
|
-
});
|
|
967
|
-
break;
|
|
968
|
-
// Backwards compatible with 2.0.0-rc
|
|
969
|
-
case "linked":
|
|
970
|
-
s && (this.dynamic = !0);
|
|
971
|
-
break;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
connectedCallback() {
|
|
975
|
-
super.connectedCallback();
|
|
976
|
-
const t = this.closest(this.$getTagNameOf(J));
|
|
977
|
-
t ? (this.$canvas = t, this.$setStyles({
|
|
978
|
-
position: "absolute",
|
|
979
|
-
transform: `translate(${this.x}px, ${this.y}px)`
|
|
980
|
-
}), this.hidden || this.$render(), this.$initSelection(!0), this.$onCanvasActionStart = this.$handleActionStart.bind(this), this.$onCanvasActionEnd = this.$handleActionEnd.bind(this), this.$onCanvasAction = this.$handleAction.bind(this), y(t, U, this.$onCanvasActionStart), y(t, L, this.$onCanvasActionEnd), y(t, K, this.$onCanvasAction)) : this.$render();
|
|
981
|
-
}
|
|
982
|
-
disconnectedCallback() {
|
|
983
|
-
const { $canvas: t } = this;
|
|
984
|
-
t && (this.$onCanvasActionStart && (v(t, U, this.$onCanvasActionStart), this.$onCanvasActionStart = null), this.$onCanvasActionEnd && (v(t, L, this.$onCanvasActionEnd), this.$onCanvasActionEnd = null), this.$onCanvasAction && (v(t, K, this.$onCanvasAction), this.$onCanvasAction = null)), super.disconnectedCallback();
|
|
985
|
-
}
|
|
986
|
-
$getSelections() {
|
|
987
|
-
let t = [];
|
|
988
|
-
return this.parentElement && (t = Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(z)))), t;
|
|
989
|
-
}
|
|
990
|
-
$initSelection(t = !1, e = !1) {
|
|
991
|
-
const { initialCoverage: s, parentElement: i } = this;
|
|
992
|
-
if (T(s) && i) {
|
|
993
|
-
const n = this.aspectRatio || this.initialAspectRatio;
|
|
994
|
-
let r = (e ? 0 : this.width) || i.offsetWidth * s, a = (e ? 0 : this.height) || i.offsetHeight * s;
|
|
995
|
-
T(n) && ({ width: r, height: a } = et({ aspectRatio: n, width: r, height: a })), this.$change(this.x, this.y, r, a), t && this.$center(), this.$initialSelection = {
|
|
996
|
-
x: this.x,
|
|
997
|
-
y: this.y,
|
|
998
|
-
width: this.width,
|
|
999
|
-
height: this.height
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
$createSelection() {
|
|
1004
|
-
const t = this.cloneNode(!0);
|
|
1005
|
-
return this.hasAttribute("id") && t.removeAttribute("id"), t.initialCoverage = NaN, this.active = !1, this.parentElement && this.parentElement.insertBefore(t, this.nextSibling), t;
|
|
1006
|
-
}
|
|
1007
|
-
$removeSelection(t = this) {
|
|
1008
|
-
if (this.parentElement) {
|
|
1009
|
-
const e = this.$getSelections();
|
|
1010
|
-
if (e.length > 1) {
|
|
1011
|
-
const s = e.indexOf(t), i = e[s + 1] || e[s - 1];
|
|
1012
|
-
i && (t.active = !1, this.parentElement.removeChild(t), i.active = !0, i.$emit(M, {
|
|
1013
|
-
x: i.x,
|
|
1014
|
-
y: i.y,
|
|
1015
|
-
width: i.width,
|
|
1016
|
-
height: i.height
|
|
1017
|
-
}));
|
|
1018
|
-
} else
|
|
1019
|
-
this.$clear();
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
$handleActionStart(t) {
|
|
1023
|
-
var e, s;
|
|
1024
|
-
const i = (s = (e = t.detail) === null || e === void 0 ? void 0 : e.relatedEvent) === null || s === void 0 ? void 0 : s.target;
|
|
1025
|
-
this.$action = "", this.$actionStartTarget = i, !this.hidden && this.multiple && !this.active && i === this && this.parentElement && (this.$getSelections().forEach((n) => {
|
|
1026
|
-
n.active = !1;
|
|
1027
|
-
}), this.active = !0, this.$emit(M, {
|
|
1028
|
-
x: this.x,
|
|
1029
|
-
y: this.y,
|
|
1030
|
-
width: this.width,
|
|
1031
|
-
height: this.height
|
|
1032
|
-
}));
|
|
1033
|
-
}
|
|
1034
|
-
$handleAction(t) {
|
|
1035
|
-
const { currentTarget: e, detail: s } = t;
|
|
1036
|
-
if (!e || !s)
|
|
1037
|
-
return;
|
|
1038
|
-
const { relatedEvent: i } = s;
|
|
1039
|
-
let { action: n } = s;
|
|
1040
|
-
if (!n && this.multiple && (n = this.$action || (i == null ? void 0 : i.target.action), this.$action = n), !n || this.hidden && n !== st || this.multiple && !this.active && n !== Z)
|
|
1041
|
-
return;
|
|
1042
|
-
const r = s.endX - s.startX, a = s.endY - s.startY, { width: l, height: c } = this;
|
|
1043
|
-
let { aspectRatio: h } = this;
|
|
1044
|
-
switch (!T(h) && i.shiftKey && (h = T(l) && T(c) ? l / c : 1), n) {
|
|
1045
|
-
case st:
|
|
1046
|
-
if (r !== 0 && a !== 0) {
|
|
1047
|
-
const { $canvas: u } = this, $ = Mt(e);
|
|
1048
|
-
(this.multiple && !this.hidden ? this.$createSelection() : this).$change(s.startX - $.left, s.startY - $.top, Math.abs(r), Math.abs(a), h), r < 0 ? a < 0 ? n = F : a > 0 && (n = V) : r > 0 && (a < 0 ? n = G : a > 0 && (n = q)), u && (u.$action = n);
|
|
1049
|
-
}
|
|
1050
|
-
break;
|
|
1051
|
-
case Vt:
|
|
1052
|
-
this.movable && (this.dynamic || this.$actionStartTarget && this.contains(this.$actionStartTarget)) && this.$move(r, a);
|
|
1053
|
-
break;
|
|
1054
|
-
case Z:
|
|
1055
|
-
if (i && this.zoomable && (this.dynamic || this.contains(i.target))) {
|
|
1056
|
-
const u = Mt(e);
|
|
1057
|
-
this.$zoom(s.scale, i.pageX - u.left, i.pageY - u.top);
|
|
1058
|
-
}
|
|
1059
|
-
break;
|
|
1060
|
-
default:
|
|
1061
|
-
this.$resize(n, r, a, h);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
$handleActionEnd() {
|
|
1065
|
-
this.$action = "", this.$actionStartTarget = null;
|
|
1066
|
-
}
|
|
1067
|
-
$handleKeyDown(t) {
|
|
1068
|
-
if (this.hidden || !this.keyboard || this.multiple && !this.active || t.defaultPrevented)
|
|
1069
|
-
return;
|
|
1070
|
-
const { activeElement: e } = document;
|
|
1071
|
-
if (!(e && (["INPUT", "TEXTAREA"].includes(e.tagName) || ["true", "plaintext-only"].includes(e.contentEditable))))
|
|
1072
|
-
switch (t.key) {
|
|
1073
|
-
case "Backspace":
|
|
1074
|
-
t.metaKey && (t.preventDefault(), this.$removeSelection());
|
|
1075
|
-
break;
|
|
1076
|
-
case "Delete":
|
|
1077
|
-
t.preventDefault(), this.$removeSelection();
|
|
1078
|
-
break;
|
|
1079
|
-
// Move to the left
|
|
1080
|
-
case "ArrowLeft":
|
|
1081
|
-
t.preventDefault(), this.$move(-1, 0);
|
|
1082
|
-
break;
|
|
1083
|
-
// Move to the right
|
|
1084
|
-
case "ArrowRight":
|
|
1085
|
-
t.preventDefault(), this.$move(1, 0);
|
|
1086
|
-
break;
|
|
1087
|
-
// Move to the top
|
|
1088
|
-
case "ArrowUp":
|
|
1089
|
-
t.preventDefault(), this.$move(0, -1);
|
|
1090
|
-
break;
|
|
1091
|
-
// Move to the bottom
|
|
1092
|
-
case "ArrowDown":
|
|
1093
|
-
t.preventDefault(), this.$move(0, 1);
|
|
1094
|
-
break;
|
|
1095
|
-
case "+":
|
|
1096
|
-
t.preventDefault(), this.$zoom(0.1);
|
|
1097
|
-
break;
|
|
1098
|
-
case "-":
|
|
1099
|
-
t.preventDefault(), this.$zoom(-0.1);
|
|
1100
|
-
break;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
/**
|
|
1104
|
-
* Aligns the selection to the center of its parent element.
|
|
1105
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1106
|
-
*/
|
|
1107
|
-
$center() {
|
|
1108
|
-
const { parentElement: t } = this;
|
|
1109
|
-
if (!t)
|
|
1110
|
-
return this;
|
|
1111
|
-
const e = (t.offsetWidth - this.width) / 2, s = (t.offsetHeight - this.height) / 2;
|
|
1112
|
-
return this.$change(e, s);
|
|
1113
|
-
}
|
|
1114
|
-
/**
|
|
1115
|
-
* Moves the selection.
|
|
1116
|
-
* @param {number} x The moving distance in the horizontal direction.
|
|
1117
|
-
* @param {number} [y] The moving distance in the vertical direction.
|
|
1118
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1119
|
-
*/
|
|
1120
|
-
$move(t, e = t) {
|
|
1121
|
-
return this.$moveTo(this.x + t, this.y + e);
|
|
1122
|
-
}
|
|
1123
|
-
/**
|
|
1124
|
-
* Moves the selection to a specific position.
|
|
1125
|
-
* @param {number} x The new position in the horizontal direction.
|
|
1126
|
-
* @param {number} [y] The new position in the vertical direction.
|
|
1127
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1128
|
-
*/
|
|
1129
|
-
$moveTo(t, e = t) {
|
|
1130
|
-
return this.movable ? this.$change(t, e) : this;
|
|
1131
|
-
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Adjusts the size the selection on a specific side or corner.
|
|
1134
|
-
* @param {string} action Indicates the side or corner to resize.
|
|
1135
|
-
* @param {number} [offsetX] The horizontal offset of the specific side or corner.
|
|
1136
|
-
* @param {number} [offsetY] The vertical offset of the specific side or corner.
|
|
1137
|
-
* @param {number} [aspectRatio] The aspect ratio for computing the new size if it is necessary.
|
|
1138
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1139
|
-
*/
|
|
1140
|
-
$resize(t, e = 0, s = 0, i = this.aspectRatio) {
|
|
1141
|
-
if (!this.resizable)
|
|
1142
|
-
return this;
|
|
1143
|
-
const n = T(i), { $canvas: r } = this;
|
|
1144
|
-
let { x: a, y: l, width: c, height: h } = this;
|
|
1145
|
-
switch (t) {
|
|
1146
|
-
case yt:
|
|
1147
|
-
l += s, h -= s, h < 0 && (t = wt, h = -h, l -= h), n && (e = s * i, a += e / 2, c -= e, c < 0 && (c = -c, a -= c));
|
|
1148
|
-
break;
|
|
1149
|
-
case Et:
|
|
1150
|
-
c += e, c < 0 && (t = St, c = -c, a -= c), n && (s = e / i, l -= s / 2, h += s, h < 0 && (h = -h, l -= h));
|
|
1151
|
-
break;
|
|
1152
|
-
case wt:
|
|
1153
|
-
h += s, h < 0 && (t = yt, h = -h, l -= h), n && (e = s * i, a -= e / 2, c += e, c < 0 && (c = -c, a -= c));
|
|
1154
|
-
break;
|
|
1155
|
-
case St:
|
|
1156
|
-
a += e, c -= e, c < 0 && (t = Et, c = -c, a -= c), n && (s = e / i, l += s / 2, h -= s, h < 0 && (h = -h, l -= h));
|
|
1157
|
-
break;
|
|
1158
|
-
case G:
|
|
1159
|
-
n && (s = -e / i), l += s, h -= s, c += e, c < 0 && h < 0 ? (t = V, c = -c, h = -h, a -= c, l -= h) : c < 0 ? (t = F, c = -c, a -= c) : h < 0 && (t = q, h = -h, l -= h);
|
|
1160
|
-
break;
|
|
1161
|
-
case F:
|
|
1162
|
-
n && (s = e / i), a += e, l += s, c -= e, h -= s, c < 0 && h < 0 ? (t = q, c = -c, h = -h, a -= c, l -= h) : c < 0 ? (t = G, c = -c, a -= c) : h < 0 && (t = V, h = -h, l -= h);
|
|
1163
|
-
break;
|
|
1164
|
-
case q:
|
|
1165
|
-
n && (s = e / i), c += e, h += s, c < 0 && h < 0 ? (t = F, c = -c, h = -h, a -= c, l -= h) : c < 0 ? (t = V, c = -c, a -= c) : h < 0 && (t = G, h = -h, l -= h);
|
|
1166
|
-
break;
|
|
1167
|
-
case V:
|
|
1168
|
-
n && (s = -e / i), a += e, c -= e, h += s, c < 0 && h < 0 ? (t = G, c = -c, h = -h, a -= c, l -= h) : c < 0 ? (t = q, c = -c, a -= c) : h < 0 && (t = F, h = -h, l -= h);
|
|
1169
|
-
break;
|
|
1170
|
-
}
|
|
1171
|
-
return r && r.$setAction(t), this.$change(a, l, c, h);
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Zooms the selection.
|
|
1175
|
-
* @param {number} scale The zoom factor. Positive numbers for zooming in, and negative numbers for zooming out.
|
|
1176
|
-
* @param {number} [x] The zoom origin in the horizontal, defaults to the center of the selection.
|
|
1177
|
-
* @param {number} [y] The zoom origin in the vertical, defaults to the center of the selection.
|
|
1178
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1179
|
-
*/
|
|
1180
|
-
$zoom(t, e, s) {
|
|
1181
|
-
if (!this.zoomable || t === 0)
|
|
1182
|
-
return this;
|
|
1183
|
-
t < 0 ? t = 1 / (1 - t) : t += 1;
|
|
1184
|
-
const { width: i, height: n } = this, r = i * t, a = n * t;
|
|
1185
|
-
let l = this.x, c = this.y;
|
|
1186
|
-
return f(e) && f(s) ? (l -= (r - i) * ((e - this.x) / i), c -= (a - n) * ((s - this.y) / n)) : (l -= (r - i) / 2, c -= (a - n) / 2), this.$change(l, c, r, a);
|
|
1187
|
-
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Changes the position and/or size of the selection.
|
|
1190
|
-
* @param {number} x The new position in the horizontal direction.
|
|
1191
|
-
* @param {number} y The new position in the vertical direction.
|
|
1192
|
-
* @param {number} [width] The new width.
|
|
1193
|
-
* @param {number} [height] The new height.
|
|
1194
|
-
* @param {number} [aspectRatio] The new aspect ratio for this change only.
|
|
1195
|
-
* @param {number} [_force] Force change.
|
|
1196
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1197
|
-
*/
|
|
1198
|
-
$change(t, e, s = this.width, i = this.height, n = this.aspectRatio, r = !1) {
|
|
1199
|
-
return this.$changing || !f(t) || !f(e) || !f(s) || !f(i) || s < 0 || i < 0 ? this : (T(n) && ({ width: s, height: i } = et({ aspectRatio: n, width: s, height: i }, "cover")), this.precise || (t = Math.round(t), e = Math.round(e), s = Math.round(s), i = Math.round(i)), t === this.x && e === this.y && s === this.width && i === this.height && Object.is(n, this.aspectRatio) && !r ? this : (this.hidden && (this.hidden = !1), this.$emit(M, {
|
|
1200
|
-
x: t,
|
|
1201
|
-
y: e,
|
|
1202
|
-
width: s,
|
|
1203
|
-
height: i
|
|
1204
|
-
}) === !1 ? this : (this.$changing = !0, this.x = t, this.y = e, this.width = s, this.height = i, this.$changing = !1, this.$render())));
|
|
1205
|
-
}
|
|
1206
|
-
/**
|
|
1207
|
-
* Resets the selection to its initial position and size.
|
|
1208
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1209
|
-
*/
|
|
1210
|
-
$reset() {
|
|
1211
|
-
const { x: t, y: e, width: s, height: i } = this.$initialSelection;
|
|
1212
|
-
return this.$change(t, e, s, i);
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Clears the selection.
|
|
1216
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1217
|
-
*/
|
|
1218
|
-
$clear() {
|
|
1219
|
-
return this.$change(0, 0, 0, 0, NaN, !0), this.hidden = !0, this;
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Refreshes the position or size of the selection.
|
|
1223
|
-
* @returns {CropperSelection} Returns `this` for chaining.
|
|
1224
|
-
*/
|
|
1225
|
-
$render() {
|
|
1226
|
-
return this.$setStyles({
|
|
1227
|
-
transform: `translate(${this.x}px, ${this.y}px)`,
|
|
1228
|
-
width: this.width,
|
|
1229
|
-
height: this.height
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Generates a real canvas element, with the image (selected area only) draw into if there is one.
|
|
1234
|
-
* @param {object} [options] The available options.
|
|
1235
|
-
* @param {number} [options.width] The width of the canvas.
|
|
1236
|
-
* @param {number} [options.height] The height of the canvas.
|
|
1237
|
-
* @param {Function} [options.beforeDraw] The function called before drawing the image onto the canvas.
|
|
1238
|
-
* @returns {Promise} Returns a promise that resolves to the generated canvas element.
|
|
1239
|
-
*/
|
|
1240
|
-
$toCanvas(t) {
|
|
1241
|
-
return new Promise((e, s) => {
|
|
1242
|
-
if (!this.isConnected) {
|
|
1243
|
-
s(new Error("The current element is not connected to the DOM."));
|
|
1244
|
-
return;
|
|
1245
|
-
}
|
|
1246
|
-
const i = document.createElement("canvas");
|
|
1247
|
-
let { width: n, height: r } = this, a = 1;
|
|
1248
|
-
if (nt(t) && (T(t.width) || T(t.height)) && ({ width: n, height: r } = et({
|
|
1249
|
-
aspectRatio: n / r,
|
|
1250
|
-
width: t.width,
|
|
1251
|
-
height: t.height
|
|
1252
|
-
}), a = n / this.width), i.width = n, i.height = r, !this.$canvas) {
|
|
1253
|
-
e(i);
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
const l = this.$canvas.querySelector(this.$getTagNameOf(ot));
|
|
1257
|
-
if (!l) {
|
|
1258
|
-
e(i);
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
l.$ready().then((c) => {
|
|
1262
|
-
const h = i.getContext("2d");
|
|
1263
|
-
if (h) {
|
|
1264
|
-
const [u, $, g, d, S, E] = l.$getTransform(), m = -this.x, C = -this.y, p = (m * d - g * C) / (u * d - g * $), b = (C * u - $ * m) / (u * d - g * $);
|
|
1265
|
-
let w = u * p + g * b + S, A = $ * p + d * b + E, k = c.naturalWidth, x = c.naturalHeight;
|
|
1266
|
-
a !== 1 && (w *= a, A *= a, k *= a, x *= a);
|
|
1267
|
-
const O = k / 2, N = x / 2;
|
|
1268
|
-
h.fillStyle = "transparent", h.fillRect(0, 0, n, r), nt(t) && vt(t.beforeDraw) && t.beforeDraw.call(this, h, i), h.save(), h.translate(O, N), h.transform(u, $, g, d, w, A), h.translate(-O, -N), h.drawImage(c, 0, 0, k, x), h.restore();
|
|
1269
|
-
}
|
|
1270
|
-
e(i);
|
|
1271
|
-
}).catch(s);
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
dt.$name = z;
|
|
1276
|
-
dt.$version = "2.0.0-rc.2";
|
|
1277
|
-
var Re = ":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}";
|
|
1278
|
-
class ut extends I {
|
|
1279
|
-
constructor() {
|
|
1280
|
-
super(...arguments), this.$style = Re, this.bordered = !1, this.columns = 3, this.covered = !1, this.rows = 3, this.slottable = !1, this.themeColor = "rgba(238, 238, 238, 0.5)";
|
|
1281
|
-
}
|
|
1282
|
-
static get observedAttributes() {
|
|
1283
|
-
return super.observedAttributes.concat([
|
|
1284
|
-
"bordered",
|
|
1285
|
-
"columns",
|
|
1286
|
-
"covered",
|
|
1287
|
-
"rows"
|
|
1288
|
-
]);
|
|
1289
|
-
}
|
|
1290
|
-
$propertyChangedCallback(t, e, s) {
|
|
1291
|
-
Object.is(s, e) || (super.$propertyChangedCallback(t, e, s), (t === "rows" || t === "columns") && this.$nextTick(() => {
|
|
1292
|
-
this.$render();
|
|
1293
|
-
}));
|
|
1294
|
-
}
|
|
1295
|
-
connectedCallback() {
|
|
1296
|
-
super.connectedCallback(), this.$render();
|
|
1297
|
-
}
|
|
1298
|
-
$render() {
|
|
1299
|
-
const t = this.$getShadowRoot(), e = document.createDocumentFragment();
|
|
1300
|
-
for (let s = 0; s < this.rows; s += 1) {
|
|
1301
|
-
const i = document.createElement("span");
|
|
1302
|
-
i.setAttribute("role", "row");
|
|
1303
|
-
for (let n = 0; n < this.columns; n += 1) {
|
|
1304
|
-
const r = document.createElement("span");
|
|
1305
|
-
r.setAttribute("role", "gridcell"), i.appendChild(r);
|
|
1306
|
-
}
|
|
1307
|
-
e.appendChild(i);
|
|
1308
|
-
}
|
|
1309
|
-
t && (t.innerHTML = "", t.appendChild(e));
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
ut.$name = ae;
|
|
1313
|
-
ut.$version = "2.0.0-rc.2";
|
|
1314
|
-
var Ie = ':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}';
|
|
1315
|
-
class ft extends I {
|
|
1316
|
-
constructor() {
|
|
1317
|
-
super(...arguments), this.$style = Ie, this.centered = !1, this.slottable = !1, this.themeColor = "rgba(238, 238, 238, 0.5)";
|
|
1318
|
-
}
|
|
1319
|
-
static get observedAttributes() {
|
|
1320
|
-
return super.observedAttributes.concat([
|
|
1321
|
-
"centered"
|
|
1322
|
-
]);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
ft.$name = ne;
|
|
1326
|
-
ft.$version = "2.0.0-rc.2";
|
|
1327
|
-
var Pe = ":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}";
|
|
1328
|
-
const Ut = /* @__PURE__ */ new WeakMap(), jt = /* @__PURE__ */ new WeakMap(), Zt = /* @__PURE__ */ new WeakMap(), Kt = /* @__PURE__ */ new WeakMap(), ze = "both", Me = "horizontal", Gt = "vertical", De = "none";
|
|
1329
|
-
class $t extends I {
|
|
1330
|
-
constructor() {
|
|
1331
|
-
super(...arguments), this.$onSelectionChange = null, this.$onSourceImageLoad = null, this.$onSourceImageTransform = null, this.$scale = 1, this.$style = Pe, this.resize = Gt, this.selection = "", this.slottable = !1;
|
|
1332
|
-
}
|
|
1333
|
-
set $image(t) {
|
|
1334
|
-
jt.set(this, t);
|
|
1335
|
-
}
|
|
1336
|
-
get $image() {
|
|
1337
|
-
return jt.get(this);
|
|
1338
|
-
}
|
|
1339
|
-
set $sourceImage(t) {
|
|
1340
|
-
Kt.set(this, t);
|
|
1341
|
-
}
|
|
1342
|
-
get $sourceImage() {
|
|
1343
|
-
return Kt.get(this);
|
|
1344
|
-
}
|
|
1345
|
-
set $canvas(t) {
|
|
1346
|
-
Ut.set(this, t);
|
|
1347
|
-
}
|
|
1348
|
-
get $canvas() {
|
|
1349
|
-
return Ut.get(this);
|
|
1350
|
-
}
|
|
1351
|
-
set $selection(t) {
|
|
1352
|
-
Zt.set(this, t);
|
|
1353
|
-
}
|
|
1354
|
-
get $selection() {
|
|
1355
|
-
return Zt.get(this);
|
|
1356
|
-
}
|
|
1357
|
-
static get observedAttributes() {
|
|
1358
|
-
return super.observedAttributes.concat([
|
|
1359
|
-
"resize",
|
|
1360
|
-
"selection"
|
|
1361
|
-
]);
|
|
1362
|
-
}
|
|
1363
|
-
connectedCallback() {
|
|
1364
|
-
super.connectedCallback();
|
|
1365
|
-
let t = null;
|
|
1366
|
-
if (this.selection ? t = this.ownerDocument.querySelector(this.selection) : t = this.closest(this.$getTagNameOf(z)), te(t)) {
|
|
1367
|
-
this.$selection = t, this.$onSelectionChange = this.$handleSelectionChange.bind(this), y(t, M, this.$onSelectionChange);
|
|
1368
|
-
const e = t.closest(this.$getTagNameOf(J));
|
|
1369
|
-
if (e) {
|
|
1370
|
-
this.$canvas = e;
|
|
1371
|
-
const s = e.querySelector(this.$getTagNameOf(ot));
|
|
1372
|
-
s && (this.$sourceImage = s, this.$image = s.cloneNode(!0), this.$getShadowRoot().appendChild(this.$image), this.$onSourceImageLoad = this.$handleSourceImageLoad.bind(this), this.$onSourceImageTransform = this.$handleSourceImageTransform.bind(this), y(s.$image, j, this.$onSourceImageLoad), y(s, pt, this.$onSourceImageTransform));
|
|
1373
|
-
}
|
|
1374
|
-
this.$render();
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
disconnectedCallback() {
|
|
1378
|
-
const { $selection: t, $sourceImage: e } = this;
|
|
1379
|
-
t && this.$onSelectionChange && (v(t, M, this.$onSelectionChange), this.$onSelectionChange = null), e && this.$onSourceImageLoad && (v(e.$image, j, this.$onSourceImageLoad), this.$onSourceImageLoad = null), e && this.$onSourceImageTransform && (v(e, pt, this.$onSourceImageTransform), this.$onSourceImageTransform = null), super.disconnectedCallback();
|
|
1380
|
-
}
|
|
1381
|
-
$handleSelectionChange(t) {
|
|
1382
|
-
this.$render(t.detail);
|
|
1383
|
-
}
|
|
1384
|
-
$handleSourceImageLoad() {
|
|
1385
|
-
const { $image: t, $sourceImage: e } = this, s = t.getAttribute("src"), i = e.getAttribute("src");
|
|
1386
|
-
i && i !== s && (t.setAttribute("src", i), t.$ready(() => {
|
|
1387
|
-
setTimeout(() => {
|
|
1388
|
-
this.$render();
|
|
1389
|
-
}, 50);
|
|
1390
|
-
}));
|
|
1391
|
-
}
|
|
1392
|
-
$handleSourceImageTransform(t) {
|
|
1393
|
-
this.$render(void 0, t.detail.matrix);
|
|
1394
|
-
}
|
|
1395
|
-
$render(t, e) {
|
|
1396
|
-
const { $canvas: s, $selection: i } = this;
|
|
1397
|
-
!t && !i.hidden && (t = i), (!t || t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0) && (t = {
|
|
1398
|
-
x: 0,
|
|
1399
|
-
y: 0,
|
|
1400
|
-
width: s.offsetWidth,
|
|
1401
|
-
height: s.offsetHeight
|
|
1402
|
-
});
|
|
1403
|
-
const { x: n, y: r, width: a, height: l } = t, c = {}, { clientWidth: h, clientHeight: u } = this;
|
|
1404
|
-
let $ = h, g = u, d = NaN;
|
|
1405
|
-
switch (this.resize) {
|
|
1406
|
-
case ze:
|
|
1407
|
-
d = 1, $ = a, g = l, c.width = a, c.height = l;
|
|
1408
|
-
break;
|
|
1409
|
-
case Me:
|
|
1410
|
-
d = l > 0 ? u / l : 0, $ = a * d, c.width = $;
|
|
1411
|
-
break;
|
|
1412
|
-
case Gt:
|
|
1413
|
-
d = a > 0 ? h / a : 0, g = l * d, c.height = g;
|
|
1414
|
-
break;
|
|
1415
|
-
case De:
|
|
1416
|
-
default:
|
|
1417
|
-
h > 0 ? d = a > 0 ? h / a : 0 : u > 0 && (d = l > 0 ? u / l : 0);
|
|
1418
|
-
}
|
|
1419
|
-
this.$scale = d, this.$setStyles(c), this.$sourceImage && this.$transformImageByOffset(e ?? this.$sourceImage.$getTransform(), -n, -r);
|
|
1420
|
-
}
|
|
1421
|
-
$transformImageByOffset(t, e, s) {
|
|
1422
|
-
const { $image: i, $scale: n, $sourceImage: r } = this;
|
|
1423
|
-
if (r && i && n >= 0) {
|
|
1424
|
-
const [a, l, c, h, u, $] = t, g = (e * h - c * s) / (a * h - c * l), d = (s * a - l * e) / (a * h - c * l), S = a * g + c * d + u, E = l * g + h * d + $;
|
|
1425
|
-
i.$ready((m) => {
|
|
1426
|
-
this.$setStyles.call(i, {
|
|
1427
|
-
width: m.naturalWidth * n,
|
|
1428
|
-
height: m.naturalHeight * n
|
|
1429
|
-
});
|
|
1430
|
-
}), i.$setTransform(a, l, c, h, S * n, E * n);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
$t.$name = he;
|
|
1435
|
-
$t.$version = "2.0.0-rc.2";
|
|
1436
|
-
/*! Cropper.js v2.0.0-rc.2 | (c) 2015-present Chen Fengyuan | MIT */
|
|
1437
|
-
rt.$define();
|
|
1438
|
-
ft.$define();
|
|
1439
|
-
ut.$define();
|
|
1440
|
-
lt.$define();
|
|
1441
|
-
ht.$define();
|
|
1442
|
-
dt.$define();
|
|
1443
|
-
ct.$define();
|
|
1444
|
-
$t.$define();
|
|
1445
|
-
const _e = /* @__PURE__ */ D({
|
|
1446
|
-
__name: "CropperCanvas",
|
|
1447
|
-
props: {
|
|
1448
|
-
background: { type: Boolean, default: !1 },
|
|
1449
|
-
disabled: { type: Boolean, default: !1 },
|
|
1450
|
-
scaleStep: { default: 0.1 },
|
|
1451
|
-
themeColor: { default: "#39f" }
|
|
1452
|
-
},
|
|
1453
|
-
setup(o, { expose: t }) {
|
|
1454
|
-
var r, a;
|
|
1455
|
-
const e = ie("canvasRef");
|
|
1456
|
-
rt.$define();
|
|
1457
|
-
const s = _("cropper-canvas", {
|
|
1458
|
-
background: o.background,
|
|
1459
|
-
disabled: o.disabled,
|
|
1460
|
-
scaleStep: o.scaleStep,
|
|
1461
|
-
themeColor: o.themeColor,
|
|
1462
|
-
style: "height: 500px"
|
|
1463
|
-
}), i = (r = e.value) == null ? void 0 : r.$setAction, n = (a = e.value) == null ? void 0 : a.$toCanvas;
|
|
1464
|
-
return t({
|
|
1465
|
-
$setAction: i,
|
|
1466
|
-
$toCanvas: n
|
|
1467
|
-
}), (l, c) => (W(), X(H(Y(s)), {
|
|
1468
|
-
ref_key: "canvasRef",
|
|
1469
|
-
ref: e
|
|
1470
|
-
}, {
|
|
1471
|
-
default: Ft(() => [
|
|
1472
|
-
qt(l.$slots, "default")
|
|
1473
|
-
]),
|
|
1474
|
-
_: 3
|
|
1475
|
-
}, 512));
|
|
1476
|
-
}
|
|
1477
|
-
}), We = /* @__PURE__ */ D({
|
|
1478
|
-
__name: "CropperImage",
|
|
1479
|
-
props: {
|
|
1480
|
-
src: {},
|
|
1481
|
-
alt: {},
|
|
1482
|
-
initialCenterSize: { default: "contain" },
|
|
1483
|
-
rotatable: { type: Boolean, default: !1 },
|
|
1484
|
-
scalable: { type: Boolean, default: !1 },
|
|
1485
|
-
skewable: { type: Boolean, default: !1 },
|
|
1486
|
-
slottable: { type: Boolean, default: !1 },
|
|
1487
|
-
translatable: { type: Boolean, default: !1 }
|
|
1488
|
-
},
|
|
1489
|
-
setup(o) {
|
|
1490
|
-
ht.$define();
|
|
1491
|
-
const t = _("cropper-image", {
|
|
1492
|
-
src: o.src,
|
|
1493
|
-
alt: o.alt,
|
|
1494
|
-
initialCenterSize: o.initialCenterSize,
|
|
1495
|
-
rotatable: o.rotatable,
|
|
1496
|
-
scalable: o.scalable,
|
|
1497
|
-
skewable: o.skewable,
|
|
1498
|
-
slottable: o.slottable,
|
|
1499
|
-
translatable: o.translatable
|
|
1500
|
-
});
|
|
1501
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1502
|
-
}
|
|
1503
|
-
}), Xe = /* @__PURE__ */ D({
|
|
1504
|
-
__name: "CropperShade",
|
|
1505
|
-
props: {
|
|
1506
|
-
x: { default: 0 },
|
|
1507
|
-
y: { default: 0 },
|
|
1508
|
-
width: { default: 0 },
|
|
1509
|
-
height: { default: 0 },
|
|
1510
|
-
slottable: { type: Boolean, default: !1 },
|
|
1511
|
-
themeColor: { default: "rgba(0, 0, 0, 0.65)" },
|
|
1512
|
-
hidden: { type: Boolean, default: !1 }
|
|
1513
|
-
},
|
|
1514
|
-
setup(o) {
|
|
1515
|
-
ct.$define();
|
|
1516
|
-
const t = _("cropper-shade", {
|
|
1517
|
-
x: o.x,
|
|
1518
|
-
y: o.y,
|
|
1519
|
-
width: o.width,
|
|
1520
|
-
height: o.height,
|
|
1521
|
-
slottable: o.slottable,
|
|
1522
|
-
themeColor: o.themeColor,
|
|
1523
|
-
hidden: o.hidden
|
|
1524
|
-
});
|
|
1525
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1526
|
-
}
|
|
1527
|
-
}), He = /* @__PURE__ */ D({
|
|
1528
|
-
__name: "CropperHandle",
|
|
1529
|
-
props: {
|
|
1530
|
-
action: { default: "none" },
|
|
1531
|
-
plain: { type: Boolean, default: !1 },
|
|
1532
|
-
slottable: { type: Boolean, default: !1 },
|
|
1533
|
-
themeColor: { default: "rgba(51, 153, 255, 0.5)" }
|
|
1534
|
-
},
|
|
1535
|
-
setup(o) {
|
|
1536
|
-
lt.$define();
|
|
1537
|
-
const t = _("cropper-handle", { action: o.action, plain: o.plain, slottable: o.slottable, themeColor: o.themeColor });
|
|
1538
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1539
|
-
}
|
|
1540
|
-
}), Ye = /* @__PURE__ */ D({
|
|
1541
|
-
__name: "CropperSelection",
|
|
1542
|
-
props: {
|
|
1543
|
-
x: { default: 0 },
|
|
1544
|
-
y: { default: 0 },
|
|
1545
|
-
width: { default: 0 },
|
|
1546
|
-
height: { default: 0 },
|
|
1547
|
-
aspectRatio: {},
|
|
1548
|
-
initialAspectRatio: {},
|
|
1549
|
-
initialCoverage: {},
|
|
1550
|
-
dynamic: { type: Boolean, default: !1 },
|
|
1551
|
-
movable: { type: Boolean, default: !1 },
|
|
1552
|
-
resizable: { type: Boolean, default: !1 },
|
|
1553
|
-
zoomable: { type: Boolean, default: !1 },
|
|
1554
|
-
multiple: { type: Boolean, default: !1 },
|
|
1555
|
-
keyboard: { type: Boolean, default: !1 },
|
|
1556
|
-
outlined: { type: Boolean, default: !1 },
|
|
1557
|
-
precise: { type: Boolean, default: !1 }
|
|
1558
|
-
},
|
|
1559
|
-
setup(o) {
|
|
1560
|
-
dt.$define();
|
|
1561
|
-
const t = _("cropper-selection", {
|
|
1562
|
-
x: o.x,
|
|
1563
|
-
y: o.y,
|
|
1564
|
-
width: o.width,
|
|
1565
|
-
height: o.height,
|
|
1566
|
-
aspectRatio: o.aspectRatio,
|
|
1567
|
-
initialAspectRatio: o.initialAspectRatio,
|
|
1568
|
-
initialCoverage: o.initialCoverage,
|
|
1569
|
-
dynamic: o.dynamic,
|
|
1570
|
-
movable: o.movable,
|
|
1571
|
-
resizable: o.resizable,
|
|
1572
|
-
zoomable: o.zoomable,
|
|
1573
|
-
multiple: o.multiple,
|
|
1574
|
-
keyboard: o.keyboard,
|
|
1575
|
-
outlined: o.outlined,
|
|
1576
|
-
precise: o.precise
|
|
1577
|
-
//
|
|
1578
|
-
});
|
|
1579
|
-
return (e, s) => (W(), X(H(Y(t)), null, {
|
|
1580
|
-
default: Ft(() => [
|
|
1581
|
-
qt(e.$slots, "default")
|
|
1582
|
-
]),
|
|
1583
|
-
_: 3
|
|
1584
|
-
}));
|
|
1585
|
-
}
|
|
1586
|
-
}), Be = /* @__PURE__ */ D({
|
|
1587
|
-
__name: "CropperCrosshair",
|
|
1588
|
-
props: {
|
|
1589
|
-
centered: { type: Boolean, default: !1 }
|
|
1590
|
-
},
|
|
1591
|
-
setup(o) {
|
|
1592
|
-
ft.$define();
|
|
1593
|
-
const t = _("cropper-crosshair", { centered: o.centered });
|
|
1594
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1595
|
-
}
|
|
1596
|
-
}), Le = /* @__PURE__ */ D({
|
|
1597
|
-
__name: "CropperGrid",
|
|
1598
|
-
props: {
|
|
1599
|
-
role: { default: "grid" },
|
|
1600
|
-
covered: { type: Boolean, default: !1 }
|
|
1601
|
-
},
|
|
1602
|
-
setup(o) {
|
|
1603
|
-
ut.$define();
|
|
1604
|
-
const t = _("cropper-grid", { role: o.role, covered: o.covered });
|
|
1605
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1606
|
-
}
|
|
1607
|
-
}), Ue = /* @__PURE__ */ D({
|
|
1608
|
-
__name: "CropperViewer",
|
|
1609
|
-
props: {
|
|
1610
|
-
resize: { default: "vertical" },
|
|
1611
|
-
selection: { default: "" }
|
|
1612
|
-
},
|
|
1613
|
-
setup(o) {
|
|
1614
|
-
$t.$define();
|
|
1615
|
-
const t = _("cropper-viewer", { resize: o.resize, selection: o.selection });
|
|
1616
|
-
return (e, s) => (W(), X(H(Y(t))));
|
|
1617
|
-
}
|
|
1618
|
-
}), Ze = {
|
|
1619
|
-
install: (o) => {
|
|
1620
|
-
o.component("CropperCanvas", _e), o.component("CropperImage", We), o.component("CropperShade", Xe), o.component("CropperHandle", He), o.component("CropperSelection", Ye), o.component("CropperCrosshair", Be), o.component("CropperGrid", Le), o.component("CropperViewer", Ue);
|
|
1621
|
-
}
|
|
1622
|
-
};
|
|
1623
|
-
export {
|
|
1624
|
-
_e as CropperCanvas,
|
|
1625
|
-
Be as CropperCrosshair,
|
|
1626
|
-
Le as CropperGrid,
|
|
1627
|
-
He as CropperHandle,
|
|
1628
|
-
We as CropperImage,
|
|
1629
|
-
Ye as CropperSelection,
|
|
1630
|
-
Xe as CropperShade,
|
|
1631
|
-
Ue as CropperViewer,
|
|
1632
|
-
Ze as default
|
|
1633
|
-
};
|