easy-component-ui 3.0.14 → 3.0.15
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/assets/icon.css +1 -0
- package/dist/components/Base.js +941 -0
- package/dist/components/ea-alert.js +213 -0
- package/dist/components/ea-avatar.js +164 -0
- package/dist/components/ea-backtop.js +136 -0
- package/dist/components/ea-badge.js +144 -0
- package/dist/components/ea-breadcrumb.js +148 -0
- package/dist/components/ea-button.js +266 -0
- package/dist/components/ea-calendar.js +10 -0
- package/dist/components/ea-calendar2.js +673 -0
- package/dist/components/ea-card.js +121 -0
- package/dist/components/ea-carousel.js +415 -0
- package/dist/components/ea-checkbox.js +446 -0
- package/dist/components/ea-collapse.js +313 -0
- package/dist/components/ea-color-picker.js +888 -0
- package/dist/components/ea-container.js +206 -0
- package/dist/components/ea-countdown.js +142 -0
- package/dist/components/ea-date-picker.js +649 -0
- package/dist/components/ea-descriptions.js +474 -0
- package/dist/components/ea-dialog.js +249 -0
- package/dist/components/ea-drawer.js +216 -0
- package/dist/components/ea-dropdown.js +228 -0
- package/dist/components/ea-empty.js +93 -0
- package/dist/components/ea-icon.js +159 -0
- package/dist/components/ea-image-preview.js +532 -0
- package/dist/components/ea-image.js +327 -0
- package/dist/components/ea-infinite-scroll.js +109 -0
- package/dist/components/ea-input-number.js +367 -0
- package/dist/components/ea-input.js +588 -0
- package/dist/components/ea-layout.js +132 -0
- package/dist/components/ea-link.js +101 -0
- package/dist/components/ea-menu.js +433 -0
- package/dist/components/ea-message-box.js +624 -0
- package/dist/components/ea-message.js +313 -0
- package/dist/components/ea-notification.js +331 -0
- package/dist/components/ea-overlay.js +168 -0
- package/dist/components/ea-page-header.js +108 -0
- package/dist/components/ea-pagination.js +481 -0
- package/dist/components/ea-popconfirm.js +275 -0
- package/dist/components/ea-popover.js +147 -0
- package/dist/components/ea-popper.js +203 -0
- package/dist/components/ea-progress.js +286 -0
- package/dist/components/ea-radio.js +364 -0
- package/dist/components/ea-rate.js +241 -0
- package/dist/components/ea-result.js +100 -0
- package/dist/components/ea-scrollbar.js +235 -0
- package/dist/components/ea-segmented.js +215 -0
- package/dist/components/ea-select.js +609 -0
- package/dist/components/ea-skeleton.js +263 -0
- package/dist/components/ea-slider.js +430 -0
- package/dist/components/ea-space.js +123 -0
- package/dist/components/ea-splitter.js +233 -0
- package/dist/components/ea-statistic.js +74 -0
- package/dist/components/ea-steps.js +346 -0
- package/dist/components/ea-switch.js +271 -0
- package/dist/components/ea-table.js +1137 -0
- package/dist/components/ea-tabs.js +503 -0
- package/dist/components/ea-tag.js +228 -0
- package/dist/components/ea-text.js +113 -0
- package/dist/components/ea-time-picker.js +510 -0
- package/dist/components/ea-timeline.js +185 -0
- package/dist/components/ea-tooltip.js +161 -0
- package/dist/components/ea-tour.js +544 -0
- package/dist/components/ea-transfer.js +949 -0
- package/dist/components/ea-tree.js +1125 -0
- package/dist/components/index.js +60 -0
- package/dist/core/FormBase.js +238 -0
- package/dist/css/ea-alert.style.js +4 -0
- package/dist/css/ea-aside.style.js +4 -0
- package/dist/css/ea-avatar.style.js +4 -0
- package/dist/css/ea-backtop.style.js +4 -0
- package/dist/css/ea-badge.style.js +4 -0
- package/dist/css/ea-breadcrumb-item.style.js +4 -0
- package/dist/css/ea-breadcrumb.style.js +4 -0
- package/dist/css/ea-button-group.style.js +4 -0
- package/dist/css/ea-button.style.js +4 -0
- package/dist/css/ea-calendar.style.js +4 -0
- package/dist/css/ea-card.style.js +4 -0
- package/dist/css/ea-carousel-item.style.js +4 -0
- package/dist/css/ea-carousel.style.js +4 -0
- package/dist/css/ea-check-tag.style.js +4 -0
- package/dist/css/ea-checkbox-group.style.js +4 -0
- package/dist/css/ea-checkbox.style.js +4 -0
- package/dist/css/ea-col.style.js +4 -0
- package/dist/css/ea-collapse-item.style.js +4 -0
- package/dist/css/ea-collapse.style.js +4 -0
- package/dist/css/ea-color-picker-panel.style.js +4 -0
- package/dist/css/ea-color-picker.style.js +4 -0
- package/dist/css/ea-container.style.js +4 -0
- package/dist/css/ea-date-picker.style.js +4 -0
- package/dist/css/ea-descriptions-item.style.js +4 -0
- package/dist/css/ea-descriptions.style.js +4 -0
- package/dist/css/ea-dialog.style.js +4 -0
- package/dist/css/ea-drawer.style.js +4 -0
- package/dist/css/ea-dropdown-item.style.js +4 -0
- package/dist/css/ea-dropdown-menu.style.js +4 -0
- package/dist/css/ea-dropdown.style.js +4 -0
- package/dist/css/ea-empty.style.js +4 -0
- package/dist/css/ea-footer.style.js +4 -0
- package/dist/css/ea-header.style.js +4 -0
- package/dist/css/ea-icon.style.js +4 -0
- package/dist/css/ea-image-preview.style.js +4 -0
- package/dist/css/ea-image.style.js +4 -0
- package/dist/css/ea-infinite-scroll.style.js +4 -0
- package/dist/css/ea-input-number.style.js +4 -0
- package/dist/css/ea-input.style.js +4 -0
- package/dist/css/ea-link.style.js +4 -0
- package/dist/css/ea-main.style.js +4 -0
- package/dist/css/ea-menu-item-group.style.js +4 -0
- package/dist/css/ea-menu-item.style.js +4 -0
- package/dist/css/ea-menu.style.js +4 -0
- package/dist/css/ea-message-box.style.js +4 -0
- package/dist/css/ea-message.style.js +4 -0
- package/dist/css/ea-notification.style.js +4 -0
- package/dist/css/ea-option-gropu.style.js +4 -0
- package/dist/css/ea-option.style.js +4 -0
- package/dist/css/ea-overlay.style.js +4 -0
- package/dist/css/ea-page-header.style.js +4 -0
- package/dist/css/ea-pagination.style.js +4 -0
- package/dist/css/ea-popconfirm.style.js +4 -0
- package/dist/css/ea-popover.style.js +4 -0
- package/dist/css/ea-popper.style.js +4 -0
- package/dist/css/ea-progress.style.js +4 -0
- package/dist/css/ea-radio-group.style.js +4 -0
- package/dist/css/ea-radio.style.js +4 -0
- package/dist/css/ea-rate.style.js +4 -0
- package/dist/css/ea-result.style.js +4 -0
- package/dist/css/ea-row.style.js +4 -0
- package/dist/css/ea-scrollbar.style.js +4 -0
- package/dist/css/ea-segmented.style.js +4 -0
- package/dist/css/ea-select.style.js +4 -0
- package/dist/css/ea-skeleton-item.style.js +4 -0
- package/dist/css/ea-skeleton.style.js +4 -0
- package/dist/css/ea-slider.style.js +4 -0
- package/dist/css/ea-space.style.js +4 -0
- package/dist/css/ea-splitter-bar.style.js +4 -0
- package/dist/css/ea-splitter-panel.style.js +4 -0
- package/dist/css/ea-splitter.style.js +4 -0
- package/dist/css/ea-statistic.style.js +4 -0
- package/dist/css/ea-step.style.js +4 -0
- package/dist/css/ea-steps.style.js +4 -0
- package/dist/css/ea-sub-menu.style.js +4 -0
- package/dist/css/ea-switch.style.js +4 -0
- package/dist/css/ea-tab-panel.style.js +4 -0
- package/dist/css/ea-tab.style.js +4 -0
- package/dist/css/ea-table-column.style.js +4 -0
- package/dist/css/ea-table.style.js +4 -0
- package/dist/css/ea-tabs.style.js +4 -0
- package/dist/css/ea-tag.style.js +4 -0
- package/dist/css/ea-text.style.js +4 -0
- package/dist/css/ea-time-picker.style.js +4 -0
- package/dist/css/ea-timeline-item.style.js +4 -0
- package/dist/css/ea-timeline.style.js +4 -0
- package/dist/css/ea-tooltip.style.js +4 -0
- package/dist/css/ea-tour-step.style.js +4 -0
- package/dist/css/ea-tour.style.js +4 -0
- package/dist/css/ea-transfer.style.js +5 -0
- package/dist/css/ea-tree.style.js +6 -0
- package/dist/css/ea-ui-component.style.js +4 -0
- package/dist/favicon.ico +0 -0
- package/dist/utils/Color.js +439 -0
- package/dist/utils/I18nManager.js +218 -0
- package/dist/utils/Utils.js +65 -0
- package/dist/utils/Variables.js +12 -0
- package/dist/utils/parseTime.js +73 -0
- package/dist/utils/timeout.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var H = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
|
+
};
|
|
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
|
+
import "./ea-image.js";
|
|
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
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
/** @type {HTMLElement} */
|
|
17
|
+
o(this, v);
|
|
18
|
+
/** @type {HTMLElement} */
|
|
19
|
+
o(this, U);
|
|
20
|
+
/** @type {HTMLElement} */
|
|
21
|
+
o(this, k);
|
|
22
|
+
/** @type {HTMLElement} */
|
|
23
|
+
o(this, S);
|
|
24
|
+
/** @type {HTMLElement} */
|
|
25
|
+
o(this, q);
|
|
26
|
+
/** @type {HTMLElement} */
|
|
27
|
+
o(this, d);
|
|
28
|
+
/** @type {HTMLElement} */
|
|
29
|
+
o(this, Y);
|
|
30
|
+
/** @type {HTMLElement} */
|
|
31
|
+
o(this, C);
|
|
32
|
+
/** @type {HTMLElement} */
|
|
33
|
+
o(this, I);
|
|
34
|
+
/** @type {HTMLElement} */
|
|
35
|
+
o(this, z);
|
|
36
|
+
/** @type {HTMLElement} */
|
|
37
|
+
o(this, R);
|
|
38
|
+
/** @type {HTMLElement} */
|
|
39
|
+
o(this, A);
|
|
40
|
+
/** @type {HTMLElement} */
|
|
41
|
+
o(this, M);
|
|
42
|
+
/** @type {HTMLElement} */
|
|
43
|
+
o(this, N);
|
|
44
|
+
/** @type {HTMLElement} */
|
|
45
|
+
o(this, P);
|
|
46
|
+
/** @type {AbortController} */
|
|
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, {
|
|
72
|
+
urlList: [],
|
|
73
|
+
/** @type {"loading" | "success" | "error"} */
|
|
74
|
+
status: "loading",
|
|
75
|
+
dirtyUpdate: !1,
|
|
76
|
+
isUrlListInit: !1,
|
|
77
|
+
position: {
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
L(this, "state", this.properties({
|
|
83
|
+
visible: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: !1,
|
|
86
|
+
observer: (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));
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"initial-index": {
|
|
93
|
+
type: Number,
|
|
94
|
+
default: 0,
|
|
95
|
+
observer: (t) => {
|
|
96
|
+
this.index = t;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
index: {
|
|
100
|
+
type: Number,
|
|
101
|
+
default: () => this["initial-index"],
|
|
102
|
+
observer: (t, s) => {
|
|
103
|
+
if (e(this, c).dirtyUpdate) return e(this, c).dirtyUpdate = !1;
|
|
104
|
+
if (this.infinite) {
|
|
105
|
+
if (!this.urlList.length) return;
|
|
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);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
infinite: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: !0,
|
|
117
|
+
observer: () => {
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"append-to-body": {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: !1,
|
|
123
|
+
observer: () => {
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
zoom: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: 1,
|
|
129
|
+
observer: () => {
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"zoom-rate": {
|
|
133
|
+
type: Number,
|
|
134
|
+
default: 1.2,
|
|
135
|
+
observer: () => {
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
scale: {
|
|
139
|
+
type: Number,
|
|
140
|
+
default: 1,
|
|
141
|
+
observer: (t, s) => {
|
|
142
|
+
if (t < this["min-scale"] || t > this["max-scale"])
|
|
143
|
+
return this.scale = s;
|
|
144
|
+
e(this, d).style.setProperty("--ea-image-preview-scale", t);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"min-scale": {
|
|
148
|
+
type: Number,
|
|
149
|
+
default: 0.2,
|
|
150
|
+
observer: () => {
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"max-scale": {
|
|
154
|
+
type: Number,
|
|
155
|
+
default: 7,
|
|
156
|
+
observer: () => {
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"close-on-press-escape": {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: !0,
|
|
162
|
+
observer: () => {
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"show-progress": {
|
|
166
|
+
type: Boolean,
|
|
167
|
+
default: !1,
|
|
168
|
+
observer: () => {
|
|
169
|
+
this.updateContainerClasslist();
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"hide-on-click-modal": {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: !1,
|
|
175
|
+
observer: (t) => {
|
|
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);
|
|
179
|
+
};
|
|
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
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
L(this, "propState", this.properties({
|
|
187
|
+
urlList: {
|
|
188
|
+
props: !0,
|
|
189
|
+
type: Array,
|
|
190
|
+
default: [],
|
|
191
|
+
/** @param {String[]} newVal */
|
|
192
|
+
observer: (t) => {
|
|
193
|
+
e(this, c).isUrlListInit = !1, e(this, c).urlList = t, this.index = this["initial-index"], e(this, c).isUrlListInit = !0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}));
|
|
197
|
+
/**
|
|
198
|
+
* 处理挂载到目标
|
|
199
|
+
*/
|
|
200
|
+
o(this, O, () => {
|
|
201
|
+
this["append-to-body"] && document.body.appendChild(this);
|
|
202
|
+
});
|
|
203
|
+
/**
|
|
204
|
+
* 处理切换
|
|
205
|
+
* @param {'prev' | 'next'} action
|
|
206
|
+
*/
|
|
207
|
+
o(this, E, (t) => {
|
|
208
|
+
t === "prev" ? this.index-- : t === "next" && this.index++;
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* 处理缩放
|
|
212
|
+
* @param {'in' | 'out'} action
|
|
213
|
+
*/
|
|
214
|
+
o(this, _, (t) => {
|
|
215
|
+
t === "in" ? this.scale = (this.scale * this["zoom-rate"]).toFixed(3) : t === "out" && (this.scale = (this.scale / this["zoom-rate"]).toFixed(3));
|
|
216
|
+
});
|
|
217
|
+
/**
|
|
218
|
+
* 处理旋转
|
|
219
|
+
* @param {'left' | 'right' | 'reset'} action
|
|
220
|
+
*/
|
|
221
|
+
o(this, x, (t) => {
|
|
222
|
+
const s = Number(
|
|
223
|
+
e(this, d).style.getPropertyValue("--ea-image-preview-rotate").split("deg")[0] || 0
|
|
224
|
+
);
|
|
225
|
+
let a = 0;
|
|
226
|
+
t === "left" ? a = s - 90 : t === "right" && (a = s + 90), e(this, d).style.setProperty(
|
|
227
|
+
"--ea-image-preview-rotate",
|
|
228
|
+
a + "deg"
|
|
229
|
+
), this.emit("rotate", {
|
|
230
|
+
detail: {
|
|
231
|
+
oldVal: s,
|
|
232
|
+
rotate: a
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
/**
|
|
237
|
+
* 处理进度
|
|
238
|
+
* @param {Number} active
|
|
239
|
+
* @param {Number} total
|
|
240
|
+
* @returns
|
|
241
|
+
*/
|
|
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);
|
|
245
|
+
};
|
|
246
|
+
if (a)
|
|
247
|
+
try {
|
|
248
|
+
a.assignedNodes().forEach((p) => {
|
|
249
|
+
const u = p.querySelectorAll("[data-active]"), w = p.querySelectorAll("[data-total]");
|
|
250
|
+
l(u, w);
|
|
251
|
+
});
|
|
252
|
+
} catch {
|
|
253
|
+
const h = a.querySelectorAll("[data-active]"), p = a.querySelectorAll("[data-total]");
|
|
254
|
+
l(h, p);
|
|
255
|
+
}
|
|
256
|
+
else
|
|
257
|
+
e(this, R).textContent = `${t} / ${s}`;
|
|
258
|
+
});
|
|
259
|
+
/**
|
|
260
|
+
* 处理图片移动事件
|
|
261
|
+
* @param {MouseEvent} startE
|
|
262
|
+
*/
|
|
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;
|
|
269
|
+
e(this, d).style.setProperty(
|
|
270
|
+
"--ea-image-preview-img-move-x",
|
|
271
|
+
`${b}px`
|
|
272
|
+
), e(this, d).style.setProperty(
|
|
273
|
+
"--ea-image-preview-img-move-y",
|
|
274
|
+
`${F}px`
|
|
275
|
+
);
|
|
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();
|
|
281
|
+
};
|
|
282
|
+
window.addEventListener("mousemove", p, {
|
|
283
|
+
signal: e(this, i).imgMove.signal
|
|
284
|
+
}), window.addEventListener("mouseup", u, {
|
|
285
|
+
signal: e(this, i).imgMove.signal
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* 初始化工具栏的事件。
|
|
290
|
+
* 若用户传入了自定义工具,则优先使用用户元素,否则使用内置元素
|
|
291
|
+
*/
|
|
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 = {
|
|
307
|
+
"switch-prev": {
|
|
308
|
+
el: null,
|
|
309
|
+
callback: () => {
|
|
310
|
+
e(this, E).call(this, "prev");
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"switch-next": {
|
|
314
|
+
el: null,
|
|
315
|
+
callback: () => {
|
|
316
|
+
e(this, E).call(this, "next");
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"zoom-out": {
|
|
320
|
+
el: e(this, M),
|
|
321
|
+
callback: () => {
|
|
322
|
+
e(this, _).call(this, "out");
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"zoom-in": {
|
|
326
|
+
el: e(this, A),
|
|
327
|
+
callback: () => {
|
|
328
|
+
e(this, _).call(this, "in");
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
"rotate-anticlockwise": {
|
|
332
|
+
el: e(this, N),
|
|
333
|
+
callback: () => {
|
|
334
|
+
e(this, x).call(this, "left");
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
"rotate-clockwise": {
|
|
338
|
+
el: e(this, P),
|
|
339
|
+
callback: () => {
|
|
340
|
+
e(this, x).call(this, "right");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
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);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
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);
|
|
366
|
+
});
|
|
367
|
+
/**
|
|
368
|
+
* 关闭 Preview
|
|
369
|
+
*/
|
|
370
|
+
o(this, D, () => {
|
|
371
|
+
this.hide(), this.visible = !1;
|
|
372
|
+
});
|
|
373
|
+
/**
|
|
374
|
+
* 设置当前项
|
|
375
|
+
* @param {Number} index
|
|
376
|
+
*/
|
|
377
|
+
L(this, "setActiveItem", (t) => {
|
|
378
|
+
this.index = t;
|
|
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
|
+
});
|
|
425
|
+
/**
|
|
426
|
+
* 重置状态
|
|
427
|
+
*/
|
|
428
|
+
L(this, "reset", () => {
|
|
429
|
+
this.index = this["initial-index"], this.scale = 1, e(this, x).call(this, "reset"), e(this, c).position = {
|
|
430
|
+
x: 0,
|
|
431
|
+
y: 0
|
|
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");
|
|
433
|
+
});
|
|
434
|
+
g(this, v, this.shadowRoot.querySelector(".ea-overlay")), e(this, v).innerHTML = e(this, v).innerHTML + `
|
|
435
|
+
<header class="ea-image-preview__header" part="header">
|
|
436
|
+
<ea-icon class="ea-image-preview__icon close-icon" name="xmark" part="icon close-icon"></ea-icon>
|
|
437
|
+
</header>
|
|
438
|
+
<main class="ea-image-preview__main" part="main">
|
|
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>
|
|
441
|
+
</main>
|
|
442
|
+
<footer class="ea-image-preview__footer" part="footer">
|
|
443
|
+
<section class="ea-image-preview__progress" part="progress">
|
|
444
|
+
<slot name="progress"></slot>
|
|
445
|
+
</section>
|
|
446
|
+
<section class="ea-image-preview__toolbar" part="toolbar">
|
|
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>
|
|
453
|
+
</section>
|
|
454
|
+
</footer>
|
|
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(
|
|
456
|
+
".ea-image-preview__progress slot[name='progress']"
|
|
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);
|
|
458
|
+
}
|
|
459
|
+
static get observedAttributes() {
|
|
460
|
+
return [
|
|
461
|
+
...super.observedAttributes,
|
|
462
|
+
"visible",
|
|
463
|
+
"index",
|
|
464
|
+
"initial-index",
|
|
465
|
+
"infinite",
|
|
466
|
+
"zoom-rate",
|
|
467
|
+
"scale",
|
|
468
|
+
"min-scale",
|
|
469
|
+
"max-scale",
|
|
470
|
+
"close-on-press-escape",
|
|
471
|
+
"hide-on-click-modal",
|
|
472
|
+
"show-progress",
|
|
473
|
+
"append-to-body"
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* 获取 classlist 列表
|
|
478
|
+
* @return {string} 属性值
|
|
479
|
+
*/
|
|
480
|
+
updateContainerClasslist() {
|
|
481
|
+
const t = `${super.updateContainerClasslist()} ${this.computedClasslist(
|
|
482
|
+
"ea-image-preview",
|
|
483
|
+
{
|
|
484
|
+
["--" + e(this, c).status]: e(this, c).status
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"show-progress": this["show-progress"]
|
|
488
|
+
}
|
|
489
|
+
)}`;
|
|
490
|
+
return e(this, v).className = t, t;
|
|
491
|
+
}
|
|
492
|
+
connectedCallback() {
|
|
493
|
+
var l;
|
|
494
|
+
super.connectedCallback(), this.assignedStyle(Q), (l = e(this, i).main) == null || l.abort(), e(this, i).main = new AbortController();
|
|
495
|
+
const t = () => {
|
|
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");
|
|
501
|
+
};
|
|
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,
|
|
510
|
+
passive: !1
|
|
511
|
+
}), this.addEventListener("closed", this.reset, {
|
|
512
|
+
signal: e(this, i).main.signal
|
|
513
|
+
}), e(this, d).addEventListener("mousedown", e(this, $), {
|
|
514
|
+
signal: e(this, i).main.signal
|
|
515
|
+
}), this["close-on-press-escape"] && window.addEventListener(
|
|
516
|
+
"keydown",
|
|
517
|
+
(h) => {
|
|
518
|
+
h.key === "Escape" && this.hide();
|
|
519
|
+
},
|
|
520
|
+
{ signal: e(this, i).main.signal }
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
$beforeUnmounted() {
|
|
524
|
+
for (const t of Object.values(e(this, i)))
|
|
525
|
+
t == null || t.abort();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
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);
|
|
530
|
+
export {
|
|
531
|
+
W as EaImagePreview
|
|
532
|
+
};
|