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,481 @@
|
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var q = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
|
+
};
|
|
5
|
+
var B = (r, n, e) => n in r ? F(r, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[n] = e;
|
|
6
|
+
var T = (r, n, e) => B(r, typeof n != "symbol" ? n + "" : n, e), $ = (r, n, e) => n.has(r) || q("Cannot " + e);
|
|
7
|
+
var t = (r, n, e) => ($(r, n, "read from private field"), e ? e.call(r) : n.get(r)), l = (r, n, e) => n.has(r) ? q("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(r) : n.set(r, e), u = (r, n, e, i) => ($(r, n, "write to private field"), i ? i.call(r, e) : n.set(r, e), e), C = (r, n, e) => ($(r, n, "access private method"), e);
|
|
8
|
+
import { B as H } from "./Base.js";
|
|
9
|
+
import { s as J } from "../css/ea-pagination.style.js";
|
|
10
|
+
import { E as R } from "../utils/Utils.js";
|
|
11
|
+
import { E as O } from "../utils/Variables.js";
|
|
12
|
+
const D = (r, n, e) => R.EaElement.h(
|
|
13
|
+
"span",
|
|
14
|
+
`ea-pagination__page ${r === n ? "is-active" : ""}`.trim(),
|
|
15
|
+
{
|
|
16
|
+
part: "page",
|
|
17
|
+
tabindex: 0,
|
|
18
|
+
"data-page": r,
|
|
19
|
+
"aria-label": `page ${r}`,
|
|
20
|
+
"aria-current": r === n
|
|
21
|
+
},
|
|
22
|
+
e || r
|
|
23
|
+
), U = (r, n) => R.EaElement.h(
|
|
24
|
+
"span",
|
|
25
|
+
"ea-pagination__page ea-pagination__more",
|
|
26
|
+
{
|
|
27
|
+
part: "more",
|
|
28
|
+
"aria-label": n === "next" ? "Next 5 pages" : "Previous 5 pages",
|
|
29
|
+
tabindex: 0,
|
|
30
|
+
"data-action": n
|
|
31
|
+
},
|
|
32
|
+
r
|
|
33
|
+
);
|
|
34
|
+
class G extends Event {
|
|
35
|
+
constructor(n) {
|
|
36
|
+
super("ea-current-change", {
|
|
37
|
+
bubbles: !0,
|
|
38
|
+
cancelable: !0,
|
|
39
|
+
composed: !0
|
|
40
|
+
}), this.detail = n;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
class Z extends Event {
|
|
44
|
+
constructor(n) {
|
|
45
|
+
super("ea-prev-click", {
|
|
46
|
+
bubbles: !0,
|
|
47
|
+
cancelable: !0,
|
|
48
|
+
composed: !0
|
|
49
|
+
}), this.detail = n;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class K extends Event {
|
|
53
|
+
constructor(n) {
|
|
54
|
+
super("ea-next-click", {
|
|
55
|
+
bubbles: !0,
|
|
56
|
+
cancelable: !0,
|
|
57
|
+
composed: !0
|
|
58
|
+
}), this.detail = n;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class Q extends Event {
|
|
62
|
+
constructor(n) {
|
|
63
|
+
super("ea-size-change", {
|
|
64
|
+
bubbles: !0,
|
|
65
|
+
cancelable: !0,
|
|
66
|
+
composed: !0
|
|
67
|
+
}), this.detail = n;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var z, c, b, m, p, y, d, g, h, S, P, A, k, I, M, j, L, N, v, E;
|
|
71
|
+
class W extends H {
|
|
72
|
+
constructor() {
|
|
73
|
+
super();
|
|
74
|
+
l(this, v);
|
|
75
|
+
/** @type {HTMLElement} */
|
|
76
|
+
l(this, z);
|
|
77
|
+
/** @type {HTMLElement} */
|
|
78
|
+
l(this, c);
|
|
79
|
+
/** @type {HTMLElement} */
|
|
80
|
+
l(this, b);
|
|
81
|
+
/** @type {HTMLElement} */
|
|
82
|
+
l(this, m);
|
|
83
|
+
/** @type {HTMLElement} */
|
|
84
|
+
l(this, p);
|
|
85
|
+
/** @type {HTMLElement} */
|
|
86
|
+
l(this, y);
|
|
87
|
+
/** @type {HTMLElement} */
|
|
88
|
+
l(this, d);
|
|
89
|
+
l(this, g, {
|
|
90
|
+
isFirstRender: !0,
|
|
91
|
+
isEaInputImported: !1,
|
|
92
|
+
isEaSelectImported: !1
|
|
93
|
+
});
|
|
94
|
+
l(this, h, {
|
|
95
|
+
/** @type {AbortController | null} */
|
|
96
|
+
paginationAbortController: null,
|
|
97
|
+
/** @type {AbortController | null} */
|
|
98
|
+
prevAbortController: null,
|
|
99
|
+
/** @type {AbortController | null} */
|
|
100
|
+
nextAbortController: null,
|
|
101
|
+
/** @type {AbortController | null} */
|
|
102
|
+
jumperAbortController: null,
|
|
103
|
+
/** @type {AbortController | null} */
|
|
104
|
+
sizesAbortController: null
|
|
105
|
+
});
|
|
106
|
+
T(this, "state", this.properties({
|
|
107
|
+
"default-page-size": {
|
|
108
|
+
type: Number,
|
|
109
|
+
default: 10,
|
|
110
|
+
/** @param {number} newVal */
|
|
111
|
+
observer: () => {
|
|
112
|
+
t(this, g).isFirstRender || C(this, v, E).call(this);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"page-size": {
|
|
116
|
+
type: Number,
|
|
117
|
+
default: () => this["default-page-size"],
|
|
118
|
+
/** @param {number} newVal */
|
|
119
|
+
observer: (e) => {
|
|
120
|
+
t(this, g).isFirstRender || (C(this, v, E).call(this), this.dispatchEvent(
|
|
121
|
+
new Q({
|
|
122
|
+
pageSize: e
|
|
123
|
+
})
|
|
124
|
+
));
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"pager-count": {
|
|
128
|
+
type: Number,
|
|
129
|
+
default: 7,
|
|
130
|
+
/** @param {number} newVal */
|
|
131
|
+
observer: () => {
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
total: {
|
|
135
|
+
type: Number,
|
|
136
|
+
default: 0,
|
|
137
|
+
/** @param {number} newVal */
|
|
138
|
+
observer: () => {
|
|
139
|
+
t(this, c) && this.layout.includes("pager") && C(this, v, E).call(this), this["hide-on-single-page"] && this.updateContainerClasslist();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"current-page": {
|
|
143
|
+
type: Number,
|
|
144
|
+
default: 1,
|
|
145
|
+
/** @param {number} newVal */
|
|
146
|
+
observer: (e) => {
|
|
147
|
+
var i;
|
|
148
|
+
t(this, g).isFirstRender || (t(this, S).call(this, e), t(this, p) && ((i = this.layout) != null && i.includes("jumper")) && (t(this, p).value = e), this.emit("change", {
|
|
149
|
+
detail: {
|
|
150
|
+
currentPage: e,
|
|
151
|
+
pageSize: this["page-size"]
|
|
152
|
+
}
|
|
153
|
+
}), this.dispatchEvent(
|
|
154
|
+
new G({ value: e })
|
|
155
|
+
), this.updateContainerClasslist());
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
background: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: !1,
|
|
161
|
+
observer: () => {
|
|
162
|
+
console.log(1, this), this.updateContainerClasslist();
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
size: {
|
|
166
|
+
type: O,
|
|
167
|
+
default: "",
|
|
168
|
+
observer: (e) => {
|
|
169
|
+
t(this, d) && t(this, d).setAttribute("size", e), t(this, p) && t(this, p).setAttribute("size", e), this.updateContainerClasslist();
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"hide-on-single-page": {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: !1,
|
|
175
|
+
observer: () => {
|
|
176
|
+
t(this, c) && this.layout.includes("pager") && this.updateContainerClasslist();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
disabled: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
default: !1,
|
|
182
|
+
observer: (e) => {
|
|
183
|
+
this.updateContainerClasslist(), this.layout.includes("jumper") && t(this, p) && (t(this, p).disabled = e);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}));
|
|
187
|
+
T(this, "propState", this.properties({
|
|
188
|
+
pageSizes: {
|
|
189
|
+
props: !0,
|
|
190
|
+
type: Array,
|
|
191
|
+
default: [10, 20, 30, 40, 50, 100],
|
|
192
|
+
/** @param {Array<number>} newVal */
|
|
193
|
+
observer: (e) => {
|
|
194
|
+
t(this, g).isFirstRender || C(this, v, E).call(this);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
layout: {
|
|
198
|
+
props: !0,
|
|
199
|
+
type: Array,
|
|
200
|
+
default: ["prev", "pager", "next", "jumper", "->", "total"],
|
|
201
|
+
/** @param {Array<'prev' | 'pager' | 'next' | '->' | 'jumper' | 'total' | 'sizes'>} newVal */
|
|
202
|
+
observer: (e) => {
|
|
203
|
+
t(this, g).isFirstRender || C(this, v, E).call(this);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}));
|
|
207
|
+
/**
|
|
208
|
+
* 更新页码样式
|
|
209
|
+
* @param {Number} [currentPage]
|
|
210
|
+
*/
|
|
211
|
+
l(this, S, (e = this["current-page"]) => {
|
|
212
|
+
var a;
|
|
213
|
+
if (!t(this, c) || !((a = this.layout) != null && a.includes("pager"))) return;
|
|
214
|
+
t(this, c).innerHTML = t(this, A).call(this, e);
|
|
215
|
+
const i = t(this, c).querySelectorAll(".ea-pagination__page"), s = t(this, c).querySelector(
|
|
216
|
+
`.ea-pagination__page[data-page="${e}"]`
|
|
217
|
+
);
|
|
218
|
+
i.forEach((o) => {
|
|
219
|
+
o.classList.toggle("is-active", o === s), o.setAttribute("aria-current", o === s);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* 获取分页器范围
|
|
224
|
+
* @param {number} newVal 当前页码
|
|
225
|
+
* @return {Array<number | string>} 分页器范围
|
|
226
|
+
*/
|
|
227
|
+
l(this, P, (e) => {
|
|
228
|
+
const i = Math.ceil(this.total / this["page-size"]), s = Math.floor(this["pager-count"] / 2), o = ((_, w) => {
|
|
229
|
+
const x = [];
|
|
230
|
+
for (let f = _; f <= w; f++)
|
|
231
|
+
x.push(f);
|
|
232
|
+
return x;
|
|
233
|
+
})(
|
|
234
|
+
Math.max(
|
|
235
|
+
2,
|
|
236
|
+
e + s > i ? (
|
|
237
|
+
/**
|
|
238
|
+
* 当 `endRange` 超出范围时,起始值 = 当前页 - (范围区间 + 1) - 后半多余区间
|
|
239
|
+
* 后半多余区间 = | 总页码数 - 当前页码 - 范围区间 |
|
|
240
|
+
*/
|
|
241
|
+
e - s + 1 - Math.abs(i - e - s)
|
|
242
|
+
) : (
|
|
243
|
+
// 因为单独处理开头,所以 `range` 起始要多一位
|
|
244
|
+
e - s + 1
|
|
245
|
+
)
|
|
246
|
+
),
|
|
247
|
+
Math.min(
|
|
248
|
+
i - 1,
|
|
249
|
+
e - s < 2 ? (
|
|
250
|
+
/**
|
|
251
|
+
* 当 `startRange` 超出范围时,终止值 = 当前页 + (范围区间 - 1) - 前半多余区间
|
|
252
|
+
* 前半多余区间 = | 当前页码 - 范围区间 - 1 |
|
|
253
|
+
*/
|
|
254
|
+
e + s - 1 + Math.abs(e - s - 1)
|
|
255
|
+
) : (
|
|
256
|
+
// 因为单独处理结尾,所以 `range` 结束要少一位
|
|
257
|
+
e + s - 1
|
|
258
|
+
)
|
|
259
|
+
)
|
|
260
|
+
);
|
|
261
|
+
return o[0] > 2 || s === 0 ? o.unshift(1, "...") : o.unshift(1), s === 0 && e > 1 && e < i && o.push(e), o[o.length - 1] < i - 1 || s === 0 && e === i - 1 ? o.push("...", i) : i > 1 && o.push(i), o;
|
|
262
|
+
});
|
|
263
|
+
/**
|
|
264
|
+
* 获取页码模板
|
|
265
|
+
* @param {Number} currentPage 当前页码
|
|
266
|
+
* @returns {String}
|
|
267
|
+
*/
|
|
268
|
+
l(this, A, (e = 1) => {
|
|
269
|
+
let i = "";
|
|
270
|
+
const s = t(this, P).call(this, e);
|
|
271
|
+
return s.forEach((a, o) => {
|
|
272
|
+
typeof a == "number" ? i += D(a, this["current-page"], a) : i += U(
|
|
273
|
+
"...",
|
|
274
|
+
s[o - 1] === s[0] ? "prev" : "next"
|
|
275
|
+
);
|
|
276
|
+
}), i;
|
|
277
|
+
});
|
|
278
|
+
/**
|
|
279
|
+
* 渲染页码部分
|
|
280
|
+
* @description 这里的事件监听采用的是,通过 `this.#pagination` 点击事件中,获取到的最近的 `页码元素` 来进行事件触发
|
|
281
|
+
*/
|
|
282
|
+
l(this, k, () => {
|
|
283
|
+
if (!t(this, c)) return;
|
|
284
|
+
if (!this.layout.includes("pager")) {
|
|
285
|
+
t(this, c).innerHTML = "";
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const e = (i) => {
|
|
289
|
+
var _;
|
|
290
|
+
const s = i.target.closest(
|
|
291
|
+
".ea-pagination__page:not(.ea-pagination__more)"
|
|
292
|
+
), a = i.target.closest(".ea-pagination__more"), o = Number((_ = s == null ? void 0 : s.dataset) == null ? void 0 : _.page);
|
|
293
|
+
if (s && this["current-page"] !== o)
|
|
294
|
+
this["current-page"] = s.dataset.page;
|
|
295
|
+
else if (a) {
|
|
296
|
+
const w = a.dataset.action, x = Math.ceil(this.total / this["page-size"]);
|
|
297
|
+
let f = this["current-page"] + (w === "next" ? 5 : -5);
|
|
298
|
+
f < 1 ? f = 1 : f > x && (f = x), this["current-page"] = f;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
t(this, c).innerHTML = t(this, A).call(this, 1), t(this, c).addEventListener("click", e, {
|
|
302
|
+
signal: t(this, h).paginationAbortController.signal
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
/**
|
|
306
|
+
* 渲染 prev 按钮
|
|
307
|
+
*/
|
|
308
|
+
l(this, I, () => {
|
|
309
|
+
if (!t(this, b) || !this.layout.includes("prev")) return;
|
|
310
|
+
const e = (a = this["current-page"]) => {
|
|
311
|
+
t(this, b).classList.toggle(
|
|
312
|
+
"is-disabled",
|
|
313
|
+
a <= 1 || this.total <= 0
|
|
314
|
+
), t(this, b).setAttribute(
|
|
315
|
+
"aria-disabled",
|
|
316
|
+
a <= 1 || this.total <= 0
|
|
317
|
+
), t(this, b).setAttribute(
|
|
318
|
+
"tabindex",
|
|
319
|
+
a <= 1 || this.total <= 0 ? -1 : 0
|
|
320
|
+
);
|
|
321
|
+
}, i = (a) => {
|
|
322
|
+
const { currentPage: o } = a.detail;
|
|
323
|
+
e(o);
|
|
324
|
+
}, s = () => {
|
|
325
|
+
this["current-page"] <= 1 || this.total <= 0 || (this["current-page"]--, this.dispatchEvent(
|
|
326
|
+
new Z({ value: this["current-page"] })
|
|
327
|
+
));
|
|
328
|
+
};
|
|
329
|
+
e(), this.addEventListener("change", i, {
|
|
330
|
+
signal: t(this, h).prevAbortController.signal
|
|
331
|
+
}), t(this, b).addEventListener("click", s, {
|
|
332
|
+
signal: t(this, h).prevAbortController.signal
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
/**
|
|
336
|
+
* 渲染 next 按钮
|
|
337
|
+
*/
|
|
338
|
+
l(this, M, () => {
|
|
339
|
+
if (!this.layout.includes("next") || !t(this, m)) return;
|
|
340
|
+
const e = (o = this["current-page"]) => o >= Math.ceil(this.total / this["page-size"]), i = (o = e()) => {
|
|
341
|
+
t(this, m).classList.toggle("is-disabled", o), t(this, m).setAttribute("aria-disabled", o), t(this, m).setAttribute("tabindex", o ? -1 : 0);
|
|
342
|
+
}, s = (o) => {
|
|
343
|
+
const { currentPage: _ } = o.detail;
|
|
344
|
+
i(e(_));
|
|
345
|
+
}, a = () => {
|
|
346
|
+
e() || (this["current-page"]++, this.dispatchEvent(
|
|
347
|
+
new K({ value: this["current-page"] })
|
|
348
|
+
));
|
|
349
|
+
};
|
|
350
|
+
i(), this.addEventListener("change", s, {
|
|
351
|
+
signal: t(this, h).nextAbortController.signal
|
|
352
|
+
}), t(this, m).addEventListener("click", a, {
|
|
353
|
+
signal: t(this, h).nextAbortController.signal
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
/**
|
|
357
|
+
* 渲染 total
|
|
358
|
+
*/
|
|
359
|
+
l(this, j, () => {
|
|
360
|
+
!this.layout.includes("total") || !t(this, y) || (t(this, y).textContent = `Total ${this.total}`);
|
|
361
|
+
});
|
|
362
|
+
/**
|
|
363
|
+
* 渲染 jumper
|
|
364
|
+
*/
|
|
365
|
+
l(this, L, async () => {
|
|
366
|
+
if (!this.layout.includes("jumper") || !t(this, p)) return;
|
|
367
|
+
const e = () => {
|
|
368
|
+
const a = t(this, p).value, o = Math.ceil(this.total / this["page-size"]);
|
|
369
|
+
R.Number.isNumber(a) && a !== "" && a <= o ? this["current-page"] = a : t(this, p).value = this["current-page"];
|
|
370
|
+
}, i = (a) => {
|
|
371
|
+
a.key === "Enter" && e();
|
|
372
|
+
}, s = (a) => {
|
|
373
|
+
t(this, p).value = a.detail.currentPage;
|
|
374
|
+
};
|
|
375
|
+
t(this, p).setAttribute("value", this["current-page"]), t(this, p).addEventListener("blur", e, {
|
|
376
|
+
signal: t(this, h).jumperAbortController.signal
|
|
377
|
+
}), t(this, p).addEventListener("keydown", i, {
|
|
378
|
+
signal: t(this, h).jumperAbortController.signal
|
|
379
|
+
}), this.addEventListener("change", s, {
|
|
380
|
+
signal: t(this, h).jumperAbortController.signal
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
/**
|
|
384
|
+
* 渲染页数组
|
|
385
|
+
*/
|
|
386
|
+
l(this, N, async () => {
|
|
387
|
+
var s;
|
|
388
|
+
if (!this.layout.includes("sizes") || !t(this, d)) return;
|
|
389
|
+
const e = (a) => R.EaElement.h(
|
|
390
|
+
"ea-option",
|
|
391
|
+
null,
|
|
392
|
+
{
|
|
393
|
+
value: a,
|
|
394
|
+
selected: a === this["page-size"]
|
|
395
|
+
},
|
|
396
|
+
`${a}/page`
|
|
397
|
+
), i = (a) => {
|
|
398
|
+
a.stopImmediatePropagation(), !t(this, g).isFirstRender && (this["page-size"] = a.target.value, this["current-page"] = Math.min(
|
|
399
|
+
this["current-page"],
|
|
400
|
+
Math.ceil(this.total / this["page-size"])
|
|
401
|
+
));
|
|
402
|
+
};
|
|
403
|
+
(s = this.pageSizes) != null && s.includes(this["page-size"]) || (this["page-size"] = this.pageSizes[0]), t(this, d).innerHTML = this.pageSizes.map(e).join(""), t(this, d).value = this["page-size"], t(this, d).addEventListener("change", i, {
|
|
404
|
+
signal: t(this, h).sizesAbortController.signal
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
this.stylesheet = J;
|
|
408
|
+
}
|
|
409
|
+
static get observedAttributes() {
|
|
410
|
+
return [
|
|
411
|
+
...super.observedAttributes,
|
|
412
|
+
"default-page-size",
|
|
413
|
+
"page-size",
|
|
414
|
+
"pager-count",
|
|
415
|
+
"total",
|
|
416
|
+
"background",
|
|
417
|
+
"current-page",
|
|
418
|
+
"hide-on-single-page",
|
|
419
|
+
"size",
|
|
420
|
+
"disabled"
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* 获取 classlist 列表
|
|
425
|
+
* @return {string} 属性值
|
|
426
|
+
*/
|
|
427
|
+
updateContainerClasslist() {
|
|
428
|
+
const e = this.computedClasslist(
|
|
429
|
+
"ea-pagination",
|
|
430
|
+
{
|
|
431
|
+
"--background": this.background,
|
|
432
|
+
[`--size-${this.size}`]: this.size
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
hide: this["hide-on-single-page"] && Math.ceil(this.total / this["page-size"]) <= 1,
|
|
436
|
+
disabled: this.disabled
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
return t(this, g).isFirstRender || (t(this, z).className = e), e;
|
|
440
|
+
}
|
|
441
|
+
$render() {
|
|
442
|
+
const e = this.layout.filter(
|
|
443
|
+
(s) => ["prev", "pager", "next", "jumper", "total", "sizes", "->"].includes(s)
|
|
444
|
+
), i = {
|
|
445
|
+
prev: `<ea-icon class="ea-pagination__icon prev-icon" name='angle-left' part='icon prev-icon' tabindex="0"></ea-icon>`,
|
|
446
|
+
pager: "<section class='ea-pagination__pager' part='pager'></section>",
|
|
447
|
+
next: `<ea-icon class="ea-pagination__icon next-icon" name='angle-right' part='icon next-icon' tabindex="0"></ea-icon>`,
|
|
448
|
+
total: "<span class='ea-pagination__total' part='total'></span>",
|
|
449
|
+
jumper: `<span class="ea-pagination__wrapper" part='jumper-wrap'>Go to <ea-input class='ea-pagination__jumper' part='jumper'></ea-input> </span>`,
|
|
450
|
+
sizes: "<ea-select class='ea-pagination__sizes' part='sizes'></ea-select>",
|
|
451
|
+
"->": "<span class='ea-pagination__separator' part='separator'></span>"
|
|
452
|
+
};
|
|
453
|
+
this.shadowRoot.innerHTML = `
|
|
454
|
+
<div class='ea-pagination' part='container'>
|
|
455
|
+
${e.map((s) => i[s]).join("")}
|
|
456
|
+
</div>
|
|
457
|
+
`, u(this, z, this.shadowRoot.querySelector(".ea-pagination")), u(this, c, this.shadowRoot.querySelector(".ea-pagination__pager")), u(this, b, this.shadowRoot.querySelector(
|
|
458
|
+
".ea-pagination__icon.prev-icon"
|
|
459
|
+
)), u(this, m, this.shadowRoot.querySelector(
|
|
460
|
+
".ea-pagination__icon.next-icon"
|
|
461
|
+
)), u(this, p, this.shadowRoot.querySelector(".ea-pagination__jumper")), u(this, y, this.shadowRoot.querySelector(".ea-pagination__total")), u(this, d, this.shadowRoot.querySelector(".ea-pagination__sizes"));
|
|
462
|
+
}
|
|
463
|
+
async connectedCallback() {
|
|
464
|
+
super.connectedCallback(), await C(this, v, E).call(this), t(this, g).isFirstRender = !1, this.updateContainerClasslist();
|
|
465
|
+
}
|
|
466
|
+
$beforeUnmounted() {
|
|
467
|
+
var e;
|
|
468
|
+
for (const i in t(this, h))
|
|
469
|
+
(e = t(this, h)[i]) == null || e.abort(), t(this, h)[i] = null;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
z = new WeakMap(), c = new WeakMap(), b = new WeakMap(), m = new WeakMap(), p = new WeakMap(), y = new WeakMap(), d = new WeakMap(), g = new WeakMap(), h = new WeakMap(), S = new WeakMap(), P = new WeakMap(), A = new WeakMap(), k = new WeakMap(), I = new WeakMap(), M = new WeakMap(), j = new WeakMap(), L = new WeakMap(), N = new WeakMap(), v = new WeakSet(), E = async function() {
|
|
473
|
+
var e, i, s;
|
|
474
|
+
for (const a in t(this, h))
|
|
475
|
+
(e = t(this, h)[a]) == null || e.abort(), t(this, h)[a] = null, t(this, h)[a] = new AbortController();
|
|
476
|
+
(i = this.layout) != null && i.includes("jumper") && !t(this, g).isEaInputImported && (await import("./ea-input.js"), await customElements.whenDefined("ea-input"), t(this, g).isEaInputImported = !0), (s = this.layout) != null && s.includes("sizes") && !t(this, g).isEaSelectImported && (await import("./ea-select.js"), await customElements.whenDefined("ea-select"), t(this, g).isEaSelectImported = !0), u(this, z, null), u(this, c, null), u(this, b, null), u(this, m, null), u(this, p, null), u(this, y, null), u(this, d, null), this.$render(), t(this, N).call(this), t(this, k).call(this), t(this, I).call(this), t(this, M).call(this), t(this, j).call(this), t(this, L).call(this);
|
|
477
|
+
};
|
|
478
|
+
window.customElements.get("ea-pagination") || window.customElements.define("ea-pagination", W);
|
|
479
|
+
export {
|
|
480
|
+
W as EaPagination
|
|
481
|
+
};
|