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.
Files changed (60) hide show
  1. package/components/Base.js +90 -0
  2. package/components/ea-alert/index.js +298 -0
  3. package/components/ea-avatar/index.js +277 -0
  4. package/components/ea-backtop/index.js +232 -0
  5. package/components/ea-badge/index.js +160 -0
  6. package/components/ea-button/index.js +584 -0
  7. package/components/ea-button-group/index.js +459 -0
  8. package/components/ea-calendar/index.js +409 -0
  9. package/components/ea-card/index.js +77 -0
  10. package/components/ea-carousel/index.js +434 -0
  11. package/components/ea-checkbox/index.js +314 -0
  12. package/components/ea-checkbox-group/index.js +107 -0
  13. package/components/ea-collapse/index.js +293 -0
  14. package/components/ea-descriptions/index.js +240 -0
  15. package/components/ea-descriptions-item/index.js +110 -0
  16. package/components/ea-empty/index.js +141 -0
  17. package/{icon → components/ea-icon}/config.json +1017 -1017
  18. package/{icon → components/ea-icon}/css/animation.css +85 -85
  19. package/{icon → components/ea-icon}/css/fontello.css +224 -224
  20. package/components/ea-icon/font/fontello.svg +683 -0
  21. package/components/ea-icon/index.css +2 -0
  22. package/components/ea-icon/index.js +47 -0
  23. package/components/ea-image/index.js +412 -0
  24. package/components/ea-infinite-scroll/index.js +170 -0
  25. package/components/ea-input/index.js +765 -0
  26. package/components/ea-input-number/index.js +458 -0
  27. package/components/ea-link/index.js +200 -0
  28. package/components/ea-loading/index.js +218 -0
  29. package/components/ea-message/MessageClass.js +71 -0
  30. package/components/ea-message/index.js +233 -0
  31. package/components/ea-message-box/EaMessageBoxClass.js +48 -0
  32. package/components/ea-message-box/index.js +202 -0
  33. package/components/ea-pagination/index.js +444 -0
  34. package/components/ea-progress/index.js +333 -0
  35. package/components/ea-radio/index.js +287 -0
  36. package/components/ea-radio-group/index.js +59 -0
  37. package/components/ea-rate/index.js +326 -0
  38. package/components/ea-result/index.js +167 -0
  39. package/components/ea-select/index.js +34 -0
  40. package/components/ea-skeleton/index.js +341 -0
  41. package/components/ea-switch/index.js +301 -0
  42. package/components/ea-tag/index.js +212 -0
  43. package/components/ea-textarea/index.js +333 -0
  44. package/components/ea-timeline/index.js +334 -0
  45. package/components/ea-ui-base-style.css +0 -0
  46. package/package.json +1 -1
  47. package/utils/createElement.js +30 -0
  48. package/utils/handleTemplate.js +19 -0
  49. package/utils/setStyle.js +8 -0
  50. package/icon/font/fontello.svg +0 -346
  51. package/icon/index.css +0 -2
  52. package/index.js +0 -1693
  53. /package/{icon → components/ea-icon}/css/fontello-codes.css +0 -0
  54. /package/{icon → components/ea-icon}/css/fontello-embedded.css +0 -0
  55. /package/{icon → components/ea-icon}/css/fontello-ie7-codes.css +0 -0
  56. /package/{icon → components/ea-icon}/css/fontello-ie7.css +0 -0
  57. /package/{icon → components/ea-icon}/font/fontello.eot +0 -0
  58. /package/{icon → components/ea-icon}/font/fontello.ttf +0 -0
  59. /package/{icon → components/ea-icon}/font/fontello.woff +0 -0
  60. /package/{icon → components/ea-icon}/font/fontello.woff2 +0 -0
@@ -0,0 +1,584 @@
1
+ // @ts-nocheck
2
+ import Base from "../Base.js";
3
+ import "../ea-icon/index.js"
4
+
5
+ const stylesheet = `
6
+ :host {
7
+ --margin-right: 0rem;
8
+ --border-radius: 6px;
9
+ --border-size: 1px;
10
+ }
11
+
12
+ :host([href]) > a {
13
+ text-decoration: none;
14
+ }
15
+
16
+ :host-context(ea-button-group) {
17
+ --margin-right: 0;
18
+ --border-size: 0;
19
+ }
20
+
21
+ .__ea-button {
22
+ box-sizing: border-box;
23
+ padding: 0.5rem 1rem;
24
+ margin-right: var(--margin-right);
25
+ cursor: pointer;
26
+ font-size: 1rem;
27
+ line-height: 1.25;
28
+ font-weight: 500;
29
+ transition: background-color 0.1s, color 0.1s;
30
+ border-radius: var(--border-radius);
31
+ }
32
+ .__ea-button.normal {
33
+ border: var(--border-size) solid #dcdfe6;
34
+ color: #606266;
35
+ background-color: transparent;
36
+ }
37
+ .__ea-button.normal.disabled {
38
+ cursor: not-allowed !important;
39
+ background-image: none !important;
40
+ background-color: rgba(64, 64, 64, 0) !important;
41
+ border-color: white !important;
42
+ color: white !important;
43
+ pointer-events: none;
44
+ border-color: #ebedf1 !important;
45
+ color: #babcbe !important;
46
+ }
47
+ .__ea-button.normal.plain {
48
+ background-color: rgba(92, 92, 92, 0);
49
+ border: var(--border-size) solid white;
50
+ color: transparent;
51
+ background-color: transparent;
52
+ border: var(--border-size) solid #dcdfe6;
53
+ color: #606266;
54
+ }
55
+ .__ea-button.normal.plain:hover {
56
+ background-color: transparent;
57
+ }
58
+ .__ea-button.normal.round {
59
+ --border-radius: 999px;
60
+ }
61
+ .__ea-button.normal.medium {
62
+ font-size: 14px;
63
+ }
64
+ .__ea-button.normal.small {
65
+ font-size: 12px;
66
+ }
67
+ .__ea-button.normal.mini {
68
+ font-size: 10px;
69
+ }
70
+ .__ea-button.normal:hover {
71
+ border: var(--border-size) solid rgba(160, 207, 255, 0.4);
72
+ color: #3a9bff;
73
+ background-color: rgba(160, 207, 255, 0.05);
74
+ }
75
+ .__ea-button.normal:active {
76
+ background-color: rgba(7, 130, 255, 0.05);
77
+ border: var(--border-size) solid rgba(33, 143, 255, 0.4);
78
+ }
79
+ .__ea-button > i {
80
+ font-size: 1rem;
81
+ margin-right: 0.5rem;
82
+ }
83
+ .__ea-button.primary {
84
+ border: var(--border-size) solid #409eff;
85
+ color: #fff;
86
+ background-color: #409eff;
87
+ }
88
+ .__ea-button.primary.disabled {
89
+ cursor: not-allowed !important;
90
+ background-image: none !important;
91
+ background-color: #c0dfff !important;
92
+ border-color: #c0dfff !important;
93
+ color: white !important;
94
+ pointer-events: none;
95
+ }
96
+ .__ea-button.primary.plain {
97
+ background-color: #f8fbff;
98
+ border: var(--border-size) solid #c0dfff;
99
+ color: #409eff;
100
+ }
101
+ .__ea-button.primary.round {
102
+ --border-radius: 999px;
103
+ }
104
+ .__ea-button.primary.medium {
105
+ font-size: 14px;
106
+ }
107
+ .__ea-button.primary.small {
108
+ font-size: 12px;
109
+ }
110
+ .__ea-button.primary.mini {
111
+ font-size: 10px;
112
+ }
113
+ .__ea-button.primary:hover {
114
+ border: var(--border-size) solid #73b8ff;
115
+ color: white;
116
+ background-color: #73b8ff;
117
+ }
118
+ .__ea-button.primary:active {
119
+ background-color: #006bd9;
120
+ }
121
+ .__ea-button > i {
122
+ font-size: 1rem;
123
+ margin-right: 0.5rem;
124
+ }
125
+ .__ea-button.success {
126
+ border: var(--border-size) solid #67c23a;
127
+ color: #fff;
128
+ background-color: #67c23a;
129
+ }
130
+ .__ea-button.success.disabled {
131
+ cursor: not-allowed !important;
132
+ background-image: none !important;
133
+ background-color: #b2e19b !important;
134
+ border-color: #b2e19b !important;
135
+ color: white !important;
136
+ pointer-events: none;
137
+ }
138
+ .__ea-button.success.plain {
139
+ background-color: #d3eec6;
140
+ border: var(--border-size) solid #b2e19b;
141
+ color: #67c23a;
142
+ }
143
+ .__ea-button.success.round {
144
+ --border-radius: 999px;
145
+ }
146
+ .__ea-button.success.medium {
147
+ font-size: 14px;
148
+ }
149
+ .__ea-button.success.small {
150
+ font-size: 12px;
151
+ }
152
+ .__ea-button.success.mini {
153
+ font-size: 10px;
154
+ }
155
+ .__ea-button.success:hover {
156
+ border: var(--border-size) solid #85cf60;
157
+ color: white;
158
+ background-color: #85cf60;
159
+ }
160
+ .__ea-button.success:active {
161
+ background-color: #3d7323;
162
+ }
163
+ .__ea-button > i {
164
+ font-size: 1rem;
165
+ margin-right: 0.5rem;
166
+ }
167
+ .__ea-button.info {
168
+ border: var(--border-size) solid #909399;
169
+ color: #fff;
170
+ background-color: #909399;
171
+ }
172
+ .__ea-button.info.disabled {
173
+ cursor: not-allowed !important;
174
+ background-image: none !important;
175
+ background-color: #d2d4d6 !important;
176
+ border-color: #d2d4d6 !important;
177
+ color: white !important;
178
+ pointer-events: none;
179
+ }
180
+ .__ea-button.info.plain {
181
+ background-color: #f0f0f1;
182
+ border: var(--border-size) solid #d2d4d6;
183
+ color: #909399;
184
+ }
185
+ .__ea-button.info.round {
186
+ --border-radius: 999px;
187
+ }
188
+ .__ea-button.info.medium {
189
+ font-size: 14px;
190
+ }
191
+ .__ea-button.info.small {
192
+ font-size: 12px;
193
+ }
194
+ .__ea-button.info.mini {
195
+ font-size: 10px;
196
+ }
197
+ .__ea-button.info:hover {
198
+ border: var(--border-size) solid #abadb1;
199
+ color: white;
200
+ background-color: #abadb1;
201
+ }
202
+ .__ea-button.info:active {
203
+ background-color: #5d6066;
204
+ }
205
+ .__ea-button > i {
206
+ font-size: 1rem;
207
+ margin-right: 0.5rem;
208
+ }
209
+ .__ea-button.warning {
210
+ border: var(--border-size) solid #e6a23c;
211
+ color: #fff;
212
+ background-color: #e6a23c;
213
+ }
214
+ .__ea-button.warning.disabled {
215
+ cursor: not-allowed !important;
216
+ background-image: none !important;
217
+ background-color: #f4d8ad !important;
218
+ border-color: #f4d8ad !important;
219
+ color: white !important;
220
+ pointer-events: none;
221
+ }
222
+ .__ea-button.warning.plain {
223
+ background-color: #fbf0df;
224
+ border: var(--border-size) solid #f4d8ad;
225
+ color: #e6a23c;
226
+ }
227
+ .__ea-button.warning.round {
228
+ --border-radius: 999px;
229
+ }
230
+ .__ea-button.warning.medium {
231
+ font-size: 14px;
232
+ }
233
+ .__ea-button.warning.small {
234
+ font-size: 12px;
235
+ }
236
+ .__ea-button.warning.mini {
237
+ font-size: 10px;
238
+ }
239
+ .__ea-button.warning:hover {
240
+ border: var(--border-size) solid #ecb869;
241
+ color: white;
242
+ background-color: #ecb869;
243
+ }
244
+ .__ea-button.warning:active {
245
+ background-color: #a76d15;
246
+ }
247
+ .__ea-button > i {
248
+ font-size: 1rem;
249
+ margin-right: 0.5rem;
250
+ }
251
+ .__ea-button.danger {
252
+ border: var(--border-size) solid #f56c6c;
253
+ color: #fff;
254
+ background-color: #f56c6c;
255
+ }
256
+ .__ea-button.danger.disabled {
257
+ cursor: not-allowed !important;
258
+ background-image: none !important;
259
+ background-color: #fde3e3 !important;
260
+ border-color: #fde3e3 !important;
261
+ color: white !important;
262
+ pointer-events: none;
263
+ }
264
+ .__ea-button.danger.plain {
265
+ background-color: white;
266
+ border: var(--border-size) solid #fde3e3;
267
+ color: #f56c6c;
268
+ background-color: #fde8e8;
269
+ }
270
+ .__ea-button.danger.round {
271
+ --border-radius: 999px;
272
+ }
273
+ .__ea-button.danger.medium {
274
+ font-size: 14px;
275
+ }
276
+ .__ea-button.danger.small {
277
+ font-size: 12px;
278
+ }
279
+ .__ea-button.danger.mini {
280
+ font-size: 10px;
281
+ }
282
+ .__ea-button.danger:hover {
283
+ border: var(--border-size) solid #f89c9c;
284
+ color: white;
285
+ background-color: #f89c9c;
286
+ }
287
+ .__ea-button.danger:active {
288
+ background-color: #eb1010;
289
+ }
290
+ .__ea-button > i {
291
+ font-size: 1rem;
292
+ margin-right: 0.5rem;
293
+ }
294
+ .__ea-button.text {
295
+ border: var(--border-size) solid transparent;
296
+ color: #409eff;
297
+ background-color: transparent;
298
+ }
299
+ .__ea-button.text.disabled {
300
+ cursor: not-allowed !important;
301
+ background-image: none !important;
302
+ background-color: rgba(64, 64, 64, 0) !important;
303
+ border-color: rgba(64, 64, 64, 0) !important;
304
+ color: white !important;
305
+ pointer-events: none;
306
+ color: #c0c4cc !important;
307
+ }
308
+ .__ea-button.text.plain {
309
+ background-color: rgba(92, 92, 92, 0);
310
+ border: var(--border-size) solid rgba(64, 64, 64, 0);
311
+ color: transparent;
312
+ }
313
+ .__ea-button.text.round {
314
+ --border-radius: 999px;
315
+ }
316
+ .__ea-button.text.medium {
317
+ font-size: 14px;
318
+ }
319
+ .__ea-button.text.small {
320
+ font-size: 12px;
321
+ }
322
+ .__ea-button.text.mini {
323
+ font-size: 10px;
324
+ }
325
+ .__ea-button.text:hover {
326
+ border: var(--border-size) solid rgba(26, 26, 26, 0);
327
+ color: #73b8ff;
328
+ background-color: rgba(26, 26, 26, 0);
329
+ }
330
+ .__ea-button.text:active {
331
+ background-color: rgba(0, 0, 0, 0);
332
+ }
333
+ .__ea-button > i {
334
+ font-size: 1rem;
335
+ margin-right: 0.5rem;
336
+ }
337
+ .__ea-button.first-child {
338
+ border-radius: 4px 0 0 4px;
339
+ }
340
+ .__ea-button.middle-child {
341
+ border-radius: 0;
342
+ }
343
+ .__ea-button.last-child {
344
+ border-radius: 0 4px 4px 0;
345
+ }
346
+ `;
347
+
348
+ export class EaButton extends Base {
349
+ #mounted = false;
350
+
351
+ constructor() {
352
+ super();
353
+
354
+ const shadowRoot = this.attachShadow({ mode: 'open' });
355
+ let dom = null;
356
+
357
+
358
+ if (this.getAttribute('href') !== null && this.getAttribute('href') !== '') dom = document.createElement('a');
359
+ else dom = document.createElement('button');
360
+
361
+ const slot = document.createElement('slot');
362
+ dom.className = "__ea-button";
363
+ dom.appendChild(slot);
364
+
365
+ this.dom = dom;
366
+
367
+ this.build(shadowRoot, stylesheet);
368
+
369
+ shadowRoot.appendChild(dom);
370
+ }
371
+
372
+ static get observedAttributes() {
373
+ return ['loading', 'disabled'];
374
+ }
375
+
376
+ get BUTTON_STYLE() {
377
+ return ['plain', 'round'];
378
+ }
379
+
380
+ get BUTTON_TYPE() {
381
+ return ['normal', 'primary', 'success', 'warning', 'danger', 'text'];
382
+ }
383
+
384
+ get BUTTON_SIZE() {
385
+ return ['medium', 'small', 'mini'];
386
+ }
387
+
388
+
389
+ // ------- 禁用 -------
390
+ // #region
391
+ get disabled() {
392
+ return this.hasAttribute('disabled');
393
+ }
394
+
395
+ set disabled(value) {
396
+ if (!this.#mounted) {
397
+ this.toggleAttribute('disabled', this.disabled, 'disabled');
398
+ } else {
399
+ this.toggleAttribute('disabled', value, 'disabled');
400
+ }
401
+ }
402
+
403
+ get ariaDisabled() {
404
+ return this.getAttribute('aria-disabled') !== null || this.getAttribute('aria-disabled') !== undefined;
405
+ }
406
+
407
+ set ariaDisabled(value) {
408
+ this.toggleAttribute('aria-disabled', value, 'disabled');
409
+ }
410
+ // #endregion
411
+ // ------- end -------
412
+
413
+ // ------- 按钮样式 -------
414
+ // #region
415
+ get plain() {
416
+ return this.getAttribute('plain') !== undefined && this.getAttribute('plain') !== null;
417
+ }
418
+ set plain(value) {
419
+ this.toggleAttribute('plain', value, 'plain');
420
+ }
421
+
422
+ get round() {
423
+ return this.getAttribute('round') !== undefined && this.getAttribute('round') !== null;
424
+ }
425
+ set round(value) {
426
+ this.toggleAttribute('round', value, 'round');
427
+
428
+ if (value) this.dom.style.setProperty('--border-radius', '999px');
429
+ }
430
+ // #endregion
431
+ // ------- end -------
432
+
433
+ // ------- type属性 -------
434
+ // #region
435
+ get type() {
436
+ const attr = this.getAttribute('type');
437
+
438
+ if (attr == null || attr == false) return 'normal';
439
+ else return attr;
440
+ }
441
+
442
+ set type(value) {
443
+ if (!this.BUTTON_TYPE.includes(value)) value = 'normal';
444
+
445
+ this.toggleAttribute('type', value, value);
446
+ }
447
+ // #endregion
448
+ // ------- end -------
449
+
450
+ // ------- 按钮大小 -------
451
+ // #region
452
+ get size() {
453
+ return this.getAttribute('size');
454
+ }
455
+ set size(value) {
456
+ if (!this.BUTTON_SIZE.includes(value)) return;
457
+
458
+ this.toggleAttribute('size', value, value);
459
+ }
460
+ // #endregion
461
+ // ------- end -------
462
+
463
+ // ------- 按钮加载 -------
464
+ // #region
465
+ get loading() {
466
+ return this.hasAttribute('loading');
467
+ }
468
+
469
+ set loading(value) {
470
+ value = value === "true" || value === "" || value === true ? true : false;
471
+ this.toggleAttribute('loading', value, 'loading');
472
+ this.disabled = value;
473
+
474
+ if (value && !this.dom.querySelector('i')) {
475
+ const i = document.createElement('i');
476
+ i.className = "icon-spin6 animate-spin";
477
+
478
+ this.dom.insertBefore(i, this.dom.firstChild)
479
+ } else if (!value && this.dom.querySelector('i')) {
480
+ this.dom.querySelector('i').remove();
481
+ }
482
+ }
483
+ // #endregion
484
+ // ------- end -------
485
+
486
+ // ------- 图标按钮 -------
487
+ // #region
488
+ get icon() {
489
+ return this.getAttribute('icon');
490
+ }
491
+
492
+ set icon(value) {
493
+ if (value) {
494
+ this.setAttribute('icon', value);
495
+
496
+ if (!this.dom.querySelector('i')) {
497
+ const eaIcon = document.createElement('ea-icon');
498
+ eaIcon.icon = value;
499
+
500
+ this.dom.insertBefore(eaIcon, this.dom.firstChild)
501
+ }
502
+ } else {
503
+ this.removeAttribute('icon');
504
+ this.dom.querySelector('i')?.remove();
505
+ }
506
+ }
507
+ // #endregion
508
+ // ------- end -------
509
+
510
+ // ------- 链接按钮 -------
511
+ // #region
512
+ get href() {
513
+ return this.getAttribute('href');
514
+ }
515
+
516
+ set href(value) {
517
+ if (this.shadowRoot.querySelector("button")) return;
518
+
519
+ if (value == null && value == false) {
520
+ this.removeAttribute('href');
521
+ this.dom.removeAttribute('href');
522
+ } else {
523
+ this.setAttribute('href', value);
524
+ this.dom.setAttribute('href', value);
525
+ }
526
+ }
527
+ // #endregion
528
+ // ------- end -------
529
+
530
+ init() {
531
+ // 禁用
532
+ this.disabled = this.hasAttribute('disabled');
533
+
534
+ // 加载
535
+ this.loading = this.loading;
536
+
537
+ // 按钮样式
538
+ for (let i = 0, style; style = this.BUTTON_STYLE[i++];) {
539
+ if (this[style]) {
540
+ this[style] = this[style];
541
+ break;
542
+ }
543
+ }
544
+
545
+ // 按钮种类
546
+ this.type = this.type;
547
+
548
+ // 按钮大小
549
+ this.size = this.size;
550
+
551
+ // 链接
552
+ this.href = this.href;
553
+
554
+ // 图标
555
+ this.icon = this.icon;
556
+ }
557
+
558
+ connectedCallback() {
559
+ this.init();
560
+
561
+ this.#mounted = true;
562
+ }
563
+
564
+ attributeChangedCallback(name, oldValue, newValue) {
565
+ if (oldValue == newValue) return;
566
+ switch (name) {
567
+ case "loading":
568
+ if (newValue === "") newValue = true;
569
+ this.loading = newValue;
570
+ break;
571
+ case "disabled":
572
+ if (this.#mounted) {
573
+ this.disabled = newValue === "true" || newValue === "";
574
+ if (newValue === "true" || newValue === "") this.setAttribute("disabled", true);
575
+ }
576
+ break;
577
+ default: break;
578
+ }
579
+ }
580
+ }
581
+
582
+ if (!window.customElements.get("ea-button")) {
583
+ window.customElements.define("ea-button", EaButton);
584
+ }