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.
Files changed (78) hide show
  1. package/README.md +162 -162
  2. package/dist/assets/icon.css +1 -1
  3. package/dist/components/Base.js +190 -188
  4. package/dist/components/ea-alert.js +71 -54
  5. package/dist/components/ea-avatar.js +42 -37
  6. package/dist/components/ea-breadcrumb.js +33 -33
  7. package/dist/components/ea-button.js +53 -52
  8. package/dist/components/ea-card.js +63 -27
  9. package/dist/components/ea-carousel.js +2 -2
  10. package/dist/components/ea-collapse.js +93 -73
  11. package/dist/components/ea-color-picker.js +221 -221
  12. package/dist/components/ea-container.js +90 -61
  13. package/dist/components/ea-countdown.js +77 -56
  14. package/dist/components/ea-date-picker.js +1 -1
  15. package/dist/components/ea-descriptions.js +133 -70
  16. package/dist/components/ea-dialog.js +4 -4
  17. package/dist/components/ea-drawer.js +93 -71
  18. package/dist/components/ea-empty.js +31 -23
  19. package/dist/components/ea-icon.js +122 -32
  20. package/dist/components/ea-image-preview.js +237 -193
  21. package/dist/components/ea-image.js +69 -44
  22. package/dist/components/ea-input-number.js +9 -9
  23. package/dist/components/ea-input.js +15 -15
  24. package/dist/components/ea-layout.js +10 -3
  25. package/dist/components/ea-link.js +1 -1
  26. package/dist/components/ea-menu.js +69 -53
  27. package/dist/components/ea-message-box.js +73 -73
  28. package/dist/components/ea-message.js +184 -121
  29. package/dist/components/ea-notification.js +80 -80
  30. package/dist/components/ea-overlay.js +41 -34
  31. package/dist/components/ea-page-header.js +5 -5
  32. package/dist/components/ea-pagination.js +6 -5
  33. package/dist/components/ea-popconfirm.js +133 -78
  34. package/dist/components/ea-popover.js +35 -11
  35. package/dist/components/ea-popper.js +9 -9
  36. package/dist/components/ea-progress.js +88 -71
  37. package/dist/components/ea-rate.js +1 -1
  38. package/dist/components/ea-result.js +20 -20
  39. package/dist/components/ea-select.js +119 -108
  40. package/dist/components/ea-skeleton.js +99 -82
  41. package/dist/components/ea-slider.js +88 -79
  42. package/dist/components/ea-splitter.js +34 -18
  43. package/dist/components/ea-statistic.js +72 -4
  44. package/dist/components/ea-steps.js +108 -74
  45. package/dist/components/ea-table.js +562 -434
  46. package/dist/components/ea-tabs.js +28 -28
  47. package/dist/components/ea-tag.js +37 -43
  48. package/dist/components/ea-time-picker.js +2 -6
  49. package/dist/components/ea-timeline.js +11 -12
  50. package/dist/components/ea-tooltip.js +63 -23
  51. package/dist/components/ea-tour.js +21 -21
  52. package/dist/components/ea-transfer.js +2 -2
  53. package/dist/components/ea-tree.js +1 -1
  54. package/dist/components/index.js +1 -2
  55. package/dist/css/ea-card.style.js +2 -2
  56. package/dist/css/ea-collapse-item.style.js +1 -1
  57. package/dist/css/ea-color-picker-panel.style.js +1 -1
  58. package/dist/css/ea-container.style.js +1 -1
  59. package/dist/css/ea-descriptions-item.style.js +2 -2
  60. package/dist/css/ea-descriptions.style.js +1 -1
  61. package/dist/css/ea-empty.style.js +1 -1
  62. package/dist/css/ea-footer.style.js +1 -1
  63. package/dist/css/ea-progress.style.js +1 -1
  64. package/dist/css/ea-skeleton.style.js +1 -1
  65. package/dist/css/ea-step.style.js +1 -1
  66. package/dist/css/ea-switch.style.js +1 -1
  67. package/dist/css/ea-tab.style.js +1 -1
  68. package/dist/css/ea-table-column.style.js +4 -0
  69. package/dist/css/ea-table.style.js +1 -1
  70. package/dist/css/ea-tabs.style.js +1 -1
  71. package/dist/css/ea-tag.style.js +1 -1
  72. package/dist/css/ea-time-picker.style.js +1 -1
  73. package/dist/css/ea-timeline-item.style.js +1 -1
  74. package/dist/utils/Variables.js +10 -17
  75. package/dist/utils/parseTime.js +73 -0
  76. package/package.json +302 -304
  77. package/dist/components/ea-loading.js +0 -151
  78. package/dist/components/ea-statistic2.js +0 -83
@@ -1,57 +1,74 @@
1
- var J = Object.defineProperty;
2
- var Z = (l) => {
3
- throw TypeError(l);
1
+ var Z = Object.defineProperty;
2
+ var H = (r) => {
3
+ throw TypeError(r);
4
4
  };
5
- var K = (l, c, t) => c in l ? J(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
6
- var L = (l, c, t) => K(l, typeof c != "symbol" ? c + "" : c, t), j = (l, c, t) => c.has(l) || Z("Cannot " + t);
7
- var e = (l, c, t) => (j(l, c, "read from private field"), t ? t.call(l) : c.get(l)), i = (l, c, t) => c.has(l) ? Z("Cannot add the same private member more than once") : c instanceof WeakSet ? c.add(l) : c.set(l, t), h = (l, c, t, a) => (j(l, c, "write to private field"), a ? a.call(l, t) : c.set(l, t), t);
8
- import { EaOverlay as Q } from "./ea-overlay.js";
9
- import { E as W } from "../utils/Utils.js";
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 V } from "../css/ea-image-preview.style.js";
12
- var m, M, k, S, C, d, T, q, R, z, A, I, N, P, U, v, p, b, f, n, X, x, _, E, $, B, D, H;
13
- class ee extends Q {
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
- i(this, m);
17
+ o(this, v);
18
18
  /** @type {HTMLElement} */
19
- i(this, M);
19
+ o(this, U);
20
20
  /** @type {HTMLElement} */
21
- i(this, k);
21
+ o(this, k);
22
22
  /** @type {HTMLElement} */
23
- i(this, S);
23
+ o(this, S);
24
24
  /** @type {HTMLElement} */
25
- i(this, C);
25
+ o(this, q);
26
26
  /** @type {HTMLElement} */
27
- i(this, d);
27
+ o(this, d);
28
28
  /** @type {HTMLElement} */
29
- i(this, T);
29
+ o(this, Y);
30
30
  /** @type {HTMLElement} */
31
- i(this, q);
31
+ o(this, C);
32
32
  /** @type {HTMLElement} */
33
- i(this, R);
33
+ o(this, I);
34
34
  /** @type {HTMLElement} */
35
- i(this, z);
35
+ o(this, z);
36
36
  /** @type {HTMLElement} */
37
- i(this, A);
37
+ o(this, R);
38
38
  /** @type {HTMLElement} */
39
- i(this, I);
39
+ o(this, A);
40
40
  /** @type {HTMLElement} */
41
- i(this, N);
41
+ o(this, M);
42
42
  /** @type {HTMLElement} */
43
- i(this, P);
43
+ o(this, N);
44
44
  /** @type {HTMLElement} */
45
- i(this, U);
45
+ o(this, P);
46
46
  /** @type {AbortController} */
47
- i(this, v);
48
- /** @type {AbortController} */
49
- i(this, p);
50
- /** @type {AbortController} */
51
- i(this, b);
52
- /** @type {AbortController} */
53
- i(this, f);
54
- i(this, n, {
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, a) => {
84
- var s;
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 r = e(this, n).urlList.length - 1;
89
- if (t > r) return this.index = 0;
90
- if (t < 0) return this.index = r;
91
- } else if (t < 0 || t > e(this, n).urlList.length - 1)
92
- return e(this, n).dirtyUpdate = !0, this.index = a;
93
- const o = e(this, n).urlList[t];
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, a) => {
141
+ observer: (t, s) => {
161
142
  if (t < this["min-scale"] || t > this["max-scale"])
162
- return this.scale = a;
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 o;
196
- const a = (s) => {
197
- !e(this, d).querySelector(".ea-image-preview__img").contains(s.target) && !e(this, k).contains(s.target) && !e(this, S).contains(s.target) && !e(this, C).contains(s.target) && (this.hide(), this.visible = !1);
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
- (o = e(this, b)) == null || o.abort(), t && (h(this, b, new AbortController()), e(this, m).addEventListener("click", a, {
200
- signal: e(this, b).signal
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, n).isUrlListInit = !1, e(this, n).urlList = t, this.index = this["initial-index"], e(this, n).isUrlListInit = !0;
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
- i(this, X, () => {
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
- i(this, x, (t) => {
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
- i(this, _, (t) => {
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
- i(this, E, (t) => {
241
- const a = Number(
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 o = 0;
245
- t === "left" ? o = a - 90 : t === "right" && (o = a + 90), e(this, d).style.setProperty(
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
- o + "deg"
228
+ a + "deg"
248
229
  ), this.emit("rotate", {
249
230
  detail: {
250
- oldVal: a,
251
- rotate: o
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
- i(this, $, (t, a) => {
262
- const o = this.querySelector("[slot='progress']"), s = (r, g) => {
263
- r.forEach((u) => u.textContent = t), g.forEach((u) => u.textContent = a);
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 (o)
246
+ if (a)
266
247
  try {
267
- o.assignedNodes().forEach((g) => {
268
- const u = g.querySelectorAll("[data-active]"), y = g.querySelectorAll("[data-total]");
269
- s(u, y);
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 r = o.querySelectorAll("[data-active]"), g = o.querySelectorAll("[data-total]");
273
- s(r, g);
253
+ const h = a.querySelectorAll("[data-active]"), p = a.querySelectorAll("[data-total]");
254
+ l(h, p);
274
255
  }
275
256
  else
276
- e(this, A).textContent = `${t} / ${a}`;
257
+ e(this, R).textContent = `${t} / ${s}`;
277
258
  });
278
259
  /**
279
260
  * 处理图片移动事件
280
261
  * @param {MouseEvent} startE
281
262
  */
282
- i(this, B, (t) => {
283
- var y;
284
- t.preventDefault(), (y = e(this, f)) == null || y.abort(), h(this, f, new AbortController());
285
- const a = t.clientX, o = t.clientY, s = e(this, n).position.x, r = e(this, n).position.y, g = (w) => {
286
- w.preventDefault();
287
- const O = w.clientX - a, F = w.clientY - o, Y = s + O, G = r + F;
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
- `${Y}px`
271
+ `${b}px`
291
272
  ), e(this, d).style.setProperty(
292
273
  "--ea-image-preview-img-move-y",
293
- `${G}px`
274
+ `${F}px`
294
275
  );
295
- }, u = (w) => {
296
- var Y;
297
- w.preventDefault();
298
- const O = w.clientX - a, F = w.clientY - o;
299
- e(this, n).position.x = s + O, e(this, n).position.y = r + F, (Y = e(this, f)) == null || Y.abort();
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", g, {
302
- signal: e(this, f).signal
282
+ window.addEventListener("mousemove", p, {
283
+ signal: e(this, i).imgMove.signal
303
284
  }), window.addEventListener("mouseup", u, {
304
- signal: e(this, f).signal
285
+ signal: e(this, i).imgMove.signal
305
286
  });
306
287
  });
307
288
  /**
308
289
  * 初始化工具栏的事件。
309
290
  * 若用户传入了自定义工具,则优先使用用户元素,否则使用内置元素
310
291
  */
311
- i(this, D, () => {
312
- const t = this.querySelector("[slot='toolbar']"), a = {
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, x).call(this, "prev");
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, x).call(this, "next");
316
+ e(this, E).call(this, "next");
323
317
  }
324
318
  },
325
319
  "zoom-out": {
326
- el: e(this, I),
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, N),
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, P),
332
+ el: e(this, N),
339
333
  callback: () => {
340
- e(this, E).call(this, "left");
334
+ e(this, x).call(this, "left");
341
335
  }
342
336
  },
343
337
  "rotate-clockwise": {
344
- el: e(this, U),
338
+ el: e(this, P),
345
339
  callback: () => {
346
- e(this, E).call(this, "right");
340
+ e(this, x).call(this, "right");
347
341
  }
348
342
  }
349
- };
350
- for (const [o, s] of Object.entries(a)) {
351
- let r = !1;
352
- try {
353
- t.assignedNodes().forEach((u) => {
354
- const y = u.querySelector(`[data-action="${o}"]`);
355
- y && (r = !0, s.el.style.display = "none", y.addEventListener("click", s.callback, {
356
- signal: e(this, p).signal
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
- i(this, H, () => {
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, E).call(this, "reset"), e(this, n).position = {
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
- h(this, m, this.shadowRoot.querySelector(".ea-overlay")), e(this, m).innerHTML = e(this, m).innerHTML + `
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" icon="icon-cancel" part="icon close-icon"></ea-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" icon="icon-angle-left" part="icon prev-icon"></ea-icon>
397
- <ea-icon class="ea-image-preview__icon next-icon" icon="icon-angle-right" part="icon next-icon"></ea-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
- <ea-icon class="ea-image-preview__icon zoom-out-icon" icon="icon-zoom-out" part="icon zoom-out-icon"></ea-icon>
405
- <ea-icon class="ea-image-preview__icon zoom-in-icon" icon="icon-zoom-in" part="icon zoom-in-icon"></ea-icon>
406
- <ea-icon class="ea-image-preview__icon rotate-left-icon" icon="icon-ccw" part="icon rotate-left-icon"></ea-icon>
407
- <ea-icon class="ea-image-preview__icon rotate-right-icon" icon="icon-cw" part="icon rotate-right-icon"></ea-icon>
408
- <slot name="toolbar"></slot>
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
- `, h(this, M, this.shadowRoot.querySelector(".ea-overlay__content")), h(this, T, this.shadowRoot.querySelector(".ea-overlay__mask")), h(this, d, this.shadowRoot.querySelector(".ea-overlay__content")), h(this, q, this.shadowRoot.querySelector(".close-icon")), h(this, R, this.shadowRoot.querySelector(".prev-icon")), h(this, z, this.shadowRoot.querySelector(".next-icon")), h(this, I, this.shadowRoot.querySelector(".zoom-in-icon")), h(this, N, this.shadowRoot.querySelector(".zoom-out-icon")), h(this, P, this.shadowRoot.querySelector(".rotate-left-icon")), h(this, U, this.shadowRoot.querySelector(".rotate-right-icon")), h(this, A, this.shadowRoot.querySelector(
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
- )), h(this, k, this.shadowRoot.querySelector(".ea-image-preview__header")), h(this, S, this.shadowRoot.querySelector(".ea-image-preview__main")), h(this, C, this.shadowRoot.querySelector(".ea-image-preview__footer")), e(this, X).call(this);
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, n).status]: e(this, n).status
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, m).className = t, t;
490
+ return e(this, v).className = t, t;
447
491
  }
448
492
  connectedCallback() {
449
- var s;
450
- super.connectedCallback(), this.assignedStyle(V), (s = e(this, p)) == null || s.abort(), h(this, p, new AbortController());
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, x).call(this, "prev");
453
- }, a = () => {
454
- e(this, x).call(this, "next");
455
- }, o = (r) => {
456
- r.preventDefault(), r.deltaY > 0 ? e(this, _).call(this, "out") : e(this, _).call(this, "in");
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, D).call(this), e(this, q).addEventListener("click", e(this, H), {
459
- signal: e(this, p).signal
460
- }), e(this, R).addEventListener("click", t, {
461
- signal: e(this, p).signal
462
- }), e(this, z).addEventListener("click", a, {
463
- signal: e(this, p).signal
464
- }), e(this, m).addEventListener("wheel", o, {
465
- signal: e(this, p).signal,
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, p).signal
469
- }), e(this, d).addEventListener("mousedown", e(this, B), {
470
- signal: e(this, p).signal
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
- (r) => {
474
- r.key === "Escape" && this.hide();
517
+ (h) => {
518
+ h.key === "Escape" && this.hide();
475
519
  },
476
- { signal: e(this, p).signal }
520
+ { signal: e(this, i).main.signal }
477
521
  );
478
522
  }
479
523
  $beforeUnmounted() {
480
- var t, a, o, s;
481
- (t = e(this, p)) == null || t.abort(), (a = e(this, v)) == null || a.abort(), (o = e(this, f)) == null || o.abort(), (s = e(this, b)) == null || s.abort();
524
+ for (const t of Object.values(e(this, i)))
525
+ t == null || t.abort();
482
526
  }
483
527
  }
484
- m = new WeakMap(), M = new WeakMap(), k = new WeakMap(), S = new WeakMap(), C = new WeakMap(), d = new WeakMap(), T = new WeakMap(), q = new WeakMap(), R = new WeakMap(), z = new WeakMap(), A = new WeakMap(), I = new WeakMap(), N = new WeakMap(), P = new WeakMap(), U = new WeakMap(), v = new WeakMap(), p = new WeakMap(), b = new WeakMap(), f = new WeakMap(), n = new WeakMap(), X = new WeakMap(), x = new WeakMap(), _ = new WeakMap(), E = new WeakMap(), $ = new WeakMap(), B = new WeakMap(), D = new WeakMap(), H = new WeakMap();
485
- window.customElements.get("ea-image-preview") || window.customElements.define("ea-image-preview", ee);
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
- ee as EaImagePreview
531
+ W as EaImagePreview
488
532
  };