easy-component-ui 3.0.14 → 3.0.15
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/dist/assets/icon.css +1 -0
- package/dist/components/Base.js +941 -0
- package/dist/components/ea-alert.js +213 -0
- package/dist/components/ea-avatar.js +164 -0
- package/dist/components/ea-backtop.js +136 -0
- package/dist/components/ea-badge.js +144 -0
- package/dist/components/ea-breadcrumb.js +148 -0
- package/dist/components/ea-button.js +266 -0
- package/dist/components/ea-calendar.js +10 -0
- package/dist/components/ea-calendar2.js +673 -0
- package/dist/components/ea-card.js +121 -0
- package/dist/components/ea-carousel.js +415 -0
- package/dist/components/ea-checkbox.js +446 -0
- package/dist/components/ea-collapse.js +313 -0
- package/dist/components/ea-color-picker.js +888 -0
- package/dist/components/ea-container.js +206 -0
- package/dist/components/ea-countdown.js +142 -0
- package/dist/components/ea-date-picker.js +649 -0
- package/dist/components/ea-descriptions.js +474 -0
- package/dist/components/ea-dialog.js +249 -0
- package/dist/components/ea-drawer.js +216 -0
- package/dist/components/ea-dropdown.js +228 -0
- package/dist/components/ea-empty.js +93 -0
- package/dist/components/ea-icon.js +159 -0
- package/dist/components/ea-image-preview.js +532 -0
- package/dist/components/ea-image.js +327 -0
- package/dist/components/ea-infinite-scroll.js +109 -0
- package/dist/components/ea-input-number.js +367 -0
- package/dist/components/ea-input.js +588 -0
- package/dist/components/ea-layout.js +132 -0
- package/dist/components/ea-link.js +101 -0
- package/dist/components/ea-menu.js +433 -0
- package/dist/components/ea-message-box.js +624 -0
- package/dist/components/ea-message.js +313 -0
- package/dist/components/ea-notification.js +331 -0
- package/dist/components/ea-overlay.js +168 -0
- package/dist/components/ea-page-header.js +108 -0
- package/dist/components/ea-pagination.js +481 -0
- package/dist/components/ea-popconfirm.js +275 -0
- package/dist/components/ea-popover.js +147 -0
- package/dist/components/ea-popper.js +203 -0
- package/dist/components/ea-progress.js +286 -0
- package/dist/components/ea-radio.js +364 -0
- package/dist/components/ea-rate.js +241 -0
- package/dist/components/ea-result.js +100 -0
- package/dist/components/ea-scrollbar.js +235 -0
- package/dist/components/ea-segmented.js +215 -0
- package/dist/components/ea-select.js +609 -0
- package/dist/components/ea-skeleton.js +263 -0
- package/dist/components/ea-slider.js +430 -0
- package/dist/components/ea-space.js +123 -0
- package/dist/components/ea-splitter.js +233 -0
- package/dist/components/ea-statistic.js +74 -0
- package/dist/components/ea-steps.js +346 -0
- package/dist/components/ea-switch.js +271 -0
- package/dist/components/ea-table.js +1137 -0
- package/dist/components/ea-tabs.js +503 -0
- package/dist/components/ea-tag.js +228 -0
- package/dist/components/ea-text.js +113 -0
- package/dist/components/ea-time-picker.js +510 -0
- package/dist/components/ea-timeline.js +185 -0
- package/dist/components/ea-tooltip.js +161 -0
- package/dist/components/ea-tour.js +544 -0
- package/dist/components/ea-transfer.js +949 -0
- package/dist/components/ea-tree.js +1125 -0
- package/dist/components/index.js +60 -0
- package/dist/core/FormBase.js +238 -0
- package/dist/css/ea-alert.style.js +4 -0
- package/dist/css/ea-aside.style.js +4 -0
- package/dist/css/ea-avatar.style.js +4 -0
- package/dist/css/ea-backtop.style.js +4 -0
- package/dist/css/ea-badge.style.js +4 -0
- package/dist/css/ea-breadcrumb-item.style.js +4 -0
- package/dist/css/ea-breadcrumb.style.js +4 -0
- package/dist/css/ea-button-group.style.js +4 -0
- package/dist/css/ea-button.style.js +4 -0
- package/dist/css/ea-calendar.style.js +4 -0
- package/dist/css/ea-card.style.js +4 -0
- package/dist/css/ea-carousel-item.style.js +4 -0
- package/dist/css/ea-carousel.style.js +4 -0
- package/dist/css/ea-check-tag.style.js +4 -0
- package/dist/css/ea-checkbox-group.style.js +4 -0
- package/dist/css/ea-checkbox.style.js +4 -0
- package/dist/css/ea-col.style.js +4 -0
- package/dist/css/ea-collapse-item.style.js +4 -0
- package/dist/css/ea-collapse.style.js +4 -0
- package/dist/css/ea-color-picker-panel.style.js +4 -0
- package/dist/css/ea-color-picker.style.js +4 -0
- package/dist/css/ea-container.style.js +4 -0
- package/dist/css/ea-date-picker.style.js +4 -0
- package/dist/css/ea-descriptions-item.style.js +4 -0
- package/dist/css/ea-descriptions.style.js +4 -0
- package/dist/css/ea-dialog.style.js +4 -0
- package/dist/css/ea-drawer.style.js +4 -0
- package/dist/css/ea-dropdown-item.style.js +4 -0
- package/dist/css/ea-dropdown-menu.style.js +4 -0
- package/dist/css/ea-dropdown.style.js +4 -0
- package/dist/css/ea-empty.style.js +4 -0
- package/dist/css/ea-footer.style.js +4 -0
- package/dist/css/ea-header.style.js +4 -0
- package/dist/css/ea-icon.style.js +4 -0
- package/dist/css/ea-image-preview.style.js +4 -0
- package/dist/css/ea-image.style.js +4 -0
- package/dist/css/ea-infinite-scroll.style.js +4 -0
- package/dist/css/ea-input-number.style.js +4 -0
- package/dist/css/ea-input.style.js +4 -0
- package/dist/css/ea-link.style.js +4 -0
- package/dist/css/ea-main.style.js +4 -0
- package/dist/css/ea-menu-item-group.style.js +4 -0
- package/dist/css/ea-menu-item.style.js +4 -0
- package/dist/css/ea-menu.style.js +4 -0
- package/dist/css/ea-message-box.style.js +4 -0
- package/dist/css/ea-message.style.js +4 -0
- package/dist/css/ea-notification.style.js +4 -0
- package/dist/css/ea-option-gropu.style.js +4 -0
- package/dist/css/ea-option.style.js +4 -0
- package/dist/css/ea-overlay.style.js +4 -0
- package/dist/css/ea-page-header.style.js +4 -0
- package/dist/css/ea-pagination.style.js +4 -0
- package/dist/css/ea-popconfirm.style.js +4 -0
- package/dist/css/ea-popover.style.js +4 -0
- package/dist/css/ea-popper.style.js +4 -0
- package/dist/css/ea-progress.style.js +4 -0
- package/dist/css/ea-radio-group.style.js +4 -0
- package/dist/css/ea-radio.style.js +4 -0
- package/dist/css/ea-rate.style.js +4 -0
- package/dist/css/ea-result.style.js +4 -0
- package/dist/css/ea-row.style.js +4 -0
- package/dist/css/ea-scrollbar.style.js +4 -0
- package/dist/css/ea-segmented.style.js +4 -0
- package/dist/css/ea-select.style.js +4 -0
- package/dist/css/ea-skeleton-item.style.js +4 -0
- package/dist/css/ea-skeleton.style.js +4 -0
- package/dist/css/ea-slider.style.js +4 -0
- package/dist/css/ea-space.style.js +4 -0
- package/dist/css/ea-splitter-bar.style.js +4 -0
- package/dist/css/ea-splitter-panel.style.js +4 -0
- package/dist/css/ea-splitter.style.js +4 -0
- package/dist/css/ea-statistic.style.js +4 -0
- package/dist/css/ea-step.style.js +4 -0
- package/dist/css/ea-steps.style.js +4 -0
- package/dist/css/ea-sub-menu.style.js +4 -0
- package/dist/css/ea-switch.style.js +4 -0
- package/dist/css/ea-tab-panel.style.js +4 -0
- package/dist/css/ea-tab.style.js +4 -0
- package/dist/css/ea-table-column.style.js +4 -0
- package/dist/css/ea-table.style.js +4 -0
- package/dist/css/ea-tabs.style.js +4 -0
- package/dist/css/ea-tag.style.js +4 -0
- package/dist/css/ea-text.style.js +4 -0
- package/dist/css/ea-time-picker.style.js +4 -0
- package/dist/css/ea-timeline-item.style.js +4 -0
- package/dist/css/ea-timeline.style.js +4 -0
- package/dist/css/ea-tooltip.style.js +4 -0
- package/dist/css/ea-tour-step.style.js +4 -0
- package/dist/css/ea-tour.style.js +4 -0
- package/dist/css/ea-transfer.style.js +5 -0
- package/dist/css/ea-tree.style.js +6 -0
- package/dist/css/ea-ui-component.style.js +4 -0
- package/dist/favicon.ico +0 -0
- package/dist/utils/Color.js +439 -0
- package/dist/utils/I18nManager.js +218 -0
- package/dist/utils/Utils.js +65 -0
- package/dist/utils/Variables.js +12 -0
- package/dist/utils/parseTime.js +73 -0
- package/dist/utils/timeout.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var z = (s) => {
|
|
3
|
+
throw TypeError(s);
|
|
4
|
+
};
|
|
5
|
+
var T = (s, i, e) => i in s ? N(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
6
|
+
var B = (s, i, e) => T(s, typeof i != "symbol" ? i + "" : i, e), R = (s, i, e) => i.has(s) || z("Cannot " + e);
|
|
7
|
+
var t = (s, i, e) => (R(s, i, "read from private field"), e ? e.call(s) : i.get(s)), a = (s, i, e) => i.has(s) ? z("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(s) : i.set(s, e), o = (s, i, e, l) => (R(s, i, "write to private field"), l ? l.call(s, e) : i.set(s, e), e);
|
|
8
|
+
import { F as $ } from "../core/FormBase.js";
|
|
9
|
+
import { s as I } from "../css/ea-checkbox.style.js";
|
|
10
|
+
import { s as F } from "../css/ea-checkbox-group.style.js";
|
|
11
|
+
var h, r, x, p, n, g, f, A, V;
|
|
12
|
+
class G extends $ {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
/** @type {HTMLElement} */
|
|
16
|
+
a(this, h);
|
|
17
|
+
/** @type {HTMLElement} */
|
|
18
|
+
a(this, r);
|
|
19
|
+
/** @type {HTMLElement} */
|
|
20
|
+
a(this, x);
|
|
21
|
+
/** @type {HTMLElement} */
|
|
22
|
+
a(this, p);
|
|
23
|
+
/** @type {AbortController} */
|
|
24
|
+
a(this, n, new AbortController());
|
|
25
|
+
B(this, "state", this.properties({
|
|
26
|
+
size: {
|
|
27
|
+
type: ["small", "default", "large"],
|
|
28
|
+
default: "",
|
|
29
|
+
observer: (e) => {
|
|
30
|
+
this.updateContainerClasslist();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "",
|
|
36
|
+
observer: (e) => {
|
|
37
|
+
t(this, r).value = e, t(this, g).call(this);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "",
|
|
43
|
+
observer: (e) => {
|
|
44
|
+
t(this, p).textContent = e;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
checked: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: !1,
|
|
50
|
+
observer: (e) => {
|
|
51
|
+
t(this, r).checked = e, t(this, g).call(this), this.updateContainerClasslist();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
disabled: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: !1,
|
|
57
|
+
observer: (e) => {
|
|
58
|
+
t(this, r).disabled = e, this.updateContainerClasslist();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
indeterminate: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: !1,
|
|
64
|
+
observer: (e) => {
|
|
65
|
+
this.updateContainerClasslist();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
border: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: !1,
|
|
71
|
+
observer: (e) => {
|
|
72
|
+
this.updateContainerClasslist();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"limit-disabled": {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: !1,
|
|
78
|
+
observer: (e) => {
|
|
79
|
+
t(this, r).disabled = e, this.updateContainerClasslist();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: !1,
|
|
85
|
+
observer: (e) => {
|
|
86
|
+
t(this, r).toggleAttribute("required", e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
/**
|
|
91
|
+
* 更新 checkbox 值
|
|
92
|
+
*/
|
|
93
|
+
a(this, g, () => {
|
|
94
|
+
this.checked ? this.setValue(this.value || this.hasAttribute("checked"), "value") : this.setValue(null, "value");
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* 派发 change 事件
|
|
98
|
+
*/
|
|
99
|
+
a(this, f, () => {
|
|
100
|
+
this.emit("change", {
|
|
101
|
+
detail: {
|
|
102
|
+
value: this.value,
|
|
103
|
+
checked: !!this.checked
|
|
104
|
+
},
|
|
105
|
+
bubbles: !0
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* change 事件
|
|
110
|
+
*/
|
|
111
|
+
a(this, A, () => {
|
|
112
|
+
this.checked = t(this, r).checked, t(this, f).call(this);
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* enter 事件
|
|
116
|
+
*/
|
|
117
|
+
a(this, V, (e) => {
|
|
118
|
+
e.key === "Enter" && (t(this, r).checked = !this.checked, t(this, f).call(this));
|
|
119
|
+
});
|
|
120
|
+
this.stylesheet = I, this.$render();
|
|
121
|
+
}
|
|
122
|
+
static get observedAttributes() {
|
|
123
|
+
return [
|
|
124
|
+
...super.observedAttributes,
|
|
125
|
+
"size",
|
|
126
|
+
"value",
|
|
127
|
+
"label",
|
|
128
|
+
"name",
|
|
129
|
+
"checked",
|
|
130
|
+
"disabled",
|
|
131
|
+
"indeterminate",
|
|
132
|
+
"border",
|
|
133
|
+
"limit-disabled",
|
|
134
|
+
"required"
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 获取 classlist 列表
|
|
139
|
+
* @return {string} 属性值
|
|
140
|
+
*/
|
|
141
|
+
updateContainerClasslist() {
|
|
142
|
+
const e = this.computedClasslist(
|
|
143
|
+
"ea-checkbox",
|
|
144
|
+
{
|
|
145
|
+
["--" + this.size]: this.size
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
checked: this.checked,
|
|
149
|
+
disabled: this.disabled,
|
|
150
|
+
indeterminate: this.indeterminate,
|
|
151
|
+
"limit-disabled": this["limit-disabled"],
|
|
152
|
+
border: this.border
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
return t(this, h).className = e, e;
|
|
156
|
+
}
|
|
157
|
+
$render() {
|
|
158
|
+
const e = Math.random().toString(36).substring(2, 15);
|
|
159
|
+
this.shadowRoot.innerHTML = `
|
|
160
|
+
<label class="ea-checkbox" part="container" for="${this.getAttribute("id") || e}">
|
|
161
|
+
<input id="${this.getAttribute("id") || e}" type="checkbox" class="ea-checkbox__orignal" part="orignal" />
|
|
162
|
+
<span class="ea-checkbox__inner" part="input" tabindex="1"></span>
|
|
163
|
+
<span class="ea-checkbox__label" part="label" tabindex="1">
|
|
164
|
+
<slot></slot>
|
|
165
|
+
</span>
|
|
166
|
+
</label>
|
|
167
|
+
`, o(this, h, this.shadowRoot.querySelector(".ea-checkbox")), o(this, p, this.shadowRoot.querySelector(".ea-checkbox__label")), o(this, x, this.shadowRoot.querySelector(".ea-checkbox__inner")), o(this, r, this.shadowRoot.querySelector(".ea-checkbox__orignal"));
|
|
168
|
+
}
|
|
169
|
+
connectedCallback() {
|
|
170
|
+
var e;
|
|
171
|
+
super.connectedCallback(), (e = t(this, n)) == null || e.abort(), o(this, n, new AbortController()), t(this, r).addEventListener("change", t(this, A), {
|
|
172
|
+
signal: t(this, n).signal
|
|
173
|
+
}), this.addEventListener("keydown", t(this, V), {
|
|
174
|
+
signal: t(this, n).signal
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
$beforeUnmounted() {
|
|
178
|
+
var e;
|
|
179
|
+
(e = t(this, n)) == null || e.abort();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 获取验证目标元素
|
|
183
|
+
* @returns {HTMLElement}
|
|
184
|
+
*/
|
|
185
|
+
get validationTarget() {
|
|
186
|
+
return t(this, h);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 更新表单验证状态
|
|
190
|
+
* checkbox 的验证逻辑:当 required 为 true 时,必须处于选中状态
|
|
191
|
+
*/
|
|
192
|
+
updateValidity() {
|
|
193
|
+
this.required && !this.checked ? this.internals.setValidity(
|
|
194
|
+
{ valueMissing: !0 },
|
|
195
|
+
"请勾选此项",
|
|
196
|
+
t(this, h)
|
|
197
|
+
) : this.internals.setValidity({}, "", t(this, h));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 检查表单字段的有效性
|
|
201
|
+
* @returns {boolean}
|
|
202
|
+
*/
|
|
203
|
+
checkValidity() {
|
|
204
|
+
return this.updateValidity(), this.internals.validity.valid;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 报告表单字段的有效性(显示验证提示)
|
|
208
|
+
* @returns {boolean}
|
|
209
|
+
*/
|
|
210
|
+
reportValidity() {
|
|
211
|
+
return this.updateValidity(), this.internals.reportValidity();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
h = new WeakMap(), r = new WeakMap(), x = new WeakMap(), p = new WeakMap(), n = new WeakMap(), g = new WeakMap(), f = new WeakMap(), A = new WeakMap(), V = new WeakMap();
|
|
215
|
+
window.customElements.get("ea-checkbox") || window.customElements.define("ea-checkbox", G);
|
|
216
|
+
var u, k, m, d, y, v, w, S, E, C, c, q;
|
|
217
|
+
class H extends $ {
|
|
218
|
+
constructor() {
|
|
219
|
+
super();
|
|
220
|
+
/** @type {HTMLElement} */
|
|
221
|
+
a(this, u);
|
|
222
|
+
/** @type {HTMLSlotElement} */
|
|
223
|
+
a(this, k);
|
|
224
|
+
/** @type {HTMLLabelElement} */
|
|
225
|
+
a(this, m);
|
|
226
|
+
/** @type {AbortController} */
|
|
227
|
+
a(this, d, new AbortController());
|
|
228
|
+
B(this, "state", this.properties({
|
|
229
|
+
label: {
|
|
230
|
+
type: String,
|
|
231
|
+
default: "",
|
|
232
|
+
observer: (e) => {
|
|
233
|
+
t(this, m).textContent = e;
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
name: {
|
|
237
|
+
type: String,
|
|
238
|
+
default: "",
|
|
239
|
+
observer: (e) => {
|
|
240
|
+
t(this, y).call(this);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
value: {
|
|
244
|
+
props: !0,
|
|
245
|
+
type: Array,
|
|
246
|
+
default: [],
|
|
247
|
+
observer: (e) => {
|
|
248
|
+
t(this, v).call(this), t(this, c).call(this);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
disabled: {
|
|
252
|
+
type: Boolean,
|
|
253
|
+
default: !1,
|
|
254
|
+
observer: (e) => {
|
|
255
|
+
this.querySelectorAll("ea-checkbox").forEach((l) => {
|
|
256
|
+
l.toggleAttribute("disabled", e);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
min: {
|
|
261
|
+
type: Number,
|
|
262
|
+
default: 0,
|
|
263
|
+
observer: (e) => {
|
|
264
|
+
t(this, c).call(this);
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
max: {
|
|
268
|
+
type: Number,
|
|
269
|
+
default: 1 / 0,
|
|
270
|
+
observer: (e) => {
|
|
271
|
+
t(this, c).call(this);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
size: {
|
|
275
|
+
type: ["small", "default", "large"],
|
|
276
|
+
default: "",
|
|
277
|
+
observer: (e) => {
|
|
278
|
+
t(this, q).call(this);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
required: {
|
|
282
|
+
type: Boolean,
|
|
283
|
+
default: !1
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
/**
|
|
287
|
+
* 更新子组件的 name 属性,因为没有限制 name 必填
|
|
288
|
+
*/
|
|
289
|
+
a(this, y, () => {
|
|
290
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
291
|
+
e.setAttribute("name", this.name);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
/**
|
|
295
|
+
* 更新子组件的初始勾选状态
|
|
296
|
+
*/
|
|
297
|
+
a(this, v, () => {
|
|
298
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
299
|
+
const l = this.value.includes(e.getAttribute("value"));
|
|
300
|
+
e.toggleAttribute("checked", l);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
/**
|
|
304
|
+
* 更新子组件
|
|
305
|
+
* @param {Boolean} isChecked
|
|
306
|
+
* @param {any} updateValue
|
|
307
|
+
*/
|
|
308
|
+
a(this, w, (e, l) => {
|
|
309
|
+
e ? this.value.some(
|
|
310
|
+
(_) => _.value === l
|
|
311
|
+
) || this.value.push(l) : this.value = this.value.filter((b) => b !== l);
|
|
312
|
+
});
|
|
313
|
+
/**
|
|
314
|
+
* 更新子组件在带有 Min 下的禁用状态
|
|
315
|
+
*/
|
|
316
|
+
a(this, S, () => {
|
|
317
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
318
|
+
const l = e.hasAttribute("checked");
|
|
319
|
+
e.toggleAttribute("limit-disabled", l);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
/**
|
|
323
|
+
* 更新子组件在带有 Max 下的禁用状态
|
|
324
|
+
*/
|
|
325
|
+
a(this, E, () => {
|
|
326
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
327
|
+
const l = e.hasAttribute("checked");
|
|
328
|
+
e.toggleAttribute("limit-disabled", !l);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
/**
|
|
332
|
+
* 还原子组件的禁用状态
|
|
333
|
+
*/
|
|
334
|
+
a(this, C, () => {
|
|
335
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
336
|
+
e.toggleAttribute("limit-disabled", !1);
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
/**
|
|
340
|
+
* 更新子组件的禁用状态
|
|
341
|
+
*/
|
|
342
|
+
a(this, c, () => {
|
|
343
|
+
this.value.length <= this.min ? t(this, S).call(this) : this.value.length >= this.max ? t(this, E).call(this) : this.max < 1 / 0 && this.min === 0 ? t(this, C).call(this) : t(this, C).call(this);
|
|
344
|
+
});
|
|
345
|
+
/**
|
|
346
|
+
* 更新子组件的尺寸
|
|
347
|
+
*/
|
|
348
|
+
a(this, q, () => {
|
|
349
|
+
this.querySelectorAll("ea-checkbox").forEach((e) => {
|
|
350
|
+
e.setAttribute("size", this.size);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
this.stylesheet = F, this.$render();
|
|
354
|
+
}
|
|
355
|
+
static get observedAttributes() {
|
|
356
|
+
return [
|
|
357
|
+
...super.observedAttributes,
|
|
358
|
+
"label",
|
|
359
|
+
"name",
|
|
360
|
+
"value",
|
|
361
|
+
"disabled",
|
|
362
|
+
"min",
|
|
363
|
+
"max",
|
|
364
|
+
"size",
|
|
365
|
+
"required"
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* 获取 classlist 列表
|
|
370
|
+
* @return {string} 属性值
|
|
371
|
+
*/
|
|
372
|
+
updateContainerClasslist() {
|
|
373
|
+
const e = this.computedClasslist("ea-checkbox-group", {
|
|
374
|
+
// ['--' + this.type]: this.type,
|
|
375
|
+
});
|
|
376
|
+
return t(this, u).className = e, e;
|
|
377
|
+
}
|
|
378
|
+
$render() {
|
|
379
|
+
this.shadowRoot.innerHTML = `
|
|
380
|
+
<label class='ea-checkbox-group__form-label' part='form-label'></label>
|
|
381
|
+
<div class='ea-checkbox-group' part='container'>
|
|
382
|
+
<slot></slot>
|
|
383
|
+
</div>
|
|
384
|
+
`, o(this, m, this.shadowRoot.querySelector(
|
|
385
|
+
".ea-checkbox-group__form-label"
|
|
386
|
+
)), o(this, u, this.shadowRoot.querySelector(".ea-checkbox-group")), o(this, k, this.shadowRoot.querySelector("slot"));
|
|
387
|
+
}
|
|
388
|
+
connectedCallback() {
|
|
389
|
+
var b;
|
|
390
|
+
super.connectedCallback(), (b = t(this, d)) == null || b.abort(), o(this, d, new AbortController()), this.name || (this.name = Math.random().toString(36).substring(2, 15));
|
|
391
|
+
const e = () => {
|
|
392
|
+
t(this, y).call(this), t(this, v).call(this), t(this, c).call(this);
|
|
393
|
+
}, l = (_) => {
|
|
394
|
+
const { checked: L, value: M } = _.detail;
|
|
395
|
+
t(this, w).call(this, L, M), t(this, c).call(this);
|
|
396
|
+
};
|
|
397
|
+
t(this, k).addEventListener("slotchange", e, {
|
|
398
|
+
signal: t(this, d).signal
|
|
399
|
+
}), this.addEventListener("change", l, {
|
|
400
|
+
signal: t(this, d).signal
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
$beforeUnmounted() {
|
|
404
|
+
var e;
|
|
405
|
+
(e = t(this, d)) == null || e.abort();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* 获取验证目标元素
|
|
409
|
+
* 返回第一个 ea-checkbox
|
|
410
|
+
* @returns {HTMLElement}
|
|
411
|
+
*/
|
|
412
|
+
get validationTarget() {
|
|
413
|
+
return this.querySelector("ea-checkbox") || t(this, u);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* 更新表单验证状态
|
|
417
|
+
*/
|
|
418
|
+
updateValidity() {
|
|
419
|
+
const e = Array.isArray(this.value) && this.value.length > 0;
|
|
420
|
+
this.required && !e ? this.internals.setValidity(
|
|
421
|
+
{ valueMissing: !0 },
|
|
422
|
+
"请至少选择一个选项",
|
|
423
|
+
this
|
|
424
|
+
) : this.internals.setValidity({}, "", this);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 检查表单字段的有效性
|
|
428
|
+
* @returns {boolean}
|
|
429
|
+
*/
|
|
430
|
+
checkValidity() {
|
|
431
|
+
return this.updateValidity(), this.internals.validity.valid;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* 报告表单字段的有效性(显示验证提示)
|
|
435
|
+
* @returns {boolean}
|
|
436
|
+
*/
|
|
437
|
+
reportValidity() {
|
|
438
|
+
return this.updateValidity(), this.internals.reportValidity();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
u = new WeakMap(), k = new WeakMap(), m = new WeakMap(), d = new WeakMap(), y = new WeakMap(), v = new WeakMap(), w = new WeakMap(), S = new WeakMap(), E = new WeakMap(), C = new WeakMap(), c = new WeakMap(), q = new WeakMap();
|
|
442
|
+
window.customElements.get("ea-checkbox-group") || window.customElements.define("ea-checkbox-group", H);
|
|
443
|
+
export {
|
|
444
|
+
G as EaCheckbox,
|
|
445
|
+
H as EaCheckboxGroup
|
|
446
|
+
};
|