easy-component-ui 3.0.11 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -162
- package/dist/assets/icon.css +1 -1
- package/dist/components/Base.js +190 -188
- package/dist/components/ea-alert.js +71 -54
- package/dist/components/ea-avatar.js +42 -37
- package/dist/components/ea-breadcrumb.js +33 -33
- package/dist/components/ea-button.js +53 -52
- package/dist/components/ea-card.js +63 -27
- package/dist/components/ea-carousel.js +2 -2
- package/dist/components/ea-collapse.js +93 -73
- package/dist/components/ea-color-picker.js +221 -221
- package/dist/components/ea-container.js +90 -61
- package/dist/components/ea-countdown.js +77 -56
- package/dist/components/ea-date-picker.js +1 -1
- package/dist/components/ea-descriptions.js +133 -70
- package/dist/components/ea-dialog.js +4 -4
- package/dist/components/ea-drawer.js +93 -71
- package/dist/components/ea-empty.js +31 -23
- package/dist/components/ea-icon.js +122 -32
- package/dist/components/ea-image-preview.js +237 -193
- package/dist/components/ea-image.js +69 -44
- package/dist/components/ea-input-number.js +9 -9
- package/dist/components/ea-input.js +15 -15
- package/dist/components/ea-layout.js +10 -3
- package/dist/components/ea-link.js +1 -1
- package/dist/components/ea-menu.js +69 -53
- package/dist/components/ea-message-box.js +73 -73
- package/dist/components/ea-message.js +184 -121
- package/dist/components/ea-notification.js +80 -80
- package/dist/components/ea-overlay.js +41 -34
- package/dist/components/ea-page-header.js +5 -5
- package/dist/components/ea-pagination.js +6 -5
- package/dist/components/ea-popconfirm.js +133 -78
- package/dist/components/ea-popover.js +35 -11
- package/dist/components/ea-popper.js +9 -9
- package/dist/components/ea-progress.js +88 -71
- package/dist/components/ea-rate.js +1 -1
- package/dist/components/ea-result.js +20 -20
- package/dist/components/ea-select.js +119 -108
- package/dist/components/ea-skeleton.js +99 -82
- package/dist/components/ea-slider.js +88 -79
- package/dist/components/ea-splitter.js +34 -18
- package/dist/components/ea-statistic.js +72 -4
- package/dist/components/ea-steps.js +108 -74
- package/dist/components/ea-table.js +562 -434
- package/dist/components/ea-tabs.js +28 -28
- package/dist/components/ea-tag.js +37 -43
- package/dist/components/ea-time-picker.js +2 -6
- package/dist/components/ea-timeline.js +11 -12
- package/dist/components/ea-tooltip.js +63 -23
- package/dist/components/ea-tour.js +21 -21
- package/dist/components/ea-transfer.js +2 -2
- package/dist/components/ea-tree.js +1 -1
- package/dist/components/index.js +1 -2
- package/dist/css/ea-card.style.js +2 -2
- package/dist/css/ea-collapse-item.style.js +1 -1
- package/dist/css/ea-color-picker-panel.style.js +1 -1
- package/dist/css/ea-container.style.js +1 -1
- package/dist/css/ea-descriptions-item.style.js +2 -2
- package/dist/css/ea-descriptions.style.js +1 -1
- package/dist/css/ea-empty.style.js +1 -1
- package/dist/css/ea-footer.style.js +1 -1
- package/dist/css/ea-progress.style.js +1 -1
- package/dist/css/ea-skeleton.style.js +1 -1
- package/dist/css/ea-step.style.js +1 -1
- package/dist/css/ea-switch.style.js +1 -1
- package/dist/css/ea-tab.style.js +1 -1
- package/dist/css/ea-table-column.style.js +4 -0
- package/dist/css/ea-table.style.js +1 -1
- package/dist/css/ea-tabs.style.js +1 -1
- package/dist/css/ea-tag.style.js +1 -1
- package/dist/css/ea-time-picker.style.js +1 -1
- package/dist/css/ea-timeline-item.style.js +1 -1
- package/dist/utils/Variables.js +10 -17
- package/dist/utils/parseTime.js +73 -0
- package/package.json +302 -304
- package/dist/components/ea-loading.js +0 -151
- package/dist/components/ea-statistic2.js +0 -83
|
@@ -1,57 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var H = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var L = (
|
|
7
|
-
var e = (
|
|
8
|
-
import { EaOverlay as
|
|
9
|
-
import { E as
|
|
5
|
+
var G = (r, n, t) => n in r ? Z(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
|
|
6
|
+
var L = (r, n, t) => G(r, typeof n != "symbol" ? n + "" : n, t), j = (r, n, t) => n.has(r) || H("Cannot " + t);
|
|
7
|
+
var e = (r, n, t) => (j(r, n, "read from private field"), t ? t.call(r) : n.get(r)), o = (r, n, t) => n.has(r) ? H("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(r) : n.set(r, t), g = (r, n, t, s) => (j(r, n, "write to private field"), s ? s.call(r, t) : n.set(r, t), t);
|
|
8
|
+
import { EaOverlay as J } from "./ea-overlay.js";
|
|
9
|
+
import { E as K } from "../utils/Utils.js";
|
|
10
10
|
import "./ea-image.js";
|
|
11
|
-
import { s as
|
|
12
|
-
var
|
|
13
|
-
class
|
|
11
|
+
import { s as Q } from "../css/ea-image-preview.style.js";
|
|
12
|
+
var v, U, k, S, q, d, Y, C, I, z, R, A, M, N, P, i, c, O, E, _, x, X, $, B, D, T;
|
|
13
|
+
class W extends J {
|
|
14
14
|
constructor() {
|
|
15
15
|
super();
|
|
16
16
|
/** @type {HTMLElement} */
|
|
17
|
-
|
|
17
|
+
o(this, v);
|
|
18
18
|
/** @type {HTMLElement} */
|
|
19
|
-
|
|
19
|
+
o(this, U);
|
|
20
20
|
/** @type {HTMLElement} */
|
|
21
|
-
|
|
21
|
+
o(this, k);
|
|
22
22
|
/** @type {HTMLElement} */
|
|
23
|
-
|
|
23
|
+
o(this, S);
|
|
24
24
|
/** @type {HTMLElement} */
|
|
25
|
-
|
|
25
|
+
o(this, q);
|
|
26
26
|
/** @type {HTMLElement} */
|
|
27
|
-
|
|
27
|
+
o(this, d);
|
|
28
28
|
/** @type {HTMLElement} */
|
|
29
|
-
|
|
29
|
+
o(this, Y);
|
|
30
30
|
/** @type {HTMLElement} */
|
|
31
|
-
|
|
31
|
+
o(this, C);
|
|
32
32
|
/** @type {HTMLElement} */
|
|
33
|
-
|
|
33
|
+
o(this, I);
|
|
34
34
|
/** @type {HTMLElement} */
|
|
35
|
-
|
|
35
|
+
o(this, z);
|
|
36
36
|
/** @type {HTMLElement} */
|
|
37
|
-
|
|
37
|
+
o(this, R);
|
|
38
38
|
/** @type {HTMLElement} */
|
|
39
|
-
|
|
39
|
+
o(this, A);
|
|
40
40
|
/** @type {HTMLElement} */
|
|
41
|
-
|
|
41
|
+
o(this, M);
|
|
42
42
|
/** @type {HTMLElement} */
|
|
43
|
-
|
|
43
|
+
o(this, N);
|
|
44
44
|
/** @type {HTMLElement} */
|
|
45
|
-
|
|
45
|
+
o(this, P);
|
|
46
46
|
/** @type {AbortController} */
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
o(this, i, {
|
|
48
|
+
/** @type {AbortController | null} */
|
|
49
|
+
main: null,
|
|
50
|
+
/** @type {AbortController | null} */
|
|
51
|
+
img: null,
|
|
52
|
+
/** @type {AbortController | null} */
|
|
53
|
+
clickModal: null,
|
|
54
|
+
/** @type {AbortController | null} */
|
|
55
|
+
imgMove: null,
|
|
56
|
+
/** @type {AbortController | null} */
|
|
57
|
+
toolbar: null,
|
|
58
|
+
/** @type {AbortController | null} */
|
|
59
|
+
switchPrev: null,
|
|
60
|
+
/** @type {AbortController | null} */
|
|
61
|
+
switchNext: null,
|
|
62
|
+
/** @type {AbortController | null} */
|
|
63
|
+
zoomOut: null,
|
|
64
|
+
/** @type {AbortController | null} */
|
|
65
|
+
zoomIn: null,
|
|
66
|
+
/** @type {AbortController | null} */
|
|
67
|
+
rotateLeft: null,
|
|
68
|
+
/** @type {AbortController | null} */
|
|
69
|
+
rotateRight: null
|
|
70
|
+
});
|
|
71
|
+
o(this, c, {
|
|
55
72
|
urlList: [],
|
|
56
73
|
/** @type {"loading" | "success" | "error"} */
|
|
57
74
|
status: "loading",
|
|
@@ -67,7 +84,9 @@ class ee extends Q {
|
|
|
67
84
|
type: Boolean,
|
|
68
85
|
default: !1,
|
|
69
86
|
observer: (t) => {
|
|
70
|
-
this.status = t
|
|
87
|
+
this.status = t, t && this.urlList.length > 0 && (e(this, d).querySelector(
|
|
88
|
+
".ea-image-preview__img"
|
|
89
|
+
) || e(this, T).call(this, this.index));
|
|
71
90
|
}
|
|
72
91
|
},
|
|
73
92
|
"initial-index": {
|
|
@@ -80,54 +99,16 @@ class ee extends Q {
|
|
|
80
99
|
index: {
|
|
81
100
|
type: Number,
|
|
82
101
|
default: () => this["initial-index"],
|
|
83
|
-
observer: (t,
|
|
84
|
-
|
|
85
|
-
if (e(this, n).dirtyUpdate) return e(this, n).dirtyUpdate = !1;
|
|
102
|
+
observer: (t, s) => {
|
|
103
|
+
if (e(this, c).dirtyUpdate) return e(this, c).dirtyUpdate = !1;
|
|
86
104
|
if (this.infinite) {
|
|
87
105
|
if (!this.urlList.length) return;
|
|
88
|
-
const
|
|
89
|
-
if (t >
|
|
90
|
-
if (t < 0) return this.index =
|
|
91
|
-
} else if (t < 0 || t >
|
|
92
|
-
return e(this,
|
|
93
|
-
|
|
94
|
-
if (e(this, d).innerHTML = "", o) {
|
|
95
|
-
(s = e(this, v)) == null || s.abort(), h(this, v, new AbortController()), e(this, d).innerHTML = W.EaElement.h(
|
|
96
|
-
"ea-image",
|
|
97
|
-
"ea-image-preview__img",
|
|
98
|
-
{
|
|
99
|
-
src: o,
|
|
100
|
-
fit: "contain"
|
|
101
|
-
},
|
|
102
|
-
`
|
|
103
|
-
<slot name="viewer-error" slot="error"></slot>
|
|
104
|
-
`
|
|
105
|
-
);
|
|
106
|
-
const r = e(this, d).querySelector(".ea-image-preview__img"), g = () => {
|
|
107
|
-
e(this, n).status = "error", this.classList.remove(
|
|
108
|
-
"ea-image-preview--success",
|
|
109
|
-
"ea-image-preview--loading"
|
|
110
|
-
), e(this, m).classList.add("ea-image-preview--error"), this.emit("error"), e(this, v).abort();
|
|
111
|
-
}, u = () => {
|
|
112
|
-
e(this, n).status = "success", e(this, m).classList.remove(
|
|
113
|
-
"ea-image-preview--error",
|
|
114
|
-
"ea-image-preview--loading"
|
|
115
|
-
), e(this, m).classList.add("ea-image-preview--success"), e(this, v).abort();
|
|
116
|
-
};
|
|
117
|
-
e(this, $).call(this, t + 1, e(this, n).urlList.length), r.addEventListener("error", g, {
|
|
118
|
-
once: !0,
|
|
119
|
-
signal: e(this, v).signal
|
|
120
|
-
}), r.addEventListener("load", u, {
|
|
121
|
-
once: !0,
|
|
122
|
-
signal: e(this, v).signal
|
|
123
|
-
}), this.visible && e(this, n).isUrlListInit && this.emit("switch", {
|
|
124
|
-
detail: {
|
|
125
|
-
index: t,
|
|
126
|
-
url: o,
|
|
127
|
-
imgTarget: r
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
106
|
+
const a = this.urlList.length - 1;
|
|
107
|
+
if (t > a) return this.index = 0;
|
|
108
|
+
if (t < 0) return this.index = a;
|
|
109
|
+
} else if (t < 0 || t > this.urlList.length - 1)
|
|
110
|
+
return e(this, c).dirtyUpdate = !0, this.index = s;
|
|
111
|
+
e(this, T).call(this, t);
|
|
131
112
|
}
|
|
132
113
|
},
|
|
133
114
|
infinite: {
|
|
@@ -157,9 +138,9 @@ class ee extends Q {
|
|
|
157
138
|
scale: {
|
|
158
139
|
type: Number,
|
|
159
140
|
default: 1,
|
|
160
|
-
observer: (t,
|
|
141
|
+
observer: (t, s) => {
|
|
161
142
|
if (t < this["min-scale"] || t > this["max-scale"])
|
|
162
|
-
return this.scale =
|
|
143
|
+
return this.scale = s;
|
|
163
144
|
e(this, d).style.setProperty("--ea-image-preview-scale", t);
|
|
164
145
|
}
|
|
165
146
|
},
|
|
@@ -192,12 +173,12 @@ class ee extends Q {
|
|
|
192
173
|
type: Boolean,
|
|
193
174
|
default: !1,
|
|
194
175
|
observer: (t) => {
|
|
195
|
-
var
|
|
196
|
-
const
|
|
197
|
-
!e(this, d).querySelector(".ea-image-preview__img").contains(
|
|
176
|
+
var a;
|
|
177
|
+
const s = (l) => {
|
|
178
|
+
!e(this, d).querySelector(".ea-image-preview__img").contains(l.target) && !e(this, k).contains(l.target) && !e(this, S).contains(l.target) && !e(this, q).contains(l.target) && (this.hide(), this.visible = !1);
|
|
198
179
|
};
|
|
199
|
-
(
|
|
200
|
-
signal: e(this,
|
|
180
|
+
(a = e(this, i).clickModal) == null || a.abort(), t && (e(this, i).clickModal = new AbortController(), e(this, v).addEventListener("click", s, {
|
|
181
|
+
signal: e(this, i).clickModal.signal
|
|
201
182
|
}));
|
|
202
183
|
}
|
|
203
184
|
}
|
|
@@ -209,46 +190,46 @@ class ee extends Q {
|
|
|
209
190
|
default: [],
|
|
210
191
|
/** @param {String[]} newVal */
|
|
211
192
|
observer: (t) => {
|
|
212
|
-
e(this,
|
|
193
|
+
e(this, c).isUrlListInit = !1, e(this, c).urlList = t, this.index = this["initial-index"], e(this, c).isUrlListInit = !0;
|
|
213
194
|
}
|
|
214
195
|
}
|
|
215
196
|
}));
|
|
216
197
|
/**
|
|
217
198
|
* 处理挂载到目标
|
|
218
199
|
*/
|
|
219
|
-
|
|
200
|
+
o(this, O, () => {
|
|
220
201
|
this["append-to-body"] && document.body.appendChild(this);
|
|
221
202
|
});
|
|
222
203
|
/**
|
|
223
204
|
* 处理切换
|
|
224
205
|
* @param {'prev' | 'next'} action
|
|
225
206
|
*/
|
|
226
|
-
|
|
207
|
+
o(this, E, (t) => {
|
|
227
208
|
t === "prev" ? this.index-- : t === "next" && this.index++;
|
|
228
209
|
});
|
|
229
210
|
/**
|
|
230
211
|
* 处理缩放
|
|
231
212
|
* @param {'in' | 'out'} action
|
|
232
213
|
*/
|
|
233
|
-
|
|
214
|
+
o(this, _, (t) => {
|
|
234
215
|
t === "in" ? this.scale = (this.scale * this["zoom-rate"]).toFixed(3) : t === "out" && (this.scale = (this.scale / this["zoom-rate"]).toFixed(3));
|
|
235
216
|
});
|
|
236
217
|
/**
|
|
237
218
|
* 处理旋转
|
|
238
219
|
* @param {'left' | 'right' | 'reset'} action
|
|
239
220
|
*/
|
|
240
|
-
|
|
241
|
-
const
|
|
221
|
+
o(this, x, (t) => {
|
|
222
|
+
const s = Number(
|
|
242
223
|
e(this, d).style.getPropertyValue("--ea-image-preview-rotate").split("deg")[0] || 0
|
|
243
224
|
);
|
|
244
|
-
let
|
|
245
|
-
t === "left" ?
|
|
225
|
+
let a = 0;
|
|
226
|
+
t === "left" ? a = s - 90 : t === "right" && (a = s + 90), e(this, d).style.setProperty(
|
|
246
227
|
"--ea-image-preview-rotate",
|
|
247
|
-
|
|
228
|
+
a + "deg"
|
|
248
229
|
), this.emit("rotate", {
|
|
249
230
|
detail: {
|
|
250
|
-
oldVal:
|
|
251
|
-
rotate:
|
|
231
|
+
oldVal: s,
|
|
232
|
+
rotate: a
|
|
252
233
|
}
|
|
253
234
|
});
|
|
254
235
|
});
|
|
@@ -258,118 +239,135 @@ class ee extends Q {
|
|
|
258
239
|
* @param {Number} total
|
|
259
240
|
* @returns
|
|
260
241
|
*/
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
242
|
+
o(this, X, (t, s) => {
|
|
243
|
+
const a = this.querySelector("[slot='progress']"), l = (h, p) => {
|
|
244
|
+
h.forEach((u) => u.textContent = t), p.forEach((u) => u.textContent = s);
|
|
264
245
|
};
|
|
265
|
-
if (
|
|
246
|
+
if (a)
|
|
266
247
|
try {
|
|
267
|
-
|
|
268
|
-
const u =
|
|
269
|
-
|
|
248
|
+
a.assignedNodes().forEach((p) => {
|
|
249
|
+
const u = p.querySelectorAll("[data-active]"), w = p.querySelectorAll("[data-total]");
|
|
250
|
+
l(u, w);
|
|
270
251
|
});
|
|
271
252
|
} catch {
|
|
272
|
-
const
|
|
273
|
-
|
|
253
|
+
const h = a.querySelectorAll("[data-active]"), p = a.querySelectorAll("[data-total]");
|
|
254
|
+
l(h, p);
|
|
274
255
|
}
|
|
275
256
|
else
|
|
276
|
-
e(this,
|
|
257
|
+
e(this, R).textContent = `${t} / ${s}`;
|
|
277
258
|
});
|
|
278
259
|
/**
|
|
279
260
|
* 处理图片移动事件
|
|
280
261
|
* @param {MouseEvent} startE
|
|
281
262
|
*/
|
|
282
|
-
|
|
283
|
-
var
|
|
284
|
-
t.preventDefault(), (
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const
|
|
263
|
+
o(this, $, (t) => {
|
|
264
|
+
var w;
|
|
265
|
+
t.preventDefault(), (w = e(this, i).imgMove) == null || w.abort(), e(this, i).imgMove = new AbortController();
|
|
266
|
+
const s = t.clientX, a = t.clientY, l = e(this, c).position.x, h = e(this, c).position.y, p = (m) => {
|
|
267
|
+
m.preventDefault();
|
|
268
|
+
const f = m.clientX - s, y = m.clientY - a, b = l + f, F = h + y;
|
|
288
269
|
e(this, d).style.setProperty(
|
|
289
270
|
"--ea-image-preview-img-move-x",
|
|
290
|
-
`${
|
|
271
|
+
`${b}px`
|
|
291
272
|
), e(this, d).style.setProperty(
|
|
292
273
|
"--ea-image-preview-img-move-y",
|
|
293
|
-
`${
|
|
274
|
+
`${F}px`
|
|
294
275
|
);
|
|
295
|
-
}, u = (
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
const
|
|
299
|
-
e(this,
|
|
276
|
+
}, u = (m) => {
|
|
277
|
+
var b;
|
|
278
|
+
m.preventDefault();
|
|
279
|
+
const f = m.clientX - s, y = m.clientY - a;
|
|
280
|
+
e(this, c).position.x = l + f, e(this, c).position.y = h + y, (b = e(this, i).imgMove) == null || b.abort();
|
|
300
281
|
};
|
|
301
|
-
window.addEventListener("mousemove",
|
|
302
|
-
signal: e(this,
|
|
282
|
+
window.addEventListener("mousemove", p, {
|
|
283
|
+
signal: e(this, i).imgMove.signal
|
|
303
284
|
}), window.addEventListener("mouseup", u, {
|
|
304
|
-
signal: e(this,
|
|
285
|
+
signal: e(this, i).imgMove.signal
|
|
305
286
|
});
|
|
306
287
|
});
|
|
307
288
|
/**
|
|
308
289
|
* 初始化工具栏的事件。
|
|
309
290
|
* 若用户传入了自定义工具,则优先使用用户元素,否则使用内置元素
|
|
310
291
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
292
|
+
o(this, B, () => {
|
|
293
|
+
var p;
|
|
294
|
+
let t = this.shadowRoot.querySelector("slot[name='toolbar']");
|
|
295
|
+
const s = this.closest(".ea-image-preview");
|
|
296
|
+
s && (t = s.querySelector("slot[name='toolbar']"));
|
|
297
|
+
for (const u in e(this, i))
|
|
298
|
+
(p = e(this, i)[u]) == null || p.abort(), e(this, i)[u] = new AbortController();
|
|
299
|
+
const a = {
|
|
300
|
+
"switch-prev": e(this, i).switchPrev,
|
|
301
|
+
"switch-next": e(this, i).switchNext,
|
|
302
|
+
"zoom-out": e(this, i).zoomOut,
|
|
303
|
+
"zoom-in": e(this, i).zoomIn,
|
|
304
|
+
"rotate-anticlockwise": e(this, i).rotateLeft,
|
|
305
|
+
"rotate-clockwise": e(this, i).rotateRight
|
|
306
|
+
}, l = {
|
|
313
307
|
"switch-prev": {
|
|
314
308
|
el: null,
|
|
315
309
|
callback: () => {
|
|
316
|
-
e(this,
|
|
310
|
+
e(this, E).call(this, "prev");
|
|
317
311
|
}
|
|
318
312
|
},
|
|
319
313
|
"switch-next": {
|
|
320
314
|
el: null,
|
|
321
315
|
callback: () => {
|
|
322
|
-
e(this,
|
|
316
|
+
e(this, E).call(this, "next");
|
|
323
317
|
}
|
|
324
318
|
},
|
|
325
319
|
"zoom-out": {
|
|
326
|
-
el: e(this,
|
|
320
|
+
el: e(this, M),
|
|
327
321
|
callback: () => {
|
|
328
322
|
e(this, _).call(this, "out");
|
|
329
323
|
}
|
|
330
324
|
},
|
|
331
325
|
"zoom-in": {
|
|
332
|
-
el: e(this,
|
|
326
|
+
el: e(this, A),
|
|
333
327
|
callback: () => {
|
|
334
328
|
e(this, _).call(this, "in");
|
|
335
329
|
}
|
|
336
330
|
},
|
|
337
331
|
"rotate-anticlockwise": {
|
|
338
|
-
el: e(this,
|
|
332
|
+
el: e(this, N),
|
|
339
333
|
callback: () => {
|
|
340
|
-
e(this,
|
|
334
|
+
e(this, x).call(this, "left");
|
|
341
335
|
}
|
|
342
336
|
},
|
|
343
337
|
"rotate-clockwise": {
|
|
344
|
-
el: e(this,
|
|
338
|
+
el: e(this, P),
|
|
345
339
|
callback: () => {
|
|
346
|
-
e(this,
|
|
340
|
+
e(this, x).call(this, "right");
|
|
347
341
|
}
|
|
348
342
|
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
343
|
+
}, h = () => {
|
|
344
|
+
Object.values(l).forEach((m) => {
|
|
345
|
+
m.el && (m.el.style.display = "");
|
|
346
|
+
});
|
|
347
|
+
const u = t.assignedElements(), w = /* @__PURE__ */ new Map();
|
|
348
|
+
u.forEach((m) => {
|
|
349
|
+
m.nodeType === Node.ELEMENT_NODE && m.querySelectorAll("[data-action]").forEach((y) => {
|
|
350
|
+
const b = y.getAttribute("data-action");
|
|
351
|
+
b && !w.has(b) && w.set(b, y);
|
|
358
352
|
});
|
|
359
|
-
} catch {
|
|
360
|
-
s.el && (r = !0, s.el.addEventListener("click", s.callback, {
|
|
361
|
-
signal: e(this, p).signal
|
|
362
|
-
}));
|
|
363
|
-
}
|
|
364
|
-
!r && s.el && s.el.addEventListener("click", s.callback, {
|
|
365
|
-
signal: e(this, p).signal
|
|
366
353
|
});
|
|
367
|
-
|
|
354
|
+
for (const [m, f] of Object.entries(l)) {
|
|
355
|
+
const y = w.get(m);
|
|
356
|
+
y ? (f.el && (f.el.style.display = "none"), y.addEventListener("click", f.callback, {
|
|
357
|
+
signal: a[m].signal
|
|
358
|
+
})) : f.el && f.el.addEventListener("click", f.callback, {
|
|
359
|
+
signal: a[m].signal
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
t.addEventListener("slotchange", h, {
|
|
364
|
+
signal: e(this, i).toolbar.signal
|
|
365
|
+
}), setTimeout(() => h(), 0);
|
|
368
366
|
});
|
|
369
367
|
/**
|
|
370
368
|
* 关闭 Preview
|
|
371
369
|
*/
|
|
372
|
-
|
|
370
|
+
o(this, D, () => {
|
|
373
371
|
this.hide(), this.visible = !1;
|
|
374
372
|
});
|
|
375
373
|
/**
|
|
@@ -379,38 +377,84 @@ class ee extends Q {
|
|
|
379
377
|
L(this, "setActiveItem", (t) => {
|
|
380
378
|
this.index = t;
|
|
381
379
|
});
|
|
380
|
+
/**
|
|
381
|
+
* 渲染指定索引的图片
|
|
382
|
+
* @param {number} index - 图片索引
|
|
383
|
+
*/
|
|
384
|
+
o(this, T, (t) => {
|
|
385
|
+
var a;
|
|
386
|
+
const s = this.urlList[t];
|
|
387
|
+
if (e(this, d).innerHTML = "", s) {
|
|
388
|
+
(a = e(this, i).img) == null || a.abort(), e(this, i).img = new AbortController(), e(this, d).innerHTML = K.EaElement.h(
|
|
389
|
+
"ea-image",
|
|
390
|
+
"ea-image-preview__img",
|
|
391
|
+
{
|
|
392
|
+
src: s,
|
|
393
|
+
fit: "contain"
|
|
394
|
+
},
|
|
395
|
+
`
|
|
396
|
+
<slot name="viewer-error" slot="error"></slot>
|
|
397
|
+
`
|
|
398
|
+
);
|
|
399
|
+
const l = e(this, d).querySelector(".ea-image-preview__img"), h = () => {
|
|
400
|
+
e(this, c).status = "error", this.classList.remove(
|
|
401
|
+
"ea-image-preview--success",
|
|
402
|
+
"ea-image-preview--loading"
|
|
403
|
+
), e(this, v).classList.add("ea-image-preview--error"), this.emit("error"), e(this, i).img.abort();
|
|
404
|
+
}, p = () => {
|
|
405
|
+
e(this, c).status = "success", e(this, v).classList.remove(
|
|
406
|
+
"ea-image-preview--error",
|
|
407
|
+
"ea-image-preview--loading"
|
|
408
|
+
), e(this, v).classList.add("ea-image-preview--success"), e(this, i).img.abort();
|
|
409
|
+
};
|
|
410
|
+
e(this, X).call(this, t + 1, this.urlList.length), l.addEventListener("error", h, {
|
|
411
|
+
once: !0,
|
|
412
|
+
signal: e(this, i).img.signal
|
|
413
|
+
}), l.addEventListener("load", p, {
|
|
414
|
+
once: !0,
|
|
415
|
+
signal: e(this, i).img.signal
|
|
416
|
+
}), this.visible && e(this, c).isUrlListInit && this.emit("switch", {
|
|
417
|
+
detail: {
|
|
418
|
+
index: t,
|
|
419
|
+
url: s,
|
|
420
|
+
imgTarget: l
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
});
|
|
382
425
|
/**
|
|
383
426
|
* 重置状态
|
|
384
427
|
*/
|
|
385
428
|
L(this, "reset", () => {
|
|
386
|
-
this.index = this["initial-index"], this.scale = 1, e(this,
|
|
429
|
+
this.index = this["initial-index"], this.scale = 1, e(this, x).call(this, "reset"), e(this, c).position = {
|
|
387
430
|
x: 0,
|
|
388
431
|
y: 0
|
|
389
432
|
}, e(this, d).style.setProperty("--ea-image-preview-img-move-x", "0"), e(this, d).style.setProperty("--ea-image-preview-img-move-y", "0");
|
|
390
433
|
});
|
|
391
|
-
|
|
434
|
+
g(this, v, this.shadowRoot.querySelector(".ea-overlay")), e(this, v).innerHTML = e(this, v).innerHTML + `
|
|
392
435
|
<header class="ea-image-preview__header" part="header">
|
|
393
|
-
<ea-icon class="ea-image-preview__icon close-icon"
|
|
436
|
+
<ea-icon class="ea-image-preview__icon close-icon" name="xmark" part="icon close-icon"></ea-icon>
|
|
394
437
|
</header>
|
|
395
438
|
<main class="ea-image-preview__main" part="main">
|
|
396
|
-
<ea-icon class="ea-image-preview__icon prev-icon"
|
|
397
|
-
<ea-icon class="ea-image-preview__icon next-icon"
|
|
439
|
+
<ea-icon class="ea-image-preview__icon prev-icon" name="angle-left" part="icon prev-icon"></ea-icon>
|
|
440
|
+
<ea-icon class="ea-image-preview__icon next-icon" name="angle-right" part="icon next-icon"></ea-icon>
|
|
398
441
|
</main>
|
|
399
442
|
<footer class="ea-image-preview__footer" part="footer">
|
|
400
443
|
<section class="ea-image-preview__progress" part="progress">
|
|
401
444
|
<slot name="progress"></slot>
|
|
402
445
|
</section>
|
|
403
446
|
<section class="ea-image-preview__toolbar" part="toolbar">
|
|
404
|
-
<
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
447
|
+
<slot name="toolbar">
|
|
448
|
+
<ea-icon class="ea-image-preview__icon zoom-out-icon" name="magnifying-glass-minus" part="icon zoom-out-icon"></ea-icon>
|
|
449
|
+
<ea-icon class="ea-image-preview__icon zoom-in-icon" name="magnifying-glass-plus" part="icon zoom-in-icon"></ea-icon>
|
|
450
|
+
<ea-icon class="ea-image-preview__icon rotate-left-icon" name="rotate-left" part="icon rotate-left-icon"></ea-icon>
|
|
451
|
+
<ea-icon class="ea-image-preview__icon rotate-right-icon" name="rotate-right" part="icon rotate-right-icon"></ea-icon>
|
|
452
|
+
</slot>
|
|
409
453
|
</section>
|
|
410
454
|
</footer>
|
|
411
|
-
`,
|
|
455
|
+
`, g(this, U, this.shadowRoot.querySelector(".ea-overlay__content")), g(this, Y, this.shadowRoot.querySelector(".ea-overlay__mask")), g(this, d, this.shadowRoot.querySelector(".ea-overlay__content")), g(this, C, this.shadowRoot.querySelector(".close-icon")), g(this, I, this.shadowRoot.querySelector(".prev-icon")), g(this, z, this.shadowRoot.querySelector(".next-icon")), g(this, A, this.shadowRoot.querySelector(".zoom-in-icon")), g(this, M, this.shadowRoot.querySelector(".zoom-out-icon")), g(this, N, this.shadowRoot.querySelector(".rotate-left-icon")), g(this, P, this.shadowRoot.querySelector(".rotate-right-icon")), g(this, R, this.shadowRoot.querySelector(
|
|
412
456
|
".ea-image-preview__progress slot[name='progress']"
|
|
413
|
-
)),
|
|
457
|
+
)), g(this, k, this.shadowRoot.querySelector(".ea-image-preview__header")), g(this, S, this.shadowRoot.querySelector(".ea-image-preview__main")), g(this, q, this.shadowRoot.querySelector(".ea-image-preview__footer")), e(this, O).call(this);
|
|
414
458
|
}
|
|
415
459
|
static get observedAttributes() {
|
|
416
460
|
return [
|
|
@@ -437,52 +481,52 @@ class ee extends Q {
|
|
|
437
481
|
const t = `${super.updateContainerClasslist()} ${this.computedClasslist(
|
|
438
482
|
"ea-image-preview",
|
|
439
483
|
{
|
|
440
|
-
["--" + e(this,
|
|
484
|
+
["--" + e(this, c).status]: e(this, c).status
|
|
441
485
|
},
|
|
442
486
|
{
|
|
443
487
|
"show-progress": this["show-progress"]
|
|
444
488
|
}
|
|
445
489
|
)}`;
|
|
446
|
-
return e(this,
|
|
490
|
+
return e(this, v).className = t, t;
|
|
447
491
|
}
|
|
448
492
|
connectedCallback() {
|
|
449
|
-
var
|
|
450
|
-
super.connectedCallback(), this.assignedStyle(
|
|
493
|
+
var l;
|
|
494
|
+
super.connectedCallback(), this.assignedStyle(Q), (l = e(this, i).main) == null || l.abort(), e(this, i).main = new AbortController();
|
|
451
495
|
const t = () => {
|
|
452
|
-
e(this,
|
|
453
|
-
},
|
|
454
|
-
e(this,
|
|
455
|
-
},
|
|
456
|
-
|
|
496
|
+
e(this, E).call(this, "prev");
|
|
497
|
+
}, s = () => {
|
|
498
|
+
e(this, E).call(this, "next");
|
|
499
|
+
}, a = (h) => {
|
|
500
|
+
h.preventDefault(), h.deltaY > 0 ? e(this, _).call(this, "out") : e(this, _).call(this, "in");
|
|
457
501
|
};
|
|
458
|
-
e(this,
|
|
459
|
-
signal: e(this,
|
|
460
|
-
}), e(this,
|
|
461
|
-
signal: e(this,
|
|
462
|
-
}), e(this, z).addEventListener("click",
|
|
463
|
-
signal: e(this,
|
|
464
|
-
}), e(this,
|
|
465
|
-
signal: e(this,
|
|
502
|
+
e(this, B).call(this), e(this, C).addEventListener("click", e(this, D), {
|
|
503
|
+
signal: e(this, i).main.signal
|
|
504
|
+
}), e(this, I).addEventListener("click", t, {
|
|
505
|
+
signal: e(this, i).main.signal
|
|
506
|
+
}), e(this, z).addEventListener("click", s, {
|
|
507
|
+
signal: e(this, i).main.signal
|
|
508
|
+
}), e(this, v).addEventListener("wheel", a, {
|
|
509
|
+
signal: e(this, i).main.signal,
|
|
466
510
|
passive: !1
|
|
467
511
|
}), this.addEventListener("closed", this.reset, {
|
|
468
|
-
signal: e(this,
|
|
469
|
-
}), e(this, d).addEventListener("mousedown", e(this,
|
|
470
|
-
signal: e(this,
|
|
512
|
+
signal: e(this, i).main.signal
|
|
513
|
+
}), e(this, d).addEventListener("mousedown", e(this, $), {
|
|
514
|
+
signal: e(this, i).main.signal
|
|
471
515
|
}), this["close-on-press-escape"] && window.addEventListener(
|
|
472
516
|
"keydown",
|
|
473
|
-
(
|
|
474
|
-
|
|
517
|
+
(h) => {
|
|
518
|
+
h.key === "Escape" && this.hide();
|
|
475
519
|
},
|
|
476
|
-
{ signal: e(this,
|
|
520
|
+
{ signal: e(this, i).main.signal }
|
|
477
521
|
);
|
|
478
522
|
}
|
|
479
523
|
$beforeUnmounted() {
|
|
480
|
-
|
|
481
|
-
|
|
524
|
+
for (const t of Object.values(e(this, i)))
|
|
525
|
+
t == null || t.abort();
|
|
482
526
|
}
|
|
483
527
|
}
|
|
484
|
-
|
|
485
|
-
window.customElements.get("ea-image-preview") || window.customElements.define("ea-image-preview",
|
|
528
|
+
v = new WeakMap(), U = new WeakMap(), k = new WeakMap(), S = new WeakMap(), q = new WeakMap(), d = new WeakMap(), Y = new WeakMap(), C = new WeakMap(), I = new WeakMap(), z = new WeakMap(), R = new WeakMap(), A = new WeakMap(), M = new WeakMap(), N = new WeakMap(), P = new WeakMap(), i = new WeakMap(), c = new WeakMap(), O = new WeakMap(), E = new WeakMap(), _ = new WeakMap(), x = new WeakMap(), X = new WeakMap(), $ = new WeakMap(), B = new WeakMap(), D = new WeakMap(), T = new WeakMap();
|
|
529
|
+
window.customElements.get("ea-image-preview") || window.customElements.define("ea-image-preview", W);
|
|
486
530
|
export {
|
|
487
|
-
|
|
531
|
+
W as EaImagePreview
|
|
488
532
|
};
|