easy-component-ui 1.0.3 → 2.0.1
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/.github/workflows/publish.yml +28 -0
- package/components/Base.js +1 -90
- package/components/ea-alert/index.js +1 -298
- package/components/ea-alert/src/style/stylesheet.js +1 -0
- package/components/ea-aside/index.js +1 -0
- package/components/ea-avatar/index.js +1 -277
- package/components/ea-avatar/src/assets/defaultAvatar.js +1 -0
- package/components/ea-avatar/src/assets/errorAvatar.js +1 -0
- package/components/ea-avatar/src/assets/iconAndTextAvatar.js +1 -0
- package/components/ea-avatar/src/style/stylesheet.js +1 -0
- package/components/ea-backtop/index.js +1 -232
- package/components/ea-backtop/src/style/stylesheet.js +1 -0
- package/components/ea-badge/index.js +1 -160
- package/components/ea-badge/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb/index.js +1 -0
- package/components/ea-breadcrumb/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb-item/index.js +1 -0
- package/components/ea-breadcrumb-item/src/style/style.js +1 -0
- package/components/ea-button/index.js +1 -584
- package/components/ea-button/src/components/ButtonComm.js +1 -0
- package/components/ea-button/src/components/HrefComm.js +1 -0
- package/components/ea-button/src/style/stylesheet.js +1 -0
- package/components/ea-button-group/index.js +1 -459
- package/components/ea-button-group/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/index.js +1 -409
- package/components/ea-calendar/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/src/utils/createChangerElement.js +1 -0
- package/components/ea-calendar/src/utils/createThead.js +1 -0
- package/components/ea-calendar/src/utils/getDate.js +1 -0
- package/components/ea-calendar/src/utils/getUserWeekStart.js +1 -0
- package/components/ea-card/index.js +1 -77
- package/components/ea-card/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/index.js +1 -434
- package/components/ea-carousel/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/src/utils/handleIndexOverflow.js +1 -0
- package/components/ea-carousel-item/index.js +1 -0
- package/components/ea-carousel-item/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox/index.js +1 -314
- package/components/ea-checkbox/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox-group/index.js +1 -107
- package/components/ea-checkbox-group/src/style/stylesheet.js +1 -0
- package/components/ea-collapse/index.js +1 -293
- package/components/ea-collapse-item/index.js +1 -0
- package/components/ea-collapse-item/src/style/stylesheet.js +1 -0
- package/components/ea-container/index.js +1 -0
- package/components/ea-date-picker/index.js +1 -0
- package/components/ea-date-picker/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions/index.js +1 -240
- package/components/ea-descriptions/src/components/contentTemplate.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_border.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_normal.js +1 -0
- package/components/ea-descriptions/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions-item/index.js +1 -110
- package/components/ea-descriptions-item/src/stylesheet.js +1 -0
- package/components/ea-drawer/index.js +1 -0
- package/components/ea-drawer/src/style/stylesheet.js +1 -0
- package/components/ea-empty/index.js +1 -141
- package/components/ea-empty/src/assets/emptyStatusSVG.js +1 -0
- package/components/ea-empty/src/style/stylesheet.js +1 -0
- package/components/ea-footer/index.js +1 -0
- package/components/ea-form/index.js +1 -0
- package/components/ea-form-item/index.js +1 -0
- package/components/ea-form-item/src/style/stylesheet.js +1 -0
- package/components/ea-header/index.js +1 -0
- package/components/ea-icon/config.json +1029 -1017
- package/components/ea-icon/css/animation.css +85 -85
- package/components/ea-icon/css/fontello.css +226 -224
- package/components/ea-icon/font/fontello.eot +0 -0
- package/components/ea-icon/font/fontello.svg +350 -683
- package/components/ea-icon/font/fontello.ttf +0 -0
- package/components/ea-icon/font/fontello.woff +0 -0
- package/components/ea-icon/font/fontello.woff2 +0 -0
- package/components/ea-icon/index.js +1 -47
- package/components/ea-image/index.js +1 -412
- package/components/ea-image/src/assets/errorImage.js +1 -0
- package/components/ea-image/src/style/stylesheet.js +1 -0
- package/components/ea-image/src/utils/createPreviewTools.js +1 -0
- package/components/ea-infinite-scroll/index.js +1 -170
- package/components/ea-infinite-scroll-item/index.js +1 -0
- package/components/ea-input/index.js +1 -765
- package/components/ea-input/src/components/createFixIcon.js +1 -0
- package/components/ea-input/src/components/createSuggestionBoard.js +1 -0
- package/components/ea-input/src/components/createWordLimitElement.js +1 -0
- package/components/ea-input/src/style/stylesheet.js +1 -0
- package/components/ea-input/src/utils/dispatchEvent.js +1 -0
- package/components/ea-input/src/utils/handleSearchResult.js +1 -0
- package/components/ea-input/src/utils/handleSuggestionBoardTrigger.js +1 -0
- package/components/ea-input-number/index.js +1 -458
- package/components/ea-input-number/src/style/stylesheet.js +1 -0
- package/components/ea-input-number/src/utils/handleCustomEvent.js +1 -0
- package/components/ea-link/index.js +1 -200
- package/components/ea-link/src/style/stylesheet.js +1 -0
- package/components/ea-loading/index.js +1 -218
- package/components/ea-loading/src/style/stylesheet.js +1 -0
- package/components/ea-main/index.js +1 -0
- package/components/ea-menu/index.js +1 -0
- package/components/ea-menu/src/style/stylesheet.js +1 -0
- package/components/ea-menu/src/utils/handleMenuItemEvent.js +1 -0
- package/components/ea-menu-item/index.js +1 -0
- package/components/ea-menu-item/src/style/stylesheet.js +1 -0
- package/components/ea-menu-item-group/index.js +1 -0
- package/components/ea-menu-item-group/src/style/stylesheet.js +1 -0
- package/components/ea-message/index.js +1 -233
- package/components/ea-message/src/style/stylesheet.js +1 -0
- package/components/ea-message/src/utils/MessageClass.js +1 -0
- package/components/ea-message-box/index.js +1 -202
- package/components/ea-message-box/src/style/stylesheet.js +1 -0
- package/components/ea-message-box/src/utils/EaMessageBoxClass.js +1 -0
- package/components/ea-option/index.js +1 -0
- package/components/ea-option/src/style/stylesheet.js +1 -0
- package/components/ea-option-gropu/index.js +1 -0
- package/components/ea-page-header/index.js +1 -0
- package/components/ea-page-header/src/style/stylesheet.js +1 -0
- package/components/ea-pagination/index.js +1 -444
- package/components/ea-pagination/src/components/getMoreItem.js +1 -0
- package/components/ea-pagination/src/components/getPageItem.js +1 -0
- package/components/ea-pagination/src/components/getShowTotalItem.js +1 -0
- package/components/ea-pagination/src/style/stylesheet.js +1 -0
- package/components/ea-pane/index.js +1 -0
- package/components/ea-pane/src/stylesheet.js +1 -0
- package/components/ea-progress/index.js +1 -333
- package/components/ea-progress/src/components/SVGComm.js +1 -0
- package/components/ea-progress/src/style/stylesheet.js +1 -0
- package/components/ea-radio/index.js +1 -287
- package/components/ea-radio/src/style/stylesheet.js +1 -0
- package/components/ea-radio-group/index.js +1 -59
- package/components/ea-rate/index.js +1 -326
- package/components/ea-rate/src/components/rateComm.js +1 -0
- package/components/ea-rate/src/style/stylesheet.js +1 -0
- package/components/ea-result/index.js +1 -167
- package/components/ea-result/src/style/stylesheet.js +1 -0
- package/components/ea-select/index.js +1 -34
- package/components/ea-select/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/index.js +1 -341
- package/components/ea-skeleton/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/src/utils/createSkeletonElement.js +1 -0
- package/components/ea-skeleton-item/index.js +1 -0
- package/components/ea-skeleton-item/src/assets/imageSVG.js +1 -0
- package/components/ea-skeleton-item/src/style/stylesheet.js +1 -0
- package/components/ea-step/index.js +1 -0
- package/components/ea-step/src/style/stylesheet.js +1 -0
- package/components/ea-steps/index.js +1 -0
- package/components/ea-steps/src/style/stylesheet.js +1 -0
- package/components/ea-submenu/index.js +1 -0
- package/components/ea-submenu/src/style/stylesheet.js +1 -0
- package/components/ea-switch/index.js +1 -301
- package/components/ea-switch/src/style/stylesheet.js +1 -0
- package/components/ea-tab/index.js +1 -0
- package/components/ea-tab/src/style/stylesheet.js +1 -0
- package/components/ea-table/index.js +1 -0
- package/components/ea-table/src/style/stylesheet.js +1 -0
- package/components/ea-table-column/index.js +1 -0
- package/components/ea-tabs/index.js +1 -0
- package/components/ea-tabs/src/style/stylesheet.js +1 -0
- package/components/ea-tag/index.js +1 -212
- package/components/ea-tag/src/style/stylesheet.js +1 -0
- package/components/ea-textarea/index.js +1 -333
- package/components/ea-textarea/src/style/stylesheet.js +1 -0
- package/components/ea-time-picker/index.js +1 -0
- package/components/ea-time-picker/src/style/stylesheet.js +1 -0
- package/components/ea-timeline/index.js +1 -334
- package/components/ea-timeline/style/stylesheet.js +1 -0
- package/components/ea-timeline-item/index.js +1 -0
- package/components/ea-timeline-item/src/style/stylesheet.js +1 -0
- package/package.json +11 -11
- package/utils/Validator.js +1 -0
- package/utils/createElement.js +1 -30
- package/utils/handleDefaultAttrIsTrue.js +1 -0
- package/utils/handleTemplate.js +1 -19
- package/utils/setStyle.js +1 -8
- package/utils/timeout.js +1 -0
- package/components/ea-message/MessageClass.js +0 -71
- package/components/ea-message-box/EaMessageBoxClass.js +0 -48
- package/components/ea-ui-base-style.css +0 -0
|
@@ -1,444 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-pagination_wrap {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
font-size: 0.9rem;
|
|
9
|
-
}
|
|
10
|
-
.ea-pagination_wrap .ea-pagination_item_wrap {
|
|
11
|
-
display: flex;
|
|
12
|
-
align-items: center;
|
|
13
|
-
}
|
|
14
|
-
.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_item,
|
|
15
|
-
.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more {
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
margin: 0 5px;
|
|
19
|
-
padding: 0 4px;
|
|
20
|
-
min-width: 30px;
|
|
21
|
-
height: 28px;
|
|
22
|
-
line-height: 28px;
|
|
23
|
-
font-size: 13px;
|
|
24
|
-
text-align: center;
|
|
25
|
-
}
|
|
26
|
-
.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_item.ea-pagination_item--active {
|
|
27
|
-
color: #409eff;
|
|
28
|
-
}
|
|
29
|
-
.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more {
|
|
30
|
-
cursor: pointer;
|
|
31
|
-
user-select: none;
|
|
32
|
-
}
|
|
33
|
-
.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more.ea-pagination_more--active {
|
|
34
|
-
color: #409eff;
|
|
35
|
-
}
|
|
36
|
-
.ea-pagination_wrap .ea-pagination_arrow {
|
|
37
|
-
user-select: none;
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
padding: 0 10px;
|
|
40
|
-
}
|
|
41
|
-
.ea-pagination_wrap .ea-pagination_arrow.disabled {
|
|
42
|
-
cursor: default;
|
|
43
|
-
pointer-events: none;
|
|
44
|
-
color: #c0c4cc;
|
|
45
|
-
}
|
|
46
|
-
.ea-pagination_wrap .ea-pagination_arrow:first-child {
|
|
47
|
-
margin-right: 0.25rem;
|
|
48
|
-
}
|
|
49
|
-
.ea-pagination_wrap .ea-pagination_arrow:last-child {
|
|
50
|
-
margin-left: 0.25rem;
|
|
51
|
-
}
|
|
52
|
-
.ea-pagination_wrap .ea-pagination_item.background,
|
|
53
|
-
.ea-pagination_wrap .ea-pagination_more.background,
|
|
54
|
-
.ea-pagination_wrap .ea-pagination_arrow.background {
|
|
55
|
-
background-color: #f4f4f5;
|
|
56
|
-
border-radius: 3px;
|
|
57
|
-
}
|
|
58
|
-
.ea-pagination_wrap .ea-pagination_item.background:hover,
|
|
59
|
-
.ea-pagination_wrap .ea-pagination_more.background:hover,
|
|
60
|
-
.ea-pagination_wrap .ea-pagination_arrow.background:hover {
|
|
61
|
-
color: #409eff;
|
|
62
|
-
}
|
|
63
|
-
.ea-pagination_wrap .ea-pagination_item.background.active,
|
|
64
|
-
.ea-pagination_wrap .ea-pagination_more.background.active,
|
|
65
|
-
.ea-pagination_wrap .ea-pagination_arrow.background.active {
|
|
66
|
-
background-color: #409eff;
|
|
67
|
-
color: #f4f4f5;
|
|
68
|
-
}
|
|
69
|
-
.ea-pagination_wrap .ea-pagination_show_total {
|
|
70
|
-
margin-right: 0.5rem;
|
|
71
|
-
font-size: 13px;
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const getPaginationWrap = () => {
|
|
77
|
-
const paginationWrap = document.createElement('div');
|
|
78
|
-
paginationWrap.className = 'ea-pagination_item_wrap';
|
|
79
|
-
|
|
80
|
-
return paginationWrap;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const getPageItem = (page, hasBgc) => {
|
|
84
|
-
const pageItem = document.createElement('span');
|
|
85
|
-
pageItem.className = 'ea-pagination_item';
|
|
86
|
-
pageItem.innerText = page;
|
|
87
|
-
pageItem.setAttribute('data-page', page);
|
|
88
|
-
|
|
89
|
-
if (hasBgc) pageItem.classList.add('background');
|
|
90
|
-
|
|
91
|
-
return pageItem;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const getArrowItem = (arrow, hasBgc) => {
|
|
95
|
-
const arrowItem = document.createElement('span');
|
|
96
|
-
arrowItem.className = 'ea-pagination_arrow';
|
|
97
|
-
arrowItem.innerHTML = arrow === "prev" ? '<' : '>';
|
|
98
|
-
|
|
99
|
-
if (hasBgc) arrowItem.classList.add('background');
|
|
100
|
-
|
|
101
|
-
return arrowItem;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const getMoreItem = (arrow, hasBgc) => {
|
|
105
|
-
const moreItem = document.createElement('span');
|
|
106
|
-
moreItem.className = 'ea-pagination_more';
|
|
107
|
-
moreItem.innerHTML = '···';
|
|
108
|
-
|
|
109
|
-
if (hasBgc) moreItem.classList.add('background');
|
|
110
|
-
|
|
111
|
-
moreItem.addEventListener('mouseenter', function (e) {
|
|
112
|
-
moreItem.classList.add('ea-pagination_more--active');
|
|
113
|
-
moreItem.innerHTML = arrow === "prev" ? '<<' : '>>';
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
moreItem.addEventListener('mouseleave', function (e) {
|
|
117
|
-
moreItem.classList.remove('ea-pagination_more--active');
|
|
118
|
-
moreItem.innerHTML = '···';
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
return moreItem;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const getShowTotalItem = () => {
|
|
125
|
-
const showTotalItem = document.createElement('span');
|
|
126
|
-
showTotalItem.className = 'ea-pagination_show_total';
|
|
127
|
-
|
|
128
|
-
return showTotalItem;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export class EaPagination extends Base {
|
|
132
|
-
#container;
|
|
133
|
-
|
|
134
|
-
// 页码元素的容器
|
|
135
|
-
#paginationWrap;
|
|
136
|
-
|
|
137
|
-
// 箭头
|
|
138
|
-
#prevArrow;
|
|
139
|
-
#nextArrow;
|
|
140
|
-
|
|
141
|
-
constructor() {
|
|
142
|
-
super();
|
|
143
|
-
|
|
144
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
145
|
-
const wrap = document.createElement('div');
|
|
146
|
-
wrap.className = 'ea-pagination_wrap';
|
|
147
|
-
|
|
148
|
-
this.#container = wrap;
|
|
149
|
-
|
|
150
|
-
const prevArrow = getArrowItem('prev', this.background);
|
|
151
|
-
const pageItemWrap = getPaginationWrap();
|
|
152
|
-
const nextArrow = getArrowItem('next', this.background);
|
|
153
|
-
|
|
154
|
-
this.#container.appendChild(prevArrow);
|
|
155
|
-
this.#container.appendChild(pageItemWrap);
|
|
156
|
-
this.#container.appendChild(nextArrow);
|
|
157
|
-
|
|
158
|
-
this.#prevArrow = prevArrow;
|
|
159
|
-
this.#paginationWrap = pageItemWrap;
|
|
160
|
-
this.#nextArrow = nextArrow;
|
|
161
|
-
|
|
162
|
-
this.build(shadowRoot, stylesheet);
|
|
163
|
-
this.shadowRoot.appendChild(wrap);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// ------- layout 布局(前一页, 页码, 后一页) -------
|
|
167
|
-
// #region
|
|
168
|
-
get layout() {
|
|
169
|
-
const arr = this.getAttribute('layout').split(',').map(item => item.trim());
|
|
170
|
-
|
|
171
|
-
return arr || ['prev', 'pager', 'next'];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
set layout(value) {
|
|
175
|
-
this.setAttribute('layout', value);
|
|
176
|
-
}
|
|
177
|
-
// #endregion
|
|
178
|
-
// ------- end -------
|
|
179
|
-
|
|
180
|
-
// ------- sizes 分页中每页多少记录 -------
|
|
181
|
-
// #region
|
|
182
|
-
get sizes() {
|
|
183
|
-
return this.getAttrNumber('sizes') || 10;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
set sizes(value) {
|
|
187
|
-
this.setAttribute('sizes', value);
|
|
188
|
-
}
|
|
189
|
-
// #endregion
|
|
190
|
-
// ------- end -------
|
|
191
|
-
|
|
192
|
-
// ------- current-page 当前页码 -------
|
|
193
|
-
// #region
|
|
194
|
-
get currentPage() {
|
|
195
|
-
return this.getAttrNumber('current-page') || 1;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
set currentPage(value) {
|
|
199
|
-
this.setAttribute('current-page', value);
|
|
200
|
-
}
|
|
201
|
-
// #endregion
|
|
202
|
-
// ------- end -------
|
|
203
|
-
|
|
204
|
-
// ------- page-count 总显示的页码数量 -------
|
|
205
|
-
// #region
|
|
206
|
-
get pageCount() {
|
|
207
|
-
return this.getAttrNumber('page-count') || 6;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
set pageCount(value) {
|
|
211
|
-
this.setAttribute('page-count', value);
|
|
212
|
-
}
|
|
213
|
-
// #endregion
|
|
214
|
-
// ------- end -------
|
|
215
|
-
|
|
216
|
-
// ------- total 总记录数 -------
|
|
217
|
-
// #region
|
|
218
|
-
|
|
219
|
-
get total() {
|
|
220
|
-
return this.getAttrNumber('total');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
set total(value) {
|
|
224
|
-
this.setAttribute('total', value);
|
|
225
|
-
}
|
|
226
|
-
// #endregion
|
|
227
|
-
// ------- end -------
|
|
228
|
-
|
|
229
|
-
// ------- paginationCount 分页总数 -------
|
|
230
|
-
// #region
|
|
231
|
-
get paginationCount() {
|
|
232
|
-
return Math.ceil(this.total / this.sizes);
|
|
233
|
-
}
|
|
234
|
-
// #endregion
|
|
235
|
-
// ------- end -------
|
|
236
|
-
|
|
237
|
-
// ------- background 背景颜色 -------
|
|
238
|
-
// #region
|
|
239
|
-
get background() {
|
|
240
|
-
return this.getAttrBoolean('background');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
set background(value) {
|
|
244
|
-
this.setAttribute('background', value);
|
|
245
|
-
}
|
|
246
|
-
// #endregion
|
|
247
|
-
// ------- end -------
|
|
248
|
-
|
|
249
|
-
handleDispatchEvent(event, options) {
|
|
250
|
-
this.dispatchEvent(new CustomEvent(event, options));
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// 初始化箭头元素
|
|
254
|
-
initArrowItem() {
|
|
255
|
-
const that = this;
|
|
256
|
-
|
|
257
|
-
this.handleArrowStatus();
|
|
258
|
-
|
|
259
|
-
if (this.layout.includes('prev')) {
|
|
260
|
-
this.#prevArrow.addEventListener('click', () => {
|
|
261
|
-
if (that.currentPage <= 1) return;
|
|
262
|
-
|
|
263
|
-
that.currentPage--;
|
|
264
|
-
that.handlePaginationChange();
|
|
265
|
-
|
|
266
|
-
that.handleDispatchEvent("change", { detail: { currentPage: that.currentPage } });
|
|
267
|
-
})
|
|
268
|
-
} else {
|
|
269
|
-
this.#prevArrow.style.display = 'none';
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (this.layout.includes('next')) {
|
|
273
|
-
this.#nextArrow.addEventListener('click', () => {
|
|
274
|
-
if (that.currentPage >= that.paginationCount) return;
|
|
275
|
-
|
|
276
|
-
that.currentPage++;
|
|
277
|
-
that.handlePaginationChange();
|
|
278
|
-
|
|
279
|
-
that.handleDispatchEvent("change", { detail: { currentPage: that.currentPage } });
|
|
280
|
-
})
|
|
281
|
-
} else {
|
|
282
|
-
this.#nextArrow.style.display = 'none';
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// 处理箭头状态
|
|
287
|
-
handleArrowStatus() {
|
|
288
|
-
if (!this.layout.includes('prev') && !this.layout.includes('next')) return;
|
|
289
|
-
|
|
290
|
-
if (this.currentPage === 1 && this.layout.includes('prev')) this.#prevArrow.classList.add('disabled');
|
|
291
|
-
else if (this.currentPage >= this.paginationCount && this.layout.includes('next')) this.#nextArrow.classList.add('disabled');
|
|
292
|
-
else {
|
|
293
|
-
this.#prevArrow.classList.remove('disabled');
|
|
294
|
-
this.#nextArrow.classList.remove('disabled');
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// 处理分页点击事件
|
|
299
|
-
handlePaginationClick(pageItem, index) {
|
|
300
|
-
const that = this;
|
|
301
|
-
|
|
302
|
-
pageItem.addEventListener('click', function (e) {
|
|
303
|
-
that.currentPage = index;
|
|
304
|
-
that.handlePaginationChange();
|
|
305
|
-
|
|
306
|
-
that.handleDispatchEvent('change', {
|
|
307
|
-
detail: {
|
|
308
|
-
currentPage: that.currentPage
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
})
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// 处理更多按钮点击事件
|
|
315
|
-
handleMoreItemClick(moreItem, arrow) {
|
|
316
|
-
const that = this;
|
|
317
|
-
|
|
318
|
-
moreItem.addEventListener('click', function (e) {
|
|
319
|
-
|
|
320
|
-
// 跳转到指定页码
|
|
321
|
-
that.currentPage += arrow === "prev" ? -5 : 5;
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* 边界处理:
|
|
325
|
-
* 页码数量小于1, 跳转到第一页
|
|
326
|
-
* 页码数量大于总页数, 跳转到最后一页
|
|
327
|
-
*/
|
|
328
|
-
if (that.currentPage < 1) that.currentPage = 1;
|
|
329
|
-
else if (that.currentPage > that.paginationCount) that.currentPage = that.paginationCount;
|
|
330
|
-
|
|
331
|
-
that.handlePaginationChange();
|
|
332
|
-
|
|
333
|
-
that.handleDispatchEvent('change', {
|
|
334
|
-
detail: {
|
|
335
|
-
currentPage: that.currentPage
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
})
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// 处理分页的页码
|
|
342
|
-
handlePaginationItemChange() {
|
|
343
|
-
const that = this;
|
|
344
|
-
|
|
345
|
-
if (!this.layout.includes('pager')) return;
|
|
346
|
-
|
|
347
|
-
this.#paginationWrap.innerHTML = '';
|
|
348
|
-
|
|
349
|
-
const interval = Math.floor(this.pageCount / 2);
|
|
350
|
-
let start = this.currentPage - interval;
|
|
351
|
-
let end = this.currentPage + interval;
|
|
352
|
-
|
|
353
|
-
// 边界处理
|
|
354
|
-
if (start <= 1) {
|
|
355
|
-
start = 1;
|
|
356
|
-
end = this.pageCount < this.paginationCount ? this.pageCount : this.paginationCount;
|
|
357
|
-
} else if (end >= this.paginationCount) {
|
|
358
|
-
start = this.paginationCount - this.pageCount + 1;
|
|
359
|
-
end = this.paginationCount;
|
|
360
|
-
} else {
|
|
361
|
-
end--;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// 添加页码
|
|
365
|
-
for (let i = start; i <= end; i++) {
|
|
366
|
-
const pageItem = getPageItem(i, this.background);
|
|
367
|
-
this.#paginationWrap.appendChild(pageItem);
|
|
368
|
-
|
|
369
|
-
// 设置当前页码选中后的样式
|
|
370
|
-
if (i === this.currentPage) {
|
|
371
|
-
pageItem.classList.add('ea-pagination_item--active');
|
|
372
|
-
if (this.background) pageItem.classList.add('active');
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// 添加点击事件
|
|
376
|
-
that.handlePaginationClick(pageItem, i);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// 添加 更多(左) + 第一页
|
|
380
|
-
if (this.total > this.pageCount && this.currentPage >= this.pageCount && this.paginationCount !== this.pageCount) {
|
|
381
|
-
const more = getMoreItem('prev', this.background);
|
|
382
|
-
that.handleMoreItemClick(more, 'prev');
|
|
383
|
-
|
|
384
|
-
const firstPage = getPageItem(1, this.background);
|
|
385
|
-
this.handlePaginationClick(firstPage, 1);
|
|
386
|
-
|
|
387
|
-
this.#paginationWrap.insertBefore(more, this.#paginationWrap.firstChild);
|
|
388
|
-
this.#paginationWrap.insertBefore(firstPage, this.#paginationWrap.firstChild);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// 添加 更多(右) + 最后一页
|
|
392
|
-
if (this.total > this.pageCount && this.currentPage < this.paginationCount - interval && this.paginationCount !== this.pageCount) {
|
|
393
|
-
const more = getMoreItem('next', this.background);
|
|
394
|
-
that.handleMoreItemClick(more, 'next');
|
|
395
|
-
|
|
396
|
-
const lastPage = getPageItem(this.paginationCount, this.background);
|
|
397
|
-
this.handlePaginationClick(lastPage, this.paginationCount);
|
|
398
|
-
|
|
399
|
-
this.#paginationWrap.appendChild(more);
|
|
400
|
-
this.#paginationWrap.appendChild(lastPage);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// 处理分页变化
|
|
405
|
-
handlePaginationChange() {
|
|
406
|
-
this.handleArrowStatus();
|
|
407
|
-
this.handlePaginationItemChange();
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// 处理显示总数
|
|
411
|
-
initTotalShow() {
|
|
412
|
-
if (!this.layout.includes('total')) return;
|
|
413
|
-
|
|
414
|
-
const totalItem = getShowTotalItem();
|
|
415
|
-
totalItem.innerHTML = `共 ${this.total} 条`;
|
|
416
|
-
|
|
417
|
-
this.#container.insertBefore(totalItem, this.#container.firstChild);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
init() {
|
|
421
|
-
const that = this;
|
|
422
|
-
|
|
423
|
-
// 设置sizes
|
|
424
|
-
this.sizes = this.sizes;
|
|
425
|
-
|
|
426
|
-
// 设置current-page
|
|
427
|
-
this.currentPage = this.currentPage;
|
|
428
|
-
|
|
429
|
-
// 设置total
|
|
430
|
-
this.total = this.total;
|
|
431
|
-
|
|
432
|
-
this.initArrowItem();
|
|
433
|
-
this.handlePaginationItemChange();
|
|
434
|
-
this.initTotalShow();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
connectedCallback() {
|
|
438
|
-
this.init();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
if (!customElements.get('ea-pagination')) {
|
|
443
|
-
customElements.define('ea-pagination', EaPagination);
|
|
444
|
-
}
|
|
1
|
+
import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";import{getMoreItem}from"./src/components/getMoreItem.js";import{getPageItem}from"./src/components/getPageItem.js";import{getShowTotalItem}from"./src/components/getShowTotalItem.js";export class EaPagination extends Base{#t;#e;#i;#a;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML=`\n <div class="ea-pagination_wrap" part="container">\n <span class="ea-pagination_arrow prev ${this.background?"background":""}" part="arrow"><</span>\n <div class="ea-pagination_item_wrap" part="item-wrap"></div>\n <span class="ea-pagination_arrow next ${this.background?"background":""}" part="arrow">></span>\n </div>\n `,this.#t=t.querySelector(".ea-pagination_wrap"),this.#i=t.querySelector(".prev"),this.#e=t.querySelector(".ea-pagination_item_wrap"),this.#a=t.querySelector(".next"),this.build(t,stylesheet)}get layout(){return this.getAttribute("layout").split(",").map((t=>t.trim()))||["prev","pager","next"]}set layout(t){this.setAttribute("layout",t)}get sizes(){return this.getAttrNumber("sizes")||10}set sizes(t){this.setAttribute("sizes",t)}get currentPage(){return this.getAttrNumber("current-page")||1}set currentPage(t){this.setAttribute("current-page",t)}get pageCount(){return this.getAttrNumber("page-count")||6}set pageCount(t){this.setAttribute("page-count",t)}get total(){return this.getAttrNumber("total")}set total(t){this.setAttribute("total",t)}get paginationCount(){return Math.ceil(this.total/this.sizes)}get background(){return this.getAttrBoolean("background")}set background(t){t&&this.setAttribute("background",t)}#n(t,e){this.dispatchEvent(new CustomEvent(t,e))}#s(){this.#r(),this.layout.includes("prev")?this.#i.addEventListener("click",(()=>{this.currentPage<=1||(this.currentPage--,this.#o(),this.#n("change",{detail:{currentPage:this.currentPage}}))})):this.#i.style.display="none",this.layout.includes("next")?this.#a.addEventListener("click",(()=>{this.currentPage>=this.paginationCount||(this.currentPage++,this.#o(),this.#n("change",{detail:{currentPage:this.currentPage}}))})):this.#a.style.display="none"}#r(){(this.layout.includes("prev")||this.layout.includes("next"))&&(1===this.currentPage&&this.layout.includes("prev")?this.#i.classList.add("disabled"):this.currentPage>=this.paginationCount&&this.layout.includes("next")?this.#a.classList.add("disabled"):(this.#i.classList.remove("disabled"),this.#a.classList.remove("disabled")))}#h(t,e){t.addEventListener("click",(t=>{this.currentPage=e,this.#o(),this.#n("change",{detail:{currentPage:this.currentPage}})}))}#g(t,e){t.addEventListener("click",(t=>{this.currentPage+="prev"===e?-5:5,this.currentPage<1?this.currentPage=1:this.currentPage>this.paginationCount&&(this.currentPage=this.paginationCount),this.#o(),this.#n("change",{detail:{currentPage:this.currentPage}})}))}#c(){if(!this.layout.includes("pager"))return;this.#e.innerHTML="";const t=Math.floor(this.pageCount/2);let e=this.currentPage-t,i=this.currentPage+t;e<=1?(e=1,i=this.pageCount<this.paginationCount?this.pageCount:this.paginationCount):i>=this.paginationCount?(e=this.paginationCount-this.pageCount+1,i=this.paginationCount):i--;for(let t=e;t<=i;t++){const e=getPageItem(t,this.background);this.#e.appendChild(e),t===this.currentPage&&(e.classList.add("ea-pagination_item--active"),this.background&&e.classList.add("active")),this.#h(e,t)}if(this.total>this.pageCount&&this.currentPage>=this.pageCount&&this.paginationCount!==this.pageCount){const t=getMoreItem("prev",this.background);this.#g(t,"prev");const e=getPageItem(1,this.background);this.#h(e,1),this.#e.insertBefore(t,this.#e.firstChild),this.#e.insertBefore(e,this.#e.firstChild)}if(this.total>this.pageCount&&this.currentPage<this.paginationCount-t&&this.paginationCount!==this.pageCount){const t=getMoreItem("next",this.background);this.#g(t,"next");const e=getPageItem(this.paginationCount,this.background);this.#h(e,this.paginationCount),this.#e.appendChild(t),this.#e.appendChild(e)}}#o(){this.#r(),this.#c()}#u(){if(!this.layout.includes("total"))return;const t=getShowTotalItem();t.innerHTML=`共 ${this.total} 条`,this.#t.insertBefore(t,this.#t.firstChild)}connectedCallback(){this.sizes=this.sizes,this.currentPage=this.currentPage,this.total=this.total,this.#s(),this.#c(),this.#u()}}customElements.get("ea-pagination")||customElements.define("ea-pagination",EaPagination);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getMoreItem=(e,n)=>{const t=document.createElement("span");return t.className="ea-pagination_more",t.innerHTML="···",n&&t.classList.add("background"),t.addEventListener("mouseenter",(function(n){t.classList.add("ea-pagination_more--active"),t.innerHTML="prev"===e?"<<":">>"})),t.addEventListener("mouseleave",(function(e){t.classList.remove("ea-pagination_more--active"),t.innerHTML="···"})),t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getPageItem=(e,t)=>{const a=document.createElement("span");return a.className="ea-pagination_item",a.innerText=e,a.setAttribute("data-page",e),t&&a.classList.add("background"),a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getShowTotalItem=()=>{const t=document.createElement("span");return t.className="ea-pagination_show_total",t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-pagination_wrap {\n display: flex;\n align-items: center;\n font-size: 0.9rem;\n}\n.ea-pagination_wrap .ea-pagination_item_wrap {\n display: flex;\n align-items: center;\n}\n.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_item,\n.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more {\n cursor: pointer;\n box-sizing: border-box;\n margin: 0 5px;\n padding: 0 4px;\n min-width: 30px;\n height: 28px;\n line-height: 28px;\n font-size: 13px;\n text-align: center;\n}\n.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_item.ea-pagination_item--active {\n color: #409eff;\n}\n.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more {\n cursor: pointer;\n user-select: none;\n}\n.ea-pagination_wrap .ea-pagination_item_wrap .ea-pagination_more.ea-pagination_more--active {\n color: #409eff;\n}\n.ea-pagination_wrap .ea-pagination_arrow {\n user-select: none;\n cursor: pointer;\n padding: 0 10px;\n line-height: 28px;\n}\n.ea-pagination_wrap .ea-pagination_arrow.disabled {\n cursor: default;\n pointer-events: none;\n color: #c0c4cc;\n}\n.ea-pagination_wrap .ea-pagination_arrow:first-child {\n margin-right: 0.25rem;\n}\n.ea-pagination_wrap .ea-pagination_arrow:last-child {\n margin-left: 0.25rem;\n}\n.ea-pagination_wrap .ea-pagination_item.background,\n.ea-pagination_wrap .ea-pagination_more.background,\n.ea-pagination_wrap .ea-pagination_arrow.background {\n background-color: #f4f4f5;\n border-radius: 3px;\n}\n.ea-pagination_wrap .ea-pagination_item.background:hover,\n.ea-pagination_wrap .ea-pagination_more.background:hover,\n.ea-pagination_wrap .ea-pagination_arrow.background:hover {\n color: #409eff;\n}\n.ea-pagination_wrap .ea-pagination_item.background.active,\n.ea-pagination_wrap .ea-pagination_more.background.active,\n.ea-pagination_wrap .ea-pagination_arrow.background.active {\n background-color: #409eff;\n color: #f4f4f5;\n}\n.ea-pagination_wrap .ea-pagination_show_total {\n margin-right: 0.5rem;\n font-size: 13px;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{stylesheet}from"./src/stylesheet.js";export class EaPane extends Base{#e;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-pane_wrap" part="container">\n <slot></slot>\n </div>\n ',this.#e=e.querySelector(".ea-pane_wrap"),this.build(e,stylesheet)}get actived(){return this.getAttribute("actived")}set actived(e){this.setAttribute("actived",e),this.#e.classList.toggle("is-actived",e)}get name(){return this.getAttribute("name")}set name(e){this.setAttribute("name",e)}}customElements.get("ea-pane")||customElements.define("ea-pane",EaPane);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-pane_wrap {\n display: none;\n}\n.ea-pane_wrap.is-actived {\n display: block;\n}\n";
|