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,277 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-avatar_wrap .ea-avatar {
|
|
6
|
-
position: relative;
|
|
7
|
-
display: inline-block;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
color: #ffffff;
|
|
10
|
-
}
|
|
11
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar-fill--fill img {
|
|
12
|
-
object-fit: fill;
|
|
13
|
-
}
|
|
14
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar-fill--contain img {
|
|
15
|
-
object-fit: contain;
|
|
16
|
-
}
|
|
17
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar-fill--cover img {
|
|
18
|
-
object-fit: cover;
|
|
19
|
-
}
|
|
20
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar-fill--none img {
|
|
21
|
-
object-fit: none;
|
|
22
|
-
}
|
|
23
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar-fill--scale-down img {
|
|
24
|
-
object-fit: scale-down;
|
|
25
|
-
}
|
|
26
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--normal {
|
|
27
|
-
width: 50px;
|
|
28
|
-
height: 50px;
|
|
29
|
-
line-height: 50px;
|
|
30
|
-
}
|
|
31
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--large {
|
|
32
|
-
width: 40px;
|
|
33
|
-
height: 40px;
|
|
34
|
-
line-height: 40px;
|
|
35
|
-
}
|
|
36
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--medium {
|
|
37
|
-
width: 36px;
|
|
38
|
-
height: 36px;
|
|
39
|
-
line-height: 36px;
|
|
40
|
-
}
|
|
41
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--small {
|
|
42
|
-
width: 28px;
|
|
43
|
-
height: 28px;
|
|
44
|
-
line-height: 28px;
|
|
45
|
-
}
|
|
46
|
-
.ea-avatar_wrap .ea-avatar .ea-avatar--text {
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 50%;
|
|
49
|
-
left: 50%;
|
|
50
|
-
transform: translate(-50%, -50%);
|
|
51
|
-
}
|
|
52
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--circle {
|
|
53
|
-
border-radius: 50%;
|
|
54
|
-
}
|
|
55
|
-
.ea-avatar_wrap .ea-avatar.ea-avatar--square {
|
|
56
|
-
border-radius: 5px;
|
|
57
|
-
}
|
|
58
|
-
.ea-avatar_wrap .ea-avatar .ea-avatar--img {
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
object-fit: cover;
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
const defaultAvatar = `
|
|
66
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
67
|
-
<defs>
|
|
68
|
-
<clipPath id="a">
|
|
69
|
-
<path d="M0 40h90v45H0z" />
|
|
70
|
-
</clipPath>
|
|
71
|
-
</defs>
|
|
72
|
-
<path fill="#c0c4cc" d="M0 0h100v100H0z" />
|
|
73
|
-
<circle cx="50" cy="35" r="20" fill="#fff" />
|
|
74
|
-
<circle cx="50" cy="97" r="40" fill="#fff" clip-path="url(#a)" />
|
|
75
|
-
</svg>
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
const errorAvatar = `
|
|
79
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
80
|
-
<path fill="#c0c4cc" d="M0 0h100v100H0z" />
|
|
81
|
-
<path fill="#fff" d="M15 20h70v60H15z" />
|
|
82
|
-
<circle r="8" cx="32" cy="35" fill="#c0c4cc" />
|
|
83
|
-
<path d="M60 42.5L39 75h42z" fill="#c0c4cc" />
|
|
84
|
-
<path d="M35 52.5L20 75h-4 32z" fill="#c0c4cc" />
|
|
85
|
-
</svg>
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
const iconAvatar = (icon) => {
|
|
89
|
-
return `
|
|
90
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
91
|
-
<path fill="#c0c4cc" d="M0 0h100v100H0z" />
|
|
92
|
-
</svg>
|
|
93
|
-
<i class="fa ea-avatar--text ${icon}"></i>
|
|
94
|
-
`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const textAvatar = (text) => {
|
|
98
|
-
return `
|
|
99
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
100
|
-
<path fill="#c0c4cc" d="M0 0h100v100H0z" />
|
|
101
|
-
</svg>
|
|
102
|
-
<span class="ea-avatar--text">${text}</span>
|
|
103
|
-
`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export class EaAvatar extends Base {
|
|
107
|
-
#wrap;
|
|
108
|
-
|
|
109
|
-
#textSlot;
|
|
110
|
-
|
|
111
|
-
#avatar;
|
|
112
|
-
#img;
|
|
113
|
-
|
|
114
|
-
constructor() {
|
|
115
|
-
super();
|
|
116
|
-
|
|
117
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
118
|
-
const wrap = document.createElement('div');
|
|
119
|
-
wrap.className = 'ea-avatar_wrap';
|
|
120
|
-
|
|
121
|
-
const avatar = document.createElement('span');
|
|
122
|
-
avatar.className = 'ea-avatar';
|
|
123
|
-
avatar.innerHTML = defaultAvatar;
|
|
124
|
-
wrap.appendChild(avatar);
|
|
125
|
-
|
|
126
|
-
const slot = document.createElement('slot');
|
|
127
|
-
avatar.appendChild(slot);
|
|
128
|
-
|
|
129
|
-
const img = document.createElement('img');
|
|
130
|
-
avatar.appendChild(img);
|
|
131
|
-
|
|
132
|
-
this.#wrap = wrap;
|
|
133
|
-
this.#textSlot = slot;
|
|
134
|
-
this.#avatar = avatar;
|
|
135
|
-
this.#img = img;
|
|
136
|
-
|
|
137
|
-
const link = document.createElement('link');
|
|
138
|
-
link.rel = 'stylesheet';
|
|
139
|
-
link.href = new URL('../ea-icon/index.css', import.meta.url).href;
|
|
140
|
-
shadowRoot.appendChild(link);
|
|
141
|
-
|
|
142
|
-
this.build(shadowRoot, stylesheet);
|
|
143
|
-
this.shadowRoot.appendChild(wrap);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ------- size 图片大小 -------
|
|
147
|
-
// #region
|
|
148
|
-
get size() {
|
|
149
|
-
const sizeNumber = this.getAttrNumber('size');
|
|
150
|
-
const sizeString = this.getAttribute('size');
|
|
151
|
-
|
|
152
|
-
if (sizeNumber === 0 || !sizeNumber) {
|
|
153
|
-
return ['large', 'medium', 'small'].includes(sizeString) ? sizeString : 'normal';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return this.getAttrNumber('size');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
set size(value) {
|
|
160
|
-
this.setAttribute('size', value);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (typeof value === "number") {
|
|
164
|
-
this.#avatar.style.width = `${value}px`;
|
|
165
|
-
this.#avatar.style.height = `${value}px`;
|
|
166
|
-
this.#avatar.style.lineHeight = `${value}px`;
|
|
167
|
-
} else if (typeof value === "string") {
|
|
168
|
-
this.#avatar.classList.add(`ea-avatar--${value}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// #endregion
|
|
172
|
-
// ------- end -------
|
|
173
|
-
|
|
174
|
-
// ------- shape 图片形状 -------
|
|
175
|
-
// #region
|
|
176
|
-
get shape() {
|
|
177
|
-
const shape = this.getAttribute('shape');
|
|
178
|
-
|
|
179
|
-
return ['circle', 'square'].includes(shape) ? shape : 'circle';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
set shape(value) {
|
|
183
|
-
this.setAttribute('shape', value);
|
|
184
|
-
this.#avatar.classList.add(`ea-avatar--${this.shape}`);
|
|
185
|
-
}
|
|
186
|
-
// #endregion
|
|
187
|
-
// ------- end -------
|
|
188
|
-
|
|
189
|
-
// ------- src 图片链接 -------
|
|
190
|
-
// #region
|
|
191
|
-
get src() {
|
|
192
|
-
return this.getAttribute('src');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
set src(value) {
|
|
196
|
-
if (!value) return;
|
|
197
|
-
|
|
198
|
-
const image = new Image();
|
|
199
|
-
image.src = value;
|
|
200
|
-
|
|
201
|
-
image.onload = () => {
|
|
202
|
-
this.setAttribute('src', value);
|
|
203
|
-
this.#avatar.innerHTML = `<img class="ea-avatar--img" src="${value}" alt="头像">`;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
image.onerror = (e) => {
|
|
207
|
-
this.setAttribute('src', value);
|
|
208
|
-
this.#avatar.innerHTML = errorAvatar;
|
|
209
|
-
|
|
210
|
-
this.dispatchEvent(new CustomEvent('error', {
|
|
211
|
-
detail: {
|
|
212
|
-
error: e,
|
|
213
|
-
},
|
|
214
|
-
}));
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
// #endregion
|
|
218
|
-
// ------- end -------
|
|
219
|
-
|
|
220
|
-
// ------- icon 图标 -------
|
|
221
|
-
// #region
|
|
222
|
-
get icon() {
|
|
223
|
-
return this.getAttribute('icon');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
set icon(value) {
|
|
227
|
-
this.setAttribute('icon', value);
|
|
228
|
-
|
|
229
|
-
this.#avatar.innerHTML = iconAvatar(value);
|
|
230
|
-
}
|
|
231
|
-
// #endregion
|
|
232
|
-
// ------- end -------
|
|
233
|
-
|
|
234
|
-
// ------- fit 图片容器适应 -------
|
|
235
|
-
// #region
|
|
236
|
-
get fit() {
|
|
237
|
-
return this.getAttribute('fit') || 'cover';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
set fit(value) {
|
|
241
|
-
this.setAttribute('fit', value);
|
|
242
|
-
|
|
243
|
-
this.#avatar.classList.add(`ea-avatar-fill--${value}`);
|
|
244
|
-
}
|
|
245
|
-
// #endregion
|
|
246
|
-
// ------- end -------
|
|
247
|
-
|
|
248
|
-
init() {
|
|
249
|
-
const that = this;
|
|
250
|
-
|
|
251
|
-
this.size = this.size;
|
|
252
|
-
|
|
253
|
-
this.shape = this.shape;
|
|
254
|
-
|
|
255
|
-
this.src = this.src;
|
|
256
|
-
|
|
257
|
-
if (this.src) {
|
|
258
|
-
this.fit = this.fit;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (!this.src && this.icon) {
|
|
262
|
-
this.icon = this.icon;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (this.innerHTML !== "" && !this.icon && !this.src) {
|
|
266
|
-
this.#avatar.innerHTML = textAvatar(this.innerHTML);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
connectedCallback() {
|
|
271
|
-
this.init();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (!customElements.get('ea-avatar')) {
|
|
276
|
-
customElements.define('ea-avatar', EaAvatar);
|
|
277
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{errorAvatar}from"./src/assets/errorAvatar.js";import{iconAvatar,textAvatar}from"./src/assets/iconAndTextAvatar.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaAvatar extends Base{#t;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-avatar_wrap" part=\'container\'>\n <span class="ea-avatar" part="avatar">\n <slot></slot>\n </span>\n </div>\n ',this.#t=t.querySelector(".ea-avatar"),this.build(t,stylesheet)}get size(){const t=this.getAttrNumber("size"),s=this.getAttribute("size");return 0!==t&&t?this.getAttrNumber("size"):["large","medium","small"].includes(s)?s:"normal"}set size(t){this.setAttribute("size",t),"number"==typeof t?(this.#t.style.width=`${t}px`,this.#t.style.height=`${t}px`,this.#t.style.lineHeight=`${t}px`):"string"==typeof t&&this.#t.classList.add(`ea-avatar--${t}`)}get shape(){const t=this.getAttribute("shape");return["circle","square"].includes(t)?t:"circle"}set shape(t){this.setAttribute("shape",t),this.#t.classList.add(`ea-avatar--${this.shape}`)}get src(){return this.getAttribute("src")}set src(t){if(!t)return;this.setAttribute("src",t);const s=new Image;s.src=t,s.onload=()=>{this.#t.innerHTML=`<img class="ea-avatar--img" src="${t}" alt="头像">`},s.onerror=t=>{this.#t.innerHTML=errorAvatar,this.dispatchEvent(new CustomEvent("error",{detail:{error:t}}))}}get icon(){return this.getAttribute("icon")||""}set icon(t){this.setAttribute("icon",t),this.#t.innerHTML=iconAvatar(t)}get fit(){return this.getAttribute("fit")||"cover"}set fit(t){this.setAttribute("fit",t),this.#t.classList.add(`ea-avatar-fill--${t}`)}connectedCallback(){this.size=this.size,this.shape=this.shape,this.src=this.src,this.src&&(this.fit=this.fit),!this.src&&this.icon&&(this.icon=this.icon),""===this.innerHTML||this.icon||this.src||(this.#t.innerHTML=textAvatar(this.innerHTML))}}customElements.get("ea-avatar")||customElements.define("ea-avatar",EaAvatar);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultAvatar='\n <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">\n <defs>\n <clipPath id="a">\n <path d="M0 40h90v45H0z" />\n </clipPath>\n </defs>\n <path fill="#c0c4cc" d="M0 0h100v100H0z" />\n <circle cx="50" cy="35" r="20" fill="#fff" />\n <circle cx="50" cy="97" r="40" fill="#fff" clip-path="url(#a)" />\n </svg>\n';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const errorAvatar='\n <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">\n <path fill="#c0c4cc" d="M0 0h100v100H0z" />\n <path fill="#fff" d="M15 20h70v60H15z" />\n <circle r="8" cx="32" cy="35" fill="#c0c4cc" />\n <path d="M60 42.5L39 75h42z" fill="#c0c4cc" />\n <path d="M35 52.5L20 75h-4 32z" fill="#c0c4cc" />\n </svg>\n';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const background='\n<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">\n <path fill="#c0c4cc" d="M0 0h100v100H0z" />\n</svg>\n';export const iconAvatar=a=>`\n ${background}\n <ea-icon class="fa ea-avatar--text" icon="${a}"></ea-icon>\n `;export const textAvatar=a=>`\n ${background}\n <span class="ea-avatar--text">${a}</span>\n `;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-avatar_wrap .ea-avatar {\n position: relative;\n display: inline-block;\n overflow: hidden;\n color: #ffffff;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar-fill--fill img {\n object-fit: fill;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar-fill--contain img {\n object-fit: contain;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar-fill--cover img {\n object-fit: cover;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar-fill--none img {\n object-fit: none;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar-fill--scale-down img {\n object-fit: scale-down;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--normal {\n width: 50px;\n height: 50px;\n line-height: 50px;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--large {\n width: 40px;\n height: 40px;\n line-height: 40px;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--medium {\n width: 36px;\n height: 36px;\n line-height: 36px;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--small {\n width: 28px;\n height: 28px;\n line-height: 28px;\n}\n.ea-avatar_wrap .ea-avatar .ea-avatar--text {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--circle {\n border-radius: 50%;\n}\n.ea-avatar_wrap .ea-avatar.ea-avatar--square {\n border-radius: 5px;\n}\n.ea-avatar_wrap .ea-avatar .ea-avatar--img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n";
|
|
@@ -1,232 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
import { createElement, createSlotElement } from '../../utils/createElement.js';
|
|
4
|
-
import "../ea-icon/index.js"
|
|
5
|
-
|
|
6
|
-
const stylesheet = `
|
|
7
|
-
.ea-backtop_wrap {
|
|
8
|
-
position: fixed;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
width: 40px;
|
|
13
|
-
height: 40px;
|
|
14
|
-
right: 40px;
|
|
15
|
-
bottom: 40px;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
background-color: #fff;
|
|
18
|
-
border-radius: 50%;
|
|
19
|
-
color: #409eff;
|
|
20
|
-
font-size: 14px;
|
|
21
|
-
box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);
|
|
22
|
-
opacity: 1;
|
|
23
|
-
z-index: 5;
|
|
24
|
-
transition: opacity 0.3s ease-in-out;
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
export class EaBacktop extends Base {
|
|
29
|
-
#wrap;
|
|
30
|
-
|
|
31
|
-
#iconSlot;
|
|
32
|
-
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
|
|
36
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
37
|
-
const wrap = document.createElement('div');
|
|
38
|
-
wrap.className = 'ea-backtop_wrap';
|
|
39
|
-
wrap.style.display = 'none';
|
|
40
|
-
|
|
41
|
-
const slot = createSlotElement('');
|
|
42
|
-
wrap.appendChild(slot);
|
|
43
|
-
this.#iconSlot = slot;
|
|
44
|
-
|
|
45
|
-
this.#wrap = wrap;
|
|
46
|
-
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
47
|
-
|
|
48
|
-
this.build(shadowRoot, stylesheet);
|
|
49
|
-
this.shadowRoot.appendChild(wrap);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// ------- target 触发滚动的对象 -------
|
|
53
|
-
// #region
|
|
54
|
-
get target() {
|
|
55
|
-
return this.getAttribute('target');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set target(value) {
|
|
59
|
-
this.setAttribute('target', value);
|
|
60
|
-
}
|
|
61
|
-
// #endregion
|
|
62
|
-
// ------- end -------
|
|
63
|
-
|
|
64
|
-
// ------- right 滚动按钮距离右边的距离 -------
|
|
65
|
-
// #region
|
|
66
|
-
get right() {
|
|
67
|
-
return this.getAttribute('right') || 40;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
set right(value) {
|
|
71
|
-
this.setAttribute('right', value);
|
|
72
|
-
|
|
73
|
-
this.#wrap.style.right = value + 'px';
|
|
74
|
-
}
|
|
75
|
-
// #endregion
|
|
76
|
-
// ------- end -------
|
|
77
|
-
|
|
78
|
-
// ------- bottom 滚动按钮距离下边的距离 -------
|
|
79
|
-
// #region
|
|
80
|
-
get bottom() {
|
|
81
|
-
return this.getAttribute('bottom') || 40;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
set bottom(value) {
|
|
85
|
-
this.setAttribute('bottom', value);
|
|
86
|
-
|
|
87
|
-
this.#wrap.style.bottom = value + 'px';
|
|
88
|
-
}
|
|
89
|
-
// #endregion
|
|
90
|
-
// ------- end -------
|
|
91
|
-
|
|
92
|
-
// ------- icon 图标类名 -------
|
|
93
|
-
// #region
|
|
94
|
-
get icon() {
|
|
95
|
-
return this.getAttribute('icon') || "icon-angle-up";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
set icon(value) {
|
|
99
|
-
this.setAttribute('icon', value);
|
|
100
|
-
|
|
101
|
-
const icon = createElement('ea-icon');
|
|
102
|
-
icon.icon = value;
|
|
103
|
-
this.#iconSlot.innerHTML = "";
|
|
104
|
-
this.#iconSlot.appendChild(icon);
|
|
105
|
-
}
|
|
106
|
-
// #endregion
|
|
107
|
-
// ------- end -------
|
|
108
|
-
|
|
109
|
-
// ------- visibility-height 滚动按钮显示和隐藏的触发条件 -------
|
|
110
|
-
// #region
|
|
111
|
-
get visibilityHeight() {
|
|
112
|
-
return this.getAttribute('visibility-height') || 200;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
set visibilityHeight(value) {
|
|
116
|
-
this.setAttribute('visibility-height', value);
|
|
117
|
-
}
|
|
118
|
-
// #endregion
|
|
119
|
-
// ------- end -------
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 根据滚动位置控制返回顶部按钮的显示和隐藏。
|
|
123
|
-
*
|
|
124
|
-
* 当页面滚动超过200像素时,显示返回顶部按钮,并在过渡结束后设置按钮为完全可见。
|
|
125
|
-
* 当页面滚动不超过200像素时,隐藏返回顶部按钮,并在过渡结束后将按钮的显示属性设置为none。
|
|
126
|
-
*
|
|
127
|
-
* @param {*} scrollDom - 用于检测滚动位置的DOM元素。
|
|
128
|
-
* @param {number} scrollFlag - 页面滚动到指定距离时触发。
|
|
129
|
-
*/
|
|
130
|
-
#handleBackTopBtnShow(scrollDom, scrollFlag) {
|
|
131
|
-
const that = this;
|
|
132
|
-
|
|
133
|
-
// 当滚动距离超过200像素时,显示返回顶部按钮
|
|
134
|
-
if (scrollDom.scrollTop > scrollFlag) {
|
|
135
|
-
this.#wrap.style.display = 'flex';
|
|
136
|
-
this.#wrap.ontransitionend = null;
|
|
137
|
-
|
|
138
|
-
// 延迟10毫秒后设置按钮的透明度为1,使其完全可见
|
|
139
|
-
setTimeout(() => {
|
|
140
|
-
this.#wrap.style.opacity = 1;
|
|
141
|
-
}, 10);
|
|
142
|
-
} else {
|
|
143
|
-
// 当滚动距离不超过200像素时,隐藏返回顶部按钮
|
|
144
|
-
this.#wrap.style.opacity = 0;
|
|
145
|
-
|
|
146
|
-
// 在过渡结束时,将按钮的显示属性设置为none
|
|
147
|
-
this.#wrap.ontransitionend = function () {
|
|
148
|
-
that.#wrap.style.display = 'none';
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 根据目标名称获取滚动事件相关DOM元素。
|
|
155
|
-
*
|
|
156
|
-
* 此函数用于确定应该监听哪个DOM元素的滚动事件。它可以是特定的DOM元素,或者是整个文档。
|
|
157
|
-
* 通过判断目标名称是否为空或未定义,来决定是获取整个文档还是指定的DOM元素。
|
|
158
|
-
*
|
|
159
|
-
* @param {string} targetName - 目标元素的选择器字符串。如果为空或未定义,则监听整个文档。
|
|
160
|
-
* @returns {Object} 返回一个对象,包含两个属性:dom和scrollDom,它们都指向同一个被选中的DOM元素,或者如果未指定目标名称,则指向document对象。
|
|
161
|
-
*/
|
|
162
|
-
#handleScrollEvent(targetName) {
|
|
163
|
-
// 保存当前上下文的引用
|
|
164
|
-
const that = this;
|
|
165
|
-
|
|
166
|
-
// 初始化dom和scrollDom变量为null
|
|
167
|
-
let dom = null;
|
|
168
|
-
let scrollDom = null;
|
|
169
|
-
|
|
170
|
-
// 判断目标名称是否为空或未定义
|
|
171
|
-
if (targetName === "null" || targetName === '' || targetName === null || targetName === undefined || targetName === 'undefined') {
|
|
172
|
-
// 如果是,设置dom和scrollDom为document对象
|
|
173
|
-
dom = document;
|
|
174
|
-
scrollDom = document.documentElement;
|
|
175
|
-
} else {
|
|
176
|
-
// 如果不是,通过目标名称查询DOM元素,并设置dom和scrollDom
|
|
177
|
-
dom = document.querySelector(targetName);
|
|
178
|
-
scrollDom = document.querySelector(targetName);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 返回包含dom和scrollDom的对象
|
|
182
|
-
return { dom, scrollDom };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#initScrollBtn() {
|
|
186
|
-
const that = this;
|
|
187
|
-
const { dom, scrollDom } = this.#handleScrollEvent(this.target);
|
|
188
|
-
|
|
189
|
-
this.#handleBackTopBtnShow(scrollDom, this.visibilityHeight);
|
|
190
|
-
|
|
191
|
-
dom.addEventListener('scroll', function () {
|
|
192
|
-
that.#handleBackTopBtnShow(scrollDom, that.visibilityHeight);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
this.#wrap.addEventListener('click', function () {
|
|
196
|
-
let step = 10;
|
|
197
|
-
|
|
198
|
-
let timer = setInterval(() => {
|
|
199
|
-
step += 5;
|
|
200
|
-
scrollDom.scrollTop -= step;
|
|
201
|
-
|
|
202
|
-
if (scrollDom.scrollTop <= 0) {
|
|
203
|
-
scrollDom.scrollTop = 0;
|
|
204
|
-
clearInterval(timer);
|
|
205
|
-
timer = null;
|
|
206
|
-
}
|
|
207
|
-
}, 12);
|
|
208
|
-
|
|
209
|
-
this.dispatchEvent(new CustomEvent('backtop', {}));
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
init() {
|
|
214
|
-
const that = this;
|
|
215
|
-
|
|
216
|
-
this.target = this.target;
|
|
217
|
-
this.right = this.right;
|
|
218
|
-
this.bottom = this.bottom;
|
|
219
|
-
this.visibilityHeight = this.visibilityHeight;
|
|
220
|
-
this.icon = this.icon;
|
|
221
|
-
|
|
222
|
-
this.#initScrollBtn();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
connectedCallback() {
|
|
226
|
-
this.init();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (!customElements.get('ea-backtop')) {
|
|
231
|
-
customElements.define('ea-backtop', EaBacktop);
|
|
232
|
-
}
|
|
1
|
+
import{timeout}from"../../utils/timeout.js";import Base from"../Base.js";import"../ea-icon/index.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaBacktop extends Base{#t;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML="\n <div class=\"ea-backtop_wrap\" part='container' style='display: none'>\n <slot></slot>\n </div>\n ",this.#t=t.querySelector(".ea-backtop_wrap"),this.build(t,stylesheet)}get target(){return this.getAttribute("target")||""}set target(t){this.setAttribute("target",t)}get right(){return this.getAttribute("right")||"40px"}set right(t){this.setAttribute("right",t),this.#t.style.right=t}get bottom(){return this.getAttribute("bottom")||"40px"}set bottom(t){this.setAttribute("bottom",t),this.#t.style.bottom=t}get icon(){return this.getAttribute("icon")||"icon-angle-up"}set icon(t){this.setAttribute("icon",t),this.#t.innerHTML=`\n <ea-icon icon="${t}" part='icon'></ea-icon>\n `}get visibilityHeight(){return this.getAttribute("visibility-height")||200}set visibilityHeight(t){this.setAttribute("visibility-height",t)}#e(t){let e=null,i=null;return"null"===t||""===t||null==t||"undefined"===t?(e=document,i=document.documentElement):(e=document.querySelector(t),i=document.querySelector(t)),{dom:e,scrollDom:i}}#i(t){t.scrollTop>this.visibilityHeight?(this.#t.style.display="flex",this.#t.ontransitionend=null,timeout((()=>{this.#t.style.opacity=1}),10)):(this.#t.style.opacity=0,this.#t.ontransitionend=()=>{this.#t.style.display="none"})}#s(){const{dom:t,scrollDom:e}=this.#e(this.target);this.#i(e),t.addEventListener("scroll",(()=>{this.#i(e)})),this.#t.addEventListener("click",(function(){let t=10,i=setInterval((()=>{t+=5,e.scrollTop-=t,e.scrollTop<=0&&(e.scrollTop=0,clearInterval(i),i=null,this.dispatchEvent(new CustomEvent("reachedTop",{})))}),12);this.dispatchEvent(new CustomEvent("backtop",{}))}))}connectedCallback(){this.target=this.target,this.right=this.right,this.bottom=this.bottom,this.visibilityHeight=this.visibilityHeight,this.icon=this.icon,this.#s()}}customElements.get("ea-backtop")||customElements.define("ea-backtop",EaBacktop);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-backtop_wrap {\n position: fixed;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n right: 40px;\n bottom: 40px;\n cursor: pointer;\n background-color: #fff;\n border-radius: 50%;\n color: #409eff;\n font-size: 14px;\n box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);\n opacity: 1;\n z-index: 5;\n transition: opacity 0.3s ease-in-out;\n}\n";
|
|
@@ -1,160 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-badge_wrap {
|
|
6
|
-
position: relative;
|
|
7
|
-
vertical-align: middle;
|
|
8
|
-
display: inline-block;
|
|
9
|
-
}
|
|
10
|
-
.ea-badge_wrap .ea-badge_content {
|
|
11
|
-
display: inline-block;
|
|
12
|
-
padding: 0 0.375rem;
|
|
13
|
-
border-radius: 0.625rem;
|
|
14
|
-
border: 1px solid #fff;
|
|
15
|
-
height: 1.125rem;
|
|
16
|
-
line-height: 1.125rem;
|
|
17
|
-
position: absolute;
|
|
18
|
-
right: 0.625rem;
|
|
19
|
-
top: 0;
|
|
20
|
-
transform: translate(100%, -50%);
|
|
21
|
-
color: #fff;
|
|
22
|
-
font-size: 0.75rem;
|
|
23
|
-
text-align: center;
|
|
24
|
-
white-space: nowrap;
|
|
25
|
-
background-color: #f56c6c;
|
|
26
|
-
}
|
|
27
|
-
.ea-badge_wrap .ea-badge_content.primary {
|
|
28
|
-
background-color: #409eff;
|
|
29
|
-
}
|
|
30
|
-
.ea-badge_wrap .ea-badge_content.success {
|
|
31
|
-
background-color: #67c23a;
|
|
32
|
-
}
|
|
33
|
-
.ea-badge_wrap .ea-badge_content.warning {
|
|
34
|
-
background-color: #e6a23c;
|
|
35
|
-
}
|
|
36
|
-
.ea-badge_wrap .ea-badge_content.info {
|
|
37
|
-
background-color: #909399;
|
|
38
|
-
}
|
|
39
|
-
.ea-badge_wrap .ea-badge_content.dot {
|
|
40
|
-
right: 0.3125rem;
|
|
41
|
-
padding: 0;
|
|
42
|
-
border-radius: 50%;
|
|
43
|
-
width: 0.5rem;
|
|
44
|
-
height: 0.5rem;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
export class EaBadge extends Base {
|
|
49
|
-
#wrap;
|
|
50
|
-
#badgeWrap;
|
|
51
|
-
|
|
52
|
-
constructor() {
|
|
53
|
-
super();
|
|
54
|
-
|
|
55
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
56
|
-
const wrap = document.createElement('div');
|
|
57
|
-
wrap.className = 'ea-badge_wrap';
|
|
58
|
-
|
|
59
|
-
const slot = document.createElement('slot');
|
|
60
|
-
wrap.appendChild(slot);
|
|
61
|
-
|
|
62
|
-
const badgeWrap = document.createElement('sup');
|
|
63
|
-
badgeWrap.className = 'ea-badge_content';
|
|
64
|
-
wrap.appendChild(badgeWrap);
|
|
65
|
-
|
|
66
|
-
this.#wrap = wrap;
|
|
67
|
-
this.#badgeWrap = badgeWrap;
|
|
68
|
-
|
|
69
|
-
this.build(shadowRoot, stylesheet);
|
|
70
|
-
this.shadowRoot.appendChild(wrap);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ------- value 徽章内的值 -------
|
|
74
|
-
// #region
|
|
75
|
-
get value() {
|
|
76
|
-
return this.getAttribute('value') || '';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
set value(value) {
|
|
80
|
-
this.setAttribute('value', value);
|
|
81
|
-
|
|
82
|
-
this.#badgeWrap.innerHTML = value;
|
|
83
|
-
}
|
|
84
|
-
// #endregion
|
|
85
|
-
// ------- end -------
|
|
86
|
-
|
|
87
|
-
// ------- type 样式类型 -------
|
|
88
|
-
// #region
|
|
89
|
-
get type() {
|
|
90
|
-
return this.getAttribute('type') || 'normal';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
set type(value) {
|
|
94
|
-
this.setAttribute('type', value);
|
|
95
|
-
|
|
96
|
-
this.#badgeWrap.classList.add(value);
|
|
97
|
-
}
|
|
98
|
-
// #endregion
|
|
99
|
-
// ------- end -------
|
|
100
|
-
|
|
101
|
-
// ------- max 最大值 -------
|
|
102
|
-
// #region
|
|
103
|
-
get max() {
|
|
104
|
-
return this.getAttrNumber('max') || Infinity;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
set max(value) {
|
|
108
|
-
if (value === Infinity) return;
|
|
109
|
-
|
|
110
|
-
value = parseInt(value);
|
|
111
|
-
|
|
112
|
-
this.setAttribute('max', value);
|
|
113
|
-
|
|
114
|
-
if (this.value > value) {
|
|
115
|
-
this.value = value + '+';
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// #endregion
|
|
119
|
-
// ------- end -------
|
|
120
|
-
|
|
121
|
-
// ------- is-dot 是否为点状徽章 -------
|
|
122
|
-
// #region
|
|
123
|
-
get isDot() {
|
|
124
|
-
return this.getAttrBoolean('is-dot') || false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
set isDot(value) {
|
|
128
|
-
this.toggleAttr('is-dot', value);
|
|
129
|
-
|
|
130
|
-
this.#badgeWrap.innerText = value ? '' : this.value;
|
|
131
|
-
this.#badgeWrap.classList.toggle('dot', value);
|
|
132
|
-
}
|
|
133
|
-
// #endregion
|
|
134
|
-
// ------- end -------
|
|
135
|
-
|
|
136
|
-
init() {
|
|
137
|
-
const that = this;
|
|
138
|
-
|
|
139
|
-
this.value = this.value;
|
|
140
|
-
|
|
141
|
-
this.type = this.type;
|
|
142
|
-
|
|
143
|
-
this.max = this.max;
|
|
144
|
-
|
|
145
|
-
this.isDot = this.isDot;
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const button = this.querySelector('ea-button');
|
|
149
|
-
if (button) button.style.setProperty('--margin-right', '0');
|
|
150
|
-
} catch (error) { }
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
connectedCallback() {
|
|
154
|
-
this.init();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!customElements.get('ea-badge')) {
|
|
159
|
-
customElements.define('ea-badge', EaBadge);
|
|
160
|
-
}
|
|
1
|
+
import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaBadge extends Base{#t;#e;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML="\n <div class=\"ea-badge_wrap\" part='container'>\n <slot></slot>\n <sup class=\"ea-badge_content\" part='content'></sup>\n </div>\n ",this.#t=t.querySelector(".ea-badge_wrap"),this.#e=t.querySelector(".ea-badge_content"),this.build(t,stylesheet)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t),this.#e.innerHTML=t}get type(){return this.getAttribute("type")||"normal"}set type(t){this.setAttribute("type",t),this.#e.classList.add(t)}get max(){return this.getAttrNumber("max")||1/0}set max(t){t!==1/0&&(t=parseInt(t),this.setAttribute("max",t),this.value>t&&(this.value=t+"+"))}get isDot(){return this.getAttrBoolean("is-dot")||!1}set isDot(t){this.toggleAttr("is-dot",t),this.#e.innerText=t?"":this.value,this.#e.classList.toggle("dot",t)}connectedCallback(){this.value=this.value,this.type=this.type,this.max=this.max,this.isDot=this.isDot}}customElements.get("ea-badge")||customElements.define("ea-badge",EaBadge);
|