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,334 @@
1
+ // @ts-nocheck
2
+ import Base from '../Base.js';
3
+ import { createElement, createSlotElement } from '../../utils/createElement.js';
4
+
5
+ const stylesheet = `
6
+ .ea-timeline-item_wrap {
7
+ position: relative;
8
+ padding-bottom: 20px;
9
+ padding-left: 28px;
10
+ list-style: none;
11
+ }
12
+ .ea-timeline-item_wrap .ea-timeline-item_circle {
13
+ position: absolute;
14
+ left: 0;
15
+ z-index: 1;
16
+ display: block;
17
+ width: 12px;
18
+ height: 12px;
19
+ font-size: 12px;
20
+ border-radius: 50%;
21
+ background-color: #e4e7ed;
22
+ }
23
+ .ea-timeline-item_wrap .ea-timeline-item_circle.ea-timeline-item--primary {
24
+ background-color: #409eff;
25
+ color: #409eff;
26
+ }
27
+ .ea-timeline-item_wrap .ea-timeline-item_circle.ea-timeline-item--success {
28
+ background-color: #67c23a;
29
+ color: #67c23a;
30
+ }
31
+ .ea-timeline-item_wrap .ea-timeline-item_circle.ea-timeline-item--warning {
32
+ background-color: #e6a23c;
33
+ color: #e6a23c;
34
+ }
35
+ .ea-timeline-item_wrap .ea-timeline-item_circle.ea-timeline-item--danger {
36
+ background-color: #f56c6c;
37
+ color: #f56c6c;
38
+ }
39
+ .ea-timeline-item_wrap .ea-timeline-item_circle.ea-timeline-item--info {
40
+ background-color: #e4e7ed;
41
+ color: #e4e7ed;
42
+ }
43
+ .ea-timeline-item_wrap .ea-timeline-item_tail {
44
+ z-index: 0;
45
+ position: absolute;
46
+ left: 0.3281rem;
47
+ height: 100%;
48
+ border-left: 2px solid #e4e7ed;
49
+ }
50
+ .ea-timeline-item_wrap .ea-timeline-item_container {
51
+ position: relative;
52
+ top: -4px;
53
+ font-size: 14px;
54
+ display: flex;
55
+ flex-direction: column;
56
+ }
57
+ .ea-timeline-item_wrap .ea-timeline-item_container .ea-timeline-item_timestamp {
58
+ color: #909399;
59
+ line-height: 1;
60
+ margin-top: 8px;
61
+ }
62
+ .ea-timeline-item_wrap .ea-timeline-item_container .ea-timeline-item_content {
63
+ color: #303133;
64
+ }
65
+ .ea-timeline-item_wrap .ea-timeline-item_container.ea-timeline-item_timestamp--top {
66
+ flex-direction: column-reverse;
67
+ }
68
+ .ea-timeline-item_wrap .ea-timeline-item_container.ea-timeline-item_timestamp--top .ea-timeline-item_timestamp {
69
+ margin-top: 0;
70
+ margin-bottom: 8px;
71
+ }
72
+ .ea-timeline-item_wrap .ea-timeline-item_container.ea-timeline-item_timestamp--bottom {
73
+ flex-direction: column;
74
+ }
75
+ .ea-timeline-item_wrap.ea-timeline-item_circle--large .ea-timeline-item_circle {
76
+ width: 14px;
77
+ height: 14px;
78
+ }
79
+ .ea-timeline-item_wrap.ea-timeline-item_circle--large .ea-timeline-item_tail {
80
+ left: 0.3906rem;
81
+ }
82
+ .ea-timeline-item_wrap.ea-timeline-item_circle--large .ea-timeline-item_container {
83
+ font-size: 16px;
84
+ }
85
+ `;
86
+
87
+ export class EaTimeline extends Base {
88
+ #mounted = false;
89
+
90
+ #wrap;
91
+
92
+ #container;
93
+
94
+ #timelineSlot;
95
+
96
+ #observer;
97
+
98
+
99
+ constructor() {
100
+ super();
101
+
102
+ const shadowRoot = this.attachShadow({ mode: 'open' });
103
+ const wrap = document.createElement('div');
104
+ wrap.className = 'ea-timeline_wrap';
105
+
106
+ const timelineSlot = createSlotElement('');
107
+ const container = createElement('ul', 'ea-timeline-item_container', [timelineSlot]);
108
+ wrap.appendChild(container);
109
+
110
+ this.#wrap = wrap;
111
+ this.#container = container;
112
+ this.#timelineSlot = timelineSlot;
113
+
114
+ this.build(shadowRoot, stylesheet);
115
+ this.shadowRoot.appendChild(wrap);
116
+ }
117
+
118
+ // ------- reverse 时间线排序 -------
119
+ // #region
120
+ get reverse() {
121
+ const attr = this.getAttribute('reverse');
122
+ const flag = ["true", "false"].includes(attr);
123
+
124
+ if (attr && flag) return attr === "true";
125
+
126
+ return true;
127
+ }
128
+
129
+ set reverse(value) {
130
+ this.setAttribute('reverse', value);
131
+
132
+ this.#sortTimeline(value);
133
+ }
134
+ // #endregion
135
+ // ------- end -------
136
+
137
+ #sortTimeline(flag) {
138
+ flag = flag === "true" || flag === true ? true : false;
139
+
140
+ setTimeout(() => {
141
+ try {
142
+ const timelineItems = Array.from(this.querySelectorAll('ea-timeline-item'));
143
+ const slotTimeline = Array.from(this.shadowRoot.querySelectorAll('ea-timeline-item'));
144
+ const timeArr = Array.from(timelineItems.concat(slotTimeline)).sort((a, b) => {
145
+ const aTime = new Date(a.time);
146
+ const bTime = new Date(b.time);
147
+
148
+ return flag ? (bTime - aTime) : (aTime - bTime);
149
+ })
150
+
151
+ timeArr.forEach((item, index) => {
152
+ this.#container.appendChild(item);
153
+ })
154
+
155
+ this.#timelineSlot.innerHTML = '';
156
+ } catch (error) { }
157
+ }, 20);
158
+ }
159
+
160
+ init() {
161
+ const that = this;
162
+
163
+ this.reverse = this.reverse;
164
+
165
+ setTimeout(() => {
166
+ const observer = new MutationObserver((mutationsList, observer) => {
167
+ this.#sortTimeline(that.reverse);
168
+ });
169
+ observer.observe(this, { childList: true });
170
+ this.#observer = observer;
171
+ }, 1000);
172
+ }
173
+
174
+ connectedCallback() {
175
+ this.init();
176
+
177
+ setTimeout(() => {
178
+ this.#mounted = true;
179
+ }, 30);
180
+ }
181
+
182
+ disconnectedCallback() {
183
+ try {
184
+ this.#observer.disconnect();
185
+ } catch (error) { }
186
+ }
187
+ }
188
+
189
+ if (!customElements.get('ea-timeline')) {
190
+ customElements.define('ea-timeline', EaTimeline);
191
+ }
192
+
193
+ export class EaTimelineItem extends Base {
194
+ #wrap;
195
+
196
+ #timeWrap;
197
+
198
+ #timelineCircle;
199
+ #timelineContent;
200
+ #timelineTimestamp;
201
+ constructor() {
202
+ super();
203
+
204
+ const shadowRoot = this.attachShadow({ mode: 'open' });
205
+
206
+ const timelineCircle = createElement('div', 'ea-timeline-item_circle');
207
+ const timelineTail = createElement('div', 'ea-timeline-item_tail');
208
+
209
+ const timelineItemSlot = createSlotElement('');
210
+ const timelineContent = createElement('div', 'ea-timeline-item_content', [timelineItemSlot]);
211
+ const timelineTimestamp = createElement('div', 'ea-timeline-item_timestamp');
212
+ const timelineContainer = createElement('div', 'ea-timeline-item_container', [timelineContent, timelineTimestamp]);
213
+
214
+ const wrap = createElement('li', 'ea-timeline-item_wrap', [timelineCircle, timelineTail, timelineContainer]);
215
+
216
+ this.#wrap = wrap;
217
+ this.#timeWrap = timelineContainer;
218
+ this.#timelineCircle = timelineCircle;
219
+ this.#timelineTimestamp = timelineTimestamp;
220
+ this.#timelineContent = timelineContent;
221
+
222
+ this.build(shadowRoot, stylesheet);
223
+ this.shadowRoot.appendChild(wrap);
224
+ }
225
+
226
+ // ------- time 时间 -------
227
+ // #region
228
+ get time() {
229
+ return this.getAttribute('time') || "";
230
+ }
231
+
232
+ set time(value) {
233
+ this.setAttribute('time', value);
234
+
235
+ this.#timelineTimestamp.innerText = value;
236
+ }
237
+ // #endregion
238
+ // ------- end -------
239
+
240
+ // ------- type 时间线类型 -------
241
+ // #region
242
+ get type() {
243
+ const attr = this.getAttribute('type');
244
+ const flag = ["primary", "success", "warning", "danger", "info"].includes(attr);
245
+
246
+ if (attr && flag) return attr;
247
+
248
+ return "info";
249
+ }
250
+
251
+ set type(value) {
252
+ this.setAttribute('type', value);
253
+
254
+ this.#timelineCircle.classList.add(`ea-timeline-item--${value}`);
255
+ }
256
+ // #endregion
257
+ // ------- end -------
258
+
259
+ // ------- color 时间线颜色 -------
260
+ // #region
261
+ get color() {
262
+ return this.getAttribute('color') || "";
263
+ }
264
+
265
+ set color(value) {
266
+ this.setAttribute('color', value);
267
+
268
+ const isColor = new Option().style.color = value;
269
+
270
+ if (isColor !== "") this.#timelineCircle.style.backgroundColor = value;
271
+ }
272
+ // #endregion
273
+ // ------- end -------
274
+
275
+ // ------- size 时间线尺寸 -------
276
+ // #region
277
+ get size() {
278
+ const attr = this.getAttribute('size');
279
+ const flag = ["normal", "large"].includes(attr);
280
+
281
+ if (attr && flag) return attr;
282
+
283
+ return "normal";
284
+ }
285
+
286
+ set size(value) {
287
+ this.setAttribute('size', value);
288
+
289
+ this.#wrap.classList.add(`ea-timeline-item_circle--${value}`);
290
+ }
291
+ // #endregion
292
+ // ------- end -------
293
+
294
+ // ------- placement 时间的显示位置 -------
295
+ // #region
296
+ get placement() {
297
+ const attr = this.getAttribute('placement');
298
+ const flag = ["top", "bottom"].includes(attr);
299
+
300
+ if (attr && flag) return attr;
301
+
302
+ return "bottom";
303
+ }
304
+
305
+ set placement(value) {
306
+ this.setAttribute('placement', value);
307
+
308
+ this.#timeWrap.classList.add(`ea-timeline-item_timestamp--${value}`);
309
+ }
310
+ // #endregion
311
+ // ------- end -------
312
+
313
+ init() {
314
+ const that = this;
315
+
316
+ this.time = this.time;
317
+
318
+ this.type = this.type;
319
+
320
+ this.color = this.color;
321
+
322
+ this.size = this.size;
323
+
324
+ this.placement = this.placement;
325
+ }
326
+
327
+ connectedCallback() {
328
+ this.init();
329
+ }
330
+ }
331
+
332
+ if (!customElements.get('ea-timeline-item')) {
333
+ customElements.define('ea-timeline-item', EaTimelineItem);
334
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-component-ui",
3
- "version": "0.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Easy-ui, 基于 Web Components 的 UI 组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 创建元素
3
+ * @param {String} tagName
4
+ * @param {String} className
5
+ * @param {HTMLElement} children
6
+ * @returns {HTMLElement}
7
+ */
8
+ export const createElement = (tagName, className, children) => {
9
+ const element = document.createElement(tagName || 'div');
10
+ element.className = className || '';
11
+
12
+ if (children) {
13
+ if (Array.isArray(children)) {
14
+ children.forEach(child => {
15
+ element.appendChild(child);
16
+ });
17
+ } else {
18
+ element.appendChild(children);
19
+ }
20
+ }
21
+
22
+ return element;
23
+ };
24
+
25
+ export const createSlotElement = (name) => {
26
+ const slot = document.createElement('slot');
27
+ slot.name = name;
28
+
29
+ return slot;
30
+ };
@@ -0,0 +1,19 @@
1
+ export const handleTemplate = (self, slotName, realSlot, tempSlot) => {
2
+ const template = self.querySelector(`[slot="${slotName}"]`);
3
+ if (!template) return;
4
+
5
+ try {
6
+ if (template.childNodes.length === 0) {
7
+ realSlot.innerHTML = template.innerHTML;
8
+ } else if (template.innerHTML === '') {
9
+ const nodes = template.childNodes;
10
+ realSlot.innerHTML = '';
11
+ Array.from(nodes).forEach(node => {
12
+ realSlot.appendChild(node.cloneNode(true));
13
+ });
14
+ }
15
+
16
+ template.remove();
17
+ tempSlot.remove();
18
+ } catch (e) { }
19
+ }
@@ -0,0 +1,8 @@
1
+ export default function setStyle(shadowRoot, href) {
2
+ const link = document.createElement('link');
3
+
4
+ link.href = href;
5
+ link.rel = "stylesheet";
6
+
7
+ shadowRoot.appendChild(link);
8
+ }