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,314 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js'
|
|
3
|
-
|
|
4
|
-
const stylesheet = `:host {
|
|
5
|
-
--margin-right: 1rem;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.ea-checkbox_wrap {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
margin-right: var(--margin-right);
|
|
12
|
-
}
|
|
13
|
-
.ea-checkbox_wrap .__ea-checkbox-input_wrap {
|
|
14
|
-
margin-right: 0.5rem;
|
|
15
|
-
}
|
|
16
|
-
.ea-checkbox_wrap .__ea-checkbox-input_wrap .__ea-checkbox-input_inner {
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
position: relative;
|
|
19
|
-
display: block;
|
|
20
|
-
width: 0.8125rem;
|
|
21
|
-
height: 0.8125rem;
|
|
22
|
-
line-height: 0.8125;
|
|
23
|
-
border-radius: 3px;
|
|
24
|
-
border: 1px solid #ccc;
|
|
25
|
-
transition: background-color 0.2s, border-color 0.2s;
|
|
26
|
-
}
|
|
27
|
-
.ea-checkbox_wrap .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::after {
|
|
28
|
-
content: "";
|
|
29
|
-
position: absolute;
|
|
30
|
-
left: 52.5%;
|
|
31
|
-
top: 45%;
|
|
32
|
-
transform: translate(-50%, -50%) rotate(-135deg);
|
|
33
|
-
display: block;
|
|
34
|
-
width: 3px;
|
|
35
|
-
height: 7px;
|
|
36
|
-
opacity: 0;
|
|
37
|
-
transition: opacity 0.2s;
|
|
38
|
-
}
|
|
39
|
-
.ea-checkbox_wrap .__ea-checkbox-input_wrap .__ea-checkbox-input_input {
|
|
40
|
-
display: none;
|
|
41
|
-
}
|
|
42
|
-
.ea-checkbox_wrap .__ea-checkbox-label_desc {
|
|
43
|
-
transition: color 0.2s;
|
|
44
|
-
}
|
|
45
|
-
.ea-checkbox_wrap.checked .__ea-checkbox-input_wrap .__ea-checkbox-input_inner {
|
|
46
|
-
border-color: #409eff;
|
|
47
|
-
background-color: #409eff;
|
|
48
|
-
}
|
|
49
|
-
.ea-checkbox_wrap.checked .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::after {
|
|
50
|
-
opacity: 1;
|
|
51
|
-
border-left: 2px solid white;
|
|
52
|
-
border-top: 2px solid white;
|
|
53
|
-
}
|
|
54
|
-
.ea-checkbox_wrap.checked .__ea-checkbox-label_desc {
|
|
55
|
-
color: #409eff;
|
|
56
|
-
}
|
|
57
|
-
.ea-checkbox_wrap.disabled .__ea-checkbox-input_wrap .__ea-checkbox-input_inner {
|
|
58
|
-
border-color: #eeeeee;
|
|
59
|
-
background-color: #eeeeee;
|
|
60
|
-
}
|
|
61
|
-
.ea-checkbox_wrap.disabled .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::before {
|
|
62
|
-
background-color: transparent;
|
|
63
|
-
}
|
|
64
|
-
.ea-checkbox_wrap.disabled .__ea-checkbox-label_desc {
|
|
65
|
-
color: #c0c4cc;
|
|
66
|
-
}
|
|
67
|
-
.ea-checkbox_wrap.disabled[checked=true] .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::before {
|
|
68
|
-
background-color: #c0c4cc;
|
|
69
|
-
}
|
|
70
|
-
.ea-checkbox_wrap.indeterminate .__ea-checkbox-input_wrap .__ea-checkbox-input_inner {
|
|
71
|
-
border-color: #409eff;
|
|
72
|
-
background-color: #409eff;
|
|
73
|
-
}
|
|
74
|
-
.ea-checkbox_wrap.indeterminate .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::after {
|
|
75
|
-
opacity: 1;
|
|
76
|
-
left: 50%;
|
|
77
|
-
top: 50%;
|
|
78
|
-
width: 80%;
|
|
79
|
-
height: 3px;
|
|
80
|
-
background-color: white;
|
|
81
|
-
transform: translate(-50%, -50%) rotate(0deg);
|
|
82
|
-
}
|
|
83
|
-
.ea-checkbox_wrap.indeterminate .__ea-checkbox-label_desc {
|
|
84
|
-
color: #409eff;
|
|
85
|
-
}
|
|
86
|
-
.ea-checkbox_wrap.indeterminate[checked=true] .__ea-checkbox-input_wrap .__ea-checkbox-input_inner {
|
|
87
|
-
border-color: #409eff;
|
|
88
|
-
background-color: #409eff;
|
|
89
|
-
}
|
|
90
|
-
.ea-checkbox_wrap.indeterminate[checked=true] .__ea-checkbox-input_wrap .__ea-checkbox-input_inner::after {
|
|
91
|
-
width: 3px;
|
|
92
|
-
height: 7px;
|
|
93
|
-
left: 52.5%;
|
|
94
|
-
top: 45%;
|
|
95
|
-
transform: translate(-50%, -50%) rotate(-135deg);
|
|
96
|
-
opacity: 1;
|
|
97
|
-
border-left: 2px solid white;
|
|
98
|
-
border-top: 2px solid white;
|
|
99
|
-
background-color: transparent;
|
|
100
|
-
}
|
|
101
|
-
.ea-checkbox_wrap.indeterminate[checked=true] .__ea-checkbox-label_desc {
|
|
102
|
-
color: #409eff;
|
|
103
|
-
}`;
|
|
104
|
-
|
|
105
|
-
const inputDom = () => {
|
|
106
|
-
const wrap = document.createElement('span');
|
|
107
|
-
wrap.className = "__ea-checkbox-input_wrap";
|
|
108
|
-
|
|
109
|
-
const checkbox = document.createElement('span');
|
|
110
|
-
checkbox.className = "__ea-checkbox-input_inner";
|
|
111
|
-
wrap.appendChild(checkbox);
|
|
112
|
-
|
|
113
|
-
const input = document.createElement('input');
|
|
114
|
-
input.type = 'checkbox';
|
|
115
|
-
input.className = "__ea-checkbox-input_input";
|
|
116
|
-
|
|
117
|
-
wrap.appendChild(input);
|
|
118
|
-
|
|
119
|
-
return { wrap, input };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const labelDom = () => {
|
|
123
|
-
const labelDesc = document.createElement('span');
|
|
124
|
-
labelDesc.className = "__ea-checkbox-label_desc";
|
|
125
|
-
const slot = document.createElement('slot');
|
|
126
|
-
labelDesc.appendChild(slot);
|
|
127
|
-
|
|
128
|
-
return labelDesc;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export class EaCheckbox extends Base {
|
|
132
|
-
#checkbox;
|
|
133
|
-
#label;
|
|
134
|
-
|
|
135
|
-
static get observedAttributes() {
|
|
136
|
-
return ['checked', 'disabled'];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
constructor() {
|
|
140
|
-
super();
|
|
141
|
-
|
|
142
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
143
|
-
const that = this;
|
|
144
|
-
let dom = document.createElement('label');
|
|
145
|
-
dom.className = "ea-checkbox_wrap";
|
|
146
|
-
|
|
147
|
-
// input + checkbox
|
|
148
|
-
const input = inputDom();
|
|
149
|
-
dom.appendChild(input.wrap);
|
|
150
|
-
|
|
151
|
-
// label 标签文字
|
|
152
|
-
const label = labelDom();
|
|
153
|
-
dom.appendChild(label);
|
|
154
|
-
|
|
155
|
-
this.#label = dom;
|
|
156
|
-
this.#checkbox = input.input;
|
|
157
|
-
|
|
158
|
-
this.build(shadowRoot, stylesheet);
|
|
159
|
-
shadowRoot.appendChild(dom);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ------- checked 选中 -------
|
|
163
|
-
// #region
|
|
164
|
-
get checked() {
|
|
165
|
-
return this.getAttrBoolean('checked');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
set checked(val) {
|
|
169
|
-
this.#checkbox.checked = val;
|
|
170
|
-
|
|
171
|
-
if (val) {
|
|
172
|
-
this.setAttribute('checked', true);
|
|
173
|
-
this.#label.setAttribute('checked', true);
|
|
174
|
-
this.#label.classList.add('checked');
|
|
175
|
-
} else {
|
|
176
|
-
this.removeAttribute('checked');
|
|
177
|
-
this.#label.removeAttribute('checked');
|
|
178
|
-
this.#label.classList.remove('checked');
|
|
179
|
-
this.#label.classList.remove('indeterminate');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// #endregion
|
|
183
|
-
// ------- end -------
|
|
184
|
-
|
|
185
|
-
// ------- name 单选框的唯一键 -------
|
|
186
|
-
// #region
|
|
187
|
-
get name() {
|
|
188
|
-
return this.getAttribute('name');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
set name(val) {
|
|
192
|
-
this.#checkbox.setAttribute('name', val);
|
|
193
|
-
}
|
|
194
|
-
// #endregion
|
|
195
|
-
// ------- end -------
|
|
196
|
-
|
|
197
|
-
// ------- value 单选框的值 -------
|
|
198
|
-
// #region
|
|
199
|
-
get value() {
|
|
200
|
-
return this.getAttribute('value');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
set value(val) {
|
|
204
|
-
this.#label.setAttribute('for', val);
|
|
205
|
-
this.#checkbox.setAttribute('id', val);
|
|
206
|
-
this.#checkbox.setAttribute('value', val);
|
|
207
|
-
}
|
|
208
|
-
// #endregion
|
|
209
|
-
// ------- end -------
|
|
210
|
-
|
|
211
|
-
// ------- disabled 禁用状态 -------
|
|
212
|
-
// #region
|
|
213
|
-
get disabled() {
|
|
214
|
-
return this.getAttrBoolean('disabled');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
set disabled(val) {
|
|
218
|
-
this.#checkbox.disabled = val;
|
|
219
|
-
this.#label.toggleAttribute('disabled', val);
|
|
220
|
-
this.#label.classList.toggle('disabled', val);
|
|
221
|
-
}
|
|
222
|
-
// #endregion
|
|
223
|
-
// ------- end -------
|
|
224
|
-
|
|
225
|
-
// ------- border 是否带有边框 -------
|
|
226
|
-
// #region
|
|
227
|
-
get border() {
|
|
228
|
-
return this.getAttrBoolean('border');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
set border(val) {
|
|
232
|
-
this.#label.classList.toggle('border', val);
|
|
233
|
-
}
|
|
234
|
-
// #endregion
|
|
235
|
-
// ------- end -------
|
|
236
|
-
|
|
237
|
-
// ------- indeterminate 状态 -------
|
|
238
|
-
// #region
|
|
239
|
-
get indeterminate() {
|
|
240
|
-
return this.getAttrBoolean('indeterminate');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
set indeterminate(val) {
|
|
244
|
-
if (val) {
|
|
245
|
-
this.checked = false;
|
|
246
|
-
this.#label.classList.remove('checked');
|
|
247
|
-
|
|
248
|
-
this.setAttribute('indeterminate', true);
|
|
249
|
-
this.#label.classList.add('indeterminate');
|
|
250
|
-
console.log(val);
|
|
251
|
-
} else {
|
|
252
|
-
this.removeAttribute('indeterminate');
|
|
253
|
-
this.#label.classList.remove('indeterminate');
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// #endregion
|
|
257
|
-
// ------- end -------
|
|
258
|
-
|
|
259
|
-
init() {
|
|
260
|
-
const that = this;
|
|
261
|
-
|
|
262
|
-
// checkbox 的 checked 属性
|
|
263
|
-
this.checked = this.checked;
|
|
264
|
-
|
|
265
|
-
// label 的 for 属性
|
|
266
|
-
this.name = this.name;
|
|
267
|
-
|
|
268
|
-
// checkbox 的 value 属性
|
|
269
|
-
this.value = this.value;
|
|
270
|
-
|
|
271
|
-
// checkbox 的 disabled 属性
|
|
272
|
-
this.disabled = this.disabled;
|
|
273
|
-
|
|
274
|
-
// border 属性
|
|
275
|
-
this.border = this.border;
|
|
276
|
-
|
|
277
|
-
// indeterminate 属性
|
|
278
|
-
this.indeterminate = this.indeterminate;
|
|
279
|
-
|
|
280
|
-
// 监听 change 事件, 修改 checked 属性
|
|
281
|
-
this.#checkbox.addEventListener('change', function (e) {
|
|
282
|
-
e.preventDefault();
|
|
283
|
-
that.checked = e.target.checked;
|
|
284
|
-
if (e.target.checked) {
|
|
285
|
-
// document.querySelectorAll(`ea-checkbox[name="${that.name}"]`).forEach(btn => {
|
|
286
|
-
// const btnInput = btn.shadowRoot.querySelector('input');
|
|
287
|
-
|
|
288
|
-
// if (btnInput !== this) {
|
|
289
|
-
// btn.checked = false;
|
|
290
|
-
// } else {
|
|
291
|
-
// btn.checked = true;
|
|
292
|
-
// }
|
|
293
|
-
// });
|
|
294
|
-
}
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
connectedCallback() {
|
|
299
|
-
this.init();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
303
|
-
// switch (name) {
|
|
304
|
-
// case 'disabled':
|
|
305
|
-
// this.#label.setAttribute('checked', true);
|
|
306
|
-
// this.#label.classList.add('checked');
|
|
307
|
-
// break;
|
|
308
|
-
// }
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (!window.customElements.get("ea-checkbox")) {
|
|
313
|
-
window.customElements.define("ea-checkbox", EaCheckbox);
|
|
314
|
-
}
|
|
1
|
+
import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaCheckbox extends Base{#e;#t;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <label class="ea-checkbox_wrap" part="container">\n <span class="ea-checkbox-input_wrap" part="input-container">\n <span class="ea-checkbox-input_inner" part="input"></span>\n <input type="checkbox" class="ea-checkbox-input_input">\n </input>\n </span>\n <span class="ea-checkbox-label_desc" part="label-container">\n <slot></slot>\n </span>\n </label>\n ',this.#t=e.querySelector(".ea-checkbox_wrap"),this.#e=e.querySelector(".ea-checkbox-input_input"),this.build(e,stylesheet)}get checked(){return this.getAttrBoolean("checked")}set checked(e){this.#e.checked=e,this.#t.classList.toggle("checked",e),this.setAttribute("checked",e),this.#t.setAttribute("checked",e),this.#t.classList.toggle("checked",e),e&&this.#t.classList.remove("indeterminate")}get name(){return this.getAttribute("name")||""}set name(e){this.#e.setAttribute("name",e)}get value(){return this.getAttribute("value")}set value(e){this.#t.setAttribute("for",e),this.#e.setAttribute("id",e),this.#e.setAttribute("value",e)}get disabled(){return this.getAttrBoolean("disabled")}set disabled(e){this.#e.disabled=e,this.#t.toggleAttribute("disabled",e),this.#t.classList.toggle("disabled",e)}get border(){return this.getAttrBoolean("border")}set border(e){this.#t.classList.toggle("border",e)}get indeterminate(){return this.getAttrBoolean("indeterminate")}set indeterminate(e){this.setAttribute("indeterminate",e),this.#t.classList.toggle("indeterminate",e),e&&(this.checked=!1,this.#t.classList.remove("checked"),this.setAttribute("indeterminate",!0))}init(){this.checked=this.checked,this.name=this.name,this.value=this.value,this.disabled=this.disabled,this.border=this.border,this.indeterminate=this.indeterminate,this.#e.addEventListener("change",(e=>{e.preventDefault(),this.checked=e.target.checked,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.checked,value:this.value,name:this.name}}))}))}connectedCallback(){this.init()}}window.customElements.get("ea-checkbox")||window.customElements.define("ea-checkbox",EaCheckbox);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet='\n:host {\n --margin-right: 1rem;\n}\n\n.ea-checkbox_wrap {\n display: inline-flex;\n align-items: center;\n white-space: nowrap;\n user-select: none;\n margin-right: var(--margin-right);\n}\n.ea-checkbox_wrap .ea-checkbox-input_wrap {\n line-height: 1;\n margin-right: 0.5rem;\n}\n.ea-checkbox_wrap .ea-checkbox-input_wrap .ea-checkbox-input_inner {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 0.8125rem;\n height: 0.8125rem;\n line-height: 0.8125;\n border-radius: 3px;\n border: 1px solid #ccc;\n transition: background-color 0.2s, border-color 0.2s;\n}\n.ea-checkbox_wrap .ea-checkbox-input_wrap .ea-checkbox-input_inner::after {\n content: "";\n position: absolute;\n left: 52.5%;\n top: 45%;\n transform: translate(-50%, -50%) rotate(-135deg);\n display: block;\n width: 3px;\n height: 7px;\n opacity: 0;\n transition: opacity 0.2s;\n}\n.ea-checkbox_wrap .ea-checkbox-input_wrap .ea-checkbox-input_input {\n display: none;\n}\n.ea-checkbox_wrap .ea-checkbox-label_desc {\n line-height: 1;\n transition: color 0.2s;\n}\n.ea-checkbox_wrap.checked .ea-checkbox-input_wrap .ea-checkbox-input_inner {\n border-color: #409eff;\n background-color: #409eff;\n}\n.ea-checkbox_wrap.checked .ea-checkbox-input_wrap .ea-checkbox-input_inner::after {\n opacity: 1;\n border-left: 2px solid white;\n border-top: 2px solid white;\n}\n.ea-checkbox_wrap.checked .ea-checkbox-label_desc {\n color: #409eff;\n}\n.ea-checkbox_wrap.disabled .ea-checkbox-input_wrap .ea-checkbox-input_inner {\n border-color: #eeeeee;\n background-color: #eeeeee;\n}\n.ea-checkbox_wrap.disabled .ea-checkbox-input_wrap .ea-checkbox-input_inner::before {\n background-color: transparent;\n}\n.ea-checkbox_wrap.disabled .ea-checkbox-label_desc {\n color: #c0c4cc;\n}\n.ea-checkbox_wrap.disabled[checked=true] .ea-checkbox-input_wrap .ea-checkbox-input_inner::before {\n background-color: #c0c4cc;\n}\n.ea-checkbox_wrap.indeterminate .ea-checkbox-input_wrap .ea-checkbox-input_inner {\n border-color: #409eff;\n background-color: #409eff;\n}\n.ea-checkbox_wrap.indeterminate .ea-checkbox-input_wrap .ea-checkbox-input_inner::after {\n opacity: 1;\n left: 50%;\n top: 50%;\n width: 80%;\n height: 3px;\n background-color: white;\n transform: translate(-50%, -50%) rotate(0deg);\n}\n.ea-checkbox_wrap.indeterminate .ea-checkbox-label_desc {\n color: #409eff;\n}\n.ea-checkbox_wrap.indeterminate[checked=true] .ea-checkbox-input_wrap .ea-checkbox-input_inner {\n border-color: #409eff;\n background-color: #409eff;\n}\n.ea-checkbox_wrap.indeterminate[checked=true] .ea-checkbox-input_wrap .ea-checkbox-input_inner::after {\n width: 3px;\n height: 7px;\n left: 52.5%;\n top: 45%;\n transform: translate(-50%, -50%) rotate(-135deg);\n opacity: 1;\n border-left: 2px solid white;\n border-top: 2px solid white;\n background-color: transparent;\n}\n.ea-checkbox_wrap.indeterminate[checked=true] .ea-checkbox-label_desc {\n color: #409eff;\n}\n';
|
|
@@ -1,107 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from "../Base.js";
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-checkbox-group {
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
.ea-checkbox-group ::slotted(ea-checkbox) {
|
|
9
|
-
margin-right: 1.5rem;
|
|
10
|
-
}`;
|
|
11
|
-
|
|
12
|
-
export class EaCheckboxGroup extends Base {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
|
|
16
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
17
|
-
|
|
18
|
-
const dom = document.createElement('div');
|
|
19
|
-
shadowRoot.appendChild(dom);
|
|
20
|
-
const slot = document.createElement('slot');
|
|
21
|
-
dom.className = "ea-checkbox-group";
|
|
22
|
-
dom.appendChild(slot);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.dom = dom;
|
|
26
|
-
|
|
27
|
-
this.build(shadowRoot, stylesheet);
|
|
28
|
-
|
|
29
|
-
shadowRoot.appendChild(dom);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ------- name 唯一键值 -------
|
|
33
|
-
// #region
|
|
34
|
-
get name() {
|
|
35
|
-
return this.getAttribute('name');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
set name(val) {
|
|
39
|
-
this.querySelectorAll('ea-checkbox').forEach(checkbox => {
|
|
40
|
-
checkbox.setAttribute('name', val);
|
|
41
|
-
checkbox.name = val;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// #endregion
|
|
45
|
-
// ------- end -------
|
|
46
|
-
|
|
47
|
-
// ------- value 指定选中值 -------
|
|
48
|
-
// #region
|
|
49
|
-
get value() {
|
|
50
|
-
if (!this.getAttribute('value')) return;
|
|
51
|
-
|
|
52
|
-
return this.getAttribute('value');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
set value(val) {
|
|
56
|
-
if (!val) return;
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const valArr = val.split(',').map(item => item.trimStart());
|
|
60
|
-
|
|
61
|
-
valArr.map(item => {
|
|
62
|
-
const checkbox = document.querySelector(`ea-checkbox[name="${this.name}"][value="${item}"]`);
|
|
63
|
-
checkbox.setAttribute('checked', 'true');
|
|
64
|
-
checkbox.checked = 'true';
|
|
65
|
-
})
|
|
66
|
-
} catch (error) {
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// #endregion
|
|
71
|
-
// ------- end -------
|
|
72
|
-
|
|
73
|
-
// ------- disabled 禁用 -------
|
|
74
|
-
// #region
|
|
75
|
-
get disabled() {
|
|
76
|
-
return this.getAttrBoolean('disabled');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
set disabled(val) {
|
|
80
|
-
const checkboxs = document.querySelectorAll(`ea-checkbox[name="${this.name}"]`);
|
|
81
|
-
|
|
82
|
-
checkboxs.forEach(checkbox => {
|
|
83
|
-
checkbox.disabled = val;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// #endregion
|
|
87
|
-
// ------- end -------
|
|
88
|
-
|
|
89
|
-
init() {
|
|
90
|
-
// name 唯一键值
|
|
91
|
-
this.name = this.name;
|
|
92
|
-
|
|
93
|
-
// value 指定选中值
|
|
94
|
-
this.value = this.value;
|
|
95
|
-
|
|
96
|
-
// disabled 禁用
|
|
97
|
-
this.disabled = this.disabled;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
connectedCallback() {
|
|
101
|
-
this.init();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!window.customElements.get("ea-checkbox-group")) {
|
|
106
|
-
window.customElements.define("ea-checkbox-group", EaCheckboxGroup);
|
|
107
|
-
}
|
|
1
|
+
import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaCheckboxGroup extends Base{constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-checkbox-group_wrap" part="container">\n <slot></slot>\n </div>\n ',this.build(e,stylesheet)}get name(){return this.getAttribute("name")||"ea-checkbox"}set name(e){this.querySelectorAll("ea-checkbox").forEach((t=>{t.setAttribute("name",e),t.name=e}))}get value(){return this.getAttribute("value")||""}set value(e){this.setAttribute("value",e);try{const t=e.split(",").map((e=>e.trimStart()));t.map((e=>{const t=this.querySelector(`ea-checkbox[name="${this.name}"][value="${e}"]`);t.setAttribute("checked","true"),t.checked="true"})),this.dispatchEvent(new CustomEvent("change",{detail:t}))}catch(e){}}get disabled(){return this.getAttrBoolean("disabled")}set disabled(e){document.querySelectorAll(`ea-checkbox[name="${this.name}"]`).forEach((t=>{t.disabled=e}))}#e(e){let t=[];Array.from(e).filter((e=>!!e.checked&&t.push(e.value))),this.value=t.join(",")}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name,this.value=this.value,this.disabled=this.disabled;const e=this.querySelectorAll("ea-checkbox");e.forEach((t=>{t.addEventListener("change",(t=>{this.#e(e)}))})),this.#e(e)}}window.customElements.get("ea-checkbox-group")||window.customElements.define("ea-checkbox-group",EaCheckboxGroup);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-checkbox-group {\n display: flex;\n}\n.ea-checkbox-group ::slotted(ea-checkbox) {\n margin-right: 1.5rem;\n}\n";
|