@gx-design-vue/image 0.2.0-beta.3 → 0.2.0-beta.31
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/Image.d.ts +83 -105
- package/dist/ImagePreview/Operations.d.ts +76 -0
- package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.d.ts +16 -0
- package/dist/ImagePreview/hooks/useImageTransform.d.ts +35 -0
- package/dist/ImagePreview/hooks/useMouseEvent.d.ts +10 -0
- package/dist/ImagePreview/hooks/useTouchEvent.d.ts +8 -0
- package/dist/ImagePreview/index.d.ts +157 -0
- package/dist/ImagePreview/props.d.ts +85 -0
- package/dist/{components → ImagePreview}/style.d.ts +10 -6
- package/dist/ImagePreview/typings.d.ts +15 -0
- package/dist/ImagePreview/utils/KeyCode.d.ts +436 -0
- package/dist/ImagePreview/utils/addEventListener.d.ts +3 -0
- package/dist/ImagePreview/utils/util.d.ts +4 -0
- package/dist/hooks/raf.d.ts +5 -0
- package/dist/hooks/useFrameSetState.d.ts +3 -0
- package/dist/image.js +1250 -0
- package/dist/image.umd.cjs +12 -0
- package/dist/index.d.ts +7 -3
- package/dist/props.d.ts +36 -83
- package/dist/slots.d.ts +3 -0
- package/dist/style.d.ts +6 -5
- package/dist/typings.d.ts +2 -0
- package/dist/utils/util.d.ts +1 -0
- package/package.json +27 -50
- package/dist/components/ImageViewer.d.ts +0 -193
- package/dist/image.mjs +0 -1495
- package/dist/image.umd.js +0 -2
package/dist/image.js
ADDED
|
@@ -0,0 +1,1250 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Gx Design Pro
|
|
3
|
+
* Version: 0.2.0-beta.30
|
|
4
|
+
* Author: gx12358
|
|
5
|
+
* Copyright (C) 2024 gx12358
|
|
6
|
+
* License: MIT License
|
|
7
|
+
* Description: Gx Design Image
|
|
8
|
+
* Date Created: 2025-08-15
|
|
9
|
+
* Homepage:
|
|
10
|
+
* Contact: gx12358@gmail.com
|
|
11
|
+
*/
|
|
12
|
+
import { ref as $, defineComponent as Ce, createVNode as s, Teleport as De, Transition as pe, withDirectives as we, Fragment as ue, cloneVNode as ot, vShow as ye, toRef as H, reactive as it, computed as b, watch as J, onMounted as Re, onUnmounted as at, mergeProps as le, watchEffect as lt, nextTick as rt } from "vue";
|
|
13
|
+
import { CloseOutlined as st, LeftOutlined as ut, RightOutlined as ct, SwapOutlined as Me, ZoomOutOutlined as dt, ZoomInOutlined as ft, RotateRightOutlined as vt, RotateLeftOutlined as gt, EyeOutlined as mt } from "@ant-design/icons-vue";
|
|
14
|
+
import { getTransitionProps as Se, Keyframe as de, useStyle as ht, mergeToken as pt, unit as ee, FastColor as wt, useProStyle as yt } from "@gx-design-vue/pro-provider";
|
|
15
|
+
import { classNames as X, getPrefixCls as Ne, isNumber as Pe, getSlotVNode as Z, isArray as St, getSlot as re, isInContainer as Ct, isString as xt, getScrollContainer as It } from "@gx-design-vue/pro-utils";
|
|
16
|
+
import { useWindowSize as Xe, isClient as Q, useThrottleFn as bt, useEventListener as ze } from "@vueuse/core";
|
|
17
|
+
import { isEqual as Lt, cloneDeep as $t, omit as Ye, fromPairs as Mt } from "lodash-es";
|
|
18
|
+
import { useState as ne, useEffect as xe, useMergedState as zt } from "@gx-design-vue/pro-hooks";
|
|
19
|
+
import { TinyColor as F } from "@ctrl/tinycolor";
|
|
20
|
+
const te = {
|
|
21
|
+
infinite: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: !0
|
|
24
|
+
},
|
|
25
|
+
zIndex: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 2e3
|
|
28
|
+
},
|
|
29
|
+
current: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 0
|
|
32
|
+
},
|
|
33
|
+
getContainer: {
|
|
34
|
+
type: String
|
|
35
|
+
}
|
|
36
|
+
}, je = {
|
|
37
|
+
preview: {
|
|
38
|
+
type: [Object, Boolean],
|
|
39
|
+
default: !0
|
|
40
|
+
},
|
|
41
|
+
src: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: ""
|
|
44
|
+
},
|
|
45
|
+
alt: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ""
|
|
48
|
+
},
|
|
49
|
+
loading: {
|
|
50
|
+
type: String
|
|
51
|
+
},
|
|
52
|
+
fit: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "contain"
|
|
55
|
+
},
|
|
56
|
+
crossOrigin: {
|
|
57
|
+
type: String
|
|
58
|
+
},
|
|
59
|
+
lazy: Boolean,
|
|
60
|
+
scrollContainer: {
|
|
61
|
+
type: [String, Object]
|
|
62
|
+
},
|
|
63
|
+
placeholder: {
|
|
64
|
+
type: [Function, Object, Boolean],
|
|
65
|
+
default: () => {
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
fallback: {
|
|
69
|
+
type: [Function, Object],
|
|
70
|
+
default: () => {
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onLoad: {
|
|
74
|
+
type: Function
|
|
75
|
+
},
|
|
76
|
+
onError: {
|
|
77
|
+
type: Function
|
|
78
|
+
},
|
|
79
|
+
onClick: {
|
|
80
|
+
type: Function
|
|
81
|
+
},
|
|
82
|
+
imageStyle: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: () => ({})
|
|
85
|
+
},
|
|
86
|
+
imageClass: String,
|
|
87
|
+
size: Number,
|
|
88
|
+
width: Number,
|
|
89
|
+
height: Number,
|
|
90
|
+
zIndex: te.zIndex,
|
|
91
|
+
getContainer: te.getContainer
|
|
92
|
+
}, G = {
|
|
93
|
+
urls: {
|
|
94
|
+
type: Array,
|
|
95
|
+
default: () => []
|
|
96
|
+
},
|
|
97
|
+
open: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: !1
|
|
100
|
+
},
|
|
101
|
+
scaleStep: {
|
|
102
|
+
type: Number,
|
|
103
|
+
default: 0.5
|
|
104
|
+
},
|
|
105
|
+
minScale: {
|
|
106
|
+
type: Number,
|
|
107
|
+
default: 0.32
|
|
108
|
+
},
|
|
109
|
+
maxScale: {
|
|
110
|
+
type: Number,
|
|
111
|
+
default: 32
|
|
112
|
+
},
|
|
113
|
+
movable: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: !0
|
|
116
|
+
},
|
|
117
|
+
disabled: Boolean,
|
|
118
|
+
zIndex: te.zIndex,
|
|
119
|
+
current: te.current,
|
|
120
|
+
infinite: te.infinite,
|
|
121
|
+
getContainer: je.getContainer,
|
|
122
|
+
onHideOnClickModal: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: !0
|
|
125
|
+
},
|
|
126
|
+
countRender: [Function, Array, Object],
|
|
127
|
+
icons: {
|
|
128
|
+
type: Object,
|
|
129
|
+
default: () => ({})
|
|
130
|
+
},
|
|
131
|
+
onTransform: Function,
|
|
132
|
+
onOpenChange: Function,
|
|
133
|
+
"onUpdate:open": Function
|
|
134
|
+
};
|
|
135
|
+
let Be = (e) => setTimeout(e, 16), Fe = (e) => clearTimeout(e);
|
|
136
|
+
typeof window < "u" && "requestAnimationFrame" in window && (Be = (e) => window.requestAnimationFrame(e), Fe = (e) => window.cancelAnimationFrame(e));
|
|
137
|
+
let Oe = 0;
|
|
138
|
+
const Ie = /* @__PURE__ */ new Map();
|
|
139
|
+
function ke(e) {
|
|
140
|
+
Ie.delete(e);
|
|
141
|
+
}
|
|
142
|
+
function He(e, t = 1) {
|
|
143
|
+
Oe += 1;
|
|
144
|
+
const o = Oe;
|
|
145
|
+
function i(n) {
|
|
146
|
+
if (n === 0)
|
|
147
|
+
ke(o), e();
|
|
148
|
+
else {
|
|
149
|
+
const r = Be(() => {
|
|
150
|
+
i(n - 1);
|
|
151
|
+
});
|
|
152
|
+
Ie.set(o, r);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return i(t), o;
|
|
156
|
+
}
|
|
157
|
+
He.cancel = (e) => {
|
|
158
|
+
const t = Ie.get(e);
|
|
159
|
+
return ke(t), Fe(t);
|
|
160
|
+
};
|
|
161
|
+
const ae = {
|
|
162
|
+
x: 0,
|
|
163
|
+
y: 0,
|
|
164
|
+
rotate: 0,
|
|
165
|
+
scale: 1,
|
|
166
|
+
flipX: !1,
|
|
167
|
+
flipY: !1
|
|
168
|
+
};
|
|
169
|
+
function Ot(e, t, o, i) {
|
|
170
|
+
const n = $(null), r = $([]), [c, p] = ne(ae), v = (m) => {
|
|
171
|
+
p(ae), Lt(ae, c.value) || i?.({ transform: ae, action: m });
|
|
172
|
+
}, d = (m, C) => {
|
|
173
|
+
n.value === null && (r.value = [], n.value = He(() => {
|
|
174
|
+
let x = $t(c.value);
|
|
175
|
+
r.value.forEach((a) => {
|
|
176
|
+
x = { ...x, ...a };
|
|
177
|
+
}), n.value = null, i?.({ transform: x, action: C }), p(x);
|
|
178
|
+
})), r.value.push({
|
|
179
|
+
...c.value,
|
|
180
|
+
...m
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
transform: c,
|
|
185
|
+
resetTransform: v,
|
|
186
|
+
updateTransform: d,
|
|
187
|
+
dispatchZoomChange: (m, C, x, a, l) => {
|
|
188
|
+
const { width: w, height: h, offsetWidth: y, offsetHeight: S, offsetLeft: L, offsetTop: T } = e.value;
|
|
189
|
+
let M = m, I = c.value.scale * m;
|
|
190
|
+
I > o.value ? (I = o.value, M = o.value / c.value.scale) : I < t.value && (I = l ? I : t.value, M = I / c.value.scale);
|
|
191
|
+
const k = x ?? innerWidth / 2, W = a ?? innerHeight / 2, R = M - 1, z = R * w * 0.5, N = R * h * 0.5, Y = R * (k - c.value.x - L), _ = R * (W - c.value.y - T);
|
|
192
|
+
let j = c.value.x - (Y - z), B = c.value.y - (_ - N);
|
|
193
|
+
if (m < 1 && I === 1) {
|
|
194
|
+
const A = y * I, f = S * I, { width: P, height: E } = Xe();
|
|
195
|
+
A <= P.value && f <= E.value && (j = 0, B = 0);
|
|
196
|
+
}
|
|
197
|
+
d({
|
|
198
|
+
x: j,
|
|
199
|
+
y: B,
|
|
200
|
+
scale: I
|
|
201
|
+
}, C);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function Tt(e, t) {
|
|
206
|
+
process.env.NODE_ENV !== "production" && console !== void 0 && console.error(`Warning: ${t}`);
|
|
207
|
+
}
|
|
208
|
+
let Ze = !1;
|
|
209
|
+
try {
|
|
210
|
+
const e = Object.defineProperty({}, "passive", {
|
|
211
|
+
get() {
|
|
212
|
+
Ze = !0;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
window.addEventListener("testPassive", null, e), window.removeEventListener("testPassive", null, e);
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
218
|
+
function V(e, t, o, i) {
|
|
219
|
+
if (e && e.addEventListener) {
|
|
220
|
+
let n = i;
|
|
221
|
+
n === void 0 && Ze && (t === "touchstart" || t === "touchmove" || t === "wheel") && (n = { passive: !1 }), e.addEventListener(t, o, n);
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
remove: () => {
|
|
225
|
+
e && e.removeEventListener && e.removeEventListener(t, o);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const q = 1, At = 1;
|
|
230
|
+
function Te(e, t, o, i) {
|
|
231
|
+
const n = t + o, r = (o - i) / 2;
|
|
232
|
+
if (o > i) {
|
|
233
|
+
if (t > 0)
|
|
234
|
+
return {
|
|
235
|
+
[e]: r
|
|
236
|
+
};
|
|
237
|
+
if (t < 0 && n < i)
|
|
238
|
+
return {
|
|
239
|
+
[e]: -r
|
|
240
|
+
};
|
|
241
|
+
} else if (t < 0 || n > i)
|
|
242
|
+
return {
|
|
243
|
+
[e]: t < 0 ? r : -r
|
|
244
|
+
};
|
|
245
|
+
return {};
|
|
246
|
+
}
|
|
247
|
+
function We(e, t, o, i) {
|
|
248
|
+
const { width: n, height: r } = Xe();
|
|
249
|
+
let c = null;
|
|
250
|
+
return e <= n.value && t <= r.value ? c = {
|
|
251
|
+
x: 0,
|
|
252
|
+
y: 0
|
|
253
|
+
} : (e > n.value || t > r.value) && (c = {
|
|
254
|
+
...Te("x", o, e, n.value),
|
|
255
|
+
...Te("y", i, t, r.value)
|
|
256
|
+
}), c;
|
|
257
|
+
}
|
|
258
|
+
function Et(e, t, o, i, n, r, c) {
|
|
259
|
+
const [p, v] = ne(!1), d = $({
|
|
260
|
+
diffX: 0,
|
|
261
|
+
diffY: 0,
|
|
262
|
+
transformX: 0,
|
|
263
|
+
transformY: 0
|
|
264
|
+
}), g = (a) => {
|
|
265
|
+
!t || a.button !== 0 || (a.preventDefault(), a.stopPropagation(), d.value = {
|
|
266
|
+
diffX: a.pageX - n.value.x,
|
|
267
|
+
diffY: a.pageY - n.value.y,
|
|
268
|
+
transformX: n.value.x,
|
|
269
|
+
transformY: n.value.y
|
|
270
|
+
}, v(!0));
|
|
271
|
+
}, m = (a) => {
|
|
272
|
+
o && p.value && r({
|
|
273
|
+
x: a.pageX - d.value.diffX,
|
|
274
|
+
y: a.pageY - d.value.diffY
|
|
275
|
+
}, "move");
|
|
276
|
+
}, C = () => {
|
|
277
|
+
if (o && p.value) {
|
|
278
|
+
v(!1);
|
|
279
|
+
const { transformX: a, transformY: l } = d.value;
|
|
280
|
+
if (!(n.value.x !== a && n.value.y !== l))
|
|
281
|
+
return;
|
|
282
|
+
const h = e.value.offsetWidth * n.value.scale, y = e.value.offsetHeight * n.value.scale, { left: S, top: L } = e.value.getBoundingClientRect(), T = n.value.rotate % 180 !== 0, M = We(T ? y : h, T ? h : y, S, L);
|
|
283
|
+
M && r({ ...M }, "dragRebound");
|
|
284
|
+
}
|
|
285
|
+
}, x = (a) => {
|
|
286
|
+
if (!o || a.deltaY === 0)
|
|
287
|
+
return;
|
|
288
|
+
const l = Math.abs(a.deltaY / 100), w = Math.min(l, At);
|
|
289
|
+
let h = q + w * i.value;
|
|
290
|
+
a.deltaY > 0 && (h = q / h), c(h, "wheel", a.clientX, a.clientY);
|
|
291
|
+
};
|
|
292
|
+
return xe(() => {
|
|
293
|
+
let a, l, w, h;
|
|
294
|
+
if (t) {
|
|
295
|
+
w = V(window, "mouseup", C, !1), h = V(window, "mousemove", m, !1);
|
|
296
|
+
try {
|
|
297
|
+
window.top !== window.self && (a = V(window.top, "mouseup", C, !1), l = V(window.top, "mousemove", m, !1));
|
|
298
|
+
} catch (y) {
|
|
299
|
+
Tt(!1, `[rc-image] ${y}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return () => {
|
|
303
|
+
w?.remove(), h?.remove(), a?.remove(), l?.remove();
|
|
304
|
+
};
|
|
305
|
+
}, [o, p, () => n.value.x, () => n.value.y, () => n.value.rotate, t]), {
|
|
306
|
+
isMoving: p,
|
|
307
|
+
onMouseDown: g,
|
|
308
|
+
onMouseMove: m,
|
|
309
|
+
onMouseUp: C,
|
|
310
|
+
onWheel: x
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function ce(e, t) {
|
|
314
|
+
const o = e.x - t.x, i = e.y - t.y;
|
|
315
|
+
return Math.hypot(o, i);
|
|
316
|
+
}
|
|
317
|
+
function Dt(e, t, o, i) {
|
|
318
|
+
const n = ce(e, o), r = ce(t, i);
|
|
319
|
+
if (n === 0 && r === 0)
|
|
320
|
+
return [e.x, e.y];
|
|
321
|
+
const c = n / (n + r), p = e.x + c * (t.x - e.x), v = e.y + c * (t.y - e.y);
|
|
322
|
+
return [p, v];
|
|
323
|
+
}
|
|
324
|
+
function Rt(e, t, o, i, n, r, c) {
|
|
325
|
+
const [p, v] = ne(!1), d = $({
|
|
326
|
+
point1: { x: 0, y: 0 },
|
|
327
|
+
point2: { x: 0, y: 0 },
|
|
328
|
+
eventType: "none"
|
|
329
|
+
}), g = (a) => {
|
|
330
|
+
d.value = {
|
|
331
|
+
...d.value,
|
|
332
|
+
...a
|
|
333
|
+
};
|
|
334
|
+
}, m = (a) => {
|
|
335
|
+
if (!t.value)
|
|
336
|
+
return;
|
|
337
|
+
a.stopPropagation(), v(!0);
|
|
338
|
+
const { touches: l = [] } = a;
|
|
339
|
+
l.length > 1 ? g({
|
|
340
|
+
point1: { x: l[0].clientX, y: l[0].clientY },
|
|
341
|
+
point2: { x: l[1].clientX, y: l[1].clientY },
|
|
342
|
+
eventType: "touchZoom"
|
|
343
|
+
}) : g({
|
|
344
|
+
point1: {
|
|
345
|
+
x: l[0].clientX - n.value.x,
|
|
346
|
+
y: l[0].clientY - n.value.y
|
|
347
|
+
},
|
|
348
|
+
eventType: "move"
|
|
349
|
+
});
|
|
350
|
+
}, C = (a) => {
|
|
351
|
+
const { touches: l = [] } = a, { point1: w, point2: h, eventType: y } = d.value;
|
|
352
|
+
if (l.length > 1 && y === "touchZoom") {
|
|
353
|
+
const S = {
|
|
354
|
+
x: l[0].clientX,
|
|
355
|
+
y: l[0].clientY
|
|
356
|
+
}, L = {
|
|
357
|
+
x: l[1].clientX,
|
|
358
|
+
y: l[1].clientY
|
|
359
|
+
}, [T, M] = Dt(w, h, S, L), I = ce(S, L) / ce(w, h);
|
|
360
|
+
c(I, "touchZoom", T, M, !0), g({
|
|
361
|
+
point1: S,
|
|
362
|
+
point2: L,
|
|
363
|
+
eventType: "touchZoom"
|
|
364
|
+
});
|
|
365
|
+
} else y === "move" && (r({
|
|
366
|
+
x: l[0].clientX - w.x,
|
|
367
|
+
y: l[0].clientY - w.y
|
|
368
|
+
}, "move"), g({ eventType: "move" }));
|
|
369
|
+
}, x = () => {
|
|
370
|
+
if (!o.value)
|
|
371
|
+
return;
|
|
372
|
+
if (p && v(!1), g({ eventType: "none" }), i.value > n.value.scale)
|
|
373
|
+
return r({ x: 0, y: 0, scale: i.value }, "touchZoom");
|
|
374
|
+
const a = e.value.offsetWidth * n.value.scale, l = e.value.offsetHeight * n.value.scale, { left: w, top: h } = e.value.getBoundingClientRect(), y = n.value.rotate % 180 !== 0, S = We(y ? l : a, y ? a : l, w, h);
|
|
375
|
+
S && r({ ...S }, "dragRebound");
|
|
376
|
+
};
|
|
377
|
+
return xe(() => {
|
|
378
|
+
let a;
|
|
379
|
+
return o.value && t.value && (a = V(window, "touchmove", (l) => l.preventDefault(), {
|
|
380
|
+
passive: !1
|
|
381
|
+
})), () => {
|
|
382
|
+
a?.remove();
|
|
383
|
+
};
|
|
384
|
+
}, [o, t]), {
|
|
385
|
+
isTouching: p,
|
|
386
|
+
onTouchStart: m,
|
|
387
|
+
onTouchMove: C,
|
|
388
|
+
onTouchEnd: x
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const Nt = /* @__PURE__ */ Ce({
|
|
392
|
+
name: "Operations",
|
|
393
|
+
inheritAttrs: !1,
|
|
394
|
+
props: {
|
|
395
|
+
open: Boolean,
|
|
396
|
+
count: {
|
|
397
|
+
type: Number,
|
|
398
|
+
default: 0
|
|
399
|
+
},
|
|
400
|
+
current: {
|
|
401
|
+
type: Number,
|
|
402
|
+
default: 0
|
|
403
|
+
},
|
|
404
|
+
showSwitch: Boolean,
|
|
405
|
+
showProgress: Boolean,
|
|
406
|
+
prefixCls: String,
|
|
407
|
+
hashId: String,
|
|
408
|
+
zIndex: G.zIndex,
|
|
409
|
+
icons: G.icons,
|
|
410
|
+
infinite: G.infinite,
|
|
411
|
+
getContainer: G.getContainer,
|
|
412
|
+
countRender: G.countRender,
|
|
413
|
+
tools: Array,
|
|
414
|
+
onClose: Function,
|
|
415
|
+
onActive: Function
|
|
416
|
+
},
|
|
417
|
+
setup(e) {
|
|
418
|
+
const t = (o, i) => {
|
|
419
|
+
o.preventDefault(), o.stopPropagation(), e.onActive?.(i);
|
|
420
|
+
};
|
|
421
|
+
return () => {
|
|
422
|
+
const {
|
|
423
|
+
prefixCls: o,
|
|
424
|
+
hashId: i,
|
|
425
|
+
tools: n
|
|
426
|
+
} = e, r = Se(`${e.prefixCls}-fade`), c = `${o}-operations-operation`, p = `${o}-operations-icon`;
|
|
427
|
+
return s(De, {
|
|
428
|
+
to: e.getContainer || "body"
|
|
429
|
+
}, {
|
|
430
|
+
default: () => [s(pe, r, {
|
|
431
|
+
default: () => [we(s("div", {
|
|
432
|
+
class: X(`${o}-operations-wrapper`, i),
|
|
433
|
+
style: {
|
|
434
|
+
zIndex: e.zIndex
|
|
435
|
+
}
|
|
436
|
+
}, [e.icons?.close === null ? null : s("button", {
|
|
437
|
+
class: `${o}-close ${i}`,
|
|
438
|
+
onClick: e.onClose
|
|
439
|
+
}, [e.icons?.close || s(st, null, null)]), e.showSwitch && s(ue, null, [s("div", {
|
|
440
|
+
class: X(`${o}-switch-left ${i}`, {
|
|
441
|
+
[`${o}-switch-left-disabled`]: e.infinite ? !1 : e.current === 0
|
|
442
|
+
}),
|
|
443
|
+
onClick: (v) => t(v, -1)
|
|
444
|
+
}, [e.icons?.left || s(ut, null, null)]), s("div", {
|
|
445
|
+
class: X(`${o}-switch-right ${i}`, {
|
|
446
|
+
[`${o}-switch-right-disabled`]: e.infinite ? !1 : e.current === e.count - 1
|
|
447
|
+
}),
|
|
448
|
+
onClick: (v) => t(v, 1)
|
|
449
|
+
}, [e.icons?.right || s(ct, null, null)])]), s("div", {
|
|
450
|
+
class: `${o}-footer ${i}`
|
|
451
|
+
}, [e.showProgress && s("div", {
|
|
452
|
+
class: `${o}-progress`
|
|
453
|
+
}, [e.countRender ? e.countRender(e.current + 1, e.count) : `${e.current + 1} / ${e.count}`]), s("div", {
|
|
454
|
+
class: `${e.prefixCls}-operations`
|
|
455
|
+
}, [n?.map(({
|
|
456
|
+
icon: v,
|
|
457
|
+
onClick: d,
|
|
458
|
+
type: g,
|
|
459
|
+
disabled: m
|
|
460
|
+
}) => s("div", {
|
|
461
|
+
class: X(c, {
|
|
462
|
+
[`${e.prefixCls}-operations-operation-disabled`]: m && m?.value
|
|
463
|
+
}),
|
|
464
|
+
onClick: d,
|
|
465
|
+
key: g
|
|
466
|
+
}, [ot(v, {
|
|
467
|
+
class: p
|
|
468
|
+
})]))])])]), [[ye, e.open]])]
|
|
469
|
+
})]
|
|
470
|
+
});
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
}), Pt = new de("viewFadeIn", {
|
|
474
|
+
"0%": {
|
|
475
|
+
opacity: 0
|
|
476
|
+
},
|
|
477
|
+
"100%": {
|
|
478
|
+
opacity: 1
|
|
479
|
+
}
|
|
480
|
+
}), Xt = new de("viewFadeOut", {
|
|
481
|
+
"0%": {
|
|
482
|
+
opacity: 1
|
|
483
|
+
},
|
|
484
|
+
"100%": {
|
|
485
|
+
opacity: 0
|
|
486
|
+
}
|
|
487
|
+
}), Yt = new de("viewZoomBadgeIn", {
|
|
488
|
+
"0%": {
|
|
489
|
+
transform: "scale(0)",
|
|
490
|
+
opacity: 0
|
|
491
|
+
},
|
|
492
|
+
"100%": {
|
|
493
|
+
transform: "scale(1)",
|
|
494
|
+
opacity: 1
|
|
495
|
+
}
|
|
496
|
+
}), jt = new de("viewZoomBadgeOut", {
|
|
497
|
+
"0%": {
|
|
498
|
+
transform: "scale(1)"
|
|
499
|
+
},
|
|
500
|
+
"100%": {
|
|
501
|
+
transform: "scale(0)",
|
|
502
|
+
opacity: 0
|
|
503
|
+
}
|
|
504
|
+
}), Ae = (e) => ({
|
|
505
|
+
position: e || "absolute",
|
|
506
|
+
inset: 0
|
|
507
|
+
});
|
|
508
|
+
function ge(e) {
|
|
509
|
+
return {
|
|
510
|
+
position: e,
|
|
511
|
+
top: 0,
|
|
512
|
+
insetInlineEnd: 0,
|
|
513
|
+
bottom: 0,
|
|
514
|
+
insetInlineStart: 0
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
const Bt = (e) => {
|
|
518
|
+
const { previewCls: t, modalMaskBg: o, marginXL: i, margin: n, colorTextLightSolid: r, previewOperationColorDisabled: c, previewOperationHoverColor: p, motionDurationSlow: v, iconCls: d } = e, g = new F(o).setAlpha(0.1), m = g.clone().setAlpha(0.2), C = new F(o).setAlpha(0.5), x = new F(o).setAlpha(0.03);
|
|
519
|
+
return {
|
|
520
|
+
[`${t}-footer`]: {
|
|
521
|
+
position: "fixed",
|
|
522
|
+
bottom: i,
|
|
523
|
+
left: {
|
|
524
|
+
_skip_check_: !0,
|
|
525
|
+
value: "50%"
|
|
526
|
+
},
|
|
527
|
+
display: "flex",
|
|
528
|
+
flexDirection: "column",
|
|
529
|
+
alignItems: "center",
|
|
530
|
+
color: e.previewOperationColor,
|
|
531
|
+
transform: "translateX(-50%)"
|
|
532
|
+
},
|
|
533
|
+
[`${t}-progress`]: {
|
|
534
|
+
marginBottom: n
|
|
535
|
+
},
|
|
536
|
+
[`${t}-close`]: {
|
|
537
|
+
position: "fixed",
|
|
538
|
+
top: i,
|
|
539
|
+
right: {
|
|
540
|
+
_skip_check_: !0,
|
|
541
|
+
value: i
|
|
542
|
+
},
|
|
543
|
+
display: "flex",
|
|
544
|
+
alignItems: "center",
|
|
545
|
+
justifyContent: "center",
|
|
546
|
+
color: r,
|
|
547
|
+
backgroundColor: g.toRgbString(),
|
|
548
|
+
borderRadius: e.borderRadiusLG,
|
|
549
|
+
backdropFilter: "saturate(180%) blur(10px)",
|
|
550
|
+
width: e.sizeXL,
|
|
551
|
+
height: e.sizeXL,
|
|
552
|
+
outline: 0,
|
|
553
|
+
border: 0,
|
|
554
|
+
cursor: "pointer",
|
|
555
|
+
transition: `all ${v}`,
|
|
556
|
+
"&:hover": {
|
|
557
|
+
backgroundColor: m.toRgbString()
|
|
558
|
+
},
|
|
559
|
+
[`& > ${d}`]: {
|
|
560
|
+
fontSize: e.previewOperationSize
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
[`${t}-operations`]: {
|
|
564
|
+
display: "flex",
|
|
565
|
+
alignItems: "center",
|
|
566
|
+
gap: e.sizeXXS,
|
|
567
|
+
padding: e.paddingXXS,
|
|
568
|
+
border: `1px solid ${e.colorBorderSecondary}`,
|
|
569
|
+
backgroundColor: C.toRgbString(),
|
|
570
|
+
borderRadius: e.borderRadiusLG,
|
|
571
|
+
backdropFilter: "saturate(150%) blur(10px)",
|
|
572
|
+
"&-operation": {
|
|
573
|
+
display: "flex",
|
|
574
|
+
alignItems: "center",
|
|
575
|
+
justifyContent: "center",
|
|
576
|
+
width: e.sizeXL + 4,
|
|
577
|
+
height: e.sizeXL + 4,
|
|
578
|
+
cursor: "pointer",
|
|
579
|
+
color: r,
|
|
580
|
+
borderRadius: e.borderRadiusSM,
|
|
581
|
+
transition: `all ${v}`,
|
|
582
|
+
userSelect: "none",
|
|
583
|
+
[`&:not(${t}-operations-operation-disabled):hover > ${d}`]: {
|
|
584
|
+
color: p
|
|
585
|
+
},
|
|
586
|
+
"&:hover": {
|
|
587
|
+
backgroundColor: x.toRgbString()
|
|
588
|
+
},
|
|
589
|
+
"&-disabled": {
|
|
590
|
+
color: c,
|
|
591
|
+
cursor: "not-allowed"
|
|
592
|
+
},
|
|
593
|
+
"&:first-of-type": {
|
|
594
|
+
marginInlineStart: 0
|
|
595
|
+
},
|
|
596
|
+
[`& > ${d}`]: {
|
|
597
|
+
fontSize: e.previewOperationSize
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}, Ft = (e) => {
|
|
603
|
+
const { modalMaskBg: t, iconCls: o, previewOperationColorDisabled: i, previewCls: n, zIndexPopup: r, motionDurationSlow: c, colorTextLightSolid: p } = e, v = new F(t).setAlpha(0.1), d = v.clone().setAlpha(0.2);
|
|
604
|
+
return {
|
|
605
|
+
[`${n}-switch-left, ${n}-switch-right`]: {
|
|
606
|
+
position: "fixed",
|
|
607
|
+
insetBlockStart: "50%",
|
|
608
|
+
zIndex: e.calc(r).add(1).equal(),
|
|
609
|
+
display: "flex",
|
|
610
|
+
alignItems: "center",
|
|
611
|
+
justifyContent: "center",
|
|
612
|
+
borderRadius: e.borderRadius,
|
|
613
|
+
backdropFilter: "saturate(180%) blur(10px)",
|
|
614
|
+
width: e.imagePreviewSwitchSize,
|
|
615
|
+
height: e.imagePreviewSwitchSize,
|
|
616
|
+
marginTop: e.calc(e.imagePreviewSwitchSize).mul(-1).div(2).equal(),
|
|
617
|
+
color: p,
|
|
618
|
+
background: v.toRgbString(),
|
|
619
|
+
transform: "translateY(-50%)",
|
|
620
|
+
cursor: "pointer",
|
|
621
|
+
transition: `all ${c}`,
|
|
622
|
+
userSelect: "none",
|
|
623
|
+
"&:hover": {
|
|
624
|
+
background: d.toRgbString()
|
|
625
|
+
},
|
|
626
|
+
"&-disabled": {
|
|
627
|
+
"&, &:hover": {
|
|
628
|
+
color: i,
|
|
629
|
+
background: "transparent",
|
|
630
|
+
cursor: "not-allowed",
|
|
631
|
+
[`> ${o}`]: {
|
|
632
|
+
cursor: "not-allowed"
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
[`> ${o}`]: {
|
|
637
|
+
fontSize: e.previewOperationSize
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
[`${n}-switch-left`]: {
|
|
641
|
+
insetInlineStart: e.marginSM
|
|
642
|
+
},
|
|
643
|
+
[`${n}-switch-right`]: {
|
|
644
|
+
insetInlineEnd: e.marginSM
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}, kt = (e) => {
|
|
648
|
+
const { motionEaseOut: t, motionDurationSlow: o } = e;
|
|
649
|
+
return {
|
|
650
|
+
[e.componentCls]: {
|
|
651
|
+
height: "100%",
|
|
652
|
+
textAlign: "center",
|
|
653
|
+
pointerEvents: "none",
|
|
654
|
+
"&-root": {
|
|
655
|
+
...ge("fixed"),
|
|
656
|
+
zIndex: e.zIndexPopup,
|
|
657
|
+
overflow: "auto",
|
|
658
|
+
outline: 0,
|
|
659
|
+
WebkitOverflowScrolling: "touch"
|
|
660
|
+
},
|
|
661
|
+
"&-wrap": {
|
|
662
|
+
...ge("fixed"),
|
|
663
|
+
zIndex: e.zIndexPopup,
|
|
664
|
+
overflow: "auto",
|
|
665
|
+
outline: 0,
|
|
666
|
+
WebkitOverflowScrolling: "touch"
|
|
667
|
+
},
|
|
668
|
+
"&-mask": {
|
|
669
|
+
...ge("fixed"),
|
|
670
|
+
zIndex: e.zIndexPopupBase,
|
|
671
|
+
height: "100%",
|
|
672
|
+
backgroundColor: e.colorBgMask,
|
|
673
|
+
backdropFilter: "blur(8px)"
|
|
674
|
+
},
|
|
675
|
+
"&-body": {
|
|
676
|
+
...Ae(),
|
|
677
|
+
overflow: "hidden"
|
|
678
|
+
},
|
|
679
|
+
"&-img": {
|
|
680
|
+
maxWidth: "100%",
|
|
681
|
+
maxHeight: "70%",
|
|
682
|
+
verticalAlign: "middle",
|
|
683
|
+
transform: "scale3d(1, 1, 1)",
|
|
684
|
+
cursor: "grab",
|
|
685
|
+
transition: `transform ${o} ${t} 0s`,
|
|
686
|
+
userSelect: "none",
|
|
687
|
+
"&-wrapper": {
|
|
688
|
+
...Ae(),
|
|
689
|
+
transition: `transform ${o} ${t} 0s`,
|
|
690
|
+
display: "flex",
|
|
691
|
+
justifyContent: "center",
|
|
692
|
+
alignItems: "center",
|
|
693
|
+
"& > *": {
|
|
694
|
+
pointerEvents: "auto"
|
|
695
|
+
},
|
|
696
|
+
"&::before": {
|
|
697
|
+
display: "inline-block",
|
|
698
|
+
width: 1,
|
|
699
|
+
height: "50%",
|
|
700
|
+
marginInlineEnd: -1,
|
|
701
|
+
content: '""'
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"&-moving": {
|
|
706
|
+
[`${e.componentCls}-view-img`]: {
|
|
707
|
+
cursor: "grabbing",
|
|
708
|
+
"&-wrapper": {
|
|
709
|
+
transitionDuration: "0s"
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
"&-mask-zoom-appear, &-mask-zoom-enter": {
|
|
714
|
+
animationName: Pt,
|
|
715
|
+
animationDuration: e.motionDurationSlow,
|
|
716
|
+
animationTimingFunction: "linear",
|
|
717
|
+
userSelect: "none"
|
|
718
|
+
},
|
|
719
|
+
"&-mask-zoom-leave": {
|
|
720
|
+
animationName: Xt,
|
|
721
|
+
animationDuration: e.motionDurationSlow,
|
|
722
|
+
animationTimingFunction: "linear",
|
|
723
|
+
pointerEvents: "none"
|
|
724
|
+
},
|
|
725
|
+
"&-zoom-appear, &-zoom-enter": {
|
|
726
|
+
animationName: Yt,
|
|
727
|
+
opacity: 0,
|
|
728
|
+
animationTimingFunction: e.motionEaseOutCirc,
|
|
729
|
+
animationFillMode: "both",
|
|
730
|
+
transform: "none",
|
|
731
|
+
animationDuration: e.motionDurationMid,
|
|
732
|
+
userSelect: "none"
|
|
733
|
+
},
|
|
734
|
+
"&-zoom-enter-active": {
|
|
735
|
+
animationPlayState: "running"
|
|
736
|
+
},
|
|
737
|
+
"&-zoom-leave": {
|
|
738
|
+
animationName: jt,
|
|
739
|
+
animationDuration: e.motionDurationSlow,
|
|
740
|
+
animationTimingFunction: e.motionEaseInOutCirc,
|
|
741
|
+
animationFillMode: "both"
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
[`${e.componentCls}-root`]: {
|
|
745
|
+
[`${e.componentCls}-wrapper`]: {
|
|
746
|
+
zIndex: e.zIndexPopup
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
[`${e.componentCls}-operations-wrapper`]: {
|
|
750
|
+
position: "fixed",
|
|
751
|
+
insetBlockStart: 0,
|
|
752
|
+
insetInlineEnd: 0,
|
|
753
|
+
zIndex: e.calc(e.zIndexPopup).add(1).equal(),
|
|
754
|
+
width: "100%"
|
|
755
|
+
},
|
|
756
|
+
"&": [Bt(e), Ft(e)]
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
function Ht(e) {
|
|
760
|
+
return ht("ImageViewer", (t) => {
|
|
761
|
+
const o = pt(t, {
|
|
762
|
+
zIndexPopup: t.zIndexPopupBase + 80,
|
|
763
|
+
previewOperationColor: new F(t.colorTextLightSolid).setAlpha(0.65).toRgbString(),
|
|
764
|
+
previewOperationHoverColor: new F(t.colorTextLightSolid).setAlpha(0.85).toRgbString(),
|
|
765
|
+
previewOperationColorDisabled: new F(t.colorTextLightSolid).setAlpha(0.25).toRgbString(),
|
|
766
|
+
imagePreviewSwitchSize: t.sizeXL,
|
|
767
|
+
modalMaskBg: new F("#000").setAlpha(0.45).toRgbString(),
|
|
768
|
+
// FIXME: Shared Token
|
|
769
|
+
previewOperationSize: t.fontSizeIcon * 1.5,
|
|
770
|
+
// FIXME: fontSizeIconLG
|
|
771
|
+
iconCls: ".anticon",
|
|
772
|
+
previewCls: t.componentCls
|
|
773
|
+
});
|
|
774
|
+
return [kt(o)];
|
|
775
|
+
}, e);
|
|
776
|
+
}
|
|
777
|
+
const me = {
|
|
778
|
+
/**
|
|
779
|
+
* ESC
|
|
780
|
+
*/
|
|
781
|
+
ESC: 27,
|
|
782
|
+
// also NUM_NORTH_WEST
|
|
783
|
+
/**
|
|
784
|
+
* LEFT
|
|
785
|
+
*/
|
|
786
|
+
LEFT: 37,
|
|
787
|
+
// also NUM_NORTH
|
|
788
|
+
/**
|
|
789
|
+
* RIGHT
|
|
790
|
+
*/
|
|
791
|
+
RIGHT: 39
|
|
792
|
+
}, U = {
|
|
793
|
+
rotateLeft: s(gt, null, null),
|
|
794
|
+
rotateRight: s(vt, null, null),
|
|
795
|
+
zoomIn: s(ft, null, null),
|
|
796
|
+
zoomOut: s(dt, null, null),
|
|
797
|
+
flipX: s(Me, null, null),
|
|
798
|
+
flipY: s(Me, {
|
|
799
|
+
rotate: 90
|
|
800
|
+
}, null)
|
|
801
|
+
}, Zt = /* @__PURE__ */ Ce({
|
|
802
|
+
name: "GImagePreview",
|
|
803
|
+
props: G,
|
|
804
|
+
inheritAttrs: !1,
|
|
805
|
+
slots: Object,
|
|
806
|
+
emits: {
|
|
807
|
+
close: () => !0,
|
|
808
|
+
transform: (e) => !0,
|
|
809
|
+
"update:open": (e) => !0
|
|
810
|
+
},
|
|
811
|
+
setup: (e, {
|
|
812
|
+
emit: t,
|
|
813
|
+
expose: o,
|
|
814
|
+
slots: i
|
|
815
|
+
}) => {
|
|
816
|
+
const n = Ne({
|
|
817
|
+
suffixCls: "image-view"
|
|
818
|
+
}), {
|
|
819
|
+
wrapSSR: r,
|
|
820
|
+
hashId: c
|
|
821
|
+
} = Ht(n), [p, v, d] = zt(e.open, {
|
|
822
|
+
value: H(e, "open"),
|
|
823
|
+
onChange: (u) => {
|
|
824
|
+
e.onOpenChange?.(u), t("update:open", u);
|
|
825
|
+
}
|
|
826
|
+
}), [g, m] = ne(!1), [C, x] = ne(!0), a = $(), {
|
|
827
|
+
transform: l,
|
|
828
|
+
resetTransform: w,
|
|
829
|
+
updateTransform: h,
|
|
830
|
+
dispatchZoomChange: y
|
|
831
|
+
} = Ot(a, H(e, "minScale"), H(e, "maxScale"), e.onTransform), {
|
|
832
|
+
isMoving: S,
|
|
833
|
+
onMouseDown: L,
|
|
834
|
+
onWheel: T
|
|
835
|
+
} = Et(a, H(e, "movable"), d, H(e, "scaleStep"), l, h, y), {
|
|
836
|
+
isTouching: M,
|
|
837
|
+
onTouchStart: I,
|
|
838
|
+
onTouchMove: k,
|
|
839
|
+
onTouchEnd: W
|
|
840
|
+
} = Rt(a, H(e, "movable"), d, H(e, "minScale"), l, h, y);
|
|
841
|
+
xe(() => {
|
|
842
|
+
C.value || x(!0);
|
|
843
|
+
}, [C]);
|
|
844
|
+
const R = $(null), z = $(e.current), N = it(/* @__PURE__ */ new Map()), Y = b(() => new Map(Array.from(N).map(([u, {
|
|
845
|
+
url: O
|
|
846
|
+
}]) => [u, O]))), _ = b(() => Y.value.get(z.value)), j = b(() => Y.value.size), B = b(() => Array.from(Y.value.keys())), A = b(() => B.value.indexOf(z.value)), f = b(() => j.value > 1), P = b(() => j.value >= 1);
|
|
847
|
+
J(d, (u) => {
|
|
848
|
+
u && (g.value = !0);
|
|
849
|
+
});
|
|
850
|
+
const E = (u) => {
|
|
851
|
+
z.value = u;
|
|
852
|
+
};
|
|
853
|
+
J(() => e.current, (u) => {
|
|
854
|
+
Pe(u) && E(u);
|
|
855
|
+
});
|
|
856
|
+
function fe(u, O) {
|
|
857
|
+
N.set(u, {
|
|
858
|
+
url: O,
|
|
859
|
+
loading: !0,
|
|
860
|
+
canPreview: !1
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
const K = () => {
|
|
864
|
+
m(!1);
|
|
865
|
+
}, oe = () => {
|
|
866
|
+
w("close"), t("close");
|
|
867
|
+
}, _e = (u) => {
|
|
868
|
+
S.value || R.value === u?.target && K();
|
|
869
|
+
}, Ue = () => {
|
|
870
|
+
const u = N.get(z.value);
|
|
871
|
+
u && (u.loading = !1, u.canPreview = !0);
|
|
872
|
+
}, Ge = (u) => {
|
|
873
|
+
const O = N.get(z.value);
|
|
874
|
+
O && (O.loading = !1, O.canPreview = !1), u.target.alt = "加载失败";
|
|
875
|
+
}, be = () => {
|
|
876
|
+
if (A.value > 0 || e.infinite) {
|
|
877
|
+
const u = A.value - 1 < 0 ? e.urls.length - 1 : A.value - 1;
|
|
878
|
+
E(B.value[u]), w("prev");
|
|
879
|
+
}
|
|
880
|
+
}, Le = () => {
|
|
881
|
+
if (A.value < j.value - 1 || e.infinite) {
|
|
882
|
+
const u = A.value + 1 > e.urls.length - 1 ? 0 : A.value + 1;
|
|
883
|
+
E(B.value[u]), w("next");
|
|
884
|
+
}
|
|
885
|
+
}, Ve = () => {
|
|
886
|
+
y(q + e.scaleStep, "zoomIn");
|
|
887
|
+
}, qe = () => {
|
|
888
|
+
y(q / (q + e.scaleStep), "zoomOut");
|
|
889
|
+
}, Ke = () => {
|
|
890
|
+
h({
|
|
891
|
+
rotate: l.value.rotate + 90
|
|
892
|
+
}, "rotateRight");
|
|
893
|
+
}, Qe = () => {
|
|
894
|
+
h({
|
|
895
|
+
rotate: l.value.rotate - 90
|
|
896
|
+
}, "rotateLeft");
|
|
897
|
+
}, Je = () => {
|
|
898
|
+
h({
|
|
899
|
+
flipX: !l.value.flipX
|
|
900
|
+
}, "flipX");
|
|
901
|
+
}, et = () => {
|
|
902
|
+
h({
|
|
903
|
+
flipY: !l.value.flipY
|
|
904
|
+
}, "flipY");
|
|
905
|
+
}, $e = [{
|
|
906
|
+
icon: Z(i, e.icons, "flipY") || U.flipY,
|
|
907
|
+
onClick: et,
|
|
908
|
+
type: "flipY"
|
|
909
|
+
}, {
|
|
910
|
+
icon: Z(i, e.icons, "flipX") || U.flipX,
|
|
911
|
+
onClick: Je,
|
|
912
|
+
type: "flipX"
|
|
913
|
+
}, {
|
|
914
|
+
icon: Z(i, e.icons, "rotateLeft") || U.rotateLeft,
|
|
915
|
+
onClick: Qe,
|
|
916
|
+
type: "rotateLeft"
|
|
917
|
+
}, {
|
|
918
|
+
icon: Z(i, e.icons, "rotateRight") || U.rotateRight,
|
|
919
|
+
onClick: Ke,
|
|
920
|
+
type: "rotateRight"
|
|
921
|
+
}, {
|
|
922
|
+
icon: Z(i, e.icons, "zoomOut") || U.zoomOut,
|
|
923
|
+
onClick: () => qe(),
|
|
924
|
+
type: "zoomOut",
|
|
925
|
+
disabled: b(() => l.value.scale <= e.minScale)
|
|
926
|
+
}, {
|
|
927
|
+
icon: Z(i, e.icons, "zoomIn") || U.zoomIn,
|
|
928
|
+
onClick: () => Ve(),
|
|
929
|
+
type: "zoomIn",
|
|
930
|
+
disabled: b(() => l.value.scale === e.maxScale)
|
|
931
|
+
}], tt = (u) => {
|
|
932
|
+
d.value && (l.value.scale !== 1 ? h({
|
|
933
|
+
x: 0,
|
|
934
|
+
y: 0,
|
|
935
|
+
scale: 1
|
|
936
|
+
}, "doubleClick") : y(q + e.scaleStep, "doubleClick", u.clientX, u.clientY));
|
|
937
|
+
}, nt = (u) => {
|
|
938
|
+
u.keyCode === me.ESC && K(), !(!d.value || !f.value) && (u.keyCode === me.LEFT ? be() : u.keyCode === me.RIGHT && Le());
|
|
939
|
+
};
|
|
940
|
+
let ve = () => {
|
|
941
|
+
};
|
|
942
|
+
return Re(() => {
|
|
943
|
+
J(() => e.urls, (u) => {
|
|
944
|
+
St(u) && u.forEach((O, ie) => {
|
|
945
|
+
fe(ie, O);
|
|
946
|
+
});
|
|
947
|
+
}, {
|
|
948
|
+
flush: "post",
|
|
949
|
+
immediate: !0
|
|
950
|
+
}), J([() => d.value, () => S.value], () => {
|
|
951
|
+
ve();
|
|
952
|
+
const u = V(window, "keydown", nt, !1);
|
|
953
|
+
ve = () => {
|
|
954
|
+
u.remove();
|
|
955
|
+
};
|
|
956
|
+
}, {
|
|
957
|
+
flush: "post",
|
|
958
|
+
immediate: !0
|
|
959
|
+
});
|
|
960
|
+
}), at(() => {
|
|
961
|
+
ve();
|
|
962
|
+
}), o({
|
|
963
|
+
setOpen: (u) => {
|
|
964
|
+
v(u), z.value = e.current;
|
|
965
|
+
}
|
|
966
|
+
}), () => {
|
|
967
|
+
const u = Se(`${n}-mask-zoom`), O = Se(`${n}-zoom`), ie = {};
|
|
968
|
+
for (const D in e.icons)
|
|
969
|
+
ie[D] = Z(i, e.icons, D);
|
|
970
|
+
return r(s(ue, null, [s(De, {
|
|
971
|
+
to: e.getContainer || "body"
|
|
972
|
+
}, {
|
|
973
|
+
default: () => [d.value && s(ue, null, [s("div", {
|
|
974
|
+
class: `${n}-root ${c.value}`
|
|
975
|
+
}, [s(pe, u, {
|
|
976
|
+
default: () => [we(s("div", {
|
|
977
|
+
class: `${n}-mask ${c.value}`
|
|
978
|
+
}, null), [[ye, d.value && g.value]])]
|
|
979
|
+
}), s("div", {
|
|
980
|
+
ref: R,
|
|
981
|
+
tabindex: -1,
|
|
982
|
+
class: [`${n}-wrap`, `${c.value}`, S.value && `${n}-moving`],
|
|
983
|
+
onClick: (D) => e.onHideOnClickModal && _e(D)
|
|
984
|
+
}, [s(pe, le(O, {
|
|
985
|
+
onAfterLeave: () => oe()
|
|
986
|
+
}), {
|
|
987
|
+
default: () => [we(s("div", {
|
|
988
|
+
role: "dialog",
|
|
989
|
+
class: `${n} ${c.value}`
|
|
990
|
+
}, [s("div", {
|
|
991
|
+
class: `${n}-content ${c.value}`
|
|
992
|
+
}, [s("div", {
|
|
993
|
+
class: `${n}-body ${c.value}`
|
|
994
|
+
}, [s("div", {
|
|
995
|
+
class: `${n}-img-wrapper ${c.value}`
|
|
996
|
+
}, [s("img", {
|
|
997
|
+
ref: a,
|
|
998
|
+
class: `${n}-img ${c.value}`,
|
|
999
|
+
src: _.value,
|
|
1000
|
+
onLoad: () => Ue(),
|
|
1001
|
+
onError: (D) => Ge(D),
|
|
1002
|
+
style: {
|
|
1003
|
+
transform: `translate3d(${l.value.x}px, ${l.value.y}px, 0) scale3d(${l.value.flipX ? "-" : ""}${l.value.scale}, ${l.value.flipY ? "-" : ""}${l.value.scale}, 1) rotate(${l.value.rotate}deg)`,
|
|
1004
|
+
transitionDuration: !C.value || M.value ? "0s" : void 0
|
|
1005
|
+
},
|
|
1006
|
+
onWheel: T,
|
|
1007
|
+
onMousedown: L,
|
|
1008
|
+
onDblclick: tt,
|
|
1009
|
+
onTouchstart: I,
|
|
1010
|
+
onTouchmove: k,
|
|
1011
|
+
onTouchend: W,
|
|
1012
|
+
onTouchcancel: W
|
|
1013
|
+
}, null)])])])]), [[ye, d.value && g.value]])]
|
|
1014
|
+
})])])])]
|
|
1015
|
+
}), d.value && g.value && s(Nt, {
|
|
1016
|
+
open: d.value && g.value,
|
|
1017
|
+
hashId: c.value,
|
|
1018
|
+
count: e.urls.length,
|
|
1019
|
+
current: z.value,
|
|
1020
|
+
zIndex: e.zIndex + 1,
|
|
1021
|
+
getContainer: e.getContainer,
|
|
1022
|
+
prefixCls: n,
|
|
1023
|
+
icons: Ye(ie, $e.map(({
|
|
1024
|
+
type: D
|
|
1025
|
+
}) => D)),
|
|
1026
|
+
tools: $e,
|
|
1027
|
+
infinite: e.infinite,
|
|
1028
|
+
countRender: re(i, e, "countRender"),
|
|
1029
|
+
showSwitch: f.value,
|
|
1030
|
+
showProgress: P.value,
|
|
1031
|
+
onClose: K,
|
|
1032
|
+
onActive: (D) => D > 0 ? Le() : be()
|
|
1033
|
+
}, null)]));
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
}), he = {
|
|
1037
|
+
width: "100%",
|
|
1038
|
+
height: "100%"
|
|
1039
|
+
}, Wt = {
|
|
1040
|
+
overflow: "hidden",
|
|
1041
|
+
whiteSpace: "nowrap",
|
|
1042
|
+
textOverflow: "ellipsis"
|
|
1043
|
+
}, _t = (e) => {
|
|
1044
|
+
const { motionDurationSlow: t, paddingXXS: o, marginXXS: i, colorTextLightSolid: n } = e, r = ".anticon";
|
|
1045
|
+
return {
|
|
1046
|
+
position: "absolute",
|
|
1047
|
+
inset: 0,
|
|
1048
|
+
display: "flex",
|
|
1049
|
+
alignItems: "center",
|
|
1050
|
+
justifyContent: "center",
|
|
1051
|
+
color: n,
|
|
1052
|
+
background: new wt("#000").setA(0.5).toRgbString(),
|
|
1053
|
+
cursor: "pointer",
|
|
1054
|
+
opacity: 0,
|
|
1055
|
+
transition: `opacity ${t}`,
|
|
1056
|
+
[`.${e.componentCls}-mask-info`]: {
|
|
1057
|
+
...Wt,
|
|
1058
|
+
padding: `0 ${ee(o)}`,
|
|
1059
|
+
[r]: {
|
|
1060
|
+
marginInlineEnd: i,
|
|
1061
|
+
svg: {
|
|
1062
|
+
verticalAlign: "baseline"
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
}, Ut = (e) => ({
|
|
1068
|
+
position: e || "absolute",
|
|
1069
|
+
inset: 0
|
|
1070
|
+
}), Gt = (e) => ({
|
|
1071
|
+
[e.componentCls]: {
|
|
1072
|
+
display: "inline-block",
|
|
1073
|
+
position: "relative",
|
|
1074
|
+
overflow: "hidden",
|
|
1075
|
+
[`${e.componentCls}-img`]: {
|
|
1076
|
+
...he,
|
|
1077
|
+
verticalAlign: "top",
|
|
1078
|
+
opacity: 1,
|
|
1079
|
+
[`&${e.componentCls}-img-preview`]: {
|
|
1080
|
+
userSelect: "none",
|
|
1081
|
+
cursor: "pointer"
|
|
1082
|
+
},
|
|
1083
|
+
"&-placeholder": {
|
|
1084
|
+
...he,
|
|
1085
|
+
backgroundColor: e.colorBgContainerDisabled,
|
|
1086
|
+
backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
|
|
1087
|
+
backgroundRepeat: "no-repeat",
|
|
1088
|
+
backgroundPosition: "center center",
|
|
1089
|
+
backgroundSize: "30%"
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
[`${e.componentCls}-error`]: {
|
|
1093
|
+
...he,
|
|
1094
|
+
display: "flex",
|
|
1095
|
+
alignItems: "center",
|
|
1096
|
+
justifyContent: "center"
|
|
1097
|
+
},
|
|
1098
|
+
[`${e.componentCls}-placeholder`]: {
|
|
1099
|
+
...Ut()
|
|
1100
|
+
},
|
|
1101
|
+
[`${e.componentCls}-mask`]: {
|
|
1102
|
+
..._t(e)
|
|
1103
|
+
},
|
|
1104
|
+
[`${e.componentCls}-mask:hover`]: {
|
|
1105
|
+
opacity: 1
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}), Vt = (e) => typeof Element > "u" ? !1 : e instanceof Element;
|
|
1109
|
+
let Ee = "";
|
|
1110
|
+
const se = /* @__PURE__ */ Ce({
|
|
1111
|
+
props: je,
|
|
1112
|
+
name: "GImage",
|
|
1113
|
+
inheritAttrs: !1,
|
|
1114
|
+
emits: {
|
|
1115
|
+
click: () => !0,
|
|
1116
|
+
load: (e) => !0,
|
|
1117
|
+
error: (e) => !0
|
|
1118
|
+
},
|
|
1119
|
+
slots: Object,
|
|
1120
|
+
setup(e, {
|
|
1121
|
+
slots: t,
|
|
1122
|
+
emit: o,
|
|
1123
|
+
attrs: i
|
|
1124
|
+
}) {
|
|
1125
|
+
const n = Q && "loading" in HTMLImageElement.prototype, r = Ne({
|
|
1126
|
+
suffixCls: "image"
|
|
1127
|
+
}), {
|
|
1128
|
+
wrapSSR: c,
|
|
1129
|
+
hashId: p
|
|
1130
|
+
} = yt("Image", [Gt], r), v = $(), d = $(), g = $(!1), m = $(!0), C = $(!1), x = $(), a = $();
|
|
1131
|
+
let l, w;
|
|
1132
|
+
const h = b(() => e.loading === "eager" ? !1 : !n && e.loading === "lazy" || e.lazy), y = b(() => Q && e.fit ? {
|
|
1133
|
+
...e.imageStyle,
|
|
1134
|
+
objectFit: e.fit
|
|
1135
|
+
} : e.imageStyle), S = b(() => typeof e.preview == "object" ? e.preview : {}), L = b(() => !!e.preview), T = b(() => {
|
|
1136
|
+
const {
|
|
1137
|
+
urls: f = [],
|
|
1138
|
+
current: P = 0
|
|
1139
|
+
} = S.value;
|
|
1140
|
+
if (Pe(P)) return f.length >= P ? P : 0;
|
|
1141
|
+
const E = f.indexOf(e.src);
|
|
1142
|
+
return E >= 0 ? E : 0;
|
|
1143
|
+
}), M = b(() => ee(e.width)), I = b(() => ee(e.height)), k = () => {
|
|
1144
|
+
Q && (m.value = !0, g.value = !1, d.value = e.src);
|
|
1145
|
+
};
|
|
1146
|
+
function W(f) {
|
|
1147
|
+
g.value || (m.value = !1, g.value = !1, o("load", f));
|
|
1148
|
+
}
|
|
1149
|
+
function R(f) {
|
|
1150
|
+
m.value = !1, g.value = !0, o("error", f);
|
|
1151
|
+
}
|
|
1152
|
+
function z() {
|
|
1153
|
+
Ct(x.value, a.value) && (k(), _());
|
|
1154
|
+
}
|
|
1155
|
+
const N = bt(z, 200, !0);
|
|
1156
|
+
async function Y() {
|
|
1157
|
+
if (!Q) return;
|
|
1158
|
+
await rt();
|
|
1159
|
+
const {
|
|
1160
|
+
scrollContainer: f
|
|
1161
|
+
} = e;
|
|
1162
|
+
Vt(f) ? a.value = f : xt(f) && f !== "" ? a.value = document.querySelector(f) ?? void 0 : x.value && (a.value = It(x.value)), a.value && (l = ze(a, "scroll", N), setTimeout(() => z(), 100));
|
|
1163
|
+
}
|
|
1164
|
+
function _() {
|
|
1165
|
+
!Q || !a.value || !N || (l?.(), a.value = void 0);
|
|
1166
|
+
}
|
|
1167
|
+
function j(f) {
|
|
1168
|
+
if (f.ctrlKey) {
|
|
1169
|
+
if (f.deltaY < 0)
|
|
1170
|
+
return f.preventDefault(), !1;
|
|
1171
|
+
if (f.deltaY > 0)
|
|
1172
|
+
return f.preventDefault(), !1;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
const B = () => {
|
|
1176
|
+
o("click"), !(m.value || g.value) && L.value && (w = ze("wheel", j, {
|
|
1177
|
+
passive: !1
|
|
1178
|
+
}), Ee = document.body.style.overflow, document.body.style.overflow = "hidden", C.value = !0);
|
|
1179
|
+
}, A = () => {
|
|
1180
|
+
w?.(), document.body.style.overflow = Ee, C.value = !1;
|
|
1181
|
+
};
|
|
1182
|
+
return J(() => e.src, () => {
|
|
1183
|
+
h.value ? (m.value = !0, g.value = !1, _(), Y()) : k();
|
|
1184
|
+
}), lt(() => {
|
|
1185
|
+
L.value && C.value ? v.value?.setOpen(!0) : v.value?.setOpen(!1);
|
|
1186
|
+
}), Re(() => {
|
|
1187
|
+
h.value ? Y() : k();
|
|
1188
|
+
}), () => {
|
|
1189
|
+
const f = Mt(Object.entries(i).filter(([oe]) => /^(?:data-|on[A-Z])/i.test(oe) || ["id", "style", "class"].includes(oe))), P = Ye(i, Object.keys(f)), E = re(t, e, "fallback", {
|
|
1190
|
+
render: !0
|
|
1191
|
+
}), fe = re(t, e, "mask", {
|
|
1192
|
+
render: !0
|
|
1193
|
+
}), K = re(t, e, "placeholder", {
|
|
1194
|
+
render: !0
|
|
1195
|
+
});
|
|
1196
|
+
return c(s("div", le({
|
|
1197
|
+
class: {
|
|
1198
|
+
[`${p.value}`]: !0,
|
|
1199
|
+
[`${r}`]: !0
|
|
1200
|
+
},
|
|
1201
|
+
ref: x
|
|
1202
|
+
}, f, {
|
|
1203
|
+
style: {
|
|
1204
|
+
width: ee(e.size) || M.value,
|
|
1205
|
+
height: ee(e.size) || I.value,
|
|
1206
|
+
...f.style || {}
|
|
1207
|
+
}
|
|
1208
|
+
}), [g.value ? s("div", {
|
|
1209
|
+
class: X(p.value, `${r}-error`)
|
|
1210
|
+
}, [E]) : s(ue, null, [s("img", le(P, {
|
|
1211
|
+
src: d.value,
|
|
1212
|
+
loading: e.loading,
|
|
1213
|
+
style: y.value,
|
|
1214
|
+
class: X(p.value, e.imageClass, `${r}-img`, {
|
|
1215
|
+
[`${r}-img-placeholder`]: e.placeholder === !0,
|
|
1216
|
+
[`${r}-img-preview`]: L.value
|
|
1217
|
+
}),
|
|
1218
|
+
crossorigin: e.crossOrigin,
|
|
1219
|
+
width: M.value,
|
|
1220
|
+
height: I.value,
|
|
1221
|
+
onClick: B,
|
|
1222
|
+
onLoad: W,
|
|
1223
|
+
onError: R
|
|
1224
|
+
}), null), m.value && s("div", {
|
|
1225
|
+
class: X(`${r}-placeholder`, p.value)
|
|
1226
|
+
}, [K])]), S.value.mask && L.value && s("div", {
|
|
1227
|
+
class: X(`${r}-mask`, S.value.maskClass, p.value),
|
|
1228
|
+
style: {
|
|
1229
|
+
display: f.style?.display === "none" ? "none" : void 0
|
|
1230
|
+
}
|
|
1231
|
+
}, [fe || s("div", {
|
|
1232
|
+
class: X(`${r}-mask-info`, p.value)
|
|
1233
|
+
}, [s(mt, null, null)])]), L.value && s(Zt, le({
|
|
1234
|
+
ref: v
|
|
1235
|
+
}, S.value, {
|
|
1236
|
+
urls: S.value.urls || [e.src],
|
|
1237
|
+
current: T.value,
|
|
1238
|
+
onClose: () => A()
|
|
1239
|
+
}), t)]));
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
se.isGImage = !0;
|
|
1244
|
+
se.install = (e) => (e.component(se.name, se), e);
|
|
1245
|
+
export {
|
|
1246
|
+
se as GImage,
|
|
1247
|
+
Zt as GImagePreview,
|
|
1248
|
+
te as baseProps,
|
|
1249
|
+
je as imageProps
|
|
1250
|
+
};
|