easy-component-ui 0.0.2 → 1.0.3
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/components/Base.js +90 -0
- package/components/ea-alert/index.js +298 -0
- package/components/ea-avatar/index.js +277 -0
- package/components/ea-backtop/index.js +232 -0
- package/components/ea-badge/index.js +160 -0
- package/components/ea-button/index.js +584 -0
- package/components/ea-button-group/index.js +459 -0
- package/components/ea-calendar/index.js +409 -0
- package/components/ea-card/index.js +77 -0
- package/components/ea-carousel/index.js +434 -0
- package/components/ea-checkbox/index.js +314 -0
- package/components/ea-checkbox-group/index.js +107 -0
- package/components/ea-collapse/index.js +293 -0
- package/components/ea-descriptions/index.js +240 -0
- package/components/ea-descriptions-item/index.js +110 -0
- package/components/ea-empty/index.js +141 -0
- package/{icon → components/ea-icon}/config.json +1017 -1017
- package/{icon → components/ea-icon}/css/animation.css +85 -85
- package/{icon → components/ea-icon}/css/fontello.css +224 -224
- package/components/ea-icon/font/fontello.svg +683 -0
- package/components/ea-icon/index.css +2 -0
- package/components/ea-icon/index.js +47 -0
- package/components/ea-image/index.js +412 -0
- package/components/ea-infinite-scroll/index.js +170 -0
- package/components/ea-input/index.js +765 -0
- package/components/ea-input-number/index.js +458 -0
- package/components/ea-link/index.js +200 -0
- package/components/ea-loading/index.js +218 -0
- package/components/ea-message/MessageClass.js +71 -0
- package/components/ea-message/index.js +233 -0
- package/components/ea-message-box/EaMessageBoxClass.js +48 -0
- package/components/ea-message-box/index.js +202 -0
- package/components/ea-pagination/index.js +444 -0
- package/components/ea-progress/index.js +333 -0
- package/components/ea-radio/index.js +287 -0
- package/components/ea-radio-group/index.js +59 -0
- package/components/ea-rate/index.js +326 -0
- package/components/ea-result/index.js +167 -0
- package/components/ea-select/index.js +34 -0
- package/components/ea-skeleton/index.js +341 -0
- package/components/ea-switch/index.js +301 -0
- package/components/ea-tag/index.js +212 -0
- package/components/ea-textarea/index.js +333 -0
- package/components/ea-timeline/index.js +334 -0
- package/components/ea-ui-base-style.css +0 -0
- package/package.json +1 -1
- package/utils/createElement.js +30 -0
- package/utils/handleTemplate.js +19 -0
- package/utils/setStyle.js +8 -0
- package/icon/font/fontello.svg +0 -346
- package/icon/index.css +0 -2
- package/index.js +0 -1693
- /package/{icon → components/ea-icon}/css/fontello-codes.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-embedded.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-ie7-codes.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-ie7.css +0 -0
- /package/{icon → components/ea-icon}/font/fontello.eot +0 -0
- /package/{icon → components/ea-icon}/font/fontello.ttf +0 -0
- /package/{icon → components/ea-icon}/font/fontello.woff +0 -0
- /package/{icon → components/ea-icon}/font/fontello.woff2 +0 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import Base from '../Base.js';
|
|
3
|
+
|
|
4
|
+
const stylesheet = `
|
|
5
|
+
.ea-input-number_wrap {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
border: 1px solid transparent;
|
|
9
|
+
border-radius: 3px;
|
|
10
|
+
transition: border 0.2s;
|
|
11
|
+
}
|
|
12
|
+
.ea-input-number_wrap .ea-input-number_sign {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
border: 1px solid #dcdfe6;
|
|
18
|
+
background-color: #f5f7fa;
|
|
19
|
+
height: 2rem;
|
|
20
|
+
width: 2rem;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
font-size: 1rem;
|
|
23
|
+
line-height: 1;
|
|
24
|
+
user-select: none;
|
|
25
|
+
}
|
|
26
|
+
.ea-input-number_wrap .ea-input-number_sign:first-child {
|
|
27
|
+
border-top-left-radius: 3px;
|
|
28
|
+
border-bottom-left-radius: 3px;
|
|
29
|
+
border-right: 0;
|
|
30
|
+
}
|
|
31
|
+
.ea-input-number_wrap .ea-input-number_sign:last-child {
|
|
32
|
+
border-top-right-radius: 3px;
|
|
33
|
+
border-bottom-right-radius: 3px;
|
|
34
|
+
border-left: 0;
|
|
35
|
+
}
|
|
36
|
+
.ea-input-number_wrap .ea-input-number_sign:hover {
|
|
37
|
+
color: #409eff;
|
|
38
|
+
}
|
|
39
|
+
.ea-input-number_wrap .ea-input-number_sign.disabled {
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
color: #c0c4cc;
|
|
43
|
+
}
|
|
44
|
+
.ea-input-number_wrap .ea-input-number_sign.ea-input-number_sign--medium {
|
|
45
|
+
height: 1.75rem;
|
|
46
|
+
width: 1.75rem;
|
|
47
|
+
}
|
|
48
|
+
.ea-input-number_wrap .ea-input-number_sign.ea-input-number_sign--small {
|
|
49
|
+
height: 1.5rem;
|
|
50
|
+
width: 1.5rem;
|
|
51
|
+
}
|
|
52
|
+
.ea-input-number_wrap .ea-input-number_sign.ea-input-number_sign--mini {
|
|
53
|
+
height: 1.25rem;
|
|
54
|
+
width: 1.25rem;
|
|
55
|
+
}
|
|
56
|
+
.ea-input-number_wrap .ea-input-number_inner {
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
border: 1px solid #dcdfe6;
|
|
60
|
+
outline: 0;
|
|
61
|
+
transition: border 0.2s;
|
|
62
|
+
border-radius: 3px;
|
|
63
|
+
padding: 0.5rem;
|
|
64
|
+
line-height: 0.8;
|
|
65
|
+
font-size: 0.8rem;
|
|
66
|
+
scrollbar-width: none;
|
|
67
|
+
width: 5rem;
|
|
68
|
+
height: 2rem;
|
|
69
|
+
border-radius: 0;
|
|
70
|
+
text-align: center;
|
|
71
|
+
}
|
|
72
|
+
.ea-input-number_wrap .ea-input-number_inner:focus {
|
|
73
|
+
border-color: #409eff;
|
|
74
|
+
}
|
|
75
|
+
.ea-input-number_wrap .ea-input-number_inner::placeholder {
|
|
76
|
+
color: #c0c4cc;
|
|
77
|
+
}
|
|
78
|
+
.ea-input-number_wrap .ea-input-number_inner.invalid {
|
|
79
|
+
border-color: #f56c6c;
|
|
80
|
+
}
|
|
81
|
+
.ea-input-number_wrap .ea-input-number_inner.disabled {
|
|
82
|
+
background-color: #eeeeee;
|
|
83
|
+
color: #c0c4cc;
|
|
84
|
+
}
|
|
85
|
+
.ea-input-number_wrap .ea-input-number_inner.ea-input_clear ::before {
|
|
86
|
+
content: "\e9c3";
|
|
87
|
+
display: block;
|
|
88
|
+
}
|
|
89
|
+
.ea-input-number_wrap .ea-input-number_inner:focus {
|
|
90
|
+
border-color: #dcdfe6;
|
|
91
|
+
}
|
|
92
|
+
.ea-input-number_wrap .ea-input-number_inner.disabled {
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
color: #c0c4cc;
|
|
95
|
+
cursor: not-allowed;
|
|
96
|
+
background-color: #f5f7fa;
|
|
97
|
+
}
|
|
98
|
+
.ea-input-number_wrap .ea-input-number_inner.ea-input-number_inner--medium {
|
|
99
|
+
height: 1.75rem;
|
|
100
|
+
line-height: 1.75rem;
|
|
101
|
+
}
|
|
102
|
+
.ea-input-number_wrap .ea-input-number_inner.ea-input-number_inner--small {
|
|
103
|
+
height: 1.5rem;
|
|
104
|
+
line-height: 1.5rem;
|
|
105
|
+
}
|
|
106
|
+
.ea-input-number_wrap .ea-input-number_inner.ea-input-number_inner--mini {
|
|
107
|
+
height: 1.25rem;
|
|
108
|
+
line-height: 1.25rem;
|
|
109
|
+
}
|
|
110
|
+
.ea-input-number_wrap.focus {
|
|
111
|
+
border: 1px solid #409eff;
|
|
112
|
+
}
|
|
113
|
+
.ea-input-number_wrap.focus .ea-input-number_sign {
|
|
114
|
+
border-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
// +/- 符号dom
|
|
119
|
+
const signDom = (sign) => {
|
|
120
|
+
const dom = document.createElement('span');
|
|
121
|
+
dom.className = `ea-input-number_sign ${sign}`;
|
|
122
|
+
|
|
123
|
+
dom.innerHTML = sign === 'minus' ? '-' : '+';
|
|
124
|
+
|
|
125
|
+
return dom;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// input dom
|
|
129
|
+
const inputDom = () => {
|
|
130
|
+
const input = document.createElement('input');
|
|
131
|
+
input.className = 'ea-input-number_inner';
|
|
132
|
+
input.type = 'text';
|
|
133
|
+
input.value = 0;
|
|
134
|
+
|
|
135
|
+
return input;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class EaInputNumber extends Base {
|
|
139
|
+
#wrap;
|
|
140
|
+
#input;
|
|
141
|
+
#signMinus;
|
|
142
|
+
#signPlus;
|
|
143
|
+
constructor() {
|
|
144
|
+
super();
|
|
145
|
+
|
|
146
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
147
|
+
const wrap = document.createElement('div');
|
|
148
|
+
wrap.className = 'ea-input-number_wrap';
|
|
149
|
+
|
|
150
|
+
const input = inputDom();
|
|
151
|
+
const signMinus = signDom('minus');
|
|
152
|
+
const signPlus = signDom('plus');
|
|
153
|
+
wrap.appendChild(signMinus);
|
|
154
|
+
wrap.appendChild(input);
|
|
155
|
+
wrap.appendChild(signPlus);
|
|
156
|
+
|
|
157
|
+
this.#wrap = wrap;
|
|
158
|
+
this.#input = input;
|
|
159
|
+
this.#signMinus = signMinus;
|
|
160
|
+
this.#signPlus = signPlus;
|
|
161
|
+
|
|
162
|
+
this.build(shadowRoot, stylesheet);
|
|
163
|
+
this.shadowRoot.appendChild(wrap);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 处理输入框加减事件
|
|
167
|
+
signEvent(sign, precision, eventName) {
|
|
168
|
+
if (this.getAttrBoolean('disabled')) return;
|
|
169
|
+
|
|
170
|
+
const val = Number(this.#input.value);
|
|
171
|
+
|
|
172
|
+
const defaultStepPrecision = this.#input.value.split('.')[1]; // 简单处理精度问题
|
|
173
|
+
const res = sign === "minu" ? val - this.step : val + this.step; // 处理加减问题
|
|
174
|
+
|
|
175
|
+
if (precision) {
|
|
176
|
+
this.#input.value = (res).toFixed(precision);
|
|
177
|
+
}
|
|
178
|
+
// 简单处理精度问题
|
|
179
|
+
else if (defaultStepPrecision?.length) {
|
|
180
|
+
this.#input.value = (res).toFixed(defaultStepPrecision.length);
|
|
181
|
+
} else {
|
|
182
|
+
this.#input.value = res;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 为外部dom添加事件监听
|
|
186
|
+
if (eventName) {
|
|
187
|
+
this.#input.dispatchEvent(
|
|
188
|
+
new CustomEvent(eventName, {
|
|
189
|
+
detail: {
|
|
190
|
+
value: this.#input.value
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 限制输入框的值
|
|
197
|
+
this.handleLimitVal();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 处理连加连减事件
|
|
201
|
+
handleCounterEvent(sign) {
|
|
202
|
+
let timer = setInterval(() => {
|
|
203
|
+
this.signEvent(sign, this.precision);
|
|
204
|
+
this.handleLimitVal();
|
|
205
|
+
}, 100);
|
|
206
|
+
|
|
207
|
+
this.addEventListener('mouseup', function () {
|
|
208
|
+
clearInterval(timer);
|
|
209
|
+
timer = null;
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 处理输入框聚焦失焦事件
|
|
214
|
+
handleWrapBorder(flag) {
|
|
215
|
+
this.#wrap.classList.toggle('focus', flag)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
handleLimitVal() {
|
|
219
|
+
if (this.min === false && this.max === false) return;
|
|
220
|
+
|
|
221
|
+
// 限制输入框的值
|
|
222
|
+
if (this.min !== undefined && this.#input.value < this.min) {
|
|
223
|
+
this.#input.value = this.min;
|
|
224
|
+
} else if (this.max !== undefined && this.#input.value > this.max) {
|
|
225
|
+
this.#input.value = this.max;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 当达到限制值时, 禁用加减按钮
|
|
229
|
+
if (this.#input.value == this.min) {
|
|
230
|
+
this.#signMinus.classList.add('disabled');
|
|
231
|
+
} else if (this.#input.value == this.max) {
|
|
232
|
+
this.#signPlus.classList.add('disabled');
|
|
233
|
+
} else {
|
|
234
|
+
try {
|
|
235
|
+
this.#signMinus.classList.remove('disabled');
|
|
236
|
+
this.#signPlus.classList.remove('disabled');
|
|
237
|
+
} catch (error) {
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ------- value 值 -------
|
|
244
|
+
// #region
|
|
245
|
+
get value() {
|
|
246
|
+
return this.getAttribute('value') || 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
set value(val) {
|
|
250
|
+
val = this.precision ? Number(val).toFixed(this.precision) : Number(val);
|
|
251
|
+
this.setAttribute('value', val);
|
|
252
|
+
|
|
253
|
+
this.#input.value = val;
|
|
254
|
+
}
|
|
255
|
+
// #endregion
|
|
256
|
+
// ------- end -------
|
|
257
|
+
|
|
258
|
+
// ------- disabled 禁用 -------
|
|
259
|
+
// #region
|
|
260
|
+
get disabled() {
|
|
261
|
+
return this.getAttrBoolean('disabled');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
set disabled(flag) {
|
|
265
|
+
this.toggleAttr('disabled', flag);
|
|
266
|
+
|
|
267
|
+
this.#input.disabled = flag;
|
|
268
|
+
this.#input.classList.toggle('disabled', flag);
|
|
269
|
+
this.#signMinus.classList.toggle('disabled', flag);
|
|
270
|
+
this.#signPlus.classList.toggle('disabled', flag);
|
|
271
|
+
}
|
|
272
|
+
// #endregion
|
|
273
|
+
// ------- end -------
|
|
274
|
+
|
|
275
|
+
// ------- step 加减的步长 -------
|
|
276
|
+
// #region
|
|
277
|
+
get step() {
|
|
278
|
+
return Number(this.getAttribute('step')) || 1;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
set step(step) {
|
|
282
|
+
this.setAttribute('step', step);
|
|
283
|
+
}
|
|
284
|
+
// #endregion
|
|
285
|
+
// ------- end -------
|
|
286
|
+
|
|
287
|
+
// ------- step-strictly 严格步长 -------
|
|
288
|
+
// #region
|
|
289
|
+
get stepStrictly() {
|
|
290
|
+
return this.getAttrBoolean('step-strictly');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
set stepStrictly(flag) {
|
|
294
|
+
this.toggleAttr('step-strictly', flag);
|
|
295
|
+
}
|
|
296
|
+
// #endregion
|
|
297
|
+
// ------- end -------
|
|
298
|
+
|
|
299
|
+
// ------- min/max 限制最大/最小值 -------
|
|
300
|
+
// #region
|
|
301
|
+
get min() {
|
|
302
|
+
if (this.getAttribute('min') === null) return false;
|
|
303
|
+
else return Number(this.getAttribute('min')) || 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
set min(min) {
|
|
307
|
+
if (min === false) {
|
|
308
|
+
this.removeAttribute('min');
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
this.setAttribute('min', min);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
get max() {
|
|
316
|
+
if (this.getAttribute('max') === null) return false;
|
|
317
|
+
else return Number(this.getAttribute('max'));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
set max(max) {
|
|
321
|
+
this.setAttribute('max', max);
|
|
322
|
+
}
|
|
323
|
+
// #endregion
|
|
324
|
+
// ------- end -------
|
|
325
|
+
|
|
326
|
+
// ------- precision 精度 -------
|
|
327
|
+
// #region
|
|
328
|
+
get precision() {
|
|
329
|
+
const num = Number(this.getAttribute('precision'));
|
|
330
|
+
if (num < 0 || !Number.isInteger(num)) {
|
|
331
|
+
console.warn(`precision must be a positive integer(precisionValue: ${num})`);
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return Number(this.getAttribute('precision')) || 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
set precision(precision) {
|
|
339
|
+
this.setAttribute('precision', precision);
|
|
340
|
+
}
|
|
341
|
+
// #endregion
|
|
342
|
+
// ------- end -------
|
|
343
|
+
|
|
344
|
+
// ------- size 按钮大小(medium、small、mini) -------
|
|
345
|
+
// #region
|
|
346
|
+
get size() {
|
|
347
|
+
return this.getAttribute('size') || '';
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
handleSize(size) {
|
|
351
|
+
this.#signMinus.classList.add(`ea-input-number_sign--${size}`);
|
|
352
|
+
this.#signPlus.classList.add(`ea-input-number_sign--${size}`);
|
|
353
|
+
this.#input.classList.add(`ea-input-number_inner--${size}`);
|
|
354
|
+
this.setAttribute('size', size);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
set size(size) {
|
|
358
|
+
switch (size) {
|
|
359
|
+
case 'medium':
|
|
360
|
+
this.handleSize('medium');
|
|
361
|
+
break;
|
|
362
|
+
case 'small':
|
|
363
|
+
this.handleSize('small');
|
|
364
|
+
break;
|
|
365
|
+
case 'mini':
|
|
366
|
+
this.handleSize('mini');
|
|
367
|
+
break;
|
|
368
|
+
default:
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
// #endregion
|
|
373
|
+
// ------- end -------
|
|
374
|
+
|
|
375
|
+
init() {
|
|
376
|
+
const that = this;
|
|
377
|
+
|
|
378
|
+
// 禁用
|
|
379
|
+
this.disabled = this.disabled;
|
|
380
|
+
|
|
381
|
+
// 大小
|
|
382
|
+
this.size = this.size;
|
|
383
|
+
|
|
384
|
+
// 默认值
|
|
385
|
+
if (this.min) this.value = this.min;
|
|
386
|
+
else this.value = this.value;
|
|
387
|
+
|
|
388
|
+
// 限制值初始化
|
|
389
|
+
this.handleLimitVal();
|
|
390
|
+
|
|
391
|
+
// 输入框获取焦点
|
|
392
|
+
this.#input.addEventListener('focus', function (e) {
|
|
393
|
+
that.handleWrapBorder(true);
|
|
394
|
+
|
|
395
|
+
this.dispatchEvent(new CustomEvent("blur",
|
|
396
|
+
{ detail: { value: this.value } }
|
|
397
|
+
))
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
// 输入框失去焦点
|
|
401
|
+
this.#input.addEventListener('blur', function (e) {
|
|
402
|
+
that.handleWrapBorder(false);
|
|
403
|
+
|
|
404
|
+
if (that.stepStrictly) {
|
|
405
|
+
const step = that.step;
|
|
406
|
+
const val = Number(that.#input.value);
|
|
407
|
+
const mod = val % step;
|
|
408
|
+
|
|
409
|
+
if (val < 0 && mod !== 0) that.#input.value = val - mod - step;
|
|
410
|
+
else if (val < 0 && mod === 0) that.#input.value = val;
|
|
411
|
+
else if (mod === 0) that.#input.value = val;
|
|
412
|
+
else that.#input.value = val - mod + step;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
that.handleLimitVal();
|
|
416
|
+
|
|
417
|
+
this.dispatchEvent(new CustomEvent("blur",
|
|
418
|
+
{ detail: { value: this.value } }
|
|
419
|
+
))
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
// 减号
|
|
423
|
+
this.#signMinus.addEventListener('click', function () {
|
|
424
|
+
that.signEvent("minu", that.precision, "minus");
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
// 加号
|
|
428
|
+
this.#signPlus.addEventListener('click', function (e) {
|
|
429
|
+
that.signEvent("plus", that.precision, "plus");
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
// 连减
|
|
433
|
+
this.#signMinus.addEventListener('mousedown', function (e) {
|
|
434
|
+
that.handleCounterEvent("minu", that.precision);
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
// 连加
|
|
438
|
+
this.#signPlus.addEventListener('mousedown', function () {
|
|
439
|
+
that.handleCounterEvent("plus", that.precision);
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
// 输入框值改变时
|
|
443
|
+
this.#input.addEventListener('change', function (e) {
|
|
444
|
+
that.handleLimitVal();
|
|
445
|
+
|
|
446
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value } }))
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
connectedCallback() {
|
|
452
|
+
this.init();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (!window.customElements.get("ea-input-number")) {
|
|
457
|
+
window.customElements.define("ea-input-number", EaInputNumber);
|
|
458
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import Base from '../Base.js'
|
|
3
|
+
import "../ea-icon/index.js"
|
|
4
|
+
|
|
5
|
+
const stylesheet = `
|
|
6
|
+
.__ea-link {
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
color: #606266;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
.__ea-link:hover {
|
|
12
|
+
color: #797b80;
|
|
13
|
+
}
|
|
14
|
+
.__ea-link.underline:hover {
|
|
15
|
+
text-decoration: underline;
|
|
16
|
+
}
|
|
17
|
+
.__ea-link.primary {
|
|
18
|
+
color: #409eff;
|
|
19
|
+
}
|
|
20
|
+
.__ea-link.primary:hover {
|
|
21
|
+
color: #73b8ff;
|
|
22
|
+
}
|
|
23
|
+
.__ea-link.success {
|
|
24
|
+
color: #67c23a;
|
|
25
|
+
}
|
|
26
|
+
.__ea-link.success:hover {
|
|
27
|
+
color: #85cf60;
|
|
28
|
+
}
|
|
29
|
+
.__ea-link.info {
|
|
30
|
+
color: #909399;
|
|
31
|
+
}
|
|
32
|
+
.__ea-link.info:hover {
|
|
33
|
+
color: #abadb1;
|
|
34
|
+
}
|
|
35
|
+
.__ea-link.warning {
|
|
36
|
+
color: #e6a23c;
|
|
37
|
+
}
|
|
38
|
+
.__ea-link.warning:hover {
|
|
39
|
+
color: #ecb869;
|
|
40
|
+
}
|
|
41
|
+
.__ea-link.danger {
|
|
42
|
+
color: #f56c6c;
|
|
43
|
+
}
|
|
44
|
+
.__ea-link.danger:hover {
|
|
45
|
+
color: #f89c9c;
|
|
46
|
+
}
|
|
47
|
+
.__ea-link.disabled {
|
|
48
|
+
color: #c0c4cc;
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
}
|
|
51
|
+
.__ea-link.disabled:hover {
|
|
52
|
+
color: #dcdee3;
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
export class EaLink extends Base {
|
|
57
|
+
constructor() {
|
|
58
|
+
super();
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
62
|
+
let dom = document.createElement('a');;
|
|
63
|
+
|
|
64
|
+
const slot = document.createElement('slot');
|
|
65
|
+
dom.className = "__ea-link";
|
|
66
|
+
dom.appendChild(slot);
|
|
67
|
+
|
|
68
|
+
this.dom = dom;
|
|
69
|
+
|
|
70
|
+
this.build(shadowRoot, stylesheet);
|
|
71
|
+
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
72
|
+
|
|
73
|
+
shadowRoot.appendChild(dom);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static get observedAttributes() {
|
|
77
|
+
return ['disabled'];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get LINK_TYPE() {
|
|
81
|
+
return ['primary', 'success', 'info', 'warning', 'danger'];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ------- href链接 -------
|
|
85
|
+
// #region
|
|
86
|
+
get href() {
|
|
87
|
+
return this.getAttribute('href');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
set href(value) {
|
|
91
|
+
if (value !== null) this.dom.href = value;
|
|
92
|
+
}
|
|
93
|
+
// #endregion
|
|
94
|
+
// ------- end -------
|
|
95
|
+
|
|
96
|
+
// ------- type类型 -------
|
|
97
|
+
// #region
|
|
98
|
+
get type() {
|
|
99
|
+
return this.getAttribute('type');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
set type(value) {
|
|
103
|
+
if (value === null) return;
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < this.LINK_TYPE.length; i++) {
|
|
106
|
+
if (value === this.LINK_TYPE[i]) {
|
|
107
|
+
this.dom.classList.add(value);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// #endregion
|
|
113
|
+
// ------- end -------
|
|
114
|
+
|
|
115
|
+
// ------- disabled禁用状态 -------
|
|
116
|
+
// #region
|
|
117
|
+
get disabled() {
|
|
118
|
+
return this.getAttribute('disabled') === "" || this.getAttribute('disabled') === 'true';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
set disabled(value) {
|
|
122
|
+
if (!value) return;
|
|
123
|
+
|
|
124
|
+
if (value) {
|
|
125
|
+
this.dom.classList.add('disabled');
|
|
126
|
+
} else {
|
|
127
|
+
this.dom.classList.remove('disabled');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// #endregion
|
|
131
|
+
// ------- end -------
|
|
132
|
+
|
|
133
|
+
// ------- underline下划线 -------
|
|
134
|
+
// #region
|
|
135
|
+
get underline() {
|
|
136
|
+
return this.getAttribute('underline') === "" || this.getAttribute('underline') === 'true';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
set underline(value) {
|
|
140
|
+
if (!value) return;
|
|
141
|
+
|
|
142
|
+
if (value) {
|
|
143
|
+
this.dom.classList.add('underline');
|
|
144
|
+
} else {
|
|
145
|
+
this.dom.classList.remove('underline');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// #endregion
|
|
149
|
+
// ------- end -------
|
|
150
|
+
|
|
151
|
+
// ------- icon图标 -------
|
|
152
|
+
// #region
|
|
153
|
+
get icon() {
|
|
154
|
+
return this.getAttribute('icon');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
set icon(value) {
|
|
158
|
+
if (value === null || value === "") return;
|
|
159
|
+
|
|
160
|
+
const icon = document.createElement('i');
|
|
161
|
+
icon.className = value;
|
|
162
|
+
this.dom.insertBefore(icon, this.dom.firstChild);
|
|
163
|
+
}
|
|
164
|
+
// #endregion
|
|
165
|
+
// ------- end -------
|
|
166
|
+
|
|
167
|
+
init() {
|
|
168
|
+
// 设置链接
|
|
169
|
+
this.href = this.href;
|
|
170
|
+
|
|
171
|
+
// 设置类型
|
|
172
|
+
this.type = this.type;
|
|
173
|
+
|
|
174
|
+
// 禁用状态
|
|
175
|
+
this.disabled = this.disabled;
|
|
176
|
+
|
|
177
|
+
// 设置下划线
|
|
178
|
+
this.underline = this.underline;
|
|
179
|
+
|
|
180
|
+
// 图标
|
|
181
|
+
this.icon = this.icon;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
connectedCallback() {
|
|
185
|
+
this.init();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
189
|
+
switch (name) {
|
|
190
|
+
case 'disabled':
|
|
191
|
+
this.disabled = newVal === "" || newVal === 'true' || newVal === true;
|
|
192
|
+
break;
|
|
193
|
+
default: break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!window.customElements.get("ea-link")) {
|
|
199
|
+
window.customElements.define("ea-link", EaLink);
|
|
200
|
+
}
|