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,301 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-switch_wrap {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
}
|
|
9
|
-
.ea-switch_wrap input {
|
|
10
|
-
display: none;
|
|
11
|
-
}
|
|
12
|
-
.ea-switch_wrap span {
|
|
13
|
-
display: block;
|
|
14
|
-
cursor: default;
|
|
15
|
-
}
|
|
16
|
-
.ea-switch_wrap .ea-switch_label {
|
|
17
|
-
color: #606266;
|
|
18
|
-
font-size: 0.875rem;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
transition: color 0.2s;
|
|
21
|
-
}
|
|
22
|
-
.ea-switch_wrap .ea-switch_label.ea-switch_label--active {
|
|
23
|
-
color: #409eff;
|
|
24
|
-
}
|
|
25
|
-
.ea-switch_wrap .ea-switch_core {
|
|
26
|
-
position: relative;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
margin: 0 0.75rem;
|
|
29
|
-
width: 2.5rem;
|
|
30
|
-
height: 1.25rem;
|
|
31
|
-
line-height: 1.25rem;
|
|
32
|
-
background-color: #dcdfe6;
|
|
33
|
-
border-radius: 999px;
|
|
34
|
-
transition: background-color 0.2s;
|
|
35
|
-
}
|
|
36
|
-
.ea-switch_wrap .ea-switch_core.ea-switch_core--checked {
|
|
37
|
-
background-color: #409eff;
|
|
38
|
-
}
|
|
39
|
-
.ea-switch_wrap .ea-switch_core::after {
|
|
40
|
-
content: "";
|
|
41
|
-
display: block;
|
|
42
|
-
position: absolute;
|
|
43
|
-
left: 2px;
|
|
44
|
-
top: 50%;
|
|
45
|
-
transform: translate(0, -50%);
|
|
46
|
-
width: 1rem;
|
|
47
|
-
height: 1rem;
|
|
48
|
-
border-radius: 999px;
|
|
49
|
-
background-color: #fff;
|
|
50
|
-
transition: left 0.2s, transform 0.2s;
|
|
51
|
-
}
|
|
52
|
-
.ea-switch_wrap .ea-switch_core.ea-switch_core--checked::after {
|
|
53
|
-
left: calc(100% - 1rem - 2px);
|
|
54
|
-
}
|
|
55
|
-
.ea-switch_wrap .ea-switch_core.ea-switch_core--disabled {
|
|
56
|
-
background-color: #c0c4cc;
|
|
57
|
-
}
|
|
58
|
-
.ea-switch_wrap.ea-switch_wrap--disabled {
|
|
59
|
-
cursor: not-allowed;
|
|
60
|
-
}
|
|
61
|
-
.ea-switch_wrap.ea-switch_wrap--disabled .ea-switch_label,
|
|
62
|
-
.ea-switch_wrap.ea-switch_wrap--disabled .ea-switch_core {
|
|
63
|
-
pointer-events: none;
|
|
64
|
-
}
|
|
65
|
-
.ea-switch_wrap.ea-switch_wrap--disabled .ea-switch_core {
|
|
66
|
-
background-color: #eff1f5;
|
|
67
|
-
}
|
|
68
|
-
.ea-switch_wrap.ea-switch_wrap--disabled .ea-switch_label {
|
|
69
|
-
color: #c0c4cc;
|
|
70
|
-
}
|
|
71
|
-
.ea-switch_wrap.ea-switch_wrap--disabled .ea-switch_label.ea-switch_label--active {
|
|
72
|
-
color: #7ebfff;
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
const inputDom = () => {
|
|
77
|
-
const input = document.createElement('input');
|
|
78
|
-
input.type = 'checkbox';
|
|
79
|
-
input.className = 'ea-switch_input';
|
|
80
|
-
|
|
81
|
-
return input;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const inputCoreDom = () => {
|
|
85
|
-
const div = document.createElement('span');
|
|
86
|
-
div.className = 'ea-switch_core';
|
|
87
|
-
|
|
88
|
-
return div;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const labelDom = (posi) => {
|
|
92
|
-
const label = document.createElement('span');
|
|
93
|
-
label.className = `ea-switch_label ea-switch_label--${posi}`;
|
|
94
|
-
|
|
95
|
-
return label;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export class EaSwitch extends Base {
|
|
99
|
-
#mounted = false;
|
|
100
|
-
|
|
101
|
-
#wrap;
|
|
102
|
-
#input;
|
|
103
|
-
|
|
104
|
-
#labelLeft;
|
|
105
|
-
#inputCore;
|
|
106
|
-
#labelRight;
|
|
107
|
-
|
|
108
|
-
static get observedAttributes() {
|
|
109
|
-
return ['checked'];
|
|
110
|
-
}
|
|
111
|
-
constructor() {
|
|
112
|
-
super();
|
|
113
|
-
|
|
114
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
115
|
-
const wrap = document.createElement('div');
|
|
116
|
-
wrap.className = 'ea-switch_wrap';
|
|
117
|
-
|
|
118
|
-
const input = inputDom();
|
|
119
|
-
const leftLabel = labelDom('left');
|
|
120
|
-
const inputCore = inputCoreDom();
|
|
121
|
-
const rightLabel = labelDom('right');
|
|
122
|
-
|
|
123
|
-
wrap.appendChild(input);
|
|
124
|
-
wrap.appendChild(leftLabel);
|
|
125
|
-
wrap.appendChild(inputCore);
|
|
126
|
-
wrap.appendChild(rightLabel);
|
|
127
|
-
|
|
128
|
-
this.#wrap = wrap;
|
|
129
|
-
this.#input = input;
|
|
130
|
-
this.#labelLeft = leftLabel;
|
|
131
|
-
this.#inputCore = inputCore;
|
|
132
|
-
this.#labelRight = rightLabel;
|
|
133
|
-
|
|
134
|
-
this.build(shadowRoot, stylesheet);
|
|
135
|
-
this.shadowRoot.appendChild(wrap);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ------- inactive-text 关闭时选项 -------
|
|
139
|
-
// #region
|
|
140
|
-
get inactiveText() {
|
|
141
|
-
return this.getAttribute('inactive-text');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
set inactiveText(value) {
|
|
145
|
-
this.setAttribute('inactive-text', value);
|
|
146
|
-
this.#labelLeft.innerText = value;
|
|
147
|
-
}
|
|
148
|
-
// #endregion
|
|
149
|
-
// ------- end -------
|
|
150
|
-
|
|
151
|
-
// ------- active-text 开启时选项 -------
|
|
152
|
-
// #region
|
|
153
|
-
get activeText() {
|
|
154
|
-
return this.getAttribute('active-text');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
set activeText(value) {
|
|
158
|
-
this.setAttribute('active-text', value);
|
|
159
|
-
this.#labelRight.innerText = value;
|
|
160
|
-
}
|
|
161
|
-
// #endregion
|
|
162
|
-
// ------- end -------
|
|
163
|
-
|
|
164
|
-
// ------- checked 选中 -------
|
|
165
|
-
// #region
|
|
166
|
-
get checked() {
|
|
167
|
-
return this.getAttrBoolean('checked');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
set checked(value) {
|
|
171
|
-
this.setAttribute('checked', value);
|
|
172
|
-
this.#input.checked = value;
|
|
173
|
-
this.#input.setAttribute('checked', value);
|
|
174
|
-
|
|
175
|
-
if (value) {
|
|
176
|
-
this.#inputCore.classList.add('ea-switch_core--checked');
|
|
177
|
-
this.#labelRight.classList.add('ea-switch_label--active');
|
|
178
|
-
|
|
179
|
-
this.#labelLeft.classList.remove('ea-switch_label--active');
|
|
180
|
-
} else {
|
|
181
|
-
this.#inputCore.classList.remove('ea-switch_core--checked');
|
|
182
|
-
this.#labelLeft.classList.add('ea-switch_label--active');
|
|
183
|
-
|
|
184
|
-
this.#labelRight.classList.remove('ea-switch_label--active');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// #endregion
|
|
188
|
-
// ------- end -------
|
|
189
|
-
|
|
190
|
-
// ------- disabled 禁用 -------
|
|
191
|
-
// #region
|
|
192
|
-
get disabled() {
|
|
193
|
-
return this.getAttrBoolean('disabled');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
set disabled(value) {
|
|
197
|
-
this.setAttribute('disabled', value);
|
|
198
|
-
this.#input.disabled = value;
|
|
199
|
-
this.#wrap.classList.toggle('ea-switch_wrap--disabled', value);
|
|
200
|
-
}
|
|
201
|
-
// #endregion
|
|
202
|
-
// ------- end -------
|
|
203
|
-
|
|
204
|
-
// ------- inactive-color 关闭时颜色 -------
|
|
205
|
-
// #region
|
|
206
|
-
get inactiveColor() {
|
|
207
|
-
return this.getAttribute('inactive-color');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
set inactiveColor(value) {
|
|
211
|
-
if (!value) return;
|
|
212
|
-
|
|
213
|
-
this.setAttribute('inactive-color', value);
|
|
214
|
-
if (value) this.#inputCore.style.backgroundColor = value;
|
|
215
|
-
}
|
|
216
|
-
// #endregion
|
|
217
|
-
// ------- end -------
|
|
218
|
-
|
|
219
|
-
// ------- active-color 开启时颜色 -------
|
|
220
|
-
// #region
|
|
221
|
-
get activeColor() {
|
|
222
|
-
return this.getAttribute('active-color');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
set activeColor(value) {
|
|
226
|
-
if (!value) return;
|
|
227
|
-
|
|
228
|
-
this.setAttribute('active-color', value);
|
|
229
|
-
this.#inputCore.style.backgroundColor = value;
|
|
230
|
-
}
|
|
231
|
-
// #endregion
|
|
232
|
-
// ------- end -------
|
|
233
|
-
|
|
234
|
-
handleInputChecked(e) {
|
|
235
|
-
const currentChecked = this.#input.checked;
|
|
236
|
-
|
|
237
|
-
if (this.inactiveColor && this.activeColor) {
|
|
238
|
-
this.#inputCore.style.backgroundColor = currentChecked ? this.inactiveColor : this.activeColor;
|
|
239
|
-
} else {
|
|
240
|
-
this.#inputCore.classList.toggle('ea-switch_core--checked', currentChecked);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
init() {
|
|
245
|
-
const that = this;
|
|
246
|
-
|
|
247
|
-
// 设置勾选值
|
|
248
|
-
this.checked = this.checked;
|
|
249
|
-
|
|
250
|
-
// 设置开启/关闭值
|
|
251
|
-
this.inactiveText = this.inactiveText;
|
|
252
|
-
this.activeText = this.activeText;
|
|
253
|
-
|
|
254
|
-
// 设置禁用
|
|
255
|
-
this.disabled = this.disabled;
|
|
256
|
-
|
|
257
|
-
// 设置颜色
|
|
258
|
-
if (this.activeColor && this.inactiveColor) {
|
|
259
|
-
if (this.checked) this.activeColor = this.activeColor;
|
|
260
|
-
else this.inactiveColor = this.inactiveColor;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
this.#labelLeft.addEventListener('click', function (e) {
|
|
265
|
-
that.checked = !that.#input.checked;
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
this.#labelRight.addEventListener('click', function (e) {
|
|
269
|
-
that.checked = !that.#input.checked;
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
this.#inputCore.addEventListener('click', function (e) {
|
|
273
|
-
that.checked = !that.#input.checked;
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
connectedCallback() {
|
|
278
|
-
this.init();
|
|
279
|
-
this.#mounted = true;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
283
|
-
if (!this.#mounted) return;
|
|
284
|
-
|
|
285
|
-
if (name === 'checked') {
|
|
286
|
-
const value = this.checked ? this.activeText : this.inactiveText;
|
|
287
|
-
this.handleInputChecked();
|
|
288
|
-
|
|
289
|
-
this.dispatchEvent(new CustomEvent("change", {
|
|
290
|
-
detail: {
|
|
291
|
-
checked: this.checked,
|
|
292
|
-
value,
|
|
293
|
-
},
|
|
294
|
-
}))
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (!customElements.get('ea-switch')) {
|
|
300
|
-
customElements.define('ea-switch', EaSwitch);
|
|
301
|
-
}
|
|
1
|
+
import Base from"../Base.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaSwitch extends Base{#t;#e;#i;#s;#a;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <label class="ea-switch_wrap" part="container">\n <input class="ea-switch_input" type="checkbox">\n <span class="ea-switch_label ea-switch_label--left" part="label-left"></span>\n <span class="ea-switch_core" part="switch"></span>\n <span class="ea-switch_label ea-switch_label--right" part="label-right"></span>\n </label>\n ',this.#t=t.querySelector(".ea-switch_wrap"),this.#e=t.querySelector(".ea-switch_input"),this.#i=t.querySelector(".ea-switch_label--left"),this.#s=t.querySelector(".ea-switch_core"),this.#a=t.querySelector(".ea-switch_label--right"),this.build(t,stylesheet)}get name(){return this.getAttribute("name")||"ea-switch"}set name(t){this.setAttribute("name",t),this.#t.setAttribute("for",t),this.#e.setAttribute("name",t),this.#e.setAttribute("id",t)}get value(){return this.inactiveText&&!this.checked?this.inactiveText:this.activeText&&this.checked?this.activeText:this.checked}set value(t){this.#e.value=t}get inactiveText(){return this.getAttribute("inactive-text")||""}set inactiveText(t){t&&(this.setAttribute("inactive-text",t),this.#i.innerText=t)}get activeText(){return this.getAttribute("active-text")||""}set activeText(t){t&&(this.setAttribute("active-text",t),this.#a.innerText=t)}get checked(){return this.getAttrBoolean("checked")}set checked(t){this.setAttribute("checked",t),this.#e.checked=t}get disabled(){return this.getAttrBoolean("disabled")}set disabled(t){this.setAttribute("disabled",t),this.#e.disabled=t,this.#t.classList.toggle("disabled",t)}get inactiveColor(){return this.getAttribute("inactive-color")||""}set inactiveColor(t){t&&this.style.setProperty("--inactive-checkbox-bgc",t)}get activeColor(){return this.getAttribute("active-color")}set activeColor(t){t&&this.style.setProperty("--active-checkbox-bgc",t)}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name,this.value=this.value,this.checked=this.checked,this.inactiveText=this.inactiveText,this.activeText=this.activeText,this.disabled=this.disabled,this.inactiveColor=this.inactiveColor,this.activeColor=this.activeColor,this.#e.addEventListener("change",(t=>{t.preventDefault(),t.stopPropagation(),this.checked=t.target.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked,value:this.value}}))}))}}customElements.get("ea-switch")||customElements.define("ea-switch",EaSwitch);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet='\n:host {\n --active-text-color: #409eff;\n --inactive-text-color: ##606266;\n --active-checkbox-bgc: #409eff;\n --inactive-checkbox-bgc: #eff1f5;\n --active-disabled-text-color: #7ebfff;\n --active-disabled-bgc: #bbdcff;\n --inactive-disabled-text-color: #c0c4cc;\n --inactive-disabled-bgc: #eff1f5;\n}\n\n.ea-switch_wrap {\n display: flex;\n align-items: center;\n cursor: pointer;\n}\n.ea-switch_wrap input {\n display: none;\n}\n.ea-switch_wrap .ea-switch_label {\n font-size: 0.875rem;\n transition: color 0.2s;\n}\n.ea-switch_wrap input + .ea-switch_label--left {\n color: var(--active-text-color);\n}\n.ea-switch_wrap input:checked + .ea-switch_label--left {\n color: var(--inactive-text-color);\n}\n.ea-switch_wrap input:checked + .ea-switch_label--left + .ea-switch_core {\n background-color: var(--active-checkbox-bgc);\n}\n.ea-switch_wrap input:checked + .ea-switch_label--left + .ea-switch_core::after {\n left: calc(100% - 1rem - 2px);\n}\n.ea-switch_wrap input:checked + .ea-switch_label--left + .ea-switch_core + .ea-switch_label--right {\n color: var(--active-text-color);\n}\n.ea-switch_wrap input:disabled + .ea-switch_label--left {\n color: var(--active-disabled-text-color);\n}\n.ea-switch_wrap input:disabled + .ea-switch_label--left + .ea-switch_core {\n background-color: var(--inactive-disabled-bgc);\n}\n.ea-switch_wrap input:disabled + .ea-switch_label--left + .ea-switch_core + .ea-switch_label--right {\n color: var(--inactive-disabled-text-color);\n}\n.ea-switch_wrap input:checked:disabled + .ea-switch_label--left {\n color: var(--inactive-disabled-text-color);\n}\n.ea-switch_wrap input:checked:disabled + .ea-switch_label--left + .ea-switch_core {\n background-color: var(--active-disabled-bgc);\n}\n.ea-switch_wrap input:checked:disabled + .ea-switch_label--left + .ea-switch_core::after {\n left: calc(100% - 1rem - 2px);\n}\n.ea-switch_wrap input:checked:disabled + .ea-switch_label--left + .ea-switch_core + .ea-switch_label--right {\n color: var(--inactive-disabled-text-color);\n}\n.ea-switch_wrap .ea-switch_core {\n position: relative;\n cursor: pointer;\n margin: 0 0.75rem;\n width: 2.5rem;\n height: 1.25rem;\n line-height: 1.25rem;\n background-color: var(--inactive-checkbox-bgc);\n border-radius: 999px;\n transition: background-color 0.2s;\n}\n.ea-switch_wrap .ea-switch_core::after {\n content: "";\n display: block;\n position: absolute;\n left: 2px;\n top: 50%;\n transform: translate(0, -50%);\n width: 1rem;\n height: 1rem;\n border-radius: 999px;\n background-color: #fff;\n transition: left 0.2s, transform 0.2s;\n}\n.ea-switch_wrap.disabled {\n cursor: not-allowed;\n}\n.ea-switch_wrap.disabled .ea-switch_label,\n.ea-switch_wrap.disabled .ea-switch_core {\n pointer-events: none;\n}\n';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import"../ea-pane/index.js";import{createElement}from"../../utils/createElement.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaTab extends Base{#t;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-tab_wrap" part="container">\n <slot></slot>\n </div>\n ',this.#t=t.querySelector(".ea-tab_wrap"),this.build(t,stylesheet)}get name(){return this.getAttribute("name")}set name(t){this.setAttribute("name",t)}get type(){return this.getAttrBoolean("type")||"normal"}set type(t){this.setAttribute("type",t),this.#t.classList.add(`ea-tab_wrap--${t}`)}get actived(){return this.getAttrBoolean("actived")}set actived(t){this.toggleAttr("actived",t),this.#t.classList.toggle("is-actived",t)}get editable(){return this.getAttrBoolean("editable")}set editable(t){this.setAttribute("editable",t),this.#t.classList.toggle("ea-tab_wrap--editable",t),t&&this.#e()}#a(){this.addEventListener("click",(t=>{const e=t.detail.value===this.getAttrBoolean("selected");this.toggleAttr("selected",e),this.dispatchEvent(new CustomEvent("tab-click",{detail:{name:this.name,event:this},bubbles:!0}))}))}#e(){const t=createElement("span","ea-tab_wrap--editable-sign");t.innerText="x",this.#t.appendChild(t),t.addEventListener("click",(t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("tab-close",{detail:{event:this,name:this.name,index:this.index},bubbles:!0}))}))}handleBorderRadius(t){this.#t.style.setProperty(t,"3px")}handleBorderRightWidth(){this.#t.style.setProperty("--border-right-width","1px")}connectedCallback(){this.editable=this.editable,this.label=this.label,this.#a()}}customElements.get("ea-tab")||customElements.define("ea-tab",EaTab);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-tab_wrap {\n --border-radius-top-left: 0;\n --border-radius-top-right: 0;\n --border-right-width: 0;\n position: relative;\n box-sizing: border-box;\n padding: 0 1.25rem;\n height: 40px;\n line-height: 40px;\n min-width: 1rem;\n font-size: 14px;\n font-weight: 500;\n color: #303133;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n cursor: pointer;\n transition: color 0.3s, background-color 0.3s, width 0.3s, min-width 0.3s;\n}\n.ea-tab_wrap:hover {\n color: #409eff;\n}\n.ea-tab_wrap.ea-tab_wrap--normal.is-actived {\n color: #409eff;\n}\n.ea-tab_wrap.ea-tabs_wrap--card {\n border-bottom: 1px solid #e4e7ed;\n}\n.ea-tab_wrap.ea-tabs_wrap--card .ea-tabs_tab-bottom-bar {\n height: 1px;\n bottom: -1px;\n background-color: white;\n}\n.ea-tab_wrap.ea-tab_wrap--card {\n border-top-left-radius: var(--border-radius-top-left);\n border-top-right-radius: var(--border-radius-top-right);\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-right-width: var(--border-right-width);\n}\n.ea-tab_wrap.ea-tab_wrap--card.is-actived {\n border-bottom-color: white;\n color: #409eff;\n}\n.ea-tab_wrap.ea-tab_wrap--border-card {\n border-top-left-radius: var(--border-radius-top-left);\n border-top-right-radius: var(--border-radius-top-right);\n border: 0px solid rgba(0, 0, 0, 0.1);\n border-right-width: var(--border-right-width);\n}\n.ea-tab_wrap.ea-tab_wrap--border-card.is-actived {\n border-bottom-color: white;\n color: #409eff;\n background-color: white;\n}\n.ea-tab_wrap.ea-tab_wrap--editable .ea-tab_wrap--editable-sign {\n display: block;\n position: absolute;\n right: 0;\n top: 50%;\n transform: translate(0, -50%);\n user-select: none;\n width: 0;\n overflow: hidden;\n transition: width 0.3s;\n}\n.ea-tab_wrap.ea-tab_wrap--editable:hover .ea-tab_wrap--editable-sign {\n width: 14px;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{createElement}from"../../utils/createElement.js";import"../ea-table-column/index.js";import"../ea-checkbox/index.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaTable extends Base{#e;#t;#r;#a;#l;#o;#s;#i;#n;#h;#d;#c;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-table_wrap" part="container">\n <div class="ea-table_header-wrap" part="header-wrap">\n <table class="ea-table_header" part="header-table">\n <colgroup></colgroup>\n <thead></thead>\n </table>\n </div>\n <div class="ea-table_body-wrap" part="body-wrap">\n <table class="ea-table_main" part="body-table">\n <colgroup></colgroup>\n <tbody></tbody>\n <slot name="empty" style="display: none;"></slot>\n </table>\n </div>\n </div>\n <slot></slot>\n <slot name="header"></slot>\n <slot name="body"></slot>\n ',this.build(e,stylesheet),this.#e=this.shadowRoot.querySelector(".ea-table_wrap"),this.#t=this.shadowRoot.querySelector(".ea-table_header"),this.#r=this.#t.querySelector(".ea-table_header colgroup"),this.#a=this.#t.querySelector(".ea-table_header thead"),this.#l=this.shadowRoot.querySelector(".ea-table_main"),this.#o=this.#l.querySelector(".ea-table_body-wrap colgroup"),this.#s=this.#l.querySelector(".ea-table_body-wrap tbody"),this.#i=this.querySelectorAll("ea-table-column")}get border(){return this.getAttrBoolean("border")}set border(e){this.setAttribute("border",e),this.#e.classList.toggle("border",e),this.#t.classList.toggle("border",e),this.#l.classList.toggle("border",e)}get stripe(){return this.getAttrBoolean("stripe")}set stripe(e){this.setAttribute("stripe",e),this.#e.classList.toggle("stripe",e)}get height(){return this.getAttrNumber("height")}set height(e){if(this.setAttribute("height",e),e){this.shadowRoot.querySelector(".ea-table_body-wrap").style.height=`${e}px`}else this.#e.style.height=""}get highlightCurrentRow(){return this.getAttrBoolean("highlight-current-row")||!1}set highlightCurrentRow(e){this.setAttribute("highlight-current-row",e)}get currentRow(){return this.getAttrNumber("current-row")||0}set currentRow(e){this.setAttribute("current-row",e)}get data(){return this.#h||[]}set data(e){const t=JSON.stringify(e);let r=JSON.parse(t);this.#h=r,this.renderTableBody(r)}get currentRowDetail(){const e=this.currentRow;return{index:e,data:this.data[e],target:this.#l.querySelectorAll(".ea-table__row")[e]||null}}#b(e,t,r,a,l,o=!1){const s=this.parentNode.clientWidth,i=Array.from(a.children).reduce(((e,t)=>e+Number(t.getAttribute("width"))),0);s>0&&i<=s?(r.style.width=s-l+"px",e.style.width=`${s}px`,t.style.width=s-l+"px",o&&(e.style.width=`${s}px`)):(r.style.width=`${s}px`,e.style.width=`${s}px`,t.style.width=`${s}px`)}#p(){const e=this.shadowRoot.querySelector(".ea-table_header-wrap"),t=this.shadowRoot.querySelector(".ea-table_body-wrap");let r=null;const a=()=>{this.#b(this.#e,this.#l,this.#t,this.#r,r)};window.addEventListener("resize",(()=>{a()})),setTimeout((()=>{r=this.#e.getBoundingClientRect().width-this.#l.getBoundingClientRect().width,a()}),0),t.addEventListener("scroll",(r=>{e.style.transform=`translateX(-${t.scrollLeft}px)`}))}#u(e,t){if(t.sortable&&"selection"!==t.type){const r=createElement("ea-icon");r.icon="icon-angle-down",r.style.float="right",e.appendChild(r),e.addEventListener("click",(()=>{r.color="#5cb6ff";"asc"===t.order?(t.order="desc",r.icon="icon-angle-up"):(t.order="asc",r.icon="icon-angle-down");let e=this.data.sort(((e,r)=>{const a="null"!==t.prop?t.prop:t.type;return"asc"===t.order?String(e[a]).localeCompare(r[a]):String(r[a]).localeCompare(e[a])}));this.renderTableBody(e),this.dispatchEvent(new CustomEvent("sort-change",{detail:{prop:t.prop,order:t.order},composed:!0,bubbles:!0}))}))}}#y(){this.querySelectorAll("ea-table-column");this.#r.innerHTML="",this.#o.innerHTML="",this.#a.innerHTML="";const e=(t,r=1)=>{const a=createElement("tr");a.part="row",a.setAttribute("index",r),Array.from(t).forEach((t=>{if("EA-TABLE-COLUMN"!==t.nodeName)return;const l=createElement("th","ea-table__cell th-cell");if(l.part="th-cell",l.setAttribute("colspan",t.colspan||1),l.setAttribute("rowspan",t.rowspan||1),l.appendChild(t),a.appendChild(l),"selection"===t.type&&(this.#n=t.querySelector("ea-checkbox")),t.children.length>0)e(t.children,++r);else{const e=createElement("col");e.setAttribute("width",t.getAttribute("width")||100);const r=createElement("col");r.setAttribute("width",t.getAttribute("width")||100),this.#r.appendChild(e),this.#o.appendChild(r),this.#a.appendChild(a),this.#u(l,t)}}))};e(this.children)}#g(e,t){e.addEventListener("click",(()=>{const r=this.#s.querySelectorAll(".ea-table__row");let a=!1,l=!1;r.forEach(((e,t)=>{"index"===e.type&&(a=!0),"selection"===e.type&&(l=!0),e.index=t,this.highlightCurrentRow&&e.classList.remove("is-current-row")})),this.highlightCurrentRow&&e.classList.add("is-current-row"),l&&delete t.selection,this.currentRow=e.index,this.dispatchEvent(new CustomEvent("current-change",{composed:!0,bubbles:!0,detail:{index:e.index,row:e,data:t}}))}))}#m(e,t){const r=this.#t.querySelectorAll("ea-table-column");let a=0,l=!1;return r.forEach(((e,r)=>{e.type===t&&(a=r,l=!0)})),l?e.map(((e,r)=>{const l={},o=Object.keys(e);return o.splice(a,0,t),o.forEach(((t,a)=>{l[t]="index"===t?r+1:"selection"===t?"<ea-checkbox></ea-checkbox>":e[t]})),l})):e}#T(){const e=this.#s.querySelectorAll("tr"),t=this.shadowRoot.querySelector('slot[name="body"]');t.assignedNodes().length?(e.forEach((e=>{const r=createElement("td","ea-table__cell");r.part="td-cell",Array.from(t.assignedNodes()).forEach((t=>{const a=t.cloneNode(!0);r.appendChild(a),a.addEventListener("click",(()=>{t.dispatchEvent(new CustomEvent("click",{bubbles:!0,composed:!0,detail:{row:e}}))}))})),e.appendChild(r)})),t.style.display="none"):t.remove()}renderTableBody(e){if(this.#s.innerHTML="",!this.#d){e=this.#m(e,"index"),e=this.#m(e,"selection");const t=Array.from(this.#t.querySelectorAll("ea-table-column")).map(((e,t)=>"default"===e.type?e.prop:e.type));e=e.map((e=>{const r={};return t.forEach((t=>{null!==t&&"null"!==t&&void 0!==t&&"undefined"!==t&&(r[t]=e[t])})),r})),this.#d=!0}e.forEach(((t,r)=>{const a=createElement("tr","ea-table__row");a.part="row",Object.entries(t).forEach((([r,l])=>{const o=createElement("td","ea-table__cell td_cell");o.part="td-cell",o.innerHTML=l,"selection"===r&&o.querySelector("ea-checkbox").addEventListener("change",(r=>{const l=this.shadowRoot.querySelectorAll("ea-checkbox"),o=Array.from(l).filter(((e,t)=>(e.index=t,e.checked))),s=o.map((t=>{const r=e[t.index];return delete r.selection,r}));this.dispatchEvent(new CustomEvent("body-selection-change",{composed:!0,bubbles:!0,detail:{checked:r.detail.checked,currentRow:a,currentRowData:t,checkedElements:o,checkedElementsData:s}}))})),a.appendChild(o)})),this.#g(a,t),this.#s.appendChild(a)})),this.#h=e;const t=this.shadowRoot.querySelector('slot[name="empty"]');e.length>0?t.style.display="none":t.style.display="block",this.#T()}#w(){const e=this.shadowRoot.querySelectorAll("ea-table-column");Array.from(e).some((e=>"selection"===e.type))&&(this.addEventListener("header-selection-change",(e=>{this.#l.querySelectorAll("ea-checkbox").forEach((t=>{t.checked=e.detail.checked}))})),this.addEventListener("body-selection-change",(e=>{const t=this.#a.querySelector("ea-table-column").shadowRoot.querySelector("ea-checkbox"),r=this.#l.querySelectorAll("ea-checkbox");let a=Array.from(r).map((e=>e.checked));a.every((e=>!0===e))?t.checked=!0:a.every((e=>!1===e))?t.checked=!1:t.indeterminate=!0})))}#E(){const e=this.shadowRoot.querySelector('slot[name="header"]');if(e.assignedNodes().length>0){const t=this.#a.querySelector("tr"),r=createElement("th","ea-table__cell th-cell");r.part="th-cell";let a=1;Array.from(this.#a.querySelectorAll("th")).forEach((e=>{e.rowSpan>a&&(a=e.rowSpan)})),r.rowSpan=a,r.appendChild(e),t.appendChild(r)}else e.remove()}connectedCallback(){this.style.position="relative",this.border=this.border,this.stripe=this.stripe,this.height=this.height,this.highlightCurrentRow=this.highlightCurrentRow,this.#y(),this.#p(),this.#w(),this.#E()}}customElements.get("ea-table")||customElements.define("ea-table",EaTable);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-table_wrap,\n.ea-table_fixed-column {\n position: relative;\n background-color: #fff;\n overflow: hidden;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main,\n.ea-table_wrap .ea-table_main,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main,\n.ea-table_fixed-column .ea-table_main {\n position: relative;\n box-sizing: border-box;\n padding: 12px 0;\n width: 100%;\n min-width: 0;\n text-overflow: ellipsis;\n vertical-align: middle;\n text-align: left;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header .ea-table__cell,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main .ea-table__cell,\n.ea-table_wrap .ea-table_main .ea-table__cell,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header .ea-table__cell,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main .ea-table__cell,\n.ea-table_fixed-column .ea-table_main .ea-table__cell {\n border-top: 1px solid #ebeef5;\n border-bottom: 1px solid #ebeef5;\n box-sizing: border-box;\n padding: 8px;\n color: #606266;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header .ea-table__cell.th-cell,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main .ea-table__cell.th-cell,\n.ea-table_wrap .ea-table_main .ea-table__cell.th-cell,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header .ea-table__cell.th-cell,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main .ea-table__cell.th-cell,\n.ea-table_fixed-column .ea-table_main .ea-table__cell.th-cell {\n color: #909399;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header .ea-table__cell.is-gutter,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main .ea-table__cell.is-gutter,\n.ea-table_wrap .ea-table_main .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_main .ea-table__cell.is-gutter {\n width: 15px;\n padding: 0;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header.border .ea-table__cell,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main.border .ea-table__cell,\n.ea-table_wrap .ea-table_main.border .ea-table__cell,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header.border .ea-table__cell,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main.border .ea-table__cell,\n.ea-table_fixed-column .ea-table_main.border .ea-table__cell {\n border: 1px solid #ebeef5;\n padding: 8px;\n color: #606266;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header.border .ea-table__cell.is-gutter,\n.ea-table_wrap .ea-table_body-wrap .ea-table_main.border .ea-table__cell.is-gutter,\n.ea-table_wrap .ea-table_main.border .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header.border .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main.border .ea-table__cell.is-gutter,\n.ea-table_fixed-column .ea-table_main.border .ea-table__cell.is-gutter {\n width: 15px;\n padding: 0;\n min-width: none;\n}\n.ea-table_wrap .ea-table_header-wrap .ea-table_header.stripe .ea-table__row:nth-child(2n),\n.ea-table_wrap .ea-table_body-wrap .ea-table_main.stripe .ea-table__row:nth-child(2n),\n.ea-table_wrap .ea-table_main.stripe .ea-table__row:nth-child(2n),\n.ea-table_fixed-column .ea-table_header-wrap .ea-table_header.stripe .ea-table__row:nth-child(2n),\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main.stripe .ea-table__row:nth-child(2n),\n.ea-table_fixed-column .ea-table_main.stripe .ea-table__row:nth-child(2n) {\n background-color: #fafafa;\n}\n.ea-table_wrap .ea-table_main,\n.ea-table_fixed-column .ea-table_main {\n position: absolute;\n left: 0;\n top: 0;\n}\n.ea-table_wrap .ea-table_body-wrap,\n.ea-table_fixed-column .ea-table_body-wrap {\n overflow-y: auto;\n}\n.ea-table_wrap .ea-table_body-wrap .ea-table_main .ea-table__row:hover,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main .ea-table__row:hover {\n background-color: #f5f7fa;\n}\n.ea-table_wrap .ea-table_body-wrap .ea-table_main .ea-table__row.is-current-row,\n.ea-table_fixed-column .ea-table_body-wrap .ea-table_main .ea-table__row.is-current-row {\n background-color: #ecf5ff;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import"../ea-checkbox/index.js";const stylesheet="";export class EaTableColumn extends Base{#t;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <th part="container">\n <slot></slot>\n <span></span>\n </th>\n ',this.build(t,""),this.#t=t.querySelector("span")}get prop(){return this.getAttribute("prop")}set prop(t){this.setAttribute("prop",t)}get width(){return this.getAttrNumber("width")||350}set width(t){this.setAttribute("width",t)}get label(){return this.getAttribute("label")||""}set label(t){this.setAttribute("label",t),""!==t&&(this.#t.innerHTML=t)}get colspan(){return this.getAttrNumber("colspan")||1}set colspan(t){this.setAttribute("colspan",t)}get rowspan(){return this.getAttrNumber("rowspan")||1}set rowspan(t){this.setAttribute("rowspan",t)}get type(){const t=this.getAttribute("type");return["default","index","selection"].includes(t)?t:"default"}set type(t){this.setAttribute("type",t),"selection"===t&&(this.#t.innerHTML="\n <ea-checkbox></ea-checkbox>\n ",this.#t.querySelector("ea-checkbox").addEventListener("change",(t=>{this.dispatchEvent(new CustomEvent("header-selection-change",{detail:{checked:t.detail.checked},composed:!0}))})))}get sortable(){return this.getAttrBoolean("sortable")||!1}set sortable(t){this.setAttribute("sortable",t)}get order(){return this.getAttribute("order")||"asc"}set order(t){this.setAttribute("order",t)}connectedCallback(){this.prop=this.prop,this.width=this.width,this.label=this.label,this.colspan=this.colspan,this.rowspan=this.rowspan,this.type=this.type,this.sortable=this.sortable,this.order=this.order}}customElements.get("ea-table-column")||customElements.define("ea-table-column",EaTableColumn);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import"../ea-tab/index.js";import"../ea-pane/index.js";import{timeout}from"../../utils/timeout.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaTabs extends Base{#t;#e;#a;#s;#i=0;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-tabs_wrap" part="container">\n <div class="ea-tabs_tab-wrap" part="tab-wrap">\n <slot></slot>\n </div>\n <div class="ea-tabs_tab-bottom-bar" part="tab-bottom-bar"></div>\n <div class="ea-tabs_pane-wrap" part="pane-wrap">\n <slot name="pane"></slot>\n </div>\n </div>\n ',this.#t=t.querySelector(".ea-tabs_wrap"),this.#e=t.querySelector(".ea-tabs_tab-bottom-bar"),this.#a=t.querySelector(".ea-tabs_pane-wrap"),this.#s=t.querySelector(".ea-tabs_tab-wrap > slot"),this.build(t,stylesheet)}get type(){return this.getAttribute("type")||"normal"}set type(t){this.setAttribute("type",t),this.#t.classList.add("ea-tabs_wrap--"+t);const e=this.querySelectorAll("ea-tab");e.forEach((e=>{e.type=t})),"border-card"!==t&&(e[0].handleBorderRadius("--border-radius-top-left"),e[e.length-1].handleBorderRadius("--border-radius-top-right"),e[e.length-1].handleBorderRightWidth())}get actived(){return this.getAttribute("actived")||this.querySelectorAll("ea-tab")[0].name||0}set actived(t){this.setAttribute("actived",t),this.querySelectorAll("ea-tab").forEach(((e,a)=>{e.actived=e.name===t}))}get editable(){return this.getAttrBoolean("editable")||!1}set editable(t){this.setAttribute("editable",t),this.#o(t)}#r(t){const e=this.querySelectorAll("ea-tab"),a=this.querySelectorAll("ea-pane"),{width:s,height:i}=t.getBoundingClientRect(),o=Array.from(e).reduce(((e,a,s)=>s<=t.index?e+a.offsetWidth:e),0),r=(t,e)=>{t.actived=!1,t.index=e};e.forEach(r),a.forEach(r),t.actived=!0,this.querySelector(`ea-pane[name="${t.name}"]`).actived=!0,this.#e.style.left=o-s+"px",this.#e.style.width=s+"px",this.#e.style.top=i+"px"}#n(){const t=this.querySelectorAll("ea-tab"),e=this.querySelectorAll("ea-pane"),a=t=>{this.#r(t.detail.event),this.actived=t.detail.name,t.detail.event.actived=!0};t.forEach(((t,e)=>{t.index=e,t.name||(t.name=e),t.removeEventListener("tab-click",a),t.addEventListener("tab-click",a)})),e.forEach(((t,e)=>{t.index=e,t.name||(t.name=e)}))}#l(){timeout((()=>{const t=this.querySelector('ea-tab[name="'+this.actived+'"]');t.actived=!0,this.#r(t)}),20)}#d(t){t.stopPropagation();const e=this.querySelectorAll("ea-tab"),{name:a,event:s,index:i}=t.detail;let o=i;e[i+1]?o=i+1:e[i-1]&&(o=i-1);try{this.actived=e[o]?.name,s.remove(),this.querySelector(`ea-pane[name="${a}"]`).remove(),e.length<=1?this.#e.style.width=0:(this.#l(),this.#n())}catch(t){}}#o(t){this.querySelectorAll("ea-tab").forEach((e=>{e.editable=t})),this.removeEventListener("tab-close",this.#d),this.addEventListener("tab-close",this.#d)}#h(){timeout((()=>{this.#i=this.#s.assignedNodes().length,this.#s.addEventListener("slotchange",(t=>{const e=t.target.assignedNodes().length;e>=this.#i?(this.#n(),this.#o(this.editable),this.type=this.type,this.#i=e,this.dispatchEvent(new CustomEvent("tab-add",{detail:{event:t,tabs:this.querySelectorAll("ea-tab"),panes:this.querySelectorAll("ea-pane")},bubbles:!0,composed:!0}))):this.#i=this.#s.assignedNodes().length}))}),20)}connectedCallback(){this.type=this.type,this.actived=this.actived,this.editable=this.editable,this.#l(),this.#n(),this.#h()}}customElements.get("ea-tabs")||customElements.define("ea-tabs",EaTabs);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-tabs_wrap {\n position: relative;\n}\n.ea-tabs_wrap .ea-tabs_tab-wrap {\n display: flex;\n align-items: center;\n overflow-x: auto;\n scrollbar-width: thin;\n}\n.ea-tabs_wrap .ea-tabs_pane-wrap {\n padding: 20px;\n}\n.ea-tabs_wrap .ea-tabs_tab-bottom-bar {\n position: absolute;\n height: 2px;\n width: 0;\n top: 40px;\n left: 0;\n border-radius: 999px;\n background-color: #409eff;\n transition: left 0.3s;\n}\n.ea-tabs_wrap.ea-tabs_wrap--normal .ea-tabs_tab-wrap {\n border-bottom: 2px solid #e4e7ed;\n}\n.ea-tabs_wrap.ea-tabs_wrap--card .ea-tabs_tab-wrap {\n border-bottom: 1px solid #e4e7ed;\n}\n.ea-tabs_wrap.ea-tabs_wrap--card .ea-tabs_tab-bottom-bar {\n height: 1px;\n bottom: -1px;\n background-color: white;\n}\n.ea-tabs_wrap.ea-tabs_wrap--border-card {\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);\n}\n.ea-tabs_wrap.ea-tabs_wrap--border-card .ea-tabs_tab-wrap {\n background-color: #f5f7fa;\n border-bottom: 1px solid #e4e7ed;\n}\n.ea-tabs_wrap.ea-tabs_wrap--border-card .ea-tabs_tab-bottom-bar {\n height: 1px;\n bottom: -1px;\n background-color: white;\n}\n";
|
|
@@ -1,212 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-tag_wrap {
|
|
6
|
-
display: inline-block;
|
|
7
|
-
height: 2rem;
|
|
8
|
-
line-height: 30px;
|
|
9
|
-
white-space: nowrap;
|
|
10
|
-
padding: 0 0.625rem;
|
|
11
|
-
border-width: 1px;
|
|
12
|
-
border-style: solid;
|
|
13
|
-
border-radius: 4px;
|
|
14
|
-
}
|
|
15
|
-
.ea-tag_wrap.ea-tag--default {
|
|
16
|
-
color: #409eff;
|
|
17
|
-
background-color: #ecf5ff;
|
|
18
|
-
border-color: #dcdfe6;
|
|
19
|
-
}
|
|
20
|
-
.ea-tag_wrap.ea-tag--default.ea-tag--dark {
|
|
21
|
-
color: #fff;
|
|
22
|
-
background-color: #409eff;
|
|
23
|
-
border-color: #409eff;
|
|
24
|
-
}
|
|
25
|
-
.ea-tag_wrap.ea-tag--default.ea-tag--plain {
|
|
26
|
-
color: #409eff;
|
|
27
|
-
background-color: #fff;
|
|
28
|
-
border-color: #dcdfe6;
|
|
29
|
-
}
|
|
30
|
-
.ea-tag_wrap.ea-tag--success {
|
|
31
|
-
color: #67c23a;
|
|
32
|
-
background-color: #f0f9eb;
|
|
33
|
-
border-color: #e1f3d8;
|
|
34
|
-
}
|
|
35
|
-
.ea-tag_wrap.ea-tag--success.ea-tag--dark {
|
|
36
|
-
color: #fff;
|
|
37
|
-
background-color: #67c23a;
|
|
38
|
-
border-color: #67c23a;
|
|
39
|
-
}
|
|
40
|
-
.ea-tag_wrap.ea-tag--success.ea-tag--plain {
|
|
41
|
-
color: #67c23a;
|
|
42
|
-
background-color: #fff;
|
|
43
|
-
border-color: #e1f3d8;
|
|
44
|
-
}
|
|
45
|
-
.ea-tag_wrap.ea-tag--info {
|
|
46
|
-
color: #909399;
|
|
47
|
-
background-color: #f4f4f5;
|
|
48
|
-
border-color: #e9e9eb;
|
|
49
|
-
}
|
|
50
|
-
.ea-tag_wrap.ea-tag--info.ea-tag--dark {
|
|
51
|
-
color: #fff;
|
|
52
|
-
background-color: #909399;
|
|
53
|
-
border-color: #909399;
|
|
54
|
-
}
|
|
55
|
-
.ea-tag_wrap.ea-tag--info.ea-tag--plain {
|
|
56
|
-
color: #909399;
|
|
57
|
-
background-color: #fff;
|
|
58
|
-
border-color: #e9e9eb;
|
|
59
|
-
}
|
|
60
|
-
.ea-tag_wrap.ea-tag--warning {
|
|
61
|
-
color: #e6a23c;
|
|
62
|
-
background-color: #fdf6ec;
|
|
63
|
-
border-color: #faecd8;
|
|
64
|
-
}
|
|
65
|
-
.ea-tag_wrap.ea-tag--warning.ea-tag--dark {
|
|
66
|
-
color: #fff;
|
|
67
|
-
background-color: #e6a23c;
|
|
68
|
-
border-color: #e6a23c;
|
|
69
|
-
}
|
|
70
|
-
.ea-tag_wrap.ea-tag--warning.ea-tag--plain {
|
|
71
|
-
color: #e6a23c;
|
|
72
|
-
background-color: #fff;
|
|
73
|
-
border-color: #faecd8;
|
|
74
|
-
}
|
|
75
|
-
.ea-tag_wrap.ea-tag--danger {
|
|
76
|
-
color: #f56c6c;
|
|
77
|
-
background-color: #fef0f0;
|
|
78
|
-
border-color: #fbc4c4;
|
|
79
|
-
}
|
|
80
|
-
.ea-tag_wrap.ea-tag--danger.ea-tag--dark {
|
|
81
|
-
color: #fff;
|
|
82
|
-
background-color: #f56c6c;
|
|
83
|
-
border-color: #f56c6c;
|
|
84
|
-
}
|
|
85
|
-
.ea-tag_wrap.ea-tag--danger.ea-tag--plain {
|
|
86
|
-
color: #f56c6c;
|
|
87
|
-
background-color: #fff;
|
|
88
|
-
border-color: #fbc4c4;
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
|
-
const closeDom = () => {
|
|
93
|
-
const closeIcon = document.createElement('i');
|
|
94
|
-
closeIcon.className = 'icon-cancel-circled2';
|
|
95
|
-
closeIcon.style.cssText = `
|
|
96
|
-
font-size: 1rem;
|
|
97
|
-
margin-left: 0.5rem;
|
|
98
|
-
cursor: pointer;
|
|
99
|
-
`;
|
|
100
|
-
|
|
101
|
-
return closeIcon;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class EaTag extends Base {
|
|
105
|
-
#wrap;
|
|
106
|
-
#closeSlot;
|
|
107
|
-
constructor() {
|
|
108
|
-
super();
|
|
109
|
-
|
|
110
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
111
|
-
const wrap = document.createElement('div');
|
|
112
|
-
wrap.className = 'ea-tag_wrap';
|
|
113
|
-
|
|
114
|
-
const textSlot = document.createElement('slot');
|
|
115
|
-
wrap.appendChild(textSlot);
|
|
116
|
-
|
|
117
|
-
const closeSlot = document.createElement('slot');
|
|
118
|
-
closeSlot.name = 'close';
|
|
119
|
-
wrap.appendChild(closeSlot);
|
|
120
|
-
|
|
121
|
-
this.#wrap = wrap;
|
|
122
|
-
this.#closeSlot = closeSlot;
|
|
123
|
-
|
|
124
|
-
this.build(shadowRoot, stylesheet);
|
|
125
|
-
this.shadowRoot.appendChild(wrap);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ------- type tag类型样式 -------
|
|
129
|
-
// #region
|
|
130
|
-
get type() {
|
|
131
|
-
return this.getAttribute('type') || "default";
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
set type(value) {
|
|
135
|
-
this.setAttribute('type', value);
|
|
136
|
-
this.#wrap.classList.add(`ea-tag--${value}`);
|
|
137
|
-
}
|
|
138
|
-
// #endregion
|
|
139
|
-
// ------- end -------
|
|
140
|
-
|
|
141
|
-
// ------- closable 是否显示可关闭 -------
|
|
142
|
-
// #region
|
|
143
|
-
get closable() {
|
|
144
|
-
return this.getAttrBoolean('closable');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
set closable(value) {
|
|
148
|
-
this.toggleAttr('closable', value);
|
|
149
|
-
}
|
|
150
|
-
// #endregion
|
|
151
|
-
// ------- end -------
|
|
152
|
-
|
|
153
|
-
// ------- effect 不同主题 -------
|
|
154
|
-
// #region
|
|
155
|
-
get effect() {
|
|
156
|
-
return this.getAttribute('effect') || "light";
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
set effect(value) {
|
|
160
|
-
if (value === "light") return;
|
|
161
|
-
|
|
162
|
-
this.setAttribute('effect', value);
|
|
163
|
-
this.#wrap.classList.add(`ea-tag--${value}`);
|
|
164
|
-
}
|
|
165
|
-
// #endregion
|
|
166
|
-
// ------- end -------
|
|
167
|
-
initCloseEvent() {
|
|
168
|
-
const that = this;
|
|
169
|
-
const closeIcon = closeDom();
|
|
170
|
-
|
|
171
|
-
closeIcon.addEventListener('mouseenter', function (e) {
|
|
172
|
-
closeIcon.className = 'icon-cancel-circled';
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
closeIcon.addEventListener('mouseleave', function (e) {
|
|
176
|
-
closeIcon.className = 'icon-cancel-circled2';
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
closeIcon.addEventListener('click', function (e) {
|
|
180
|
-
that.dispatchEvent(new CustomEvent('close', {
|
|
181
|
-
detail: {
|
|
182
|
-
value: that.innerText
|
|
183
|
-
},
|
|
184
|
-
bubbles: true,
|
|
185
|
-
}));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
this.#closeSlot.appendChild(closeIcon);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
init() {
|
|
192
|
-
const that = this;
|
|
193
|
-
|
|
194
|
-
// tag类型
|
|
195
|
-
this.type = this.type;
|
|
196
|
-
|
|
197
|
-
// 显示可关闭
|
|
198
|
-
this.closable = this.closable;
|
|
199
|
-
if (this.closable) this.initCloseEvent();
|
|
200
|
-
|
|
201
|
-
// 主题
|
|
202
|
-
this.effect = this.effect;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
connectedCallback() {
|
|
206
|
-
this.init();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (!customElements.get('ea-tag')) {
|
|
211
|
-
customElements.define('ea-tag', EaTag);
|
|
212
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaTag extends Base{#e;#t;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-tag_wrap" part="container">\n <slot></slot>\n </div>\n ',this.#e=e.querySelector(".ea-tag_wrap"),this.build(e,stylesheet)}get type(){return this.getAttribute("type")||"default"}set type(e){this.setAttribute("type",e),this.#e.classList.add(`ea-tag--${e}`)}get closable(){return this.getAttrBoolean("closable")}set closable(e){this.toggleAttr("closable",e)}get effect(){return this.getAttribute("effect")||"light"}set effect(e){"light"!==e&&(this.setAttribute("effect",e),this.#e.classList.add(`ea-tag--${e}`))}#s(){if(!this.closable)return;const e=document.createElement("ea-icon");e.icon="icon-cancel-circled2",e.part="close-icon",e.addEventListener("mouseenter",(t=>{e.icon="icon-cancel-circled"})),e.addEventListener("mouseleave",(t=>{e.icon="icon-cancel-circled2"})),e.addEventListener("click",(e=>{this.dispatchEvent(new CustomEvent("close",{detail:{value:this.innerText},bubbles:!0}))})),this.#e.appendChild(e)}connectedCallback(){this.effect=this.effect,this.type=this.type,this.closable=this.closable,this.#s()}}customElements.get("ea-tag")||customElements.define("ea-tag",EaTag);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-tag_wrap {\n display: inline-block;\n height: 2rem;\n line-height: 30px;\n white-space: nowrap;\n padding: 0 0.625rem;\n border-width: 1px;\n border-style: solid;\n border-radius: 4px;\n}\n.ea-tag_wrap ea-icon {\n font-size: 1rem;\n margin-left: 0.5rem;\n cursor: pointer;\n}\n.ea-tag_wrap.ea-tag--default {\n color: #409eff;\n background-color: #ecf5ff;\n border-color: #dcdfe6;\n}\n.ea-tag_wrap.ea-tag--default.ea-tag--dark {\n color: #fff;\n background-color: #409eff;\n border-color: #409eff;\n}\n.ea-tag_wrap.ea-tag--default.ea-tag--plain {\n color: #409eff;\n background-color: #fff;\n border-color: #dcdfe6;\n}\n.ea-tag_wrap.ea-tag--success {\n color: #67c23a;\n background-color: #f0f9eb;\n border-color: #e1f3d8;\n}\n.ea-tag_wrap.ea-tag--success.ea-tag--dark {\n color: #fff;\n background-color: #67c23a;\n border-color: #67c23a;\n}\n.ea-tag_wrap.ea-tag--success.ea-tag--plain {\n color: #67c23a;\n background-color: #fff;\n border-color: #e1f3d8;\n}\n.ea-tag_wrap.ea-tag--info {\n color: #909399;\n background-color: #f4f4f5;\n border-color: #e9e9eb;\n}\n.ea-tag_wrap.ea-tag--info.ea-tag--dark {\n color: #fff;\n background-color: #909399;\n border-color: #909399;\n}\n.ea-tag_wrap.ea-tag--info.ea-tag--plain {\n color: #909399;\n background-color: #fff;\n border-color: #e9e9eb;\n}\n.ea-tag_wrap.ea-tag--warning {\n color: #e6a23c;\n background-color: #fdf6ec;\n border-color: #faecd8;\n}\n.ea-tag_wrap.ea-tag--warning.ea-tag--dark {\n color: #fff;\n background-color: #e6a23c;\n border-color: #e6a23c;\n}\n.ea-tag_wrap.ea-tag--warning.ea-tag--plain {\n color: #e6a23c;\n background-color: #fff;\n border-color: #faecd8;\n}\n.ea-tag_wrap.ea-tag--danger {\n color: #f56c6c;\n background-color: #fef0f0;\n border-color: #fbc4c4;\n}\n.ea-tag_wrap.ea-tag--danger.ea-tag--dark {\n color: #fff;\n background-color: #f56c6c;\n border-color: #f56c6c;\n}\n.ea-tag_wrap.ea-tag--danger.ea-tag--plain {\n color: #f56c6c;\n background-color: #fff;\n border-color: #fbc4c4;\n}\n";
|