easy-component-ui 1.0.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +28 -0
- package/components/Base.js +1 -90
- package/components/ea-alert/index.js +1 -298
- package/components/ea-alert/src/style/stylesheet.js +1 -0
- package/components/ea-aside/index.js +1 -0
- package/components/ea-avatar/index.js +1 -277
- package/components/ea-avatar/src/assets/defaultAvatar.js +1 -0
- package/components/ea-avatar/src/assets/errorAvatar.js +1 -0
- package/components/ea-avatar/src/assets/iconAndTextAvatar.js +1 -0
- package/components/ea-avatar/src/style/stylesheet.js +1 -0
- package/components/ea-backtop/index.js +1 -232
- package/components/ea-backtop/src/style/stylesheet.js +1 -0
- package/components/ea-badge/index.js +1 -160
- package/components/ea-badge/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb/index.js +1 -0
- package/components/ea-breadcrumb/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb-item/index.js +1 -0
- package/components/ea-breadcrumb-item/src/style/style.js +1 -0
- package/components/ea-button/index.js +1 -584
- package/components/ea-button/src/components/ButtonComm.js +1 -0
- package/components/ea-button/src/components/HrefComm.js +1 -0
- package/components/ea-button/src/style/stylesheet.js +1 -0
- package/components/ea-button-group/index.js +1 -459
- package/components/ea-button-group/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/index.js +1 -409
- package/components/ea-calendar/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/src/utils/createChangerElement.js +1 -0
- package/components/ea-calendar/src/utils/createThead.js +1 -0
- package/components/ea-calendar/src/utils/getDate.js +1 -0
- package/components/ea-calendar/src/utils/getUserWeekStart.js +1 -0
- package/components/ea-card/index.js +1 -77
- package/components/ea-card/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/index.js +1 -434
- package/components/ea-carousel/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/src/utils/handleIndexOverflow.js +1 -0
- package/components/ea-carousel-item/index.js +1 -0
- package/components/ea-carousel-item/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox/index.js +1 -314
- package/components/ea-checkbox/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox-group/index.js +1 -107
- package/components/ea-checkbox-group/src/style/stylesheet.js +1 -0
- package/components/ea-collapse/index.js +1 -293
- package/components/ea-collapse-item/index.js +1 -0
- package/components/ea-collapse-item/src/style/stylesheet.js +1 -0
- package/components/ea-container/index.js +1 -0
- package/components/ea-date-picker/index.js +1 -0
- package/components/ea-date-picker/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions/index.js +1 -240
- package/components/ea-descriptions/src/components/contentTemplate.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_border.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_normal.js +1 -0
- package/components/ea-descriptions/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions-item/index.js +1 -110
- package/components/ea-descriptions-item/src/stylesheet.js +1 -0
- package/components/ea-drawer/index.js +1 -0
- package/components/ea-drawer/src/style/stylesheet.js +1 -0
- package/components/ea-empty/index.js +1 -141
- package/components/ea-empty/src/assets/emptyStatusSVG.js +1 -0
- package/components/ea-empty/src/style/stylesheet.js +1 -0
- package/components/ea-footer/index.js +1 -0
- package/components/ea-form/index.js +1 -0
- package/components/ea-form-item/index.js +1 -0
- package/components/ea-form-item/src/style/stylesheet.js +1 -0
- package/components/ea-header/index.js +1 -0
- package/components/ea-icon/config.json +1029 -1017
- package/components/ea-icon/css/animation.css +85 -85
- package/components/ea-icon/css/fontello.css +226 -224
- package/components/ea-icon/font/fontello.eot +0 -0
- package/components/ea-icon/font/fontello.svg +350 -683
- package/components/ea-icon/font/fontello.ttf +0 -0
- package/components/ea-icon/font/fontello.woff +0 -0
- package/components/ea-icon/font/fontello.woff2 +0 -0
- package/components/ea-icon/index.js +1 -47
- package/components/ea-image/index.js +1 -412
- package/components/ea-image/src/assets/errorImage.js +1 -0
- package/components/ea-image/src/style/stylesheet.js +1 -0
- package/components/ea-image/src/utils/createPreviewTools.js +1 -0
- package/components/ea-infinite-scroll/index.js +1 -170
- package/components/ea-infinite-scroll-item/index.js +1 -0
- package/components/ea-input/index.js +1 -765
- package/components/ea-input/src/components/createFixIcon.js +1 -0
- package/components/ea-input/src/components/createSuggestionBoard.js +1 -0
- package/components/ea-input/src/components/createWordLimitElement.js +1 -0
- package/components/ea-input/src/style/stylesheet.js +1 -0
- package/components/ea-input/src/utils/dispatchEvent.js +1 -0
- package/components/ea-input/src/utils/handleSearchResult.js +1 -0
- package/components/ea-input/src/utils/handleSuggestionBoardTrigger.js +1 -0
- package/components/ea-input-number/index.js +1 -458
- package/components/ea-input-number/src/style/stylesheet.js +1 -0
- package/components/ea-input-number/src/utils/handleCustomEvent.js +1 -0
- package/components/ea-link/index.js +1 -200
- package/components/ea-link/src/style/stylesheet.js +1 -0
- package/components/ea-loading/index.js +1 -218
- package/components/ea-loading/src/style/stylesheet.js +1 -0
- package/components/ea-main/index.js +1 -0
- package/components/ea-menu/index.js +1 -0
- package/components/ea-menu/src/style/stylesheet.js +1 -0
- package/components/ea-menu/src/utils/handleMenuItemEvent.js +1 -0
- package/components/ea-menu-item/index.js +1 -0
- package/components/ea-menu-item/src/style/stylesheet.js +1 -0
- package/components/ea-menu-item-group/index.js +1 -0
- package/components/ea-menu-item-group/src/style/stylesheet.js +1 -0
- package/components/ea-message/index.js +1 -233
- package/components/ea-message/src/style/stylesheet.js +1 -0
- package/components/ea-message/src/utils/MessageClass.js +1 -0
- package/components/ea-message-box/index.js +1 -202
- package/components/ea-message-box/src/style/stylesheet.js +1 -0
- package/components/ea-message-box/src/utils/EaMessageBoxClass.js +1 -0
- package/components/ea-option/index.js +1 -0
- package/components/ea-option/src/style/stylesheet.js +1 -0
- package/components/ea-option-gropu/index.js +1 -0
- package/components/ea-page-header/index.js +1 -0
- package/components/ea-page-header/src/style/stylesheet.js +1 -0
- package/components/ea-pagination/index.js +1 -444
- package/components/ea-pagination/src/components/getMoreItem.js +1 -0
- package/components/ea-pagination/src/components/getPageItem.js +1 -0
- package/components/ea-pagination/src/components/getShowTotalItem.js +1 -0
- package/components/ea-pagination/src/style/stylesheet.js +1 -0
- package/components/ea-pane/index.js +1 -0
- package/components/ea-pane/src/stylesheet.js +1 -0
- package/components/ea-progress/index.js +1 -333
- package/components/ea-progress/src/components/SVGComm.js +1 -0
- package/components/ea-progress/src/style/stylesheet.js +1 -0
- package/components/ea-radio/index.js +1 -287
- package/components/ea-radio/src/style/stylesheet.js +1 -0
- package/components/ea-radio-group/index.js +1 -59
- package/components/ea-rate/index.js +1 -326
- package/components/ea-rate/src/components/rateComm.js +1 -0
- package/components/ea-rate/src/style/stylesheet.js +1 -0
- package/components/ea-result/index.js +1 -167
- package/components/ea-result/src/style/stylesheet.js +1 -0
- package/components/ea-select/index.js +1 -34
- package/components/ea-select/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/index.js +1 -341
- package/components/ea-skeleton/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/src/utils/createSkeletonElement.js +1 -0
- package/components/ea-skeleton-item/index.js +1 -0
- package/components/ea-skeleton-item/src/assets/imageSVG.js +1 -0
- package/components/ea-skeleton-item/src/style/stylesheet.js +1 -0
- package/components/ea-step/index.js +1 -0
- package/components/ea-step/src/style/stylesheet.js +1 -0
- package/components/ea-steps/index.js +1 -0
- package/components/ea-steps/src/style/stylesheet.js +1 -0
- package/components/ea-submenu/index.js +1 -0
- package/components/ea-submenu/src/style/stylesheet.js +1 -0
- package/components/ea-switch/index.js +1 -301
- package/components/ea-switch/src/style/stylesheet.js +1 -0
- package/components/ea-tab/index.js +1 -0
- package/components/ea-tab/src/style/stylesheet.js +1 -0
- package/components/ea-table/index.js +1 -0
- package/components/ea-table/src/style/stylesheet.js +1 -0
- package/components/ea-table-column/index.js +1 -0
- package/components/ea-tabs/index.js +1 -0
- package/components/ea-tabs/src/style/stylesheet.js +1 -0
- package/components/ea-tag/index.js +1 -212
- package/components/ea-tag/src/style/stylesheet.js +1 -0
- package/components/ea-textarea/index.js +1 -333
- package/components/ea-textarea/src/style/stylesheet.js +1 -0
- package/components/ea-time-picker/index.js +1 -0
- package/components/ea-time-picker/src/style/stylesheet.js +1 -0
- package/components/ea-timeline/index.js +1 -334
- package/components/ea-timeline/style/stylesheet.js +1 -0
- package/components/ea-timeline-item/index.js +1 -0
- package/components/ea-timeline-item/src/style/stylesheet.js +1 -0
- package/package.json +11 -11
- package/utils/Validator.js +1 -0
- package/utils/createElement.js +1 -30
- package/utils/handleDefaultAttrIsTrue.js +1 -0
- package/utils/handleTemplate.js +1 -19
- package/utils/setStyle.js +1 -8
- package/utils/timeout.js +1 -0
- package/components/ea-message/MessageClass.js +0 -71
- package/components/ea-message-box/EaMessageBoxClass.js +0 -48
- package/components/ea-ui-base-style.css +0 -0
|
@@ -1,765 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from "../Base.js";
|
|
3
|
-
import "../ea-icon/index.js"
|
|
4
|
-
|
|
5
|
-
const stylesheet = `
|
|
6
|
-
@charset "UTF-8";
|
|
7
|
-
|
|
8
|
-
:host {
|
|
9
|
-
--border-top-left-radius: 0;
|
|
10
|
-
--border-top-right-radius: 0;
|
|
11
|
-
--border-bottom-left-radius: 0;
|
|
12
|
-
--border-bottom-right-radius: 0;
|
|
13
|
-
--border-left-width: 0;
|
|
14
|
-
--border-right-width: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ea-input_wrap {
|
|
18
|
-
position: relative;
|
|
19
|
-
width: 100%;
|
|
20
|
-
/* ------- 特定的属性的图标(clearable, password) ------- */
|
|
21
|
-
/* #region */
|
|
22
|
-
/* #endregion */
|
|
23
|
-
/* ------- end ------- */
|
|
24
|
-
/* ------- 标识图标在输入框前还是后 ------- */
|
|
25
|
-
/* #region */
|
|
26
|
-
/* #endregion */
|
|
27
|
-
/* ------- end ------- */
|
|
28
|
-
/* ------- 输入框前后的dom ------- */
|
|
29
|
-
/* #region */
|
|
30
|
-
/* #endregion */
|
|
31
|
-
/* ------- end ------- */
|
|
32
|
-
}
|
|
33
|
-
.ea-input_wrap .ea-input_inner {
|
|
34
|
-
box-sizing: border-box;
|
|
35
|
-
box-shadow: none;
|
|
36
|
-
border: 1px solid #dcdfe6;
|
|
37
|
-
outline: 0;
|
|
38
|
-
transition: border 0.2s;
|
|
39
|
-
border-radius: 3px;
|
|
40
|
-
padding: 0.5rem;
|
|
41
|
-
width: 100%;
|
|
42
|
-
line-height: 0.8;
|
|
43
|
-
font-size: 0.8rem;
|
|
44
|
-
scrollbar-width: none;
|
|
45
|
-
}
|
|
46
|
-
.ea-input_wrap .ea-input_inner:focus {
|
|
47
|
-
border-color: #409eff;
|
|
48
|
-
}
|
|
49
|
-
.ea-input_wrap .ea-input_inner::placeholder {
|
|
50
|
-
color: #c0c4cc;
|
|
51
|
-
}
|
|
52
|
-
.ea-input_wrap .ea-input_inner.invalid {
|
|
53
|
-
border-color: #f56c6c;
|
|
54
|
-
}
|
|
55
|
-
.ea-input_wrap .ea-input_inner.disabled {
|
|
56
|
-
background-color: #eeeeee;
|
|
57
|
-
color: #c0c4cc;
|
|
58
|
-
}
|
|
59
|
-
.ea-input_wrap .ea-input_inner.ea-input_clear ::before {
|
|
60
|
-
content: "\e9c3";
|
|
61
|
-
display: block;
|
|
62
|
-
}
|
|
63
|
-
.ea-input_wrap i {
|
|
64
|
-
font-size: 0.9rem;
|
|
65
|
-
line-height: 0.8;
|
|
66
|
-
}
|
|
67
|
-
.ea-input_wrap i[class=icon-cancel-circled2],
|
|
68
|
-
.ea-input_wrap i[class=icon-eye],
|
|
69
|
-
.ea-input_wrap i[class=icon-eye-off] {
|
|
70
|
-
position: absolute;
|
|
71
|
-
left: calc(100% - 1.75rem);
|
|
72
|
-
top: 50%;
|
|
73
|
-
color: #c0c4cc;
|
|
74
|
-
transform: translate(calc(-100% - 0.25rem), -50%);
|
|
75
|
-
}
|
|
76
|
-
.ea-input_wrap.clearable .ea-input_inner, .ea-input_wrap.password .ea-input_inner {
|
|
77
|
-
width: calc(100% - 1.75rem);
|
|
78
|
-
padding-right: 1.75rem;
|
|
79
|
-
}
|
|
80
|
-
.ea-input_wrap.prefix i, .ea-input_wrap.suffix i {
|
|
81
|
-
position: absolute;
|
|
82
|
-
top: 50%;
|
|
83
|
-
color: #c0c4cc;
|
|
84
|
-
}
|
|
85
|
-
.ea-input_wrap.prefix .ea-input_inner, .ea-input_wrap.suffix .ea-input_inner {
|
|
86
|
-
width: calc(100% - 1.75rem);
|
|
87
|
-
}
|
|
88
|
-
.ea-input_wrap.prefix i {
|
|
89
|
-
left: 2.5%;
|
|
90
|
-
transform: translate(-2.5%, -50%);
|
|
91
|
-
}
|
|
92
|
-
.ea-input_wrap.prefix .ea-input_inner {
|
|
93
|
-
padding-left: 1.75rem;
|
|
94
|
-
}
|
|
95
|
-
.ea-input_wrap.suffix i {
|
|
96
|
-
left: calc(100% - 1.75rem);
|
|
97
|
-
transform: translate(calc(-100% - 0.25rem), -50%);
|
|
98
|
-
}
|
|
99
|
-
.ea-input_wrap.suffix .ea-input_inner {
|
|
100
|
-
padding-right: 1.75rem;
|
|
101
|
-
}
|
|
102
|
-
.ea-input_wrap.prepend-slot, .ea-input_wrap.append-slot {
|
|
103
|
-
display: flex;
|
|
104
|
-
align-items: center;
|
|
105
|
-
font-size: 0.925rem;
|
|
106
|
-
line-height: 1;
|
|
107
|
-
}
|
|
108
|
-
.ea-input_wrap.prepend-slot ::slotted(div), .ea-input_wrap.append-slot ::slotted(div) {
|
|
109
|
-
border: 1px solid #dcdfe6;
|
|
110
|
-
border-left-width: var(--border-left-width);
|
|
111
|
-
border-right-width: var(--border-right-width);
|
|
112
|
-
border-top-right-radius: var(--border-top-right-radius);
|
|
113
|
-
border-bottom-right-radius: var(--border-bottom-right-radius);
|
|
114
|
-
border-top-left-radius: var(--border-top-left-radius);
|
|
115
|
-
border-bottom-left-radius: var(--border-bottom-left-radius);
|
|
116
|
-
}
|
|
117
|
-
.ea-input_wrap.prepend-slot .ea-input_inner {
|
|
118
|
-
border-top-left-radius: 0;
|
|
119
|
-
border-bottom-left-radius: 0;
|
|
120
|
-
}
|
|
121
|
-
.ea-input_wrap.append-slot .ea-input_inner {
|
|
122
|
-
border-top-right-radius: 0;
|
|
123
|
-
border-bottom-right-radius: 0;
|
|
124
|
-
}
|
|
125
|
-
.ea-input_wrap .ea-input_suggestion-wrap {
|
|
126
|
-
list-style-type: none;
|
|
127
|
-
padding: 0;
|
|
128
|
-
margin: 0;
|
|
129
|
-
margin-block-start: 0;
|
|
130
|
-
margin-block-end: 0;
|
|
131
|
-
padding-inline-start: 0;
|
|
132
|
-
unicode-bidi: unset;
|
|
133
|
-
display: none;
|
|
134
|
-
position: absolute;
|
|
135
|
-
box-sizing: border-box;
|
|
136
|
-
z-index: 3;
|
|
137
|
-
top: calc(100% + 5px);
|
|
138
|
-
left: 0;
|
|
139
|
-
padding: 0.5rem 0;
|
|
140
|
-
width: 100%;
|
|
141
|
-
max-height: 10rem;
|
|
142
|
-
overflow-y: auto;
|
|
143
|
-
scrollbar-width: thin;
|
|
144
|
-
background-color: white;
|
|
145
|
-
box-shadow: 0 1px 8px 1px rgba(0, 0, 0, 0.2);
|
|
146
|
-
}
|
|
147
|
-
.ea-input_wrap .ea-input_suggestion-wrap li {
|
|
148
|
-
padding: 0.5rem;
|
|
149
|
-
font-size: 0.9rem;
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
}
|
|
152
|
-
.ea-input_wrap .ea-input_suggestion-wrap li:hover {
|
|
153
|
-
background-color: #f5f7fa;
|
|
154
|
-
}
|
|
155
|
-
.ea-input_wrap .ea-input_suggestion-wrap.loading {
|
|
156
|
-
height: 5rem;
|
|
157
|
-
display: flex;
|
|
158
|
-
align-items: center;
|
|
159
|
-
justify-content: center;
|
|
160
|
-
}
|
|
161
|
-
.ea-input_wrap .ea-input_suggestion-wrap.loading::after {
|
|
162
|
-
font-family: "fontello";
|
|
163
|
-
font-style: normal;
|
|
164
|
-
font-weight: normal;
|
|
165
|
-
speak: never;
|
|
166
|
-
display: inline-block;
|
|
167
|
-
text-decoration: inherit;
|
|
168
|
-
width: 1em;
|
|
169
|
-
margin-right: 0.2em;
|
|
170
|
-
text-align: center;
|
|
171
|
-
font-variant: normal;
|
|
172
|
-
text-transform: none;
|
|
173
|
-
line-height: 1em;
|
|
174
|
-
margin-left: 0.2em;
|
|
175
|
-
-webkit-font-smoothing: antialiased;
|
|
176
|
-
-moz-osx-font-smoothing: grayscale;
|
|
177
|
-
content: "\e839";
|
|
178
|
-
font-size: 1.5rem;
|
|
179
|
-
animation: spin 1s linear infinite;
|
|
180
|
-
animation-play-state: running;
|
|
181
|
-
}
|
|
182
|
-
.ea-input_wrap.word-limit {
|
|
183
|
-
border: 1px solid #dcdfe6;
|
|
184
|
-
border-radius: 3px;
|
|
185
|
-
}
|
|
186
|
-
.ea-input_wrap.word-limit .ea-input_inner {
|
|
187
|
-
border: 0;
|
|
188
|
-
width: calc(100% - 3rem);
|
|
189
|
-
}
|
|
190
|
-
.ea-input_wrap.word-limit .ea-input_word-limit {
|
|
191
|
-
padding-right: 0.5rem;
|
|
192
|
-
width: 2.5rem;
|
|
193
|
-
font-size: 0.75rem;
|
|
194
|
-
text-align: center;
|
|
195
|
-
}
|
|
196
|
-
`;
|
|
197
|
-
|
|
198
|
-
const inputDom = (type) => {
|
|
199
|
-
const input = document.createElement('input');
|
|
200
|
-
|
|
201
|
-
input.className = "ea-input_inner";
|
|
202
|
-
input.type = type || "text";
|
|
203
|
-
input.autocomplete = "off";
|
|
204
|
-
|
|
205
|
-
return input;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const suggestionBoardDom = () => {
|
|
209
|
-
const suggestionBoard = document.createElement('ul');
|
|
210
|
-
suggestionBoard.className = "ea-input_suggestion-wrap";
|
|
211
|
-
|
|
212
|
-
return suggestionBoard;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const slotDom = (name) => {
|
|
216
|
-
const slot = document.createElement('slot');
|
|
217
|
-
slot.name = name;
|
|
218
|
-
|
|
219
|
-
return slot;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export class EaInput extends Base {
|
|
223
|
-
#wrap;
|
|
224
|
-
#input;
|
|
225
|
-
#clearIcon;
|
|
226
|
-
#showPasswordIcon;
|
|
227
|
-
#mounted = false;
|
|
228
|
-
|
|
229
|
-
#suggestion = [];
|
|
230
|
-
#suggestionBoard;
|
|
231
|
-
|
|
232
|
-
#prependSlot;
|
|
233
|
-
#appendSlot;
|
|
234
|
-
|
|
235
|
-
constructor() {
|
|
236
|
-
super();
|
|
237
|
-
|
|
238
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
239
|
-
const wrap = document.createElement('div');
|
|
240
|
-
wrap.className = "ea-input_wrap";
|
|
241
|
-
|
|
242
|
-
const dom = inputDom(this.type);
|
|
243
|
-
|
|
244
|
-
// slot 和 template, 用于输入框前后 的 插槽
|
|
245
|
-
const prependSlot = slotDom('prepend');
|
|
246
|
-
const appendSlot = slotDom('append');
|
|
247
|
-
|
|
248
|
-
const prependTemplate = this.querySelector('[slot=prepend]');
|
|
249
|
-
const appendTemplate = this.querySelector('[slot=append]');
|
|
250
|
-
|
|
251
|
-
if (prependTemplate) {
|
|
252
|
-
wrap.classList.add('prepend-slot');
|
|
253
|
-
|
|
254
|
-
prependTemplate.style.setProperty('--border-top-left-radius', '3px');
|
|
255
|
-
prependTemplate.style.setProperty('--border-bottom-left-radius', '3px');
|
|
256
|
-
|
|
257
|
-
prependTemplate.style.setProperty('--border-right-width', '0');
|
|
258
|
-
prependTemplate.style.setProperty('--border-left-width', '1px');
|
|
259
|
-
|
|
260
|
-
prependSlot.appendChild(prependTemplate.cloneNode(true));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (appendTemplate) {
|
|
264
|
-
wrap.classList.add('append-slot');
|
|
265
|
-
|
|
266
|
-
appendTemplate.style.setProperty('--border-top-right-radius', '3px');
|
|
267
|
-
appendTemplate.style.setProperty('--border-bottom-right-radius', '3px');
|
|
268
|
-
|
|
269
|
-
appendTemplate.style.setProperty('--border-left-width', '0');
|
|
270
|
-
appendTemplate.style.setProperty('--border-right-width', '1px');
|
|
271
|
-
|
|
272
|
-
appendSlot.appendChild(appendTemplate.cloneNode(true));
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
wrap.appendChild(dom);
|
|
276
|
-
wrap.insertBefore(prependSlot, dom);
|
|
277
|
-
wrap.appendChild(appendSlot);
|
|
278
|
-
|
|
279
|
-
this.#wrap = wrap;
|
|
280
|
-
this.#input = dom;
|
|
281
|
-
this.#prependSlot = prependSlot;
|
|
282
|
-
this.#appendSlot = appendSlot;
|
|
283
|
-
|
|
284
|
-
// 输入建议
|
|
285
|
-
if (this.suggestion.length > 0 || this.remote) {
|
|
286
|
-
this.suggestionEvent();
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
290
|
-
|
|
291
|
-
this.build(shadowRoot, stylesheet);
|
|
292
|
-
this.shadowRoot.appendChild(wrap);
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// ------- type 标识是 input 还是 textarea -------
|
|
297
|
-
// #region
|
|
298
|
-
get type() {
|
|
299
|
-
return this.getAttribute("type") || "text";
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
set type(val) {
|
|
303
|
-
this.setAttribute("type", val);
|
|
304
|
-
}
|
|
305
|
-
// #endregion
|
|
306
|
-
// ------- end -------
|
|
307
|
-
|
|
308
|
-
// ------- value 输入框的值 -------
|
|
309
|
-
// #region
|
|
310
|
-
get value() {
|
|
311
|
-
if (!this.#mounted) {
|
|
312
|
-
this.#input.value = this.getAttribute("value") || '';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return this.getAttribute('value');
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
set value(val) {
|
|
319
|
-
if (!val) return;
|
|
320
|
-
|
|
321
|
-
this.setAttribute("value", val);
|
|
322
|
-
this.#input.value = val;
|
|
323
|
-
}
|
|
324
|
-
// #endregion
|
|
325
|
-
// ------- end -------
|
|
326
|
-
|
|
327
|
-
// ------- placeholder 提示 -------
|
|
328
|
-
// #region
|
|
329
|
-
get placeholder() {
|
|
330
|
-
return this.getAttribute("placeholder") || '';
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
set placeholder(val) {
|
|
334
|
-
this.setAttribute("placeholder", val);
|
|
335
|
-
this.#input.placeholder = val;
|
|
336
|
-
}
|
|
337
|
-
// #endregion
|
|
338
|
-
// ------- end -------
|
|
339
|
-
|
|
340
|
-
// ------- disabled 输入框禁用 -------
|
|
341
|
-
// #region
|
|
342
|
-
get disabled() {
|
|
343
|
-
return this.getAttrBoolean("disabled");
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
set disabled(val) {
|
|
347
|
-
this.toggleAttr("disabled", val);
|
|
348
|
-
this.#input.disabled = val;
|
|
349
|
-
this.#input.classList.toggle("disabled", val);
|
|
350
|
-
}
|
|
351
|
-
// #endregion
|
|
352
|
-
// ------- end -------
|
|
353
|
-
|
|
354
|
-
// ------- clearable 可清除 -------
|
|
355
|
-
// #region
|
|
356
|
-
get clearable() {
|
|
357
|
-
return this.getAttrBoolean("clearable");
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
set clearable(val) {
|
|
361
|
-
if (!val) return;
|
|
362
|
-
|
|
363
|
-
this.setAttribute("clearable", val);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// 清除图标
|
|
367
|
-
clearableEvent(e) {
|
|
368
|
-
if (!this.clearable) return;
|
|
369
|
-
|
|
370
|
-
if (this.clearable && e.target.value !== '') {
|
|
371
|
-
this.#clearIcon.style.display = 'block';
|
|
372
|
-
} else {
|
|
373
|
-
this.#clearIcon.style.display = 'none';
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// 清除图标初始化
|
|
378
|
-
initClearableIcon() {
|
|
379
|
-
if (this.clearable) {
|
|
380
|
-
const clearIcon = this.iconInit('icon-cancel-circled2');
|
|
381
|
-
|
|
382
|
-
clearIcon.addEventListener('click', () => {
|
|
383
|
-
this.value = '';
|
|
384
|
-
this.#input.focus();
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
this.#clearIcon = clearIcon;
|
|
388
|
-
|
|
389
|
-
if (this.value) {
|
|
390
|
-
this.#clearIcon.style.display = 'block';
|
|
391
|
-
} else {
|
|
392
|
-
this.#clearIcon.style.display = 'none';
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
this.iconAppend('clearable', this.clearable, clearIcon);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
// #endregion
|
|
399
|
-
// ------- end -------
|
|
400
|
-
|
|
401
|
-
// ------- show-password 密码 -------
|
|
402
|
-
// #region
|
|
403
|
-
get showPassword() {
|
|
404
|
-
return this.getAttrBoolean("show-password");
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
set showPassword(val) {
|
|
408
|
-
if (!val) return;
|
|
409
|
-
this.setAttribute("show-password", val);
|
|
410
|
-
|
|
411
|
-
if (val) {
|
|
412
|
-
this.#input.type = "password";
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// 显示/隐藏密码图标
|
|
417
|
-
showPasswordEvent(e) {
|
|
418
|
-
if (!this.showPassword) return;
|
|
419
|
-
|
|
420
|
-
if (this.showPassword && e.target.value !== '') {
|
|
421
|
-
this.#showPasswordIcon.style.display = 'block';
|
|
422
|
-
} else {
|
|
423
|
-
this.#showPasswordIcon.style.display = 'none';
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// 初始化 显示/隐藏密码
|
|
428
|
-
initShowPasswordIcon() {
|
|
429
|
-
if (this.showPassword) {
|
|
430
|
-
const showPasswordIcon = this.iconInit('icon-eye');
|
|
431
|
-
if (!this.value) showPasswordIcon.style.display = 'none';
|
|
432
|
-
|
|
433
|
-
showPasswordIcon.addEventListener('click', (e) => {
|
|
434
|
-
this.#showPasswordIcon.className = this.#input.type === "password" ? "icon-eye-off" : "icon-eye";
|
|
435
|
-
this.#input.type = this.#input.type === "password" ? "text" : "password";
|
|
436
|
-
|
|
437
|
-
this.#input.focus();
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
this.#showPasswordIcon = showPasswordIcon;
|
|
441
|
-
|
|
442
|
-
this.iconAppend('password', this.showPassword, showPasswordIcon);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
// #endregion
|
|
446
|
-
// ------- end -------
|
|
447
|
-
|
|
448
|
-
// ------- prefix/surfix 指定图标显示位置 -------
|
|
449
|
-
// #region
|
|
450
|
-
get prefixIcon() {
|
|
451
|
-
return this.getAttribute("prefix-icon") || '';
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
set prefixIcon(val) {
|
|
455
|
-
if (!val) return;
|
|
456
|
-
|
|
457
|
-
this.setAttribute("prefix", val);
|
|
458
|
-
const prefixIcon = this.iconInit(val);
|
|
459
|
-
this.iconAppend('prefix', true, prefixIcon);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
get surfixIcon() {
|
|
463
|
-
return this.getAttribute("suffix-icon") || '';
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
set surfixIcon(val) {
|
|
467
|
-
if (!val) return;
|
|
468
|
-
|
|
469
|
-
this.setAttribute("suffix", val);
|
|
470
|
-
const surfixIcon = this.iconInit(val);
|
|
471
|
-
this.iconAppend('suffix', true, surfixIcon);
|
|
472
|
-
}
|
|
473
|
-
// #endregion
|
|
474
|
-
// ------- end -------
|
|
475
|
-
|
|
476
|
-
// ------- suggestion 建议 -------
|
|
477
|
-
// #region
|
|
478
|
-
|
|
479
|
-
// 建议列表
|
|
480
|
-
get suggestion() {
|
|
481
|
-
return this.#suggestion;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
set suggestion(val) {
|
|
485
|
-
if (!val) return;
|
|
486
|
-
|
|
487
|
-
// console.log(val);
|
|
488
|
-
this.#suggestion = val;
|
|
489
|
-
// this.setAttribute("primary-key", nanoid());
|
|
490
|
-
// this.primaryKey = nanoid();
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// 输入框激活时列出输入建议
|
|
494
|
-
get triggerOnFocus() {
|
|
495
|
-
return this.getAttrBoolean("trigger-on-focus");
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
set triggerOnFocus(val) {
|
|
499
|
-
if (!val) return;
|
|
500
|
-
|
|
501
|
-
this.setAttribute("trigger-on-focus", val);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// 输入框输入后匹配输入建议
|
|
505
|
-
get triggerAfterInput() {
|
|
506
|
-
return this.getAttrBoolean("trigger-after-input");
|
|
507
|
-
}
|
|
508
|
-
set triggerAfterInput(val) {
|
|
509
|
-
if (!val) return;
|
|
510
|
-
|
|
511
|
-
this.setAttribute("trigger-after-input", val);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// 数据为远程加载时, 显示加载中
|
|
515
|
-
get remote() {
|
|
516
|
-
return this.getAttrBoolean("remote");
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
set remote(val) {
|
|
520
|
-
if (val === null || val === undefined) return;
|
|
521
|
-
|
|
522
|
-
try {
|
|
523
|
-
const flag = this.#suggestionBoard.style.display
|
|
524
|
-
if (flag == "flex") this.#suggestionBoard.style.display = "block";
|
|
525
|
-
else if (flag == "") this.#suggestionBoard.style.display = "none";
|
|
526
|
-
|
|
527
|
-
this.#suggestionBoard.classList.toggle('loading', val);
|
|
528
|
-
this.setAttribute("remote", val);
|
|
529
|
-
|
|
530
|
-
if (this.#mounted) this.refresh();
|
|
531
|
-
} catch (error) {
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// 数据更新时调用
|
|
537
|
-
refresh() {
|
|
538
|
-
try {
|
|
539
|
-
this.#suggestionBoard.innerHTML = '';
|
|
540
|
-
this.suggestionEvent();
|
|
541
|
-
} catch (error) {
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// 输入建议逻辑
|
|
547
|
-
suggestionEvent() {
|
|
548
|
-
const suggestionBoard = !this.#mounted ? suggestionBoardDom() : this.#suggestionBoard;
|
|
549
|
-
|
|
550
|
-
// 利用 li 标签 将用户传入值 进行渲染
|
|
551
|
-
this.suggestion.forEach(item => {
|
|
552
|
-
const li = document.createElement('li');
|
|
553
|
-
li.innerText = item.value;
|
|
554
|
-
|
|
555
|
-
li.addEventListener('click', () => {
|
|
556
|
-
this.value = item.value;
|
|
557
|
-
suggestionBoard.style.display = 'none';
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
suggestionBoard.appendChild(li);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
// 当点击其他地方时, 关闭输入建议
|
|
564
|
-
document.addEventListener('click', (e) => {
|
|
565
|
-
if (e.target !== this) {
|
|
566
|
-
suggestionBoard.style.display = 'none';
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
// 匹配输入建议
|
|
571
|
-
this.#input.addEventListener('input', (e) => {
|
|
572
|
-
this.shadowRoot.querySelectorAll('li').forEach(item => {
|
|
573
|
-
if (item.innerText.includes(e.target.value)) {
|
|
574
|
-
item.style.display = 'block';
|
|
575
|
-
} else {
|
|
576
|
-
item.style.display = 'none';
|
|
577
|
-
}
|
|
578
|
-
})
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
// 激活时列出输入建议
|
|
582
|
-
if (this.triggerOnFocus) {
|
|
583
|
-
this.#input.addEventListener('focus', (e) => {
|
|
584
|
-
suggestionBoard.style.display = this.remote ? "flex" : 'block';
|
|
585
|
-
});
|
|
586
|
-
// 输入时列出输入建议
|
|
587
|
-
} else if (this.triggerAfterInput) {
|
|
588
|
-
this.#input.addEventListener('input', (e) => {
|
|
589
|
-
if (e.target.value.length > 0) {
|
|
590
|
-
suggestionBoard.style.display = 'block';
|
|
591
|
-
} else {
|
|
592
|
-
suggestionBoard.style.display = 'none';
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (!this.#mounted) {
|
|
598
|
-
this.#suggestionBoard = suggestionBoard;
|
|
599
|
-
this.#wrap.appendChild(suggestionBoard);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// #endregion
|
|
604
|
-
// ------- end -------
|
|
605
|
-
|
|
606
|
-
// ------- max-length 最大长度 -------
|
|
607
|
-
// #region
|
|
608
|
-
|
|
609
|
-
// 获取最大限制值
|
|
610
|
-
get maxLength() {
|
|
611
|
-
return this.getAttribute("max-length");
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
set maxLength(val) {
|
|
615
|
-
if (!val || this.#input.type !== "text") return;
|
|
616
|
-
|
|
617
|
-
this.setAttribute("max-length", val);
|
|
618
|
-
this.#input.maxLength = val;
|
|
619
|
-
|
|
620
|
-
this.#input.addEventListener('input', (e) => {
|
|
621
|
-
if (e.target.value.length > val) {
|
|
622
|
-
e.target.value = e.target.value.slice(0, val);
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
if (this.showWordLimit) this.showWordLimit = true;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// 获取最小限制值
|
|
630
|
-
get minLength() {
|
|
631
|
-
return this.getAttribute("min-length");
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
set minLength(val) {
|
|
635
|
-
if (!val || this.#input.type !== "text") return;
|
|
636
|
-
|
|
637
|
-
this.setAttribute("min-length", val);
|
|
638
|
-
this.#input.minLength = val;
|
|
639
|
-
|
|
640
|
-
this.#input.addEventListener('input', (e) => {
|
|
641
|
-
if (e.target.value.length < val) {
|
|
642
|
-
e.target.classList.add('invalid');
|
|
643
|
-
} else {
|
|
644
|
-
e.target.classList.remove('invalid');
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
// 显示 当前文字长度 和 限制值
|
|
650
|
-
get showWordLimit() {
|
|
651
|
-
return this.getAttrBoolean("show-word-limit");
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
set showWordLimit(val) {
|
|
655
|
-
if (!val || this.#input.type !== "text") return;
|
|
656
|
-
|
|
657
|
-
this.setAttribute("show-word-limit", val);
|
|
658
|
-
|
|
659
|
-
// 加入显示的dom
|
|
660
|
-
const wordLimit = document.createElement('span');
|
|
661
|
-
this.#wrap.classList.toggle('word-limit', val);
|
|
662
|
-
this.#wrap.classList.toggle('append-slot', val);
|
|
663
|
-
wordLimit.className = 'ea-input_word-limit';
|
|
664
|
-
wordLimit.innerText = `${this.#input.value.length}/${this.maxLength}`;
|
|
665
|
-
|
|
666
|
-
this.#input.addEventListener('input', (e) => {
|
|
667
|
-
wordLimit.innerText = `${e.target.value.length}/${this.maxLength}`;
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
this.#appendSlot.appendChild(wordLimit);
|
|
672
|
-
this.#wrap.appendChild(wordLimit);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
// #endregion
|
|
676
|
-
// ------- end -------
|
|
677
|
-
|
|
678
|
-
// 图标dom初始化
|
|
679
|
-
iconInit(className) {
|
|
680
|
-
const clearIcon = document.createElement('i');
|
|
681
|
-
clearIcon.className = className;
|
|
682
|
-
|
|
683
|
-
return clearIcon;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// 图标dom添加
|
|
687
|
-
iconAppend(className, isClassName, element) {
|
|
688
|
-
this.#wrap.classList.toggle(className, isClassName);
|
|
689
|
-
this.#wrap.appendChild(element);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// 事件初始化
|
|
693
|
-
eventInit(e, eventName) {
|
|
694
|
-
this.dispatchEvent(
|
|
695
|
-
new CustomEvent(eventName, {
|
|
696
|
-
detail: {
|
|
697
|
-
value: e.target.value
|
|
698
|
-
}
|
|
699
|
-
})
|
|
700
|
-
);
|
|
701
|
-
|
|
702
|
-
this.clearableEvent(e);
|
|
703
|
-
this.showPasswordEvent(e);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
init() {
|
|
707
|
-
const that = this;
|
|
708
|
-
|
|
709
|
-
// 按钮类型
|
|
710
|
-
this.type = this.type;
|
|
711
|
-
|
|
712
|
-
// 输入框提示
|
|
713
|
-
this.placeholder = this.placeholder;
|
|
714
|
-
|
|
715
|
-
// 输入框的值
|
|
716
|
-
this.value = this.value;
|
|
717
|
-
|
|
718
|
-
// 禁用
|
|
719
|
-
this.disabled = this.disabled;
|
|
720
|
-
|
|
721
|
-
// 可清除
|
|
722
|
-
this.clearable = this.clearable;
|
|
723
|
-
this.initClearableIcon();
|
|
724
|
-
|
|
725
|
-
// 密码
|
|
726
|
-
this.showPassword = this.showPassword;
|
|
727
|
-
this.initShowPasswordIcon();
|
|
728
|
-
|
|
729
|
-
// 输入框图标
|
|
730
|
-
this.prefixIcon = this.prefixIcon;
|
|
731
|
-
this.surfixIcon = this.surfixIcon;
|
|
732
|
-
|
|
733
|
-
// 输入建议
|
|
734
|
-
this.suggestion = this.suggestion;
|
|
735
|
-
if (this.remote) this.remote = this.remote;
|
|
736
|
-
|
|
737
|
-
// 输入长度限制
|
|
738
|
-
this.maxLength = this.maxLength;
|
|
739
|
-
this.minLength = this.minLength;
|
|
740
|
-
|
|
741
|
-
// 输入时
|
|
742
|
-
this.#input.addEventListener("input", (e) => {
|
|
743
|
-
this.eventInit(e, "change");
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
// 聚焦时
|
|
747
|
-
this.#input.addEventListener("focus", (e) => {
|
|
748
|
-
this.eventInit(e, "focus");
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
// 失焦时
|
|
752
|
-
this.#input.addEventListener("blur", (e) => {
|
|
753
|
-
this.eventInit(e, "blur");
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
connectedCallback() {
|
|
758
|
-
this.init();
|
|
759
|
-
this.#mounted = true;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (!window.customElements.get("ea-input")) {
|
|
764
|
-
window.customElements.define("ea-input", EaInput);
|
|
765
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{stylesheet}from"./src/style/stylesheet.js";import{createClearableFixIcon,createFixIcon,createShowPasswordIcon}from"./src/components/createFixIcon.js";import{createWordLimitElement}from"./src/components/createWordLimitElement.js";import{createSuggestionBoard}from"./src/components/createSuggestionBoard.js";import{withTransitionTimeOut}from"../../utils/timeout.js";import{dispatchEvent}from"./src/utils/dispatchEvent.js";import{handleSearchResult}from"./src/utils/handleSearchResult.js";import{initTriggerAfterInputEvent,initTriggerOnFocusEvent}from"./src/utils/handleSuggestionBoardTrigger.js";export class EaInput extends Base{#t;#e;#i=[];#s;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class=\'ea-input_container\' part=\'container\'>\n <div class="ea-input_wrap" part="input-wrap">\n <div class="ea-input_prepend-slot" part="prepend-wrap">\n <slot name="prepend"></slot>\n </div>\n <input class="ea-input_inner" type="text" part="input" autocomplete="off" />\n <div class="ea-input_append-slot" part="append-wrap">\n <slot name="append"></slot>\n </div>\n </div>\n </div>\n ',this.#t=t.querySelector(".ea-input_wrap"),this.#e=t.querySelector(".ea-input_inner"),this.build(t,stylesheet)}get name(){return this.getAttribute("name")||""}set name(t){this.setAttribute("name",t)}get type(){return this.getAttribute("type")||"text"}set type(t){this.setAttribute("type",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t),this.#e.value=t}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(t){this.setAttribute("placeholder",t),this.#e.placeholder=t}get disabled(){return this.getAttrBoolean("disabled")}set disabled(t){this.setAttribute("disabled",t),this.#e.disabled=t,this.#e.classList.toggle("disabled",t)}get clearable(){return this.getAttrBoolean("clearable")}set clearable(t){if(!t)return;this.setAttribute("clearable",t);createClearableFixIcon.call(this,this.#t,this.#e,"icon-cancel-circled2")}get showPassword(){return this.getAttrBoolean("show-password")}set showPassword(t){if(!t)return;this.setAttribute("show-password",t),this.#e.type="password";createShowPasswordIcon(this.#t,this.#e,"icon-eye")}get prefixIcon(){return this.getAttribute("prefix-icon")||""}set prefixIcon(t){t&&(this.setAttribute("prefix",t),createFixIcon(this.#t,t,"prefix"))}get surfixIcon(){return this.getAttribute("suffix-icon")||""}set surfixIcon(t){t&&(this.setAttribute("suffix",t),createFixIcon(this.#t,t,"surfix"))}get suggestion(){return this.#i}set suggestion(t){if(!(t&&t instanceof Array))return;this.#i=t;const e=createSuggestionBoard.call(this,this.#t,t);this.#e.addEventListener("input",(t=>{handleSearchResult(e,t.target.value)})),this.triggerAfterInput?initTriggerAfterInputEvent(this.#e,e):initTriggerOnFocusEvent(e,this.#e),handleSearchResult(e,this.#e.value),this.#t.appendChild(e),this.#s=e}get triggerOnFocus(){return this.getAttrBoolean("trigger-on-focus")}set triggerOnFocus(t){t&&this.setAttribute("trigger-on-focus",t)}get triggerAfterInput(){return this.getAttrBoolean("trigger-after-input")}set triggerAfterInput(t){t&&this.setAttribute("trigger-after-input",t)}get remote(){return this.getAttrBoolean("remote")}set remote(t){this.setAttribute("remote",t);const e=createSuggestionBoard.call(this,this.#t,this.#i);e.classList.toggle("loading",t),this.#e.addEventListener("focus",(()=>{e.classList.add("is-open")})),this.#s=e}get maxLength(){return this.getAttribute("max-length")}set maxLength(t){t&&"text"===this.#e.type&&(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&&"text"===this.#e.type&&(this.setAttribute("min-length",t),this.#e.minLength=t,this.#e.addEventListener("input",(e=>{this.#e.classList.toggle("invalid",e.target.value.length<t)})))}get showWordLimit(){return this.getAttrBoolean("show-word-limit")}set showWordLimit(t){if(!t||"text"!==this.#e.type)return;this.setAttribute("show-word-limit",t);const e=createWordLimitElement.call(this,this.#e);this.#t.classList.toggle("word-limit",t),this.#t.appendChild(e)}get readonly(){return this.getAttrBoolean("readonly")}set readonly(t){t&&(this.setAttribute("readonly",t),this.#e.readOnly=t)}focus(){this.#e.focus()}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name,this.type=this.type,this.placeholder=this.placeholder,this.value=this.value,this.disabled=this.disabled,this.clearable=this.clearable,this.clearable||(this.showPassword=this.showPassword),this.prefixIcon=this.prefixIcon,this.clearable||this.showPassword||(this.surfixIcon=this.surfixIcon),this.triggerOnFocus=this.triggerOnFocus,this.triggerAfterInput=this.triggerAfterInput,this.remote&&(this.remote=this.remote),this.maxLength=this.maxLength,this.minLength=this.minLength,this.readonly=this.readonly,this.#e.addEventListener("input",(t=>{this.value=t.target.value,dispatchEvent.call(this,t,"change")})),this.#e.addEventListener("focus",(t=>{dispatchEvent.call(this,t,"focus")})),this.#e.addEventListener("blur",(t=>{dispatchEvent.call(this,t,"blur")})),withTransitionTimeOut(this.#t)}}window.customElements.get("ea-input")||window.customElements.define("ea-input",EaInput);
|