@gx-design-vue/image 0.2.0-beta.26 → 0.2.0-beta.28

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.js CHANGED
@@ -1,54 +1,268 @@
1
- import { ref as N, reactive as ae, onMounted as De, defineComponent as ye, createVNode as r, Teleport as ze, Transition as ge, withDirectives as we, Fragment as Se, cloneVNode as Je, vShow as he, shallowRef as Z, computed as y, watch as H, onUnmounted as et, mergeProps as pe, watchEffect as tt, createTextVNode as nt, nextTick as ot } from "vue";
2
- import { useState as xe, onMountedOrActivated as it } from "@gx-design-vue/pro-hooks";
3
- import { getTransitionProps as Ie, Keyframe as re, useStyle as at, mergeToken as lt, unit as rt, useProStyle as st } from "@gx-design-vue/pro-provider";
4
- import { classNames as oe, getPrefixCls as Ue, isNumber as Ee, getSlotVNode as $, isArray as _e, getSlot as ct, isServer as ie, isInContainer as ut, getSlotsProps as dt, isString as ft, getScrollContainer as vt } from "@gx-design-vue/pro-utils";
5
- import { useThrottleFn as mt, useEventListener as Le } from "@vueuse/core";
6
- import { omit as gt, pick as wt } from "lodash-es";
7
- import { CloseOutlined as St, LeftOutlined as ht, RightOutlined as pt, RotateLeftOutlined as It, RotateRightOutlined as Et, ZoomInOutlined as Ct, ZoomOutOutlined as yt, SwapOutlined as be } from "@ant-design/icons-vue";
8
- import { TinyColor as Y } from "@ctrl/tinycolor";
9
- function Nt(e, t) {
10
- process.env.NODE_ENV !== "production" && !e && console !== void 0 && console.error(`Warning: ${t}`);
1
+ import { ref as L, defineComponent as Se, createVNode as u, Teleport as Te, Transition as he, withDirectives as we, Fragment as se, cloneVNode as it, vShow as pe, toRef as k, reactive as at, computed as b, watch as J, onMounted as De, onUnmounted as lt, mergeProps as le, watchEffect as rt, nextTick as st } from "vue";
2
+ import { CloseOutlined as ut, LeftOutlined as ct, RightOutlined as dt, SwapOutlined as ze, ZoomOutOutlined as ft, ZoomInOutlined as vt, RotateRightOutlined as gt, RotateLeftOutlined as mt, EyeOutlined as ht } from "@ant-design/icons-vue";
3
+ import { getTransitionProps as ye, Keyframe as ce, useStyle as wt, mergeToken as pt, unit as ee, FastColor as yt, useProStyle as St } from "@gx-design-vue/pro-provider";
4
+ import { classNames as X, getPrefixCls as Re, isNumber as Ne, getSlotVNode as H, isArray as Ct, getSlot as Pe, getSlotsProps as xt, isInContainer as It, isString as bt, getScrollContainer as $t } from "@gx-design-vue/pro-utils";
5
+ import { useWindowSize as Xe, isClient as Q, useThrottleFn as zt, useEventListener as Le } from "@vueuse/core";
6
+ import { isEqual as Lt, cloneDeep as Ot, omit as Ye, fromPairs as Mt, pick as At } from "lodash-es";
7
+ import { useState as ne, useEffect as Ce, useMergedState as Et } from "@gx-design-vue/pro-hooks";
8
+ import { TinyColor as Z } from "@ctrl/tinycolor";
9
+ let je = (e) => setTimeout(e, 16), Be = (e) => clearTimeout(e);
10
+ typeof window < "u" && "requestAnimationFrame" in window && (je = (e) => window.requestAnimationFrame(e), Be = (e) => window.cancelAnimationFrame(e));
11
+ let Oe = 0;
12
+ const xe = /* @__PURE__ */ new Map();
13
+ function Fe(e) {
14
+ xe.delete(e);
11
15
  }
12
- let Fe = (e) => setTimeout(e, 16), Be = (e) => clearTimeout(e);
13
- typeof window < "u" && "requestAnimationFrame" in window && (Fe = (e) => window.requestAnimationFrame(e), Be = (e) => window.cancelAnimationFrame(e));
14
- let Te = 0;
15
- const Ne = /* @__PURE__ */ new Map();
16
- function He(e) {
17
- Ne.delete(e);
18
- }
19
- function Ce(e, t = 1) {
20
- Te += 1;
21
- const i = Te;
22
- function l(o) {
23
- if (o === 0)
24
- He(i), e();
16
+ function ke(e, n = 1) {
17
+ Oe += 1;
18
+ const o = Oe;
19
+ function l(t) {
20
+ if (t === 0)
21
+ Fe(o), e();
25
22
  else {
26
- const f = Fe(() => {
27
- l(o - 1);
23
+ const r = je(() => {
24
+ l(t - 1);
28
25
  });
29
- Ne.set(i, f);
26
+ xe.set(o, r);
30
27
  }
31
28
  }
32
- return l(t), i;
29
+ return l(n), o;
33
30
  }
34
- Ce.cancel = (e) => {
35
- const t = Ne.get(e);
36
- return He(t), Be(t);
31
+ ke.cancel = (e) => {
32
+ const n = xe.get(e);
33
+ return Fe(n), Be(n);
34
+ };
35
+ const ae = {
36
+ x: 0,
37
+ y: 0,
38
+ rotate: 0,
39
+ scale: 1,
40
+ flipX: !1,
41
+ flipY: !1
37
42
  };
38
- function Mt(e) {
39
- const t = N(null), i = ae({ ...e }), l = N([]), o = (f) => {
40
- t.value === null && (l.value = [], t.value = Ce(() => {
41
- let c;
42
- l.value.forEach((d) => {
43
- c = { ...c, ...d };
44
- }), Object.assign(i, c), t.value = null;
45
- })), l.value.push(f);
43
+ function Tt(e, n, o, l) {
44
+ const t = L(null), r = L([]), [c, h] = ne(ae), y = (m) => {
45
+ h(ae), Lt(ae, c.value) || l == null || l({ transform: ae, action: m });
46
+ }, d = (m, w) => {
47
+ t.value === null && (r.value = [], t.value = ke(() => {
48
+ let x = Ot(c.value);
49
+ r.value.forEach((a) => {
50
+ x = { ...x, ...a };
51
+ }), t.value = null, l == null || l({ transform: x, action: w }), h(x);
52
+ })), r.value.push({
53
+ ...c.value,
54
+ ...m
55
+ });
56
+ };
57
+ return {
58
+ transform: c,
59
+ resetTransform: y,
60
+ updateTransform: d,
61
+ dispatchZoomChange: (m, w, x, a, i) => {
62
+ const { width: p, height: g, offsetWidth: S, offsetHeight: C, offsetLeft: $, offsetTop: T } = e.value;
63
+ let O = m, I = c.value.scale * m;
64
+ I > o.value ? (I = o.value, O = o.value / c.value.scale) : I < n.value && (I = i ? I : n.value, O = I / c.value.scale);
65
+ const F = x ?? innerWidth / 2, W = a ?? innerHeight / 2, N = O - 1, M = N * p * 0.5, P = N * g * 0.5, Y = N * (F - c.value.x - $), _ = N * (W - c.value.y - T);
66
+ let j = c.value.x - (Y - M), B = c.value.y - (_ - P);
67
+ if (m < 1 && I === 1) {
68
+ const D = S * I, f = C * I, { width: A, height: E } = Xe();
69
+ D <= A.value && f <= E.value && (j = 0, B = 0);
70
+ }
71
+ d({
72
+ x: j,
73
+ y: B,
74
+ scale: I
75
+ }, w);
76
+ }
77
+ };
78
+ }
79
+ function Dt(e, n) {
80
+ process.env.NODE_ENV !== "production" && console !== void 0 && console.error(`Warning: ${n}`);
81
+ }
82
+ let He = !1;
83
+ try {
84
+ const e = Object.defineProperty({}, "passive", {
85
+ get() {
86
+ He = !0;
87
+ }
88
+ });
89
+ window.addEventListener("testPassive", null, e), window.removeEventListener("testPassive", null, e);
90
+ } catch {
91
+ }
92
+ function q(e, n, o, l) {
93
+ if (e && e.addEventListener) {
94
+ let t = l;
95
+ t === void 0 && He && (n === "touchstart" || n === "touchmove" || n === "wheel") && (t = { passive: !1 }), e.addEventListener(n, o, t);
96
+ }
97
+ return {
98
+ remove: () => {
99
+ e && e.removeEventListener && e.removeEventListener(n, o);
100
+ }
101
+ };
102
+ }
103
+ const K = 1, Rt = 1;
104
+ function Me(e, n, o, l) {
105
+ const t = n + o, r = (o - l) / 2;
106
+ if (o > l) {
107
+ if (n > 0)
108
+ return {
109
+ [e]: r
110
+ };
111
+ if (n < 0 && t < l)
112
+ return {
113
+ [e]: -r
114
+ };
115
+ } else if (n < 0 || t > l)
116
+ return {
117
+ [e]: n < 0 ? r : -r
118
+ };
119
+ return {};
120
+ }
121
+ function Ze(e, n, o, l) {
122
+ const { width: t, height: r } = Xe();
123
+ let c = null;
124
+ return e <= t.value && n <= r.value ? c = {
125
+ x: 0,
126
+ y: 0
127
+ } : (e > t.value || n > r.value) && (c = {
128
+ ...Me("x", o, e, t.value),
129
+ ...Me("y", l, n, r.value)
130
+ }), c;
131
+ }
132
+ function Nt(e, n, o, l, t, r, c) {
133
+ const [h, y] = ne(!1), d = L({
134
+ diffX: 0,
135
+ diffY: 0,
136
+ transformX: 0,
137
+ transformY: 0
138
+ }), v = (a) => {
139
+ !n || a.button !== 0 || (a.preventDefault(), a.stopPropagation(), d.value = {
140
+ diffX: a.pageX - t.value.x,
141
+ diffY: a.pageY - t.value.y,
142
+ transformX: t.value.x,
143
+ transformY: t.value.y
144
+ }, y(!0));
145
+ }, m = (a) => {
146
+ o && h.value && r({
147
+ x: a.pageX - d.value.diffX,
148
+ y: a.pageY - d.value.diffY
149
+ }, "move");
150
+ }, w = () => {
151
+ if (o && h.value) {
152
+ y(!1);
153
+ const { transformX: a, transformY: i } = d.value;
154
+ if (!(t.value.x !== a && t.value.y !== i))
155
+ return;
156
+ const g = e.value.offsetWidth * t.value.scale, S = e.value.offsetHeight * t.value.scale, { left: C, top: $ } = e.value.getBoundingClientRect(), T = t.value.rotate % 180 !== 0, O = Ze(T ? S : g, T ? g : S, C, $);
157
+ O && r({ ...O }, "dragRebound");
158
+ }
159
+ }, x = (a) => {
160
+ if (!o || a.deltaY === 0)
161
+ return;
162
+ const i = Math.abs(a.deltaY / 100), p = Math.min(i, Rt);
163
+ let g = K + p * l.value;
164
+ a.deltaY > 0 && (g = K / g), c(g, "wheel", a.clientX, a.clientY);
165
+ };
166
+ return Ce(() => {
167
+ let a, i, p, g;
168
+ if (n) {
169
+ p = q(window, "mouseup", w, !1), g = q(window, "mousemove", m, !1);
170
+ try {
171
+ window.top !== window.self && (a = q(window.top, "mouseup", w, !1), i = q(window.top, "mousemove", m, !1));
172
+ } catch (S) {
173
+ Dt(!1, `[rc-image] ${S}`);
174
+ }
175
+ }
176
+ return () => {
177
+ p == null || p.remove(), g == null || g.remove(), a == null || a.remove(), i == null || i.remove();
178
+ };
179
+ }, [o, h, () => t.value.x, () => t.value.y, () => t.value.rotate, n]), {
180
+ isMoving: h,
181
+ onMouseDown: v,
182
+ onMouseMove: m,
183
+ onMouseUp: w,
184
+ onWheel: x
185
+ };
186
+ }
187
+ function ue(e, n) {
188
+ const o = e.x - n.x, l = e.y - n.y;
189
+ return Math.hypot(o, l);
190
+ }
191
+ function Pt(e, n, o, l) {
192
+ const t = ue(e, o), r = ue(n, l);
193
+ if (t === 0 && r === 0)
194
+ return [e.x, e.y];
195
+ const c = t / (t + r), h = e.x + c * (n.x - e.x), y = e.y + c * (n.y - e.y);
196
+ return [h, y];
197
+ }
198
+ function Xt(e, n, o, l, t, r, c) {
199
+ const [h, y] = ne(!1), d = L({
200
+ point1: { x: 0, y: 0 },
201
+ point2: { x: 0, y: 0 },
202
+ eventType: "none"
203
+ }), v = (a) => {
204
+ d.value = {
205
+ ...d.value,
206
+ ...a
207
+ };
208
+ }, m = (a) => {
209
+ if (!n.value)
210
+ return;
211
+ a.stopPropagation(), y(!0);
212
+ const { touches: i = [] } = a;
213
+ i.length > 1 ? v({
214
+ point1: { x: i[0].clientX, y: i[0].clientY },
215
+ point2: { x: i[1].clientX, y: i[1].clientY },
216
+ eventType: "touchZoom"
217
+ }) : v({
218
+ point1: {
219
+ x: i[0].clientX - t.value.x,
220
+ y: i[0].clientY - t.value.y
221
+ },
222
+ eventType: "move"
223
+ });
224
+ }, w = (a) => {
225
+ const { touches: i = [] } = a, { point1: p, point2: g, eventType: S } = d.value;
226
+ if (i.length > 1 && S === "touchZoom") {
227
+ const C = {
228
+ x: i[0].clientX,
229
+ y: i[0].clientY
230
+ }, $ = {
231
+ x: i[1].clientX,
232
+ y: i[1].clientY
233
+ }, [T, O] = Pt(p, g, C, $), I = ue(C, $) / ue(p, g);
234
+ c(I, "touchZoom", T, O, !0), v({
235
+ point1: C,
236
+ point2: $,
237
+ eventType: "touchZoom"
238
+ });
239
+ } else S === "move" && (r({
240
+ x: i[0].clientX - p.x,
241
+ y: i[0].clientY - p.y
242
+ }, "move"), v({ eventType: "move" }));
243
+ }, x = () => {
244
+ if (!o.value)
245
+ return;
246
+ if (h && y(!1), v({ eventType: "none" }), l.value > t.value.scale)
247
+ return r({ x: 0, y: 0, scale: l.value }, "touchZoom");
248
+ const a = e.value.offsetWidth * t.value.scale, i = e.value.offsetHeight * t.value.scale, { left: p, top: g } = e.value.getBoundingClientRect(), S = t.value.rotate % 180 !== 0, C = Ze(S ? i : a, S ? a : i, p, g);
249
+ C && r({ ...C }, "dragRebound");
250
+ };
251
+ return Ce(() => {
252
+ let a;
253
+ return o.value && n.value && (a = q(window, "touchmove", (i) => i.preventDefault(), {
254
+ passive: !1
255
+ })), () => {
256
+ a == null || a.remove();
257
+ };
258
+ }, [o, n]), {
259
+ isTouching: h,
260
+ onTouchStart: m,
261
+ onTouchMove: w,
262
+ onTouchEnd: x
46
263
  };
47
- return De(() => {
48
- t.value && Ce.cancel(t.value);
49
- }), [i, o];
50
264
  }
51
- const V = {
265
+ const te = {
52
266
  infinite: {
53
267
  type: Boolean,
54
268
  default: !0
@@ -64,17 +278,9 @@ const V = {
64
278
  getContainer: {
65
279
  type: String
66
280
  }
67
- }, je = {
281
+ }, We = {
68
282
  preview: {
69
- type: Object,
70
- default: () => ({
71
- current: 0,
72
- infinite: !0,
73
- onHideOnClickModal: !0
74
- })
75
- },
76
- showPreview: {
77
- type: Boolean,
283
+ type: [Object, Boolean],
78
284
  default: !0
79
285
  },
80
286
  src: {
@@ -85,16 +291,22 @@ const V = {
85
291
  type: String,
86
292
  default: ""
87
293
  },
294
+ loading: {
295
+ type: String
296
+ },
88
297
  fit: {
89
298
  type: String,
90
299
  default: "contain"
91
300
  },
301
+ crossOrigin: {
302
+ type: String
303
+ },
92
304
  lazy: Boolean,
93
305
  scrollContainer: {
94
306
  type: [String, Object]
95
307
  },
96
308
  placeholder: {
97
- type: [Function, Object],
309
+ type: [Function, Object, Boolean],
98
310
  default: () => {
99
311
  }
100
312
  },
@@ -112,22 +324,46 @@ const V = {
112
324
  onClick: {
113
325
  type: Function
114
326
  },
115
- imageClassName: String,
116
- imageStyle: Object,
327
+ imageStyle: {
328
+ type: Object,
329
+ default: () => ({})
330
+ },
331
+ imageClass: String,
332
+ size: Number,
117
333
  width: Number,
118
334
  height: Number,
119
- zIndex: V.zIndex,
120
- getContainer: V.getContainer
121
- }, j = {
122
- previewUrls: {
335
+ zIndex: te.zIndex,
336
+ getContainer: te.getContainer
337
+ }, V = {
338
+ urls: {
123
339
  type: Array,
124
340
  default: () => []
125
341
  },
342
+ open: {
343
+ type: Boolean,
344
+ default: !1
345
+ },
346
+ scaleStep: {
347
+ type: Number,
348
+ default: 0.5
349
+ },
350
+ minScale: {
351
+ type: Number,
352
+ default: 0.32
353
+ },
354
+ maxScale: {
355
+ type: Number,
356
+ default: 32
357
+ },
358
+ movable: {
359
+ type: Boolean,
360
+ default: !0
361
+ },
126
362
  disabled: Boolean,
127
- zIndex: V.zIndex,
128
- current: V.current,
129
- infinite: V.infinite,
130
- getContainer: je.getContainer,
363
+ zIndex: te.zIndex,
364
+ current: te.current,
365
+ infinite: te.infinite,
366
+ getContainer: We.getContainer,
131
367
  onHideOnClickModal: {
132
368
  type: Boolean,
133
369
  default: !0
@@ -136,8 +372,11 @@ const V = {
136
372
  icons: {
137
373
  type: Object,
138
374
  default: () => ({})
139
- }
140
- }, Ot = /* @__PURE__ */ ye({
375
+ },
376
+ onTransform: Function,
377
+ onOpenChange: Function,
378
+ "onUpdate:open": Function
379
+ }, Yt = /* @__PURE__ */ Se({
141
380
  name: "Operations",
142
381
  inheritAttrs: !1,
143
382
  props: {
@@ -154,107 +393,107 @@ const V = {
154
393
  showProgress: Boolean,
155
394
  prefixCls: String,
156
395
  hashId: String,
157
- zIndex: j.zIndex,
158
- icons: j.icons,
159
- infinite: j.infinite,
160
- getContainer: j.getContainer,
161
- countRender: j.countRender,
396
+ zIndex: V.zIndex,
397
+ icons: V.icons,
398
+ infinite: V.infinite,
399
+ getContainer: V.getContainer,
400
+ countRender: V.countRender,
162
401
  tools: Array,
163
402
  onClose: Function,
164
403
  onActive: Function
165
404
  },
166
405
  setup(e) {
167
- const t = (i, l) => {
168
- var o;
169
- i.preventDefault(), i.stopPropagation(), (o = e.onActive) == null || o.call(e, l);
406
+ const n = (o, l) => {
407
+ var t;
408
+ o.preventDefault(), o.stopPropagation(), (t = e.onActive) == null || t.call(e, l);
170
409
  };
171
410
  return () => {
172
411
  const {
173
- prefixCls: i,
412
+ prefixCls: o,
174
413
  hashId: l,
175
- tools: o
176
- } = e, f = Ie(`${e.prefixCls}-fade`), c = `${i}-operations-operation`, d = `${i}-operations-icon`;
177
- return r(ze, {
414
+ tools: t
415
+ } = e, r = ye(`${e.prefixCls}-fade`), c = `${o}-operations-operation`, h = `${o}-operations-icon`;
416
+ return u(Te, {
178
417
  to: e.getContainer || "body"
179
418
  }, {
180
- default: () => [r(ge, f, {
419
+ default: () => [u(he, r, {
181
420
  default: () => {
182
- var E, g, h, C;
183
- return [we(r("div", {
184
- class: oe(`${i}-operations-wrapper`, l),
421
+ var y, d, v, m;
422
+ return [we(u("div", {
423
+ class: X(`${o}-operations-wrapper`, l),
185
424
  style: {
186
425
  zIndex: e.zIndex
187
426
  }
188
- }, [((E = e.icons) == null ? void 0 : E.close) === null ? null : r("button", {
189
- class: `${i}-close ${l}`,
427
+ }, [((y = e.icons) == null ? void 0 : y.close) === null ? null : u("button", {
428
+ class: `${o}-close ${l}`,
190
429
  onClick: e.onClose
191
- }, [((g = e.icons) == null ? void 0 : g.close) || r(St, null, null)]), e.showSwitch && r(Se, null, [r("div", {
192
- class: oe(`${i}-switch-left ${l}`, {
193
- [`${i}-switch-left-disabled`]: e.infinite ? !1 : e.current === 0
430
+ }, [((d = e.icons) == null ? void 0 : d.close) || u(ut, null, null)]), e.showSwitch && u(se, null, [u("div", {
431
+ class: X(`${o}-switch-left ${l}`, {
432
+ [`${o}-switch-left-disabled`]: e.infinite ? !1 : e.current === 0
194
433
  }),
195
- onClick: (v) => t(v, -1)
196
- }, [((h = e.icons) == null ? void 0 : h.left) || r(ht, null, null)]), r("div", {
197
- class: oe(`${i}-switch-right ${l}`, {
198
- [`${i}-switch-right-disabled`]: e.infinite ? !1 : e.current === e.count - 1
434
+ onClick: (w) => n(w, -1)
435
+ }, [((v = e.icons) == null ? void 0 : v.left) || u(ct, null, null)]), u("div", {
436
+ class: X(`${o}-switch-right ${l}`, {
437
+ [`${o}-switch-right-disabled`]: e.infinite ? !1 : e.current === e.count - 1
199
438
  }),
200
- onClick: (v) => t(v, 1)
201
- }, [((C = e.icons) == null ? void 0 : C.right) || r(pt, null, null)])]), r("div", {
202
- class: `${i}-footer ${l}`
203
- }, [e.showProgress && r("div", {
204
- class: `${i}-progress`
205
- }, [e.countRender ? e.countRender(e.current + 1, e.count) : `${e.current + 1} / ${e.count}`]), r("div", {
439
+ onClick: (w) => n(w, 1)
440
+ }, [((m = e.icons) == null ? void 0 : m.right) || u(dt, null, null)])]), u("div", {
441
+ class: `${o}-footer ${l}`
442
+ }, [e.showProgress && u("div", {
443
+ class: `${o}-progress`
444
+ }, [e.countRender ? e.countRender(e.current + 1, e.count) : `${e.current + 1} / ${e.count}`]), u("div", {
206
445
  class: `${e.prefixCls}-operations`
207
- }, [o == null ? void 0 : o.map(({
208
- icon: v,
209
- onClick: u,
210
- type: M,
211
- disabled: w
212
- }) => r("div", {
213
- class: oe(c, {
214
- [`${e.prefixCls}-operations-operation-disabled`]: w && (w == null ? void 0 : w.value)
446
+ }, [t == null ? void 0 : t.map(({
447
+ icon: w,
448
+ onClick: x,
449
+ type: a,
450
+ disabled: i
451
+ }) => u("div", {
452
+ class: X(c, {
453
+ [`${e.prefixCls}-operations-operation-disabled`]: i && (i == null ? void 0 : i.value)
215
454
  }),
216
- onClick: u,
217
- key: M
218
- }, [Je(v, {
219
- class: d
220
- })]))])])]), [[he, e.open]])];
455
+ onClick: x,
456
+ key: a
457
+ }, [it(w, {
458
+ class: h
459
+ })]))])])]), [[pe, e.open]])];
221
460
  }
222
461
  })]
223
462
  });
224
463
  };
225
464
  }
226
- }), At = new re("viewFadeIn", {
465
+ }), jt = new ce("viewFadeIn", {
227
466
  "0%": {
228
467
  opacity: 0
229
468
  },
230
469
  "100%": {
231
470
  opacity: 1
232
471
  }
233
- }), xt = new re("viewFadeOut", {
472
+ }), Bt = new ce("viewFadeOut", {
234
473
  "0%": {
235
474
  opacity: 1
236
475
  },
237
476
  "100%": {
238
477
  opacity: 0
239
478
  }
240
- }), Lt = new re("viewZoomBadgeIn", {
479
+ }), Ft = new ce("viewZoomBadgeIn", {
241
480
  "0%": {
242
- transform: "scale(0.2)",
481
+ transform: "scale(0)",
243
482
  opacity: 0
244
483
  },
245
484
  "100%": {
246
485
  transform: "scale(1)",
247
486
  opacity: 1
248
487
  }
249
- }), bt = new re("viewZoomBadgeOut", {
488
+ }), kt = new ce("viewZoomBadgeOut", {
250
489
  "0%": {
251
490
  transform: "scale(1)"
252
491
  },
253
492
  "100%": {
254
- transform: "scale(0.2)",
493
+ transform: "scale(0)",
255
494
  opacity: 0
256
495
  }
257
- }), Pe = (e) => ({
496
+ }), Ae = (e) => ({
258
497
  position: e || "absolute",
259
498
  inset: 0
260
499
  });
@@ -267,12 +506,12 @@ function ve(e) {
267
506
  insetInlineStart: 0
268
507
  };
269
508
  }
270
- const Tt = (e) => {
271
- const { previewCls: t, modalMaskBg: i, paddingSM: l, marginXL: o, margin: f, paddingLG: c, previewOperationColorDisabled: d, previewOperationHoverColor: E, motionDurationSlow: g, iconCls: h, colorTextLightSolid: C } = e, v = new Y(i).setAlpha(0.1), u = v.clone().setAlpha(0.2);
509
+ const Ht = (e) => {
510
+ const { previewCls: n, modalMaskBg: o, marginXL: l, margin: t, colorTextLightSolid: r, previewOperationColorDisabled: c, previewOperationHoverColor: h, motionDurationSlow: y, iconCls: d } = e, v = new Z(o).setAlpha(0.1), m = v.clone().setAlpha(0.2), w = new Z(o).setAlpha(0.06);
272
511
  return {
273
- [`${t}-footer`]: {
512
+ [`${n}-footer`]: {
274
513
  position: "fixed",
275
- bottom: o,
514
+ bottom: l,
276
515
  left: {
277
516
  _skip_check_: !0,
278
517
  value: "50%"
@@ -283,1244 +522,720 @@ const Tt = (e) => {
283
522
  color: e.previewOperationColor,
284
523
  transform: "translateX(-50%)"
285
524
  },
286
- [`${t}-progress`]: {
287
- marginBottom: f
525
+ [`${n}-progress`]: {
526
+ marginBottom: t
288
527
  },
289
- [`${t}-close`]: {
528
+ [`${n}-close`]: {
290
529
  position: "fixed",
291
- top: o,
530
+ top: l,
292
531
  right: {
293
532
  _skip_check_: !0,
294
- value: o
533
+ value: l
295
534
  },
296
535
  display: "flex",
297
- color: C,
536
+ alignItems: "center",
537
+ justifyContent: "center",
538
+ color: r,
298
539
  backgroundColor: v.toRgbString(),
299
- borderRadius: "50%",
300
- padding: l,
540
+ borderRadius: e.borderRadiusLG,
541
+ backdropFilter: "saturate(180%) blur(10px)",
542
+ width: e.sizeXL,
543
+ height: e.sizeXL,
301
544
  outline: 0,
302
545
  border: 0,
303
546
  cursor: "pointer",
304
- transition: `all ${g}`,
547
+ transition: `all ${y}`,
305
548
  "&:hover": {
306
- backgroundColor: u.toRgbString()
549
+ backgroundColor: m.toRgbString()
307
550
  },
308
- [`& > ${h}`]: {
551
+ [`& > ${d}`]: {
309
552
  fontSize: e.previewOperationSize
310
553
  }
311
554
  },
312
- [`${t}-operations`]: {
555
+ [`${n}-operations`]: {
313
556
  display: "flex",
314
557
  alignItems: "center",
315
- padding: `0 ${rt(c)}`,
558
+ gap: e.sizeXXS,
559
+ padding: e.paddingXXS,
316
560
  backgroundColor: v.toRgbString(),
317
- borderRadius: 100,
561
+ borderRadius: e.borderRadiusLG,
562
+ backdropFilter: "saturate(180%) blur(10px)",
318
563
  "&-operation": {
319
- marginInlineStart: l,
320
- padding: l,
564
+ display: "flex",
565
+ alignItems: "center",
566
+ justifyContent: "center",
567
+ width: e.sizeXL + 4,
568
+ height: e.sizeXL + 4,
321
569
  cursor: "pointer",
322
- transition: `all ${g}`,
570
+ color: r,
571
+ borderRadius: e.borderRadiusSM,
572
+ transition: `all ${y}`,
323
573
  userSelect: "none",
324
- [`&:not(${t}-operations-operation-disabled):hover > ${h}`]: {
325
- color: E
574
+ [`&:not(${n}-operations-operation-disabled):hover > ${d}`]: {
575
+ color: h
576
+ },
577
+ "&:hover": {
578
+ backgroundColor: w.toRgbString()
326
579
  },
327
580
  "&-disabled": {
328
- color: d,
581
+ color: c,
329
582
  cursor: "not-allowed"
330
583
  },
331
584
  "&:first-of-type": {
332
585
  marginInlineStart: 0
333
586
  },
334
- [`& > ${h}`]: {
587
+ [`& > ${d}`]: {
335
588
  fontSize: e.previewOperationSize
336
589
  }
337
590
  }
338
591
  }
339
592
  };
340
- }, Pt = (e) => {
341
- const { modalMaskBg: t, iconCls: i, previewOperationColorDisabled: l, previewCls: o, zIndexPopup: f, motionDurationSlow: c } = e, d = new Y(t).setAlpha(0.1), E = d.clone().setAlpha(0.2);
593
+ }, Zt = (e) => {
594
+ const { modalMaskBg: n, iconCls: o, previewOperationColorDisabled: l, previewCls: t, zIndexPopup: r, motionDurationSlow: c, colorTextLightSolid: h } = e, y = new Z(n).setAlpha(0.1), d = y.clone().setAlpha(0.2);
342
595
  return {
343
- [`${o}-switch-left, ${o}-switch-right`]: {
596
+ [`${t}-switch-left, ${t}-switch-right`]: {
344
597
  position: "fixed",
345
598
  insetBlockStart: "50%",
346
- zIndex: e.calc(f).add(1).equal(),
599
+ zIndex: e.calc(r).add(1).equal(),
347
600
  display: "flex",
348
601
  alignItems: "center",
349
602
  justifyContent: "center",
603
+ borderRadius: e.borderRadius,
604
+ backdropFilter: "saturate(180%) blur(10px)",
350
605
  width: e.imagePreviewSwitchSize,
351
606
  height: e.imagePreviewSwitchSize,
352
607
  marginTop: e.calc(e.imagePreviewSwitchSize).mul(-1).div(2).equal(),
353
- color: e.previewOperationColor,
354
- background: d.toRgbString(),
355
- borderRadius: "50%",
608
+ color: h,
609
+ background: y.toRgbString(),
356
610
  transform: "translateY(-50%)",
357
611
  cursor: "pointer",
358
612
  transition: `all ${c}`,
359
613
  userSelect: "none",
360
614
  "&:hover": {
361
- background: E.toRgbString()
615
+ background: d.toRgbString()
362
616
  },
363
617
  "&-disabled": {
364
618
  "&, &:hover": {
365
619
  color: l,
366
620
  background: "transparent",
367
621
  cursor: "not-allowed",
368
- [`> ${i}`]: {
622
+ [`> ${o}`]: {
369
623
  cursor: "not-allowed"
370
624
  }
371
625
  }
372
626
  },
373
- [`> ${i}`]: {
627
+ [`> ${o}`]: {
374
628
  fontSize: e.previewOperationSize
375
629
  }
376
630
  },
377
- [`${o}-switch-left`]: {
631
+ [`${t}-switch-left`]: {
378
632
  insetInlineStart: e.marginSM
379
633
  },
380
- [`${o}-switch-right`]: {
634
+ [`${t}-switch-right`]: {
381
635
  insetInlineEnd: e.marginSM
382
636
  }
383
637
  };
384
- }, Rt = (e) => ({
385
- [e.componentCls]: {
386
- height: "100%",
387
- textAlign: "center",
388
- pointerEvents: "none",
389
- "&-root": {
390
- ...ve("fixed"),
391
- zIndex: e.zIndexPopup,
392
- overflow: "auto",
393
- outline: 0,
394
- WebkitOverflowScrolling: "touch"
395
- },
396
- "&-wrap": {
397
- ...ve("fixed"),
398
- zIndex: e.zIndexPopup,
399
- overflow: "auto",
400
- outline: 0,
401
- WebkitOverflowScrolling: "touch"
402
- },
403
- "&-mask": {
404
- ...ve("fixed"),
405
- zIndex: e.zIndexPopupBase,
638
+ }, Wt = (e) => {
639
+ const { motionEaseOut: n, motionDurationSlow: o } = e;
640
+ return {
641
+ [e.componentCls]: {
406
642
  height: "100%",
407
- backgroundColor: e.colorBgMask
408
- },
409
- "&-body": {
410
- ...Pe(),
411
- overflow: "hidden"
412
- },
413
- "&-img": {
414
- maxWidth: "100%",
415
- maxHeight: "100%",
416
- verticalAlign: "middle",
417
- transform: "scale3d(1, 1, 1)",
418
- cursor: "grab",
419
- transition: `transform ${e.motionDurationSlow} ${e.motionEaseOut} 0s`,
420
- userSelect: "none",
421
- pointerEvents: "auto",
422
- "&-wrapper": {
423
- ...Pe(),
424
- display: "flex",
425
- justifyContent: "center",
426
- alignItems: "center",
427
- transition: `transform ${e.motionDurationSlow} ${e.motionEaseOut} 0s`,
428
- "&::before": {
429
- display: "inline-block",
430
- width: 1,
431
- height: "50%",
432
- marginInlineEnd: -1,
433
- content: '""'
643
+ textAlign: "center",
644
+ pointerEvents: "none",
645
+ "&-root": {
646
+ ...ve("fixed"),
647
+ zIndex: e.zIndexPopup,
648
+ overflow: "auto",
649
+ outline: 0,
650
+ WebkitOverflowScrolling: "touch"
651
+ },
652
+ "&-wrap": {
653
+ ...ve("fixed"),
654
+ zIndex: e.zIndexPopup,
655
+ overflow: "auto",
656
+ outline: 0,
657
+ WebkitOverflowScrolling: "touch"
658
+ },
659
+ "&-mask": {
660
+ ...ve("fixed"),
661
+ zIndex: e.zIndexPopupBase,
662
+ height: "100%",
663
+ backgroundColor: e.colorBgMask,
664
+ backdropFilter: "blur(2px)"
665
+ },
666
+ "&-body": {
667
+ ...Ae(),
668
+ overflow: "hidden"
669
+ },
670
+ "&-img": {
671
+ maxWidth: "100%",
672
+ maxHeight: "70%",
673
+ verticalAlign: "middle",
674
+ transform: "scale3d(1, 1, 1)",
675
+ cursor: "grab",
676
+ transition: `transform ${o} ${n} 0s`,
677
+ userSelect: "none",
678
+ "&-wrapper": {
679
+ ...Ae(),
680
+ transition: `transform ${o} ${n} 0s`,
681
+ display: "flex",
682
+ justifyContent: "center",
683
+ alignItems: "center",
684
+ "& > *": {
685
+ pointerEvents: "auto"
686
+ },
687
+ "&::before": {
688
+ display: "inline-block",
689
+ width: 1,
690
+ height: "50%",
691
+ marginInlineEnd: -1,
692
+ content: '""'
693
+ }
694
+ }
695
+ },
696
+ "&-moving": {
697
+ [`${e.componentCls}-view-img`]: {
698
+ cursor: "grabbing",
699
+ "&-wrapper": {
700
+ transitionDuration: "0s"
701
+ }
434
702
  }
703
+ },
704
+ "&-mask-zoom-appear, &-mask-zoom-enter": {
705
+ animationName: jt,
706
+ animationDuration: e.motionDurationSlow,
707
+ animationTimingFunction: "linear",
708
+ userSelect: "none"
709
+ },
710
+ "&-mask-zoom-leave": {
711
+ animationName: Bt,
712
+ animationDuration: e.motionDurationSlow,
713
+ animationTimingFunction: "linear",
714
+ pointerEvents: "none"
715
+ },
716
+ "&-zoom-appear, &-zoom-enter": {
717
+ animationName: Ft,
718
+ opacity: 0,
719
+ animationTimingFunction: e.motionEaseOutCirc,
720
+ animationFillMode: "both",
721
+ transform: "none",
722
+ animationDuration: e.motionDurationMid,
723
+ userSelect: "none"
724
+ },
725
+ "&-zoom-enter-active": {
726
+ animationPlayState: "running"
727
+ },
728
+ "&-zoom-leave": {
729
+ animationName: kt,
730
+ animationDuration: e.motionDurationSlow,
731
+ animationTimingFunction: e.motionEaseInOutCirc,
732
+ animationFillMode: "both"
435
733
  }
436
734
  },
437
- "&-fade-appear, &-fade-enter": {
438
- animationName: At,
439
- animationDuration: e.motionDurationSlow,
440
- animationTimingFunction: "linear"
441
- },
442
- "&-fade-leave": {
443
- animationName: xt,
444
- animationDuration: e.motionDurationSlow,
445
- animationTimingFunction: "linear"
446
- },
447
- "&-zoom-appear, &-zoom-enter": {
448
- animationName: Lt,
449
- opacity: 0,
450
- animationTimingFunction: e.motionEaseOutCirc,
451
- animationFillMode: "both",
452
- transform: "none",
453
- animationDuration: e.motionDurationSlow,
454
- userSelect: "none"
735
+ [`${e.componentCls}-root`]: {
736
+ [`${e.componentCls}-wrapper`]: {
737
+ zIndex: e.zIndexPopup
738
+ }
455
739
  },
456
- "&-zoom-enter-active": {
457
- animationPlayState: "running"
740
+ [`${e.componentCls}-operations-wrapper`]: {
741
+ position: "fixed",
742
+ insetBlockStart: 0,
743
+ insetInlineEnd: 0,
744
+ zIndex: e.calc(e.zIndexPopup).add(1).equal(),
745
+ width: "100%"
458
746
  },
459
- "&-zoom-leave": {
460
- animationName: bt,
461
- animationDuration: e.motionDurationSlow,
462
- animationTimingFunction: e.motionEaseOutBack,
463
- animationFillMode: "both"
464
- }
465
- },
466
- [`${e.componentCls}-root`]: {
467
- [`${e.componentCls}-wrapper`]: {
468
- zIndex: e.zIndexPopup
469
- }
470
- },
471
- [`${e.componentCls}-operations-wrapper`]: {
472
- position: "fixed",
473
- insetBlockStart: 0,
474
- insetInlineEnd: 0,
475
- zIndex: e.zIndexPopup + 1,
476
- width: "100%"
477
- },
478
- "&": [Tt(e), Pt(e)]
479
- });
480
- function $t(e) {
481
- return at("ImageViewer", (t) => {
482
- const i = lt(t, {
483
- zIndexPopup: t.zIndexPopupBase + 80,
484
- previewOperationColorDisabled: new Y(t.colorTextLightSolid).setAlpha(0.25).toRgbString(),
485
- previewOperationHoverColor: new Y(t.colorTextLightSolid).setAlpha(0.85).toRgbString(),
486
- modalMaskBg: new Y("#000").setAlpha(0.45).toRgbString(),
747
+ "&": [Ht(e), Zt(e)]
748
+ };
749
+ };
750
+ function _t(e) {
751
+ return wt("ImageViewer", (n) => {
752
+ const o = pt(n, {
753
+ zIndexPopup: n.zIndexPopupBase + 80,
754
+ previewOperationColor: new Z(n.colorTextLightSolid).setAlpha(0.65).toRgbString(),
755
+ previewOperationHoverColor: new Z(n.colorTextLightSolid).setAlpha(0.85).toRgbString(),
756
+ previewOperationColorDisabled: new Z(n.colorTextLightSolid).setAlpha(0.25).toRgbString(),
757
+ imagePreviewSwitchSize: n.sizeXL,
758
+ modalMaskBg: new Z("#000").setAlpha(0.45).toRgbString(),
487
759
  // FIXME: Shared Token
488
- previewOperationColor: new Y(t.colorTextLightSolid).toRgbString(),
489
- previewOperationSize: t.fontSizeIcon * 1.5,
760
+ previewOperationSize: n.fontSizeIcon * 1.5,
490
761
  // FIXME: fontSizeIconLG
491
- imagePreviewSwitchSize: t.controlHeightLG,
492
- iconCls: "anticon",
493
- previewCls: t.componentCls
762
+ iconCls: ".anticon",
763
+ previewCls: n.componentCls
494
764
  });
495
- return [Rt(i)];
765
+ return [Wt(o)];
496
766
  }, e);
497
767
  }
498
- let Ye = !1;
499
- try {
500
- const e = Object.defineProperty({}, "passive", {
501
- get() {
502
- Ye = !0;
503
- }
504
- });
505
- window.addEventListener("testPassive", null, e), window.removeEventListener("testPassive", null, e);
506
- } catch {
507
- }
508
- function F(e, t, i, l) {
509
- if (e && e.addEventListener) {
510
- let o = l;
511
- o === void 0 && Ye && (t === "touchstart" || t === "touchmove" || t === "wheel") && (o = { passive: !1 }), e.addEventListener(t, i, o);
512
- }
513
- return {
514
- remove: () => {
515
- e && e.removeEventListener && e.removeEventListener(t, i);
516
- }
517
- };
518
- }
519
- const a = {
520
- /**
521
- * MAC_ENTER
522
- */
523
- MAC_ENTER: 3,
524
- /**
525
- * BACKSPACE
526
- */
527
- BACKSPACE: 8,
528
- /**
529
- * TAB
530
- */
531
- TAB: 9,
532
- /**
533
- * NUMLOCK on FF/Safari Mac
534
- */
535
- NUM_CENTER: 12,
536
- // NUMLOCK on FF/Safari Mac
537
- /**
538
- * ENTER
539
- */
540
- ENTER: 13,
541
- /**
542
- * SHIFT
543
- */
544
- SHIFT: 16,
545
- /**
546
- * CTRL
547
- */
548
- CTRL: 17,
549
- /**
550
- * ALT
551
- */
552
- ALT: 18,
553
- /**
554
- * PAUSE
555
- */
556
- PAUSE: 19,
557
- /**
558
- * CAPS_LOCK
559
- */
560
- CAPS_LOCK: 20,
768
+ const ge = {
561
769
  /**
562
770
  * ESC
563
771
  */
564
772
  ESC: 27,
565
- /**
566
- * SPACE
567
- */
568
- SPACE: 32,
569
- /**
570
- * PAGE_UP
571
- */
572
- PAGE_UP: 33,
573
- // also NUM_NORTH_EAST
574
- /**
575
- * PAGE_DOWN
576
- */
577
- PAGE_DOWN: 34,
578
- // also NUM_SOUTH_EAST
579
- /**
580
- * END
581
- */
582
- END: 35,
583
- // also NUM_SOUTH_WEST
584
- /**
585
- * HOME
586
- */
587
- HOME: 36,
588
773
  // also NUM_NORTH_WEST
589
774
  /**
590
775
  * LEFT
591
776
  */
592
777
  LEFT: 37,
593
- // also NUM_WEST
594
- /**
595
- * UP
596
- */
597
- UP: 38,
598
778
  // also NUM_NORTH
599
779
  /**
600
780
  * RIGHT
601
781
  */
602
- RIGHT: 39,
603
- // also NUM_EAST
604
- /**
605
- * DOWN
606
- */
607
- DOWN: 40,
608
- // also NUM_SOUTH
609
- /**
610
- * PRINT_SCREEN
611
- */
612
- PRINT_SCREEN: 44,
613
- /**
614
- * INSERT
615
- */
616
- INSERT: 45,
617
- // also NUM_INSERT
618
- /**
619
- * DELETE
620
- */
621
- DELETE: 46,
622
- // also NUM_DELETE
623
- /**
624
- * ZERO
625
- */
626
- ZERO: 48,
627
- /**
628
- * ONE
629
- */
630
- ONE: 49,
631
- /**
632
- * TWO
633
- */
634
- TWO: 50,
635
- /**
636
- * THREE
637
- */
638
- THREE: 51,
639
- /**
640
- * FOUR
641
- */
642
- FOUR: 52,
643
- /**
644
- * FIVE
645
- */
646
- FIVE: 53,
647
- /**
648
- * SIX
649
- */
650
- SIX: 54,
651
- /**
652
- * SEVEN
653
- */
654
- SEVEN: 55,
655
- /**
656
- * EIGHT
657
- */
658
- EIGHT: 56,
659
- /**
660
- * NINE
661
- */
662
- NINE: 57,
663
- /**
664
- * QUESTION_MARK
665
- */
666
- QUESTION_MARK: 63,
667
- // needs localization
668
- /**
669
- * A
670
- */
671
- A: 65,
672
- /**
673
- * B
674
- */
675
- B: 66,
676
- /**
677
- * C
678
- */
679
- C: 67,
680
- /**
681
- * D
682
- */
683
- D: 68,
684
- /**
685
- * E
686
- */
687
- E: 69,
688
- /**
689
- * F
690
- */
691
- F: 70,
692
- /**
693
- * G
694
- */
695
- G: 71,
696
- /**
697
- * H
698
- */
699
- H: 72,
700
- /**
701
- * I
702
- */
703
- I: 73,
704
- /**
705
- * J
706
- */
707
- J: 74,
708
- /**
709
- * K
710
- */
711
- K: 75,
712
- /**
713
- * L
714
- */
715
- L: 76,
716
- /**
717
- * M
718
- */
719
- M: 77,
720
- /**
721
- * N
722
- */
723
- N: 78,
724
- /**
725
- * O
726
- */
727
- O: 79,
728
- /**
729
- * P
730
- */
731
- P: 80,
732
- /**
733
- * Q
734
- */
735
- Q: 81,
736
- /**
737
- * R
738
- */
739
- R: 82,
740
- /**
741
- * S
742
- */
743
- S: 83,
744
- /**
745
- * T
746
- */
747
- T: 84,
748
- /**
749
- * U
750
- */
751
- U: 85,
752
- /**
753
- * V
754
- */
755
- V: 86,
756
- /**
757
- * W
758
- */
759
- W: 87,
760
- /**
761
- * X
762
- */
763
- X: 88,
764
- /**
765
- * Y
766
- */
767
- Y: 89,
768
- /**
769
- * Z
770
- */
771
- Z: 90,
772
- /**
773
- * META
774
- */
775
- META: 91,
776
- // WIN_KEY_LEFT
777
- /**
778
- * WIN_KEY_RIGHT
779
- */
780
- WIN_KEY_RIGHT: 92,
781
- /**
782
- * CONTEXT_MENU
783
- */
784
- CONTEXT_MENU: 93,
785
- /**
786
- * NUM_ZERO
787
- */
788
- NUM_ZERO: 96,
789
- /**
790
- * NUM_ONE
791
- */
792
- NUM_ONE: 97,
793
- /**
794
- * NUM_TWO
795
- */
796
- NUM_TWO: 98,
797
- /**
798
- * NUM_THREE
799
- */
800
- NUM_THREE: 99,
801
- /**
802
- * NUM_FOUR
803
- */
804
- NUM_FOUR: 100,
805
- /**
806
- * NUM_FIVE
807
- */
808
- NUM_FIVE: 101,
809
- /**
810
- * NUM_SIX
811
- */
812
- NUM_SIX: 102,
813
- /**
814
- * NUM_SEVEN
815
- */
816
- NUM_SEVEN: 103,
817
- /**
818
- * NUM_EIGHT
819
- */
820
- NUM_EIGHT: 104,
821
- /**
822
- * NUM_NINE
823
- */
824
- NUM_NINE: 105,
825
- /**
826
- * NUM_MULTIPLY
827
- */
828
- NUM_MULTIPLY: 106,
829
- /**
830
- * NUM_PLUS
831
- */
832
- NUM_PLUS: 107,
833
- /**
834
- * NUM_MINUS
835
- */
836
- NUM_MINUS: 109,
837
- /**
838
- * NUM_PERIOD
839
- */
840
- NUM_PERIOD: 110,
841
- /**
842
- * NUM_DIVISION
843
- */
844
- NUM_DIVISION: 111,
845
- /**
846
- * F1
847
- */
848
- F1: 112,
849
- /**
850
- * F2
851
- */
852
- F2: 113,
853
- /**
854
- * F3
855
- */
856
- F3: 114,
857
- /**
858
- * F4
859
- */
860
- F4: 115,
861
- /**
862
- * F5
863
- */
864
- F5: 116,
865
- /**
866
- * F6
867
- */
868
- F6: 117,
869
- /**
870
- * F7
871
- */
872
- F7: 118,
873
- /**
874
- * F8
875
- */
876
- F8: 119,
877
- /**
878
- * F9
879
- */
880
- F9: 120,
881
- /**
882
- * F10
883
- */
884
- F10: 121,
885
- /**
886
- * F11
887
- */
888
- F11: 122,
889
- /**
890
- * F12
891
- */
892
- F12: 123,
893
- /**
894
- * NUMLOCK
895
- */
896
- NUMLOCK: 144,
897
- /**
898
- * SEMICOLON
899
- */
900
- SEMICOLON: 186,
901
- // needs localization
902
- /**
903
- * DASH
904
- */
905
- DASH: 189,
906
- // needs localization
907
- /**
908
- * EQUALS
909
- */
910
- EQUALS: 187,
911
- // needs localization
912
- /**
913
- * COMMA
914
- */
915
- COMMA: 188,
916
- // needs localization
917
- /**
918
- * PERIOD
919
- */
920
- PERIOD: 190,
921
- // needs localization
922
- /**
923
- * SLASH
924
- */
925
- SLASH: 191,
926
- // needs localization
927
- /**
928
- * APOSTROPHE
929
- */
930
- APOSTROPHE: 192,
931
- // needs localization
932
- /**
933
- * SINGLE_QUOTE
934
- */
935
- SINGLE_QUOTE: 222,
936
- // needs localization
937
- /**
938
- * OPEN_SQUARE_BRACKET
939
- */
940
- OPEN_SQUARE_BRACKET: 219,
941
- // needs localization
942
- /**
943
- * BACKSLASH
944
- */
945
- BACKSLASH: 220,
946
- // needs localization
947
- /**
948
- * CLOSE_SQUARE_BRACKET
949
- */
950
- CLOSE_SQUARE_BRACKET: 221,
951
- // needs localization
952
- /**
953
- * WIN_KEY
954
- */
955
- WIN_KEY: 224,
956
- /**
957
- * MAC_FF_META
958
- */
959
- MAC_FF_META: 224,
960
- // Firefox (Gecko) fires this for the meta key instead of 91
961
- /**
962
- * WIN_IME
963
- */
964
- WIN_IME: 229,
965
- // ======================== Function ========================
966
- /**
967
- * whether text and modified key is entered at the same time.
968
- */
969
- isTextModifyingKeyEvent: function(t) {
970
- const { keyCode: i } = t;
971
- if (t.altKey && !t.ctrlKey || t.metaKey || // Function keys don't generate text
972
- i >= a.F1 && i <= a.F12)
973
- return !1;
974
- switch (i) {
975
- case a.ALT:
976
- case a.CAPS_LOCK:
977
- case a.CONTEXT_MENU:
978
- case a.CTRL:
979
- case a.DOWN:
980
- case a.END:
981
- case a.ESC:
982
- case a.HOME:
983
- case a.INSERT:
984
- case a.LEFT:
985
- case a.MAC_FF_META:
986
- case a.META:
987
- case a.NUMLOCK:
988
- case a.NUM_CENTER:
989
- case a.PAGE_DOWN:
990
- case a.PAGE_UP:
991
- case a.PAUSE:
992
- case a.PRINT_SCREEN:
993
- case a.RIGHT:
994
- case a.SHIFT:
995
- case a.UP:
996
- case a.WIN_KEY:
997
- case a.WIN_KEY_RIGHT:
998
- return !1;
999
- default:
1000
- return !0;
1001
- }
1002
- },
1003
- /**
1004
- * whether character is entered.
1005
- */
1006
- isCharacterKey: function(t) {
1007
- if (t >= a.ZERO && t <= a.NINE || t >= a.NUM_ZERO && t <= a.NUM_MULTIPLY || t >= a.A && t <= a.Z || window.navigator.userAgent.includes("WebKit") && t === 0)
1008
- return !0;
1009
- switch (t) {
1010
- case a.SPACE:
1011
- case a.QUESTION_MARK:
1012
- case a.NUM_PLUS:
1013
- case a.NUM_MINUS:
1014
- case a.NUM_PERIOD:
1015
- case a.NUM_DIVISION:
1016
- case a.SEMICOLON:
1017
- case a.DASH:
1018
- case a.EQUALS:
1019
- case a.COMMA:
1020
- case a.PERIOD:
1021
- case a.SLASH:
1022
- case a.APOSTROPHE:
1023
- case a.SINGLE_QUOTE:
1024
- case a.OPEN_SQUARE_BRACKET:
1025
- case a.BACKSLASH:
1026
- case a.CLOSE_SQUARE_BRACKET:
1027
- return !0;
1028
- default:
1029
- return !1;
1030
- }
1031
- }
1032
- };
1033
- function Dt(e) {
1034
- const t = e.getBoundingClientRect(), i = document.documentElement;
1035
- return {
1036
- left: t.left + (window.scrollX || i.scrollLeft) - (i.clientLeft || document.body.clientLeft || 0),
1037
- top: t.top + (window.scrollY || i.scrollTop) - (i.clientTop || document.body.clientTop || 0)
1038
- };
1039
- }
1040
- function zt() {
1041
- const e = document.documentElement.clientWidth, t = window.innerHeight || document.documentElement.clientHeight;
1042
- return {
1043
- width: e,
1044
- height: t
1045
- };
1046
- }
1047
- function Re(e, t, i, l) {
1048
- const o = t + i, f = (i - l) / 2;
1049
- if (i > l) {
1050
- if (t > 0)
1051
- return {
1052
- [e]: f
1053
- };
1054
- if (t < 0 && o < l)
1055
- return {
1056
- [e]: -f
1057
- };
1058
- } else if (t < 0 || o > l)
1059
- return {
1060
- [e]: t < 0 ? f : -f
1061
- };
1062
- return {};
1063
- }
1064
- function Ut(e, t, i, l) {
1065
- const { width: o, height: f } = zt();
1066
- let c = null;
1067
- return e <= o && t <= f ? c = {
1068
- x: 0,
1069
- y: 0
1070
- } : (e > o || t > f) && (c = {
1071
- ...Re("x", i, e, o),
1072
- ...Re("y", l, t, f)
1073
- }), c;
1074
- }
1075
- const D = {
1076
- x: 0,
1077
- y: 0
1078
- }, B = {
1079
- rotateLeft: r(It, null, null),
1080
- rotateRight: r(Et, null, null),
1081
- zoomIn: r(Ct, null, null),
1082
- zoomOut: r(yt, null, null),
1083
- flipX: r(be, null, null),
1084
- flipY: r(be, {
782
+ RIGHT: 39
783
+ }, U = {
784
+ rotateLeft: u(mt, null, null),
785
+ rotateRight: u(gt, null, null),
786
+ zoomIn: u(vt, null, null),
787
+ zoomOut: u(ft, null, null),
788
+ flipX: u(ze, null, null),
789
+ flipY: u(ze, {
1085
790
  rotate: 90
1086
791
  }, null)
1087
- }, Ke = ["close", "left", "right", "rotateRight", "rotateRight", "zoomOut", "flipX", "flipY", "rotateLeft"], _t = /* @__PURE__ */ ye({
792
+ }, _e = ["close", "left", "right", "rotateRight", "rotateRight", "zoomOut", "flipX", "flipY", "rotateLeft"], Gt = /* @__PURE__ */ Se({
1088
793
  name: "GImagePreview",
1089
- props: j,
794
+ props: V,
1090
795
  inheritAttrs: !1,
1091
- emits: ["close", "switch", "afterClose"],
1092
- emit: Object,
796
+ slots: Object,
797
+ emits: {
798
+ close: () => !0,
799
+ transform: (e) => !0,
800
+ "update:open": (e) => !0
801
+ },
1093
802
  setup: (e, {
1094
- emit: t,
1095
- expose: i,
803
+ emit: n,
804
+ expose: o,
1096
805
  slots: l
1097
806
  }) => {
1098
- const o = Ue({
807
+ const t = Re({
1099
808
  suffixCls: "image-view"
1100
809
  }), {
1101
- wrapSSR: f,
810
+ wrapSSR: r,
1102
811
  hashId: c
1103
- } = $t(o), [d, E] = xe(!1), [g, h] = xe(!1), C = N(null), v = N(e.current), u = Z(1), M = Z(0), w = Z(!1), O = ae({
1104
- x: 1,
1105
- y: 1
1106
- }), [p, L] = Mt(D), K = Z({
1107
- wheelDirection: 0
1108
- }), P = Z(), A = ae({
1109
- originX: 0,
1110
- originY: 0,
1111
- deltaX: 0,
1112
- deltaY: 0
1113
- }), R = ae(/* @__PURE__ */ new Map()), z = y(() => new Map(Array.from(R).map(([n, {
1114
- url: m
1115
- }]) => [n, m]))), Q = y(() => z.value.get(v.value)), U = y(() => z.value.size), W = y(() => Array.from(z.value.keys())), b = y(() => W.value.indexOf(v.value)), k = y(() => U.value > 1), G = y(() => U.value >= 1);
1116
- H(d, (n) => {
1117
- n && (g.value = !0);
812
+ } = _t(t), [h, y, d] = Et(e.open, {
813
+ value: k(e, "open"),
814
+ onChange: (s) => {
815
+ var z;
816
+ (z = e.onOpenChange) == null || z.call(e, s), n("update:open", s);
817
+ }
818
+ }), [v, m] = ne(!1), [w, x] = ne(!0), a = L(), {
819
+ transform: i,
820
+ resetTransform: p,
821
+ updateTransform: g,
822
+ dispatchZoomChange: S
823
+ } = Tt(a, k(e, "minScale"), k(e, "maxScale"), e.onTransform), {
824
+ isMoving: C,
825
+ onMouseDown: $,
826
+ onWheel: T
827
+ } = Nt(a, k(e, "movable"), d, k(e, "scaleStep"), i, g, S), {
828
+ isTouching: O,
829
+ onTouchStart: I,
830
+ onTouchMove: F,
831
+ onTouchEnd: W
832
+ } = Xt(a, k(e, "movable"), d, k(e, "minScale"), i, g, S);
833
+ Ce(() => {
834
+ w.value || x(!0);
835
+ }, [w]);
836
+ const N = L(null), M = L(e.current), P = at(/* @__PURE__ */ new Map()), Y = b(() => new Map(Array.from(P).map(([s, {
837
+ url: z
838
+ }]) => [s, z]))), _ = b(() => Y.value.get(M.value)), j = b(() => Y.value.size), B = b(() => Array.from(Y.value.keys())), D = b(() => B.value.indexOf(M.value)), f = b(() => j.value > 1), A = b(() => j.value >= 1);
839
+ J(d, (s) => {
840
+ s && (v.value = !0);
1118
841
  });
1119
- const s = (n) => {
1120
- v.value = n;
842
+ const E = (s) => {
843
+ M.value = s;
1121
844
  };
1122
- H(() => e.current, (n) => {
1123
- Ee(n) && s(n);
845
+ J(() => e.current, (s) => {
846
+ Ne(s) && E(s);
1124
847
  });
1125
- function S(n, m) {
1126
- R.set(n, {
1127
- url: m,
848
+ function de(s, z) {
849
+ P.set(s, {
850
+ url: z,
1128
851
  loading: !0,
1129
852
  canPreview: !1
1130
853
  });
1131
854
  }
1132
- const x = () => {
1133
- h(!1), v.value = e.current;
1134
- }, se = () => {
1135
- u.value = 1, M.value = 0, O.x = 1, O.y = 1, L(D), t("close");
1136
- }, ce = (n) => {
1137
- w.value || C.value === (n == null ? void 0 : n.target) && x();
1138
- }, ue = () => {
1139
- const n = R.get(v.value);
1140
- n && (n.loading = !1, n.canPreview = !0);
1141
- }, q = (n) => {
1142
- const m = R.get(v.value);
1143
- m && (m.loading = !1, m.canPreview = !1), n.target.alt = "加载失败";
1144
- }, J = () => {
1145
- if (b.value > 0 || e.infinite) {
1146
- const n = b.value - 1 < 0 ? e.previewUrls.length - 1 : b.value - 1;
1147
- s(W.value[n]);
855
+ const G = () => {
856
+ m(!1);
857
+ }, oe = () => {
858
+ p("close"), n("close");
859
+ }, Ge = (s) => {
860
+ C.value || N.value === (s == null ? void 0 : s.target) && G();
861
+ }, Ue = () => {
862
+ const s = P.get(M.value);
863
+ s && (s.loading = !1, s.canPreview = !0);
864
+ }, Ve = (s) => {
865
+ const z = P.get(M.value);
866
+ z && (z.loading = !1, z.canPreview = !1), s.target.alt = "加载失败";
867
+ }, Ie = () => {
868
+ if (D.value > 0 || e.infinite) {
869
+ const s = D.value - 1 < 0 ? e.urls.length - 1 : D.value - 1;
870
+ E(B.value[s]), p("prev");
1148
871
  }
1149
- }, ee = () => {
1150
- if (b.value < U.value - 1 || e.infinite) {
1151
- const n = b.value + 1 > e.previewUrls.length - 1 ? 0 : b.value + 1;
1152
- s(W.value[n]);
872
+ }, be = () => {
873
+ if (D.value < j.value - 1 || e.infinite) {
874
+ const s = D.value + 1 > e.urls.length - 1 ? 0 : D.value + 1;
875
+ E(B.value[s]), p("next");
1153
876
  }
1154
- }, _ = (n) => {
1155
- n ? u.value += 0.5 : u.value++, L(D);
1156
- }, X = (n) => {
1157
- u.value > 1 && (n ? u.value -= 0.5 : u.value--), L(D);
1158
- }, de = () => {
1159
- M.value += 90;
1160
- }, We = () => {
1161
- M.value -= 90;
1162
- }, Ge = () => {
1163
- O.x = -O.x;
1164
- }, Xe = () => {
1165
- O.y = -O.y;
1166
- }, Me = [{
1167
- icon: $(l, e.icons, "zoomIn") || B.zoomIn,
1168
- onClick: () => _(),
1169
- type: "zoomIn"
1170
- }, {
1171
- icon: $(l, e.icons, "zoomOut") || B.zoomOut,
1172
- onClick: () => X(),
1173
- type: "zoomOut",
1174
- disabled: y(() => u.value === 1)
877
+ }, qe = () => {
878
+ S(K + e.scaleStep, "zoomIn");
879
+ }, Ke = () => {
880
+ S(K / (K + e.scaleStep), "zoomOut");
881
+ }, Qe = () => {
882
+ g({
883
+ rotate: i.value.rotate + 90
884
+ }, "rotateRight");
885
+ }, Je = () => {
886
+ g({
887
+ rotate: i.value.rotate - 90
888
+ }, "rotateLeft");
889
+ }, et = () => {
890
+ g({
891
+ flipX: !i.value.flipX
892
+ }, "flipX");
893
+ }, tt = () => {
894
+ g({
895
+ flipY: !i.value.flipY
896
+ }, "flipY");
897
+ }, $e = [{
898
+ icon: H(l, e.icons, "flipY") || U.flipY,
899
+ onClick: tt,
900
+ type: "flipY"
1175
901
  }, {
1176
- icon: $(l, e.icons, "rotateRight") || B.rotateRight,
1177
- onClick: de,
1178
- type: "rotateRight"
902
+ icon: H(l, e.icons, "flipX") || U.flipX,
903
+ onClick: et,
904
+ type: "flipX"
1179
905
  }, {
1180
- icon: $(l, e.icons, "rotateLeft") || B.rotateLeft,
1181
- onClick: We,
906
+ icon: H(l, e.icons, "rotateLeft") || U.rotateLeft,
907
+ onClick: Je,
1182
908
  type: "rotateLeft"
1183
909
  }, {
1184
- icon: $(l, e.icons, "flipX") || B.flipX,
1185
- onClick: Ge,
1186
- type: "flipX"
910
+ icon: H(l, e.icons, "rotateRight") || U.rotateRight,
911
+ onClick: Qe,
912
+ type: "rotateRight"
1187
913
  }, {
1188
- icon: $(l, e.icons, "flipY") || B.flipY,
1189
- onClick: Xe,
1190
- type: "flipY"
1191
- }], Oe = () => {
1192
- if (d.value && w.value && P.value) {
1193
- const n = P.value.offsetWidth * u.value, m = P.value.offsetHeight * u.value, {
1194
- left: T,
1195
- top: I
1196
- } = Dt(P.value), te = M.value % 180 !== 0;
1197
- w.value = !1;
1198
- const ne = Ut(te ? m : n, te ? n : m, T, I);
1199
- ne && L({
1200
- ...ne
1201
- });
1202
- }
1203
- }, Ze = (n) => {
1204
- n.button === 0 && (n.preventDefault(), n.stopPropagation(), A.deltaX = n.pageX - p.x, A.deltaY = n.pageY - p.y, A.originX = p.x, A.originY = p.y, w.value = !0);
1205
- }, Ae = (n) => {
1206
- d.value && w.value && L({
1207
- x: n.pageX - A.deltaX,
1208
- y: n.pageY - A.deltaY
1209
- });
1210
- }, Ve = (n) => {
1211
- if (!d.value) return;
1212
- n.preventDefault();
1213
- const m = n.deltaY;
1214
- K.value = {
1215
- wheelDirection: m
1216
- };
1217
- }, Qe = (n) => {
1218
- !d.value || !k.value || (n.keyCode === a.LEFT ? J() : n.keyCode === a.RIGHT && ee());
1219
- }, ke = () => {
1220
- d.value && (u.value !== 1 && (u.value = 1), (p.x !== D.x || p.y !== D.y) && L(D));
914
+ icon: H(l, e.icons, "zoomOut") || U.zoomOut,
915
+ onClick: () => Ke(),
916
+ type: "zoomOut",
917
+ disabled: b(() => i.value.scale <= e.minScale)
918
+ }, {
919
+ icon: H(l, e.icons, "zoomIn") || U.zoomIn,
920
+ onClick: () => qe(),
921
+ type: "zoomIn",
922
+ disabled: b(() => i.value.scale === e.maxScale)
923
+ }], nt = (s) => {
924
+ d.value && (i.value.scale !== 1 ? g({
925
+ x: 0,
926
+ y: 0,
927
+ scale: 1
928
+ }, "doubleClick") : S(K + e.scaleStep, "doubleClick", s.clientX, s.clientY));
929
+ }, ot = (s) => {
930
+ s.keyCode === ge.ESC && G(), !(!d.value || !f.value) && (s.keyCode === ge.LEFT ? Ie() : s.keyCode === ge.RIGHT && be());
1221
931
  };
1222
932
  let fe = () => {
1223
933
  };
1224
934
  return De(() => {
1225
- H(() => e.previewUrls, (n) => {
1226
- _e(n) && n.forEach((m, T) => {
1227
- S(T, m);
935
+ J(() => e.urls, (s) => {
936
+ Ct(s) && s.forEach((z, ie) => {
937
+ de(ie, z);
1228
938
  });
1229
939
  }, {
1230
940
  flush: "post",
1231
941
  immediate: !0
1232
- }), H([() => d.value, w], () => {
942
+ }), J([() => d.value, () => C.value], () => {
1233
943
  fe();
1234
- let n, m;
1235
- const T = F(window, "mouseup", Oe, !1), I = F(window, "mousemove", Ae, !1), te = F(window, "wheel", Ve, {
1236
- passive: !1
1237
- }), ne = F(window, "keydown", Qe, !1);
1238
- try {
1239
- window.top !== window.self && (n = F(window.top, "mouseup", Oe, !1), m = F(window.top, "mousemove", Ae, !1));
1240
- } catch (qe) {
1241
- Nt(!1, `[vc-image] ${qe}`);
1242
- }
944
+ const s = q(window, "keydown", ot, !1);
1243
945
  fe = () => {
1244
- T.remove(), I.remove(), te.remove(), ne.remove(), n && n.remove(), m && m.remove();
946
+ s.remove();
1245
947
  };
1246
948
  }, {
1247
949
  flush: "post",
1248
950
  immediate: !0
1249
- }), H([K], () => {
1250
- const {
1251
- wheelDirection: n
1252
- } = K.value;
1253
- n > 0 ? X(!0) : n < 0 && _(!0);
1254
951
  });
1255
- }), et(() => {
952
+ }), lt(() => {
1256
953
  fe();
1257
- }), i({
1258
- setOpen: E
954
+ }), o({
955
+ setOpen: (s) => {
956
+ y(s), M.value = e.current;
957
+ }
1259
958
  }), () => {
1260
- const n = Ie(`${o}-fade`), m = Ie(`${o}-zoom`), T = {};
1261
- for (const I in e.icons)
1262
- T[I] = $(l, e.icons, I);
1263
- return f(r(Se, null, [r(ze, {
959
+ const s = ye(`${t}-mask-zoom`), z = ye(`${t}-zoom`), ie = {};
960
+ for (const R in e.icons)
961
+ ie[R] = H(l, e.icons, R);
962
+ return r(u(se, null, [u(Te, {
1264
963
  to: e.getContainer || "body"
1265
964
  }, {
1266
- default: () => [d.value && r(Se, null, [r("div", {
1267
- class: `${o}-root ${c.value}`
1268
- }, [r(ge, n, {
1269
- default: () => [we(r("div", {
1270
- class: `${o}-mask ${c.value}`
1271
- }, null), [[he, d.value && g.value]])]
1272
- }), r("div", {
1273
- ref: C,
965
+ default: () => [d.value && u(se, null, [u("div", {
966
+ class: `${t}-root ${c.value}`
967
+ }, [u(he, s, {
968
+ default: () => [we(u("div", {
969
+ class: `${t}-mask ${c.value}`
970
+ }, null), [[pe, d.value && v.value]])]
971
+ }), u("div", {
972
+ ref: N,
1274
973
  tabindex: -1,
1275
- class: [`${o}-wrap`, `${c.value}`],
1276
- onClick: (I) => e.onHideOnClickModal && ce(I)
1277
- }, [r(ge, pe(m, {
1278
- onAfterLeave: () => se()
974
+ class: [`${t}-wrap`, `${c.value}`, C.value && `${t}-moving`],
975
+ onClick: (R) => e.onHideOnClickModal && Ge(R)
976
+ }, [u(he, le(z, {
977
+ onAfterLeave: () => oe()
1279
978
  }), {
1280
- default: () => [we(r("div", {
979
+ default: () => [we(u("div", {
1281
980
  role: "dialog",
1282
- class: `${o} ${c.value}`
1283
- }, [r("div", {
1284
- class: `${o}-content ${c.value}`
1285
- }, [r("div", {
1286
- class: `${o}-body ${c.value}`
1287
- }, [r("div", {
1288
- class: `${o}-img-wrapper ${c.value}`,
1289
- style: {
1290
- transform: `translate3d(${p.x}px, ${p.y}px, 0)`
1291
- }
1292
- }, [r("img", {
1293
- onMousedown: Ze,
1294
- onDblclick: ke,
1295
- ref: P,
1296
- class: `${o}-img ${c.value}`,
1297
- src: Q.value,
1298
- onLoad: () => ue(),
1299
- onError: (I) => q(I),
981
+ class: `${t} ${c.value}`
982
+ }, [u("div", {
983
+ class: `${t}-content ${c.value}`
984
+ }, [u("div", {
985
+ class: `${t}-body ${c.value}`
986
+ }, [u("div", {
987
+ class: `${t}-img-wrapper ${c.value}`
988
+ }, [u("img", {
989
+ ref: a,
990
+ class: `${t}-img ${c.value}`,
991
+ src: _.value,
992
+ onLoad: () => Ue(),
993
+ onError: (R) => Ve(R),
1300
994
  style: {
1301
- transform: `scale3d(${O.x * u.value}, ${O.y * u.value}, 1) rotate(${M.value}deg)`
1302
- }
1303
- }, null)])])])]), [[he, d.value && g.value]])]
995
+ transform: `translate3d(${i.value.x}px, ${i.value.y}px, 0) scale3d(${i.value.flipX ? "-" : ""}${i.value.scale}, ${i.value.flipY ? "-" : ""}${i.value.scale}, 1) rotate(${i.value.rotate}deg)`,
996
+ transitionDuration: !w.value || O.value ? "0s" : void 0
997
+ },
998
+ onWheel: T,
999
+ onMousedown: $,
1000
+ onDblclick: nt,
1001
+ onTouchstart: I,
1002
+ onTouchmove: F,
1003
+ onTouchend: W,
1004
+ onTouchcancel: W
1005
+ }, null)])])])]), [[pe, d.value && v.value]])]
1304
1006
  })])])])]
1305
- }), d.value && g.value && r(Ot, {
1306
- open: d.value && g.value,
1007
+ }), d.value && v.value && u(Yt, {
1008
+ open: d.value && v.value,
1307
1009
  hashId: c.value,
1308
- count: e.previewUrls.length,
1309
- current: v.value,
1010
+ count: e.urls.length,
1011
+ current: M.value,
1310
1012
  zIndex: e.zIndex + 1,
1311
1013
  getContainer: e.getContainer,
1312
- prefixCls: o,
1313
- icons: gt(T, Me.map(({
1314
- type: I
1315
- }) => I)),
1316
- tools: Me,
1014
+ prefixCls: t,
1015
+ icons: Ye(ie, $e.map(({
1016
+ type: R
1017
+ }) => R)),
1018
+ tools: $e,
1317
1019
  infinite: e.infinite,
1318
- countRender: ct(l, e, "countRenders"),
1319
- showSwitch: k.value,
1320
- showProgress: G.value,
1321
- onClose: x,
1322
- onActive: (I) => I > 0 ? ee() : J()
1020
+ countRender: Pe(l, e, "countRenders"),
1021
+ showSwitch: f.value,
1022
+ showProgress: A.value,
1023
+ onClose: G,
1024
+ onActive: (R) => R > 0 ? be() : Ie()
1323
1025
  }, null)]));
1324
1026
  };
1325
1027
  }
1326
1028
  }), me = {
1327
1029
  width: "100%",
1328
1030
  height: "100%"
1329
- }, Ft = () => ({
1330
- position: "absolute",
1331
- inset: 0,
1332
- display: "flex",
1333
- alignItems: "center",
1334
- justifyContent: "center",
1335
- cursor: "pointer",
1336
- opacity: 0
1337
- }), Bt = (e) => ({
1031
+ }, Ut = {
1032
+ overflow: "hidden",
1033
+ whiteSpace: "nowrap",
1034
+ textOverflow: "ellipsis"
1035
+ }, Vt = (e) => {
1036
+ const { motionDurationSlow: n, paddingXXS: o, marginXXS: l, colorTextLightSolid: t } = e, r = ".anticon";
1037
+ return {
1038
+ position: "absolute",
1039
+ inset: 0,
1040
+ display: "flex",
1041
+ alignItems: "center",
1042
+ justifyContent: "center",
1043
+ color: t,
1044
+ background: new yt("#000").setA(0.5).toRgbString(),
1045
+ cursor: "pointer",
1046
+ opacity: 0,
1047
+ transition: `opacity ${n}`,
1048
+ [`.${e.componentCls}-mask-info`]: {
1049
+ ...Ut,
1050
+ padding: `0 ${ee(o)}`,
1051
+ [r]: {
1052
+ marginInlineEnd: l,
1053
+ svg: {
1054
+ verticalAlign: "baseline"
1055
+ }
1056
+ }
1057
+ }
1058
+ };
1059
+ }, qt = (e) => ({
1060
+ position: e || "absolute",
1061
+ inset: 0
1062
+ }), Kt = (e) => ({
1338
1063
  [e.componentCls]: {
1339
1064
  display: "inline-block",
1340
1065
  position: "relative",
1341
1066
  overflow: "hidden",
1342
- "&-inner": {
1067
+ [`${e.componentCls}-img`]: {
1343
1068
  ...me,
1344
1069
  verticalAlign: "top",
1345
1070
  opacity: 1,
1346
- [`&${e.componentCls}-inner-preview`]: {
1347
- userSelect: "none"
1071
+ [`&${e.componentCls}-img-preview`]: {
1072
+ userSelect: "none",
1073
+ cursor: "pointer"
1074
+ },
1075
+ "&-placeholder": {
1076
+ ...me,
1077
+ backgroundColor: e.colorBgContainerDisabled,
1078
+ backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
1079
+ backgroundRepeat: "no-repeat",
1080
+ backgroundPosition: "center center",
1081
+ backgroundSize: "30%"
1348
1082
  }
1349
1083
  },
1350
- "&-placeholder": {
1351
- ...me,
1352
- backgroundColor: e.colorBgContainerDisabled,
1353
- backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
1354
- backgroundRepeat: "no-repeat",
1355
- backgroundPosition: "center center",
1356
- backgroundSize: "30%"
1357
- },
1358
- "&-error": {
1084
+ [`${e.componentCls}-error`]: {
1359
1085
  ...me,
1360
1086
  display: "flex",
1361
1087
  alignItems: "center",
1362
- justifyContent: "center",
1363
- color: e.colorText,
1364
- backgroundColor: e.colorBgContainerDisabled
1088
+ justifyContent: "center"
1089
+ },
1090
+ [`${e.componentCls}-placeholder`]: {
1091
+ ...qt()
1092
+ },
1093
+ [`${e.componentCls}-mask`]: {
1094
+ ...Vt(e)
1365
1095
  },
1366
- "&-preview": Ft()
1096
+ [`${e.componentCls}-mask:hover`]: {
1097
+ opacity: 1
1098
+ }
1367
1099
  }
1368
- }), Ht = (e) => e && e.nodeType === Node.ELEMENT_NODE;
1369
- let $e = "";
1370
- const jt = [...Ke, "fallback", "placeholder"], le = /* @__PURE__ */ ye({
1371
- props: je,
1100
+ }), Qt = (e) => typeof Element > "u" ? !1 : e instanceof Element;
1101
+ let Ee = "";
1102
+ const Jt = [..._e, "placeholder", "fallback"], re = /* @__PURE__ */ Se({
1103
+ props: We,
1372
1104
  name: "GImage",
1373
- emits: ["error", "click", "load"],
1105
+ inheritAttrs: !1,
1106
+ emits: {
1107
+ click: () => !0,
1108
+ load: (e) => !0,
1109
+ error: (e) => !0
1110
+ },
1374
1111
  slots: Object,
1375
1112
  setup(e, {
1376
- slots: t,
1377
- emit: i,
1113
+ slots: n,
1114
+ emit: o,
1378
1115
  attrs: l
1379
1116
  }) {
1380
- const o = Ue({
1117
+ const t = Q && "loading" in HTMLImageElement.prototype, r = Re({
1381
1118
  suffixCls: "image"
1382
1119
  }), {
1383
- wrapSSR: f,
1384
- hashId: c
1385
- } = st("Image", [Bt], o), d = N(), E = N(""), g = N(!1), h = N(!0), C = N(!1), v = N(null), u = N();
1386
- let M, w;
1387
- const O = y(() => !ie && e.fit ? {
1388
- "object-fit": e.fit
1389
- } : {}), p = y(() => {
1120
+ wrapSSR: c,
1121
+ hashId: h
1122
+ } = St("Image", [Kt], r), y = L(), d = L(), v = L(!1), m = L(!0), w = L(!1), x = L(), a = L();
1123
+ let i, p;
1124
+ const g = b(() => e.loading === "eager" ? !1 : !t && e.loading === "lazy" || e.lazy), S = b(() => Q && e.fit ? {
1125
+ ...e.imageStyle,
1126
+ objectFit: e.fit
1127
+ } : e.imageStyle), C = b(() => typeof e.preview == "object" ? e.preview : {}), $ = b(() => !!e.preview), T = b(() => {
1390
1128
  const {
1391
- previewUrls: s
1392
- } = e.preview;
1393
- return _e(s) && s.length > 0 || e.showPreview;
1394
- }), L = y(() => {
1395
- const {
1396
- previewUrls: s = [],
1397
- current: S = 0
1398
- } = e.preview;
1399
- if (Ee(S)) return s.length >= S ? S : 0;
1400
- const x = s.indexOf(e.src);
1401
- return x >= 0 ? x : 0;
1402
- }), K = (s) => {
1403
- E.value = e.src, h.value = !1, g.value = !1, i("load", s);
1404
- }, P = (s) => {
1405
- h.value = !1, g.value = !0, i("error", s);
1406
- }, A = () => {
1407
- if (ie) return;
1408
- h.value = !0, g.value = !1;
1409
- const s = new Image();
1410
- s.onload = (S) => K(S), s.onerror = P, Object.keys(l || {}).forEach((S) => {
1411
- if (S.toLowerCase() === "onload") return;
1412
- const x = (l || {})[S];
1413
- s.setAttribute(S, x);
1414
- }), s.src = e.src;
1415
- }, R = mt(Q, 200), z = () => {
1416
- ie || !u.value || !R || (M(), u.value = void 0);
1129
+ urls: f = [],
1130
+ current: A = 0
1131
+ } = C.value;
1132
+ if (Ne(A)) return f.length >= A ? A : 0;
1133
+ const E = f.indexOf(e.src);
1134
+ return E >= 0 ? E : 0;
1135
+ }), O = b(() => ee(e.width)), I = b(() => ee(e.height)), F = () => {
1136
+ Q && (m.value = !0, v.value = !1, d.value = e.src);
1417
1137
  };
1418
- function Q() {
1419
- ut(v.value, u.value) && (A(), z());
1138
+ function W(f) {
1139
+ v.value || (m.value = !1, v.value = !1, o("load", f));
1140
+ }
1141
+ function N(f) {
1142
+ m.value = !1, v.value = !0, o("error", f);
1143
+ }
1144
+ function M() {
1145
+ It(x.value, a.value) && (F(), _());
1420
1146
  }
1421
- const U = async () => {
1422
- if (ie) return;
1423
- await ot();
1147
+ const P = zt(M, 200, !0);
1148
+ async function Y() {
1149
+ if (!Q) return;
1150
+ await st();
1424
1151
  const {
1425
- scrollContainer: s
1152
+ scrollContainer: f
1426
1153
  } = e;
1427
- Ht(s) ? u.value = s : ft(s) && s !== "" ? u.value = document.querySelector(s) ?? void 0 : v.value && (u.value = vt(v.value)), u.value && (M = Le(u, "scroll", R), setTimeout(() => Q(), 200));
1428
- }, W = (s) => {
1429
- if (s.ctrlKey) {
1430
- if (s.deltaY < 0)
1431
- return s.preventDefault(), !1;
1432
- if (s.deltaY > 0)
1433
- return s.preventDefault(), !1;
1154
+ Qt(f) ? a.value = f : bt(f) && f !== "" ? a.value = document.querySelector(f) ?? void 0 : x.value && (a.value = $t(x.value)), a.value && (i = Le(a, "scroll", P), setTimeout(() => M(), 100));
1155
+ }
1156
+ function _() {
1157
+ !Q || !a.value || !P || (i == null || i(), a.value = void 0);
1158
+ }
1159
+ function j(f) {
1160
+ if (f.ctrlKey) {
1161
+ if (f.deltaY < 0)
1162
+ return f.preventDefault(), !1;
1163
+ if (f.deltaY > 0)
1164
+ return f.preventDefault(), !1;
1434
1165
  }
1435
- }, b = () => {
1436
- p.value && (w = Le("wheel", W, {
1166
+ }
1167
+ const B = () => {
1168
+ o("click"), !(m.value || v.value) && $.value && (p = Le("wheel", j, {
1437
1169
  passive: !1
1438
- }), $e = document.body.style.overflow, document.body.style.overflow = "hidden", C.value = !0);
1439
- }, k = () => {
1440
- w == null || w(), document.body.style.overflow = $e, C.value = !1;
1170
+ }), Ee = document.body.style.overflow, document.body.style.overflow = "hidden", w.value = !0);
1171
+ }, D = () => {
1172
+ p == null || p(), document.body.style.overflow = Ee, w.value = !1;
1441
1173
  };
1442
- H(() => e.src, () => {
1443
- e.lazy ? (h.value = !0, g.value = !1, z(), U()) : A();
1444
- }), tt(() => {
1445
- var s, S;
1446
- p.value && C.value ? (s = d.value) == null || s.setOpen(!0) : (S = d.value) == null || S.setOpen(!1);
1447
- });
1448
- const G = (s) => Ee(s) ? s + "px" : s;
1449
- return it(() => {
1450
- e.lazy ? U() : A();
1174
+ return J(() => e.src, () => {
1175
+ g.value ? (m.value = !0, v.value = !1, _(), Y()) : F();
1176
+ }), rt(() => {
1177
+ var f, A;
1178
+ $.value && w.value ? (f = y.value) == null || f.setOpen(!0) : (A = y.value) == null || A.setOpen(!1);
1179
+ }), De(() => {
1180
+ g.value ? Y() : F();
1451
1181
  }), () => {
1452
- var X;
1453
- const {
1454
- crossorigin: s,
1455
- decoding: S,
1456
- alt: x,
1457
- sizes: se,
1458
- srcset: ce,
1459
- usemap: ue,
1460
- class: q,
1461
- style: J = {}
1462
- } = l, ee = {
1463
- crossorigin: s,
1464
- decoding: S,
1465
- alt: x,
1466
- sizes: se,
1467
- srcset: ce,
1468
- usemap: ue,
1469
- style: {
1470
- ...O.value,
1471
- height: e.height ? G(e.height) : void 0
1472
- }
1473
- }, _ = dt(jt, t, e, {
1182
+ var G;
1183
+ const f = Mt(Object.entries(l).filter(([oe]) => /^(?:data-|on[A-Z])/i.test(oe) || ["id", "style", "class"].includes(oe))), A = Ye(l, Object.keys(f)), E = xt(Jt, n, e, {
1474
1184
  render: !0
1475
- });
1476
- return f(r("div", {
1185
+ }), de = Pe(n, e, ["preview", "mask"], !0);
1186
+ return c(u("div", le({
1477
1187
  class: {
1478
- [`${c.value}`]: !0,
1479
- [`${o}`]: !0,
1480
- [`${q}`]: !!q
1188
+ [`${h.value}`]: !0,
1189
+ [`${r}`]: !0
1481
1190
  },
1482
- ref: (de) => v.value = de,
1191
+ ref: x
1192
+ }, f, {
1483
1193
  style: {
1484
- width: e.width ? G(e.width) : void 0,
1485
- height: e.height ? G(e.height) : void 0,
1486
- display: e.lazy ? "block" : void 0,
1487
- ...J
1488
- },
1489
- onClick: () => {
1490
- i("click");
1194
+ width: ee(e.size) || O.value,
1195
+ height: ee(e.size) || I.value,
1196
+ ...f.style || {}
1491
1197
  }
1492
- }, [h.value ? _.placeholder || r("div", {
1493
- class: `${o}-placeholder ${c.value}`
1494
- }, null) : g.value ? _.fallback || r("div", {
1495
- class: `${o}-error ${c.value}`
1496
- }, [nt("加载失败")]) : E.value && r("img", pe(ee, {
1497
- class: {
1498
- [`${c.value}`]: !0,
1499
- [`${e.imageClassName}`]: !!e.imageClassName,
1500
- [`${o}-inner`]: !0,
1501
- [`${o}-inner-preview`]: p.value
1502
- },
1503
- alt: e.alt,
1504
- src: E.value
1505
- }), null), p.value && r("div", {
1506
- class: `${o}-preview ${c.value}`,
1507
- onClick: () => b()
1508
- }, null), p.value && r(_t, pe({
1509
- ref: d
1510
- }, e.preview, wt(_, Ke), {
1511
- previewUrls: ((X = e.preview) == null ? void 0 : X.previewUrls) || [e.src],
1512
- current: L.value,
1513
- onClose: () => k()
1198
+ }), [v.value ? u("div", {
1199
+ class: X(h.value, `${r}-error`)
1200
+ }, [E.fallback]) : u(se, null, [u("img", le(A, {
1201
+ src: d.value,
1202
+ loading: e.loading,
1203
+ style: S.value,
1204
+ class: X(h.value, e.imageClass, `${r}-img`, {
1205
+ [`${r}-img-placeholder`]: e.placeholder === !0,
1206
+ [`${r}-img-preview`]: $.value
1207
+ }),
1208
+ crossorigin: e.crossOrigin,
1209
+ width: O.value,
1210
+ height: I.value,
1211
+ onClick: B,
1212
+ onLoad: W,
1213
+ onError: N
1214
+ }), null), m.value && u("div", {
1215
+ class: X(`${r}-placeholder`, h.value)
1216
+ }, [E.placeholder])]), C.value.mask && $.value && u("div", {
1217
+ class: X(`${r}-mask`, C.value.maskClass, h.value),
1218
+ style: {
1219
+ display: ((G = f.style) == null ? void 0 : G.display) === "none" ? "none" : void 0
1220
+ }
1221
+ }, [de || u("div", {
1222
+ class: X(`${r}-mask-info`, h.value)
1223
+ }, [u(ht, null, null)])]), $.value && u(Gt, le({
1224
+ ref: y
1225
+ }, C.value, At(E, _e), {
1226
+ urls: C.value.urls || [e.src],
1227
+ current: T.value,
1228
+ onClose: () => D()
1514
1229
  }), null)]));
1515
1230
  };
1516
1231
  }
1517
1232
  });
1518
- le.isGImage = !0;
1519
- le.install = (e) => (e.component(le.name, le), e);
1233
+ re.isGImage = !0;
1234
+ re.install = (e) => (e.component(re.name, re), e);
1520
1235
  export {
1521
- le as GImage,
1522
- _t as GImagePreview,
1523
- V as baseProps,
1524
- le as default,
1525
- je as imageProps
1236
+ re as GImage,
1237
+ Gt as GImagePreview,
1238
+ te as baseProps,
1239
+ re as default,
1240
+ We as imageProps
1526
1241
  };