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.
Files changed (176) hide show
  1. package/.github/workflows/publish.yml +28 -0
  2. package/components/Base.js +1 -90
  3. package/components/ea-alert/index.js +1 -298
  4. package/components/ea-alert/src/style/stylesheet.js +1 -0
  5. package/components/ea-aside/index.js +1 -0
  6. package/components/ea-avatar/index.js +1 -277
  7. package/components/ea-avatar/src/assets/defaultAvatar.js +1 -0
  8. package/components/ea-avatar/src/assets/errorAvatar.js +1 -0
  9. package/components/ea-avatar/src/assets/iconAndTextAvatar.js +1 -0
  10. package/components/ea-avatar/src/style/stylesheet.js +1 -0
  11. package/components/ea-backtop/index.js +1 -232
  12. package/components/ea-backtop/src/style/stylesheet.js +1 -0
  13. package/components/ea-badge/index.js +1 -160
  14. package/components/ea-badge/src/style/stylesheet.js +1 -0
  15. package/components/ea-breadcrumb/index.js +1 -0
  16. package/components/ea-breadcrumb/src/style/stylesheet.js +1 -0
  17. package/components/ea-breadcrumb-item/index.js +1 -0
  18. package/components/ea-breadcrumb-item/src/style/style.js +1 -0
  19. package/components/ea-button/index.js +1 -584
  20. package/components/ea-button/src/components/ButtonComm.js +1 -0
  21. package/components/ea-button/src/components/HrefComm.js +1 -0
  22. package/components/ea-button/src/style/stylesheet.js +1 -0
  23. package/components/ea-button-group/index.js +1 -459
  24. package/components/ea-button-group/src/style/stylesheet.js +1 -0
  25. package/components/ea-calendar/index.js +1 -409
  26. package/components/ea-calendar/src/style/stylesheet.js +1 -0
  27. package/components/ea-calendar/src/utils/createChangerElement.js +1 -0
  28. package/components/ea-calendar/src/utils/createThead.js +1 -0
  29. package/components/ea-calendar/src/utils/getDate.js +1 -0
  30. package/components/ea-calendar/src/utils/getUserWeekStart.js +1 -0
  31. package/components/ea-card/index.js +1 -77
  32. package/components/ea-card/src/style/stylesheet.js +1 -0
  33. package/components/ea-carousel/index.js +1 -434
  34. package/components/ea-carousel/src/style/stylesheet.js +1 -0
  35. package/components/ea-carousel/src/utils/handleIndexOverflow.js +1 -0
  36. package/components/ea-carousel-item/index.js +1 -0
  37. package/components/ea-carousel-item/src/style/stylesheet.js +1 -0
  38. package/components/ea-checkbox/index.js +1 -314
  39. package/components/ea-checkbox/src/style/stylesheet.js +1 -0
  40. package/components/ea-checkbox-group/index.js +1 -107
  41. package/components/ea-checkbox-group/src/style/stylesheet.js +1 -0
  42. package/components/ea-collapse/index.js +1 -293
  43. package/components/ea-collapse-item/index.js +1 -0
  44. package/components/ea-collapse-item/src/style/stylesheet.js +1 -0
  45. package/components/ea-container/index.js +1 -0
  46. package/components/ea-date-picker/index.js +1 -0
  47. package/components/ea-date-picker/src/style/stylesheet.js +1 -0
  48. package/components/ea-descriptions/index.js +1 -240
  49. package/components/ea-descriptions/src/components/contentTemplate.js +1 -0
  50. package/components/ea-descriptions/src/components/getTdTemplate_border.js +1 -0
  51. package/components/ea-descriptions/src/components/getTdTemplate_direction.js +1 -0
  52. package/components/ea-descriptions/src/components/getThTemplate_direction.js +1 -0
  53. package/components/ea-descriptions/src/components/getThTemplate_normal.js +1 -0
  54. package/components/ea-descriptions/src/style/stylesheet.js +1 -0
  55. package/components/ea-descriptions-item/index.js +1 -110
  56. package/components/ea-descriptions-item/src/stylesheet.js +1 -0
  57. package/components/ea-drawer/index.js +1 -0
  58. package/components/ea-drawer/src/style/stylesheet.js +1 -0
  59. package/components/ea-empty/index.js +1 -141
  60. package/components/ea-empty/src/assets/emptyStatusSVG.js +1 -0
  61. package/components/ea-empty/src/style/stylesheet.js +1 -0
  62. package/components/ea-footer/index.js +1 -0
  63. package/components/ea-form/index.js +1 -0
  64. package/components/ea-form-item/index.js +1 -0
  65. package/components/ea-form-item/src/style/stylesheet.js +1 -0
  66. package/components/ea-header/index.js +1 -0
  67. package/components/ea-icon/config.json +1029 -1017
  68. package/components/ea-icon/css/animation.css +85 -85
  69. package/components/ea-icon/css/fontello.css +226 -224
  70. package/components/ea-icon/font/fontello.eot +0 -0
  71. package/components/ea-icon/font/fontello.svg +350 -683
  72. package/components/ea-icon/font/fontello.ttf +0 -0
  73. package/components/ea-icon/font/fontello.woff +0 -0
  74. package/components/ea-icon/font/fontello.woff2 +0 -0
  75. package/components/ea-icon/index.js +1 -47
  76. package/components/ea-image/index.js +1 -412
  77. package/components/ea-image/src/assets/errorImage.js +1 -0
  78. package/components/ea-image/src/style/stylesheet.js +1 -0
  79. package/components/ea-image/src/utils/createPreviewTools.js +1 -0
  80. package/components/ea-infinite-scroll/index.js +1 -170
  81. package/components/ea-infinite-scroll-item/index.js +1 -0
  82. package/components/ea-input/index.js +1 -765
  83. package/components/ea-input/src/components/createFixIcon.js +1 -0
  84. package/components/ea-input/src/components/createSuggestionBoard.js +1 -0
  85. package/components/ea-input/src/components/createWordLimitElement.js +1 -0
  86. package/components/ea-input/src/style/stylesheet.js +1 -0
  87. package/components/ea-input/src/utils/dispatchEvent.js +1 -0
  88. package/components/ea-input/src/utils/handleSearchResult.js +1 -0
  89. package/components/ea-input/src/utils/handleSuggestionBoardTrigger.js +1 -0
  90. package/components/ea-input-number/index.js +1 -458
  91. package/components/ea-input-number/src/style/stylesheet.js +1 -0
  92. package/components/ea-input-number/src/utils/handleCustomEvent.js +1 -0
  93. package/components/ea-link/index.js +1 -200
  94. package/components/ea-link/src/style/stylesheet.js +1 -0
  95. package/components/ea-loading/index.js +1 -218
  96. package/components/ea-loading/src/style/stylesheet.js +1 -0
  97. package/components/ea-main/index.js +1 -0
  98. package/components/ea-menu/index.js +1 -0
  99. package/components/ea-menu/src/style/stylesheet.js +1 -0
  100. package/components/ea-menu/src/utils/handleMenuItemEvent.js +1 -0
  101. package/components/ea-menu-item/index.js +1 -0
  102. package/components/ea-menu-item/src/style/stylesheet.js +1 -0
  103. package/components/ea-menu-item-group/index.js +1 -0
  104. package/components/ea-menu-item-group/src/style/stylesheet.js +1 -0
  105. package/components/ea-message/index.js +1 -233
  106. package/components/ea-message/src/style/stylesheet.js +1 -0
  107. package/components/ea-message/src/utils/MessageClass.js +1 -0
  108. package/components/ea-message-box/index.js +1 -202
  109. package/components/ea-message-box/src/style/stylesheet.js +1 -0
  110. package/components/ea-message-box/src/utils/EaMessageBoxClass.js +1 -0
  111. package/components/ea-option/index.js +1 -0
  112. package/components/ea-option/src/style/stylesheet.js +1 -0
  113. package/components/ea-option-gropu/index.js +1 -0
  114. package/components/ea-page-header/index.js +1 -0
  115. package/components/ea-page-header/src/style/stylesheet.js +1 -0
  116. package/components/ea-pagination/index.js +1 -444
  117. package/components/ea-pagination/src/components/getMoreItem.js +1 -0
  118. package/components/ea-pagination/src/components/getPageItem.js +1 -0
  119. package/components/ea-pagination/src/components/getShowTotalItem.js +1 -0
  120. package/components/ea-pagination/src/style/stylesheet.js +1 -0
  121. package/components/ea-pane/index.js +1 -0
  122. package/components/ea-pane/src/stylesheet.js +1 -0
  123. package/components/ea-progress/index.js +1 -333
  124. package/components/ea-progress/src/components/SVGComm.js +1 -0
  125. package/components/ea-progress/src/style/stylesheet.js +1 -0
  126. package/components/ea-radio/index.js +1 -287
  127. package/components/ea-radio/src/style/stylesheet.js +1 -0
  128. package/components/ea-radio-group/index.js +1 -59
  129. package/components/ea-rate/index.js +1 -326
  130. package/components/ea-rate/src/components/rateComm.js +1 -0
  131. package/components/ea-rate/src/style/stylesheet.js +1 -0
  132. package/components/ea-result/index.js +1 -167
  133. package/components/ea-result/src/style/stylesheet.js +1 -0
  134. package/components/ea-select/index.js +1 -34
  135. package/components/ea-select/src/style/stylesheet.js +1 -0
  136. package/components/ea-skeleton/index.js +1 -341
  137. package/components/ea-skeleton/src/style/stylesheet.js +1 -0
  138. package/components/ea-skeleton/src/utils/createSkeletonElement.js +1 -0
  139. package/components/ea-skeleton-item/index.js +1 -0
  140. package/components/ea-skeleton-item/src/assets/imageSVG.js +1 -0
  141. package/components/ea-skeleton-item/src/style/stylesheet.js +1 -0
  142. package/components/ea-step/index.js +1 -0
  143. package/components/ea-step/src/style/stylesheet.js +1 -0
  144. package/components/ea-steps/index.js +1 -0
  145. package/components/ea-steps/src/style/stylesheet.js +1 -0
  146. package/components/ea-submenu/index.js +1 -0
  147. package/components/ea-submenu/src/style/stylesheet.js +1 -0
  148. package/components/ea-switch/index.js +1 -301
  149. package/components/ea-switch/src/style/stylesheet.js +1 -0
  150. package/components/ea-tab/index.js +1 -0
  151. package/components/ea-tab/src/style/stylesheet.js +1 -0
  152. package/components/ea-table/index.js +1 -0
  153. package/components/ea-table/src/style/stylesheet.js +1 -0
  154. package/components/ea-table-column/index.js +1 -0
  155. package/components/ea-tabs/index.js +1 -0
  156. package/components/ea-tabs/src/style/stylesheet.js +1 -0
  157. package/components/ea-tag/index.js +1 -212
  158. package/components/ea-tag/src/style/stylesheet.js +1 -0
  159. package/components/ea-textarea/index.js +1 -333
  160. package/components/ea-textarea/src/style/stylesheet.js +1 -0
  161. package/components/ea-time-picker/index.js +1 -0
  162. package/components/ea-time-picker/src/style/stylesheet.js +1 -0
  163. package/components/ea-timeline/index.js +1 -334
  164. package/components/ea-timeline/style/stylesheet.js +1 -0
  165. package/components/ea-timeline-item/index.js +1 -0
  166. package/components/ea-timeline-item/src/style/stylesheet.js +1 -0
  167. package/package.json +11 -11
  168. package/utils/Validator.js +1 -0
  169. package/utils/createElement.js +1 -30
  170. package/utils/handleDefaultAttrIsTrue.js +1 -0
  171. package/utils/handleTemplate.js +1 -19
  172. package/utils/setStyle.js +1 -8
  173. package/utils/timeout.js +1 -0
  174. package/components/ea-message/MessageClass.js +0 -71
  175. package/components/ea-message-box/EaMessageBoxClass.js +0 -48
  176. package/components/ea-ui-base-style.css +0 -0
@@ -1,333 +1 @@
1
- // @ts-nocheck
2
- import Base from "../Base.js";
3
-
4
- const stylesheet = `
5
- .ea-textarea_wrap {
6
- position: relative;
7
- width: 100%;
8
- }
9
- .ea-textarea_wrap .ea-textarea_inner {
10
- box-sizing: border-box;
11
- box-shadow: none;
12
- resize: vertical;
13
- min-height: 1.75rem;
14
- border: 1px solid #dcdfe6;
15
- outline: 0;
16
- transition: border 0.2s;
17
- border-radius: 3px;
18
- padding: 0.5rem;
19
- line-height: 0.8;
20
- font-size: 0.8rem;
21
- scrollbar-width: none;
22
- }
23
- .ea-textarea_wrap .ea-textarea_inner:focus {
24
- border-color: #409eff;
25
- }
26
- .ea-textarea_wrap .ea-textarea_inner::placeholder {
27
- color: #c0c4cc;
28
- }
29
- .ea-textarea_wrap .ea-textarea_inner.disabled {
30
- background-color: #eeeeee;
31
- color: #c0c4cc;
32
- }
33
- .ea-textarea_wrap .ea-textarea_inner.invalid {
34
- border-color: #f56c6c;
35
- }
36
- .ea-textarea_wrap .ea-input_word-limit {
37
- position: absolute;
38
- font-size: 0.75rem;
39
- bottom: 0.5rem;
40
- right: 0.5rem;
41
- }
42
- `;
43
-
44
- const inputDom = () => {
45
- let input = document.createElement('textarea');
46
-
47
- input.className = "ea-textarea_inner";
48
-
49
- return input;
50
- }
51
-
52
- export class EaTextarea extends Base {
53
- #wrap;
54
- #input;
55
- #mounted = false;
56
-
57
- constructor() {
58
- super();
59
-
60
- const shadowRoot = this.attachShadow({ mode: 'open' });
61
- const wrap = document.createElement('div');
62
- wrap.className = "ea-textarea_wrap";
63
- this.#wrap = wrap;
64
-
65
- const dom = inputDom();
66
- this.#input = dom;
67
-
68
- this.#wrap.appendChild(dom);
69
-
70
- this.build(shadowRoot, stylesheet);
71
- this.shadowRoot.appendChild(wrap);
72
- }
73
-
74
- // ------- value 输入框的值 -------
75
- // #region
76
- get value() {
77
- if (!this.#mounted) {
78
- this.#input.value = this.getAttribute("value") || '';
79
- }
80
-
81
- return this.getAttribute('value');
82
- }
83
-
84
- set value(val) {
85
- if (!val) return;
86
-
87
- this.setAttribute("value", val);
88
- this.#input.value = val;
89
- }
90
- // #endregion
91
- // ------- end -------
92
-
93
- // ------- placeholder 提示 -------
94
- // #region
95
- get placeholder() {
96
- return this.getAttribute("placeholder") || '';
97
- }
98
-
99
- set placeholder(val) {
100
- this.setAttribute("placeholder", val);
101
- this.#input.placeholder = val;
102
- }
103
- // #endregion
104
- // ------- end -------
105
-
106
- // ------- rows 默认行数 -------
107
- // #region
108
- get rows() {
109
- return this.getAttribute("rows") || 2;
110
- }
111
-
112
- set rows(val) {
113
- if (!val) return;
114
-
115
- this.setAttribute("rows", val);
116
- this.#input.rows = val;
117
- this.#input.setAttribute("rows", val);
118
- }
119
- // #endregion
120
- // ------- end -------
121
-
122
- // ------- autosize 自动调整高度 -------
123
- // #region
124
- get autosize() {
125
- return this.getAttrBoolean("autosize");
126
- }
127
-
128
- set autosize(val) {
129
- if (!val) return;
130
-
131
- this.setAttribute("autosize", val);
132
-
133
- this.#input.addEventListener('input', (e) => {
134
- if (e.target.type === 'textarea') {
135
- const cols = this.#input.cols;
136
- const chars = e.target.value.length;
137
-
138
- let rows = Math.ceil(chars / cols) <= Number(this.#input.rows) ? Number(this.#input.rows) : Math.ceil(chars / cols);
139
- if (chars % cols == 1) {
140
- if (this.minRows > rows) this.setTextareaHeight(this.minRows);
141
- else if (this.maxRows < rows) this.setTextareaHeight(this.maxRows);
142
- else this.setTextareaHeight(rows);
143
- }
144
- }
145
- })
146
- }
147
- // #endregion
148
- // ------- end -------
149
-
150
- // ------- min-rows/max-rows 最小/最大行数 -------
151
- // #region
152
-
153
- setTextareaHeight(rows) {
154
- rows = Number(rows);
155
- this.#input.rows = rows;
156
- }
157
-
158
- get minRows() {
159
- const val = Number(this.getAttribute("min-rows"));
160
- return val !== 0 && val > 0
161
- ? val
162
- : 1;
163
- }
164
-
165
- set minRows(val) {
166
- if (!val) return;
167
-
168
- this.setAttribute("min-rows", val);
169
- this.setTextareaHeight(Number(val));
170
- }
171
-
172
- get maxRows() {
173
- const val = Number(this.getAttribute("max-rows"));
174
- return val !== 0 && val > 0
175
- ? val
176
- : 10;
177
- }
178
-
179
- set maxRows(val) {
180
- if (!val) return;
181
-
182
- this.setAttribute("max-rows", val);
183
- this.setTextareaHeight(Number(val));
184
- }
185
-
186
- // #endregion
187
- // ------- end -------
188
-
189
- // ------- max-length/min-length 最大/最小字符长度 -------
190
- // #region
191
-
192
- // 获取最大限制值
193
- get maxLength() {
194
- return this.getAttribute("max-length");
195
- }
196
-
197
- set maxLength(val) {
198
- if (!val) return;
199
-
200
- this.setAttribute("max-length", val);
201
- this.#input.maxLength = val;
202
-
203
- this.#input.addEventListener('input', (e) => {
204
- if (e.target.value.length > val) {
205
- e.target.value = e.target.value.slice(0, val);
206
- }
207
- });
208
-
209
- if (this.showWordLimit) this.showWordLimit = true;
210
- }
211
-
212
- // 获取最小限制值
213
- get minLength() {
214
- return this.getAttribute("min-length");
215
- }
216
-
217
- set minLength(val) {
218
- if (!val) return;
219
-
220
- this.setAttribute("min-length", val);
221
- this.#input.minLength = val;
222
-
223
- this.#input.addEventListener('input', (e) => {
224
- if (e.target.value.length < val) {
225
- e.target.classList.add('invalid');
226
- } else {
227
- e.target.classList.remove('invalid');
228
- }
229
- });
230
- }
231
- // #endregion
232
- // ------- end -------
233
-
234
- // ------- 显示 当前文字长度 和 限制值 -------
235
- // #region
236
-
237
- get showWordLimit() {
238
- return this.getAttrBoolean("show-word-limit");
239
- }
240
-
241
- set showWordLimit(val) {
242
- if (!val) return;
243
-
244
- this.setAttribute("show-word-limit", val);
245
-
246
- // 加入显示的dom
247
- const wordLimit = document.createElement('span');
248
- this.#wrap.classList.toggle('word-limit', val);
249
- this.#wrap.classList.toggle('append-slot', val);
250
- wordLimit.className = 'ea-input_word-limit';
251
- wordLimit.innerText = `${this.#input.value.length}/${this.maxLength}`;
252
-
253
-
254
- this.#input.addEventListener('input', (e) => {
255
- wordLimit.innerText = `${e.target.value.length}/${this.maxLength}`;
256
- });
257
-
258
- this.#wrap.appendChild(wordLimit);
259
- wordLimit.style.left = (this.#input.getBoundingClientRect().width - wordLimit.getBoundingClientRect().width - 5) + 'px';
260
- }
261
- // #endregion
262
- // ------- end -------
263
-
264
-
265
- init() {
266
- const that = this;
267
-
268
- // 输入框提示
269
- this.placeholder = this.placeholder;
270
-
271
- // 输入框的值
272
- this.value = this.value;
273
-
274
- // 禁用
275
- this.disabled = this.disabled;
276
-
277
- // 自动调整高度
278
- this.autosize = this.autosize;
279
-
280
- // 最大最小行数
281
- if (this.maxRows) this.maxRows = this.maxRows;
282
- if (this.minRows) this.minRows = this.minRows;
283
-
284
- // 默认行数
285
- this.rows = this.rows;
286
-
287
- // 输入长度限制
288
- this.maxLength = this.maxLength;
289
- this.minLength = this.minLength;
290
-
291
- // 输入时
292
- this.#input.addEventListener("input", (e) => {
293
- this.dispatchEvent(
294
- new CustomEvent("change", {
295
- detail: {
296
- value: e.target.value
297
- }
298
- })
299
- );
300
- });
301
-
302
- // 聚焦时
303
- this.#input.addEventListener("focus", (e) => {
304
- this.dispatchEvent(
305
- new CustomEvent("focus", {
306
- detail: {
307
- value: e.target.value
308
- }
309
- })
310
- );
311
- });
312
-
313
- // 失焦时
314
- this.#input.addEventListener("blur", (e) => {
315
- this.dispatchEvent(
316
- new CustomEvent("blur", {
317
- detail: {
318
- value: e.target.value
319
- }
320
- })
321
- );
322
- });
323
- }
324
-
325
- connectedCallback() {
326
- this.init();
327
- this.#mounted = true;
328
- }
329
- }
330
-
331
- if (!window.customElements.get("ea-textarea")) {
332
- window.customElements.define("ea-textarea", EaTextarea);
333
- }
1
+ import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaTextarea extends Base{#t;#e;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-textarea_wrap" part="container">\n <textarea class="ea-textarea_inner" part="textarea" placeholder="请输入内容"></textarea>\n </div>\n ',this.#t=t.querySelector(".ea-textarea_wrap"),this.#e=t.querySelector(".ea-textarea_inner"),this.build(t,stylesheet)}get name(){return this.getAttribute("name")||"ea-textarea"}set name(t){this.setAttribute("name",t)}get value(){return this.#e.value}set value(t){this.#e.value=t}get disabled(){return this.getAttrBoolean("disabled")}set disabled(t){this.toggleAttr("disabled",t),this.#e.disabled=t}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(t){t&&(this.setAttribute("placeholder",t),this.#e.placeholder=t)}get rows(){return this.getAttribute("rows")||2}set rows(t){this.setAttribute("rows",t),this.#e.rows=t}get autosize(){return this.getAttrBoolean("autosize")}set autosize(t){t&&(this.setAttribute("autosize",t),this.#e.addEventListener("input",(t=>{if(this.#e.style.height!==this.#e.scrollHeight+"px"&&(this.#e.style.height=this.#e.scrollHeight+"px",this.#e.style.minHeight=this.#e.scrollHeight+"px"),"textarea"===t.target.type){const e=this.#e.cols,i=t.target.value.length;let s=Math.ceil(i/e)<=Number(this.#e.rows)?Number(this.#e.rows):Math.ceil(i/e);i%e==1&&(this.minRows>s?this.#i(this.minRows):this.maxRows<s?this.#i(this.maxRows):this.#i(s))}})))}get minRows(){const t=this.getAttrNumber("min-rows");return 0!==t&&t>0?t:0}set minRows(t){t&&(this.setAttribute("min-rows",t),this.#i(Number(t)))}get maxRows(){const t=Number(this.getAttribute("max-rows"));return 0!==t&&t>0?t:0}set maxRows(t){t&&(this.setAttribute("max-rows",t),this.#i(Number(t)))}get maxLength(){return this.getAttribute("max-length")}set maxLength(t){t&&(this.setAttribute("max-length",t),this.#e.maxLength=t,this.showWordLimit&&(this.showWordLimit=!0))}get minLength(){return this.getAttribute("min-length")}set minLength(t){t&&(this.setAttribute("min-length",t),this.#e.minLength=t)}get showWordLimit(){return this.getAttrBoolean("show-word-limit")}set showWordLimit(t){if(!t)return;this.setAttribute("show-word-limit",t);const e=document.createElement("span");e.className="ea-input_word-limit",e.innerText=`${this.#e.value.length}/${this.maxLength}`,this.#e.addEventListener("input",(t=>{e.innerText=`${t.target.value.length}/${this.maxLength}`})),this.#t.appendChild(e),e.style.left=this.#e.getBoundingClientRect().width-e.getBoundingClientRect().width-5+"px"}#i(t){t=Number(t),this.#e.rows=t}#s(t,e){this.dispatchEvent(new CustomEvent(t,{detail:{value:e.target.value}}))}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name,this.placeholder=this.placeholder,this.value=this.value,this.#e.value=this.getAttribute("value")||"",this.disabled=this.disabled,this.autosize=this.autosize,this.maxRows&&(this.maxRows=this.maxRows),this.minRows&&(this.minRows=this.minRows),this.rows=this.rows,this.maxLength=this.maxLength,this.minLength=this.minLength,this.#e.addEventListener("input",(t=>{this.#s("change",t)})),this.#e.addEventListener("focus",(t=>{this.#s("focus",t)})),this.#e.addEventListener("blur",(t=>{this.#s("blur",t)}))}}window.customElements.get("ea-textarea")||window.customElements.define("ea-textarea",EaTextarea);
@@ -0,0 +1 @@
1
+ export const stylesheet="\n.ea-textarea_wrap {\n position: relative;\n width: 100%;\n}\n.ea-textarea_wrap .ea-textarea_inner {\n box-sizing: border-box;\n box-shadow: none;\n resize: vertical;\n min-height: 1.75rem;\n border: 1px solid #dcdfe6;\n outline: 0;\n transition: border 0.2s;\n border-radius: 3px;\n padding: 0.5rem;\n line-height: 0.8;\n font-size: 0.8rem;\n scrollbar-width: none;\n}\n.ea-textarea_wrap .ea-textarea_inner:focus {\n border-color: #409eff;\n}\n.ea-textarea_wrap .ea-textarea_inner::placeholder {\n color: #c0c4cc;\n}\n.ea-textarea_wrap .ea-textarea_inner:disabled {\n background-color: #eeeeee;\n color: #c0c4cc;\n}\n.ea-textarea_wrap .ea-textarea_inner:invalid {\n border-color: #f56c6c;\n}\n.ea-textarea_wrap .ea-input_word-limit {\n position: absolute;\n font-size: 0.75rem;\n bottom: 0.5rem;\n right: 0.5rem;\n}\n";
@@ -0,0 +1 @@
1
+ import Base from"../Base.js";import"../ea-icon/index.js";import{createElement}from"../../utils/createElement.js";import{timeout}from"../../utils/timeout.js";import{stylesheet}from"./src/style/stylesheet.js";import"../ea-input/index.js";import"../ea-button/index.js";export class EaTimePicker extends Base{#e;#t;#i;#n;#r;#s;#a=!1;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML="\n <div class='ea-time-picker_wrap' part='container'>\n <ea-input part='input' autocomplete=\"off\" readonly prefix-icon=\"icon-clock\"></ea-input>\n <div class=\"ea-time-picker_dropdown-wrap\" part='dropdown-wrap'>\n <div class=\"ea-time-picker_dropdown-inner-wrap\" part='dropdown-inner-wrap'>\n <ul class=\"ea-time-picker_dropdown-inner ea-time-picker_dropdown-inner-hour\" part='dropdown-time'>\n </ul>\n <ul class=\"ea-time-picker_dropdown-inner ea-time-picker_dropdown-inner-minute\" part='dropdown-time'>\n </ul>\n <ul class=\"ea-time-picker_dropdown-inner ea-time-picker_dropdown-inner-second\" part='dropdown-time'>\n </ul>\n </div>\n </div>\n </div>\n ",this.#e=e.querySelector(".ea-time-picker_wrap"),this.#t=e.querySelector("ea-input"),this.#i=e.querySelector(".ea-time-picker_dropdown-wrap"),this.#n=e.querySelector(".ea-time-picker_dropdown-inner-hour"),this.#r=e.querySelector(".ea-time-picker_dropdown-inner-minute"),this.#s=e.querySelector(".ea-time-picker_dropdown-inner-second"),this.build(e,stylesheet)}get width(){return this.getAttribute("width")||"200px"}set width(e){this.setAttribute("width",e),this.#e.style.width=e}get time(){return this.getAttribute("time")||"00:00:00"}set time(e){this.setAttribute("time",e);const[t,i,n]=e.split(":");this.hour=t,this.minute=i,this.second=n}get name(){return this.getAttribute("name")||"timePicker"}set name(e){this.setAttribute("name",e)}get hour(){const e=this.getAttrNumber("hour");return this.#o(e)}set hour(e){this.setAttribute("hour",e),this.#h(this.#n,e)}get minute(){const e=this.getAttrNumber("minute");return this.#o(e)}set minute(e){this.setAttribute("minute",e),this.#h(this.#r,e)}get second(){const e=this.getAttrNumber("second");return this.#o(e)}set second(e){this.setAttribute("second",e),this.#h(this.#s,e)}get value(){return this.time}set value(e){this.time=e}get disabled(){return this.getAttrBoolean("disabled")||!1}set disabled(e){this.setAttribute("disabled",e),this.#t.disabled=e}get align(){return this.getAttribute("align")||"left"}set align(e){this.setAttribute("align",e),this.#t.shadowRoot.querySelector("input").style.textAlign=e}get limitRangeStart(){if(this.getAttribute("limit-range-start")){const[e,t,i]=this.getAttribute("limit-range-start")?.split(":");return`${this.#o(e)}:${this.#o(t)}:${this.#o(i)}`}return"00:00:00"}set limitRangeStart(e){this.setAttribute("limit-range-start",e)}get limitRangeEnd(){if(this.getAttribute("limit-range-end")){const[e,t,i]=this.getAttribute("limit-range-end")?.split(":");return`${this.#o(e)}:${this.#o(t)}:${this.#o(i)}`}return"23:59:59"}set limitRangeEnd(e){this.setAttribute("limit-range-end",e)}#o(e,t="00"){return(e=Number(e))<10?`0${e}`:e||t}#h(e,t){e.querySelectorAll("li").forEach((e=>{Number(e.innerText)===Number(this.#o(t))&&e.click()}))}#d(){this.#i.style.width=this.#t.getBoundingClientRect().width+"px",timeout((()=>{this.#e.classList.add("with-transition")}),50)}#l(e,t,i,n){e.addEventListener("click",(()=>{i.querySelectorAll("li").forEach((e=>{e.classList.remove("is-active")})),e.classList.add("is-active");const r=this.#o(t);switch(n){case"hour":this.hour=r;break;case"minute":this.minute=r;break;case"second":this.second=r}this.#a&&this.dispatchEvent(new CustomEvent("change",{detail:{time:this.time}})),this.#t.value=`${this.hour}:${this.minute}:${this.second}`,this.time=`${this.hour}:${this.minute}:${this.second}`;const s=e.getBoundingClientRect().height*t;i.scrollTo({top:s,behavior:"smooth"})}))}#c(e){e.addEventListener("wheel",(()=>{timeout((()=>{const t=e.querySelectorAll("li"),i=t[0].getBoundingClientRect().height,{scrollTop:n}=e,r=Math.floor(n/i);t[r]&&t[r].click()}),100)}))}#m(){const[e,t,i]=this.limitRangeStart.split(":"),[n,r,s]=this.limitRangeEnd.split(":"),a=new Date;if(new Date(a.getFullYear(),a.getMonth(),a.getDate(),e,t,i)>new Date(a.getFullYear(),a.getMonth(),a.getDate(),n,r,s))throw new Error("limit-range-start must be less than limit-range-end");const o=(t,i,r,s)=>{t=Number(t),i=Number(i);let a=0,o=0;if("hour"===s)a=0,o=23;else a=0,o=59,String(t).localeCompare(i)||e===n||(i=0===i?59:i);for(let e=a;e<=o;e++){const n=createElement("li","ea-time-picker_dropdown-item");n.innerText=this.#o(e),r.appendChild(n),e>=t&&e<=i?this.#l(n,e,r,s):n.classList.add("is-disabled")}};o(e,n,this.#n,"hour"),o(t,r,this.#r,"minute"),o(i,s,this.#s,"second"),this.#c(this.#n),this.#c(this.#r),this.#c(this.#s)}#u(){let e=!1;const t=()=>{this.time=this.time,e=!0,this.#a=!0,this.#i.removeEventListener("transitionend",t)};this.#t.addEventListener("focus",(()=>{this.#e.classList.add("is-open"),e||this.#i.addEventListener("transitionend",t)})),window.addEventListener("click",(e=>{this.contains(e.target)?this.#t.shadowRoot.querySelector(".ea-input_inner").focus():this.#e.classList.remove("is-open")}))}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name,this.width=this.width,this.disabled=this.disabled,this.align=this.align,this.limitRangeStart=this.limitRangeStart,this.limitRangeEnd=this.limitRangeEnd,this.#d(),this.#m(),this.time=this.time,this.#t.value=`${this.hour}:${this.minute}:${this.second}`,this.#u()}}customElements.get("ea-time-picker")||customElements.define("ea-time-picker",EaTimePicker);
@@ -0,0 +1 @@
1
+ export const stylesheet='\n.ea-time-picker_wrap {\n position: relative;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap {\n position: absolute;\n bottom: -12px;\n left: 0;\n transform-origin: center top;\n transform: translateY(100%) scaleY(0);\n box-sizing: border-box;\n background-color: #fff;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n z-index: 2;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap::before {\n content: "";\n position: absolute;\n top: 0;\n left: 0.5rem;\n border: 0.5rem solid transparent;\n border-bottom-color: #fff;\n transform: translateY(-100%);\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap {\n display: flex;\n position: relative;\n margin: 1rem 0;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap::before, .ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap::after {\n content: "";\n position: absolute;\n left: 0;\n transform: translateY(-50%);\n width: 100%;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap::before {\n top: calc(50% - 16px);\n border-bottom: 1px solid #e4e7ed;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap::after {\n top: calc(50% + 16px);\n border-bottom: 1px solid #e4e7ed;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap .ea-time-picker_dropdown-inner {\n flex: 1;\n max-height: 190px;\n box-sizing: border-box;\n padding: 5rem 0;\n text-align: center;\n overflow: auto;\n scrollbar-width: none;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n padding-inline-start: 0px;\n list-style-type: none;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap .ea-time-picker_dropdown-inner .ea-time-picker_dropdown-item {\n height: 32px;\n line-height: 32px;\n font-size: 12px;\n color: #606266;\n transition: color 0.3s;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap .ea-time-picker_dropdown-inner .ea-time-picker_dropdown-item.is-active {\n color: #409eff;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-inner-wrap .ea-time-picker_dropdown-inner .ea-time-picker_dropdown-item.is-disabled {\n color: #c0c4cc;\n}\n.ea-time-picker_wrap .ea-time-picker_dropdown-wrap .ea-time-picker_dropdown-button-group {\n text-align: right;\n box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.1);\n border-top: 1px solid rgba(0, 0, 0, 0.1);\n}\n.ea-time-picker_wrap.is-open .ea-time-picker_dropdown-wrap {\n transform: translateY(100%) scaleY(1);\n}\n.ea-time-picker_wrap.with-transition .ea-time-picker_dropdown-wrap {\n transition: transform 0.3s ease-in-out;\n}\n';
@@ -1,334 +1 @@
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
- }
1
+ import Base from"../Base.js";import"../ea-timeline-item/index.js";import{handleDefaultAttrIsTrue}from"../../utils/handleDefaultAttrIsTrue.js";import{timeout}from"../../utils/timeout.js";import{stylesheet}from"./style/stylesheet.js";export class EaTimeline extends Base{#e;#t;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML="\n <div class='ea-timeline_wrap' part='container'>\n <ul class='ea-timeline-item_container' part='list-wrap'>\n <slot></slot>\n </ul>\n </div>\n ",this.#e=e.querySelector(".ea-timeline_wrap"),this.#t=e.querySelector(".ea-timeline-item_container"),this.build(e,stylesheet)}get reverse(){const e=this.getAttribute("reverse");return handleDefaultAttrIsTrue(e)}set reverse(e){this.setAttribute("reverse",e),this.#i(e)}#i(e){e="true"===e||!0===e;Array.from(this.querySelectorAll("ea-timeline-item")).sort(((t,i)=>{const r=new Date(t.time),s=new Date(i.time);return e?s-r:r-s})).forEach(((e,t)=>{this.appendChild(e)}))}connectedCallback(){this.reverse=this.reverse}}customElements.get("ea-timeline")||customElements.define("ea-timeline",EaTimeline);