easy-component-ui 3.0.5 → 3.0.6

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.
@@ -1,22 +1,24 @@
1
- var m = Object.defineProperty;
2
- var c = (t) => {
3
- throw TypeError(t);
1
+ var f = Object.defineProperty;
2
+ var p = (s) => {
3
+ throw TypeError(s);
4
4
  };
5
- var f = (t, i, e) => i in t ? m(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
6
- var d = (t, i, e) => f(t, typeof i != "symbol" ? i + "" : i, e), p = (t, i, e) => i.has(t) || c("Cannot " + e);
7
- var s = (t, i, e) => (p(t, i, "read from private field"), e ? e.call(t) : i.get(t)), l = (t, i, e) => i.has(t) ? c("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(t) : i.set(t, e), h = (t, i, e, r) => (p(t, i, "write to private field"), r ? r.call(t, e) : i.set(t, e), e);
8
- import { F as y } from "../core/FormBase.js";
9
- import { s as C } from "../css/ea-button.style.js";
10
- import { B as g } from "./Base.js";
11
- import { s as v } from "../css/ea-button-group.style.js";
12
- var a, n, u;
13
- class w extends y {
5
+ var y = (s, i, t) => i in s ? f(s, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[i] = t;
6
+ var d = (s, i, t) => y(s, typeof i != "symbol" ? i + "" : i, t), b = (s, i, t) => i.has(s) || p("Cannot " + t);
7
+ var e = (s, i, t) => (b(s, i, "read from private field"), t ? t.call(s) : i.get(s)), u = (s, i, t) => i.has(s) ? p("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(s) : i.set(s, t), h = (s, i, t, o) => (b(s, i, "write to private field"), o ? o.call(s, t) : i.set(s, t), t);
8
+ import { F as C } from "../core/FormBase.js";
9
+ import { s as g } from "../css/ea-button.style.js";
10
+ import { B as v } from "./Base.js";
11
+ import { s as w } from "../css/ea-button-group.style.js";
12
+ var a, l, n, c;
13
+ class A extends C {
14
14
  constructor() {
15
15
  super();
16
16
  /** @type {HTMLButtonElement | HTMLLinkElement} */
17
- l(this, a);
17
+ u(this, a);
18
+ /** @type {HTMLIconElement} */
19
+ u(this, l);
18
20
  /** @type {AbortController} */
19
- l(this, n);
21
+ u(this, n);
20
22
  /**
21
23
  * @typedef {Object} state
22
24
  * @property {boolean} disabled
@@ -36,106 +38,103 @@ class w extends y {
36
38
  disabled: {
37
39
  type: Boolean,
38
40
  default: !1,
39
- observer: (e) => {
40
- s(this, a).className = this.updateContainerClasslist();
41
+ observer: (t) => {
42
+ e(this, a).className = this.updateContainerClasslist();
41
43
  }
42
44
  },
43
45
  type: {
44
46
  type: ["normal", "primary", "success", "warning", "danger"],
45
47
  default: "normal",
46
- observer: (e) => {
47
- s(this, a).className = this.updateContainerClasslist();
48
+ observer: (t) => {
49
+ e(this, a).className = this.updateContainerClasslist();
48
50
  }
49
51
  },
50
52
  text: {
51
53
  type: Boolean,
52
54
  default: !1,
53
- observer: (e) => {
54
- s(this, a).className = this.updateContainerClasslist();
55
+ observer: (t) => {
56
+ e(this, a).className = this.updateContainerClasslist();
55
57
  }
56
58
  },
57
59
  plain: {
58
60
  type: Boolean,
59
61
  default: !1,
60
- observer: (e) => {
61
- s(this, a).className = this.updateContainerClasslist();
62
+ observer: (t) => {
63
+ e(this, a).className = this.updateContainerClasslist();
62
64
  }
63
65
  },
64
66
  round: {
65
67
  type: Boolean,
66
68
  default: !1,
67
- observer: (e) => {
68
- s(this, a).className = this.updateContainerClasslist();
69
+ observer: (t) => {
70
+ e(this, a).className = this.updateContainerClasslist();
69
71
  }
70
72
  },
71
73
  circle: {
72
74
  type: Boolean,
73
75
  default: !1,
74
- observer: (e) => {
75
- s(this, a).className = this.updateContainerClasslist();
76
+ observer: (t) => {
77
+ e(this, a).className = this.updateContainerClasslist();
76
78
  }
77
79
  },
78
80
  link: {
79
81
  type: Boolean,
80
82
  default: !1,
81
- observer: (e) => {
82
- s(this, a).className = this.updateContainerClasslist();
83
+ observer: (t) => {
84
+ this.$render(), e(this, a).href = this.getAttribute("href"), e(this, a).className = this.updateContainerClasslist();
83
85
  }
84
86
  },
85
87
  href: {
86
88
  type: String,
87
89
  default: "",
88
- observer: (e) => {
89
- s(this, a).className = this.updateContainerClasslist(), s(this, a).setAttribute("href", e);
90
+ observer: (t) => {
91
+ e(this, a).className = this.updateContainerClasslist(), e(this, a).setAttribute("href", t);
90
92
  }
91
93
  },
92
94
  size: {
93
95
  type: ["small", "medium", "large"],
94
96
  default: "medium",
95
- observer: (e) => {
96
- s(this, a).className = this.updateContainerClasslist();
97
+ observer: (t) => {
98
+ e(this, a).className = this.updateContainerClasslist();
97
99
  }
98
100
  },
99
101
  loading: {
100
102
  type: Boolean,
101
103
  default: !1,
102
- observer: (e) => {
103
- var r;
104
- if (e = e === "true" || e === !0, this.toggleAttribute("disabled", e), e) {
105
- const o = document.createElement("ea-icon");
106
- o.id = "ea-loading-icon", o.icon = "icon-cw animate-spin", o.size = this.size, o.part = "loading-icon", s(this, a).insertBefore(o, s(this, a).firstChild);
104
+ observer: (t) => {
105
+ var o;
106
+ if (t = t === "true" || t === !0, this.toggleAttribute("disabled", t), t) {
107
+ const r = document.createElement("ea-icon");
108
+ r.id = "ea-loading-icon", r.icon = "icon-cw animate-spin", r.size = this.size, r.part = "loading-icon", e(this, a).insertBefore(r, e(this, a).firstChild);
107
109
  } else {
108
- const o = (r = s(this, a)) == null ? void 0 : r.querySelectorAll("#ea-loading-icon");
109
- (o == null ? void 0 : o.length) > 0 && (o == null || o.forEach((b) => b.remove()));
110
+ const r = (o = e(this, a)) == null ? void 0 : o.querySelectorAll("#ea-loading-icon");
111
+ (r == null ? void 0 : r.length) > 0 && (r == null || r.forEach((m) => m.remove()));
110
112
  }
111
- s(this, a).className = this.updateContainerClasslist();
113
+ e(this, a).className = this.updateContainerClasslist();
112
114
  }
113
115
  },
114
116
  icon: {
115
117
  type: String,
116
118
  default: "",
117
- observer: (e) => {
118
- if (e && !s(this, a).querySelector("ea-icon")) {
119
- const r = document.createElement("ea-icon");
120
- r.size = this.size, r.icon = e, r.part = "icon", s(this, a).insertBefore(r, s(this, a).firstChild);
121
- }
119
+ observer: (t) => {
120
+ e(this, l).setAttribute("icon", t), e(this, l).setAttribute("size", this.size), e(this, a).className = this.updateContainerClasslist();
122
121
  }
123
122
  },
124
123
  "button-type": {
125
124
  type: ["button", "submit", "reset"],
126
125
  default: "button",
127
- observer: (e) => {
128
- s(this, a).type = e;
126
+ observer: (t) => {
127
+ e(this, a).type = t;
129
128
  }
130
129
  }
131
130
  }));
132
131
  /**
133
132
  * @param {KeyboardEvent} e
134
133
  */
135
- l(this, u, (e) => {
136
- e.key === "Enter" && this.click();
134
+ u(this, c, (t) => {
135
+ t.key === "Enter" && this.click();
137
136
  });
138
- this.stylesheet = C, this.$render();
137
+ this.stylesheet = g, this.$render();
139
138
  }
140
139
  static get observedAttributes() {
141
140
  return [
@@ -159,46 +158,52 @@ class w extends y {
159
158
  * @return {string} 属性值
160
159
  */
161
160
  updateContainerClasslist() {
162
- return this.computedClasslist("ea-button", {
163
- ["--" + this.type]: this.type,
164
- "--disabled": this.disabled || this.loading,
165
- "--text": this.text || this.link,
166
- "--plain": this.plain,
167
- "--round": this.round,
168
- "--circle": this.circle,
169
- ["--" + this.size]: this.size
170
- });
161
+ var t;
162
+ return this.computedClasslist(
163
+ "ea-button",
164
+ {
165
+ ["--" + this.type]: this.type,
166
+ "--disabled": this.disabled || this.loading,
167
+ "--text": this.text || this.link,
168
+ "--plain": this.plain,
169
+ "--round": this.round,
170
+ "--circle": this.circle,
171
+ ["--" + this.size]: this.size
172
+ },
173
+ { icon: (t = this.icon) == null ? void 0 : t.length }
174
+ );
171
175
  }
172
176
  $render() {
173
- const e = this.getAttrBoolean("link") ? "a" : "button";
177
+ const t = this.getAttrBoolean("link") ? "a" : "button";
174
178
  this.shadowRoot.innerHTML = `
175
- <${e} class="ea-button" part="container" tabindex="-1">
179
+ <${t} class="ea-button" part="container" tabindex="-1">
180
+ <ea-icon class="ea-button__icon" part="icon"></ea-icon>
176
181
  <slot></slot>
177
- </${e}>
178
- `, h(this, a, this.shadowRoot.querySelector(".ea-button"));
182
+ </${t}>
183
+ `, h(this, a, this.shadowRoot.querySelector(".ea-button")), h(this, l, this.shadowRoot.querySelector(".ea-button__icon")), e(this, a).className = this.updateContainerClasslist();
179
184
  }
180
185
  connectedCallback() {
181
- var e;
182
- super.connectedCallback(), (e = s(this, n)) == null || e.abort(), h(this, n, new AbortController()), this.addEventListener("keypress", s(this, u), {
183
- signal: s(this, n).signal
184
- }), this.addEventListener("click", (r) => {
186
+ var t;
187
+ super.connectedCallback(), (t = e(this, n)) == null || t.abort(), h(this, n, new AbortController()), this.addEventListener("keypress", e(this, c), {
188
+ signal: e(this, n).signal
189
+ }), this.addEventListener("click", (o) => {
185
190
  if (this["button-type"] === "submit") {
186
- const o = this.getForm();
187
- o && (r.preventDefault(), o.dispatchEvent(new Event("submit")));
191
+ const r = this.getForm();
192
+ r && (o.preventDefault(), r.dispatchEvent(new Event("submit")));
188
193
  } else if (this["button-type"] === "reset") {
189
- const o = this.getForm();
190
- o && (r.preventDefault(), o.reset());
194
+ const r = this.getForm();
195
+ r && (o.preventDefault(), r.reset());
191
196
  }
192
- }), this.emit("ea-button-ready");
197
+ });
193
198
  }
194
199
  $beforeUnmounted() {
195
- var e;
196
- (e = s(this, n)) == null || e.abort();
200
+ var t;
201
+ (t = e(this, n)) == null || t.abort();
197
202
  }
198
203
  }
199
- a = new WeakMap(), n = new WeakMap(), u = new WeakMap();
200
- window.customElements.get("ea-button") || window.customElements.define("ea-button", w);
201
- class E extends g {
204
+ a = new WeakMap(), l = new WeakMap(), n = new WeakMap(), c = new WeakMap();
205
+ window.customElements.get("ea-button") || window.customElements.define("ea-button", A);
206
+ class E extends v {
202
207
  constructor() {
203
208
  super();
204
209
  /**
@@ -212,32 +217,32 @@ class E extends g {
212
217
  disabled: {
213
218
  type: Boolean,
214
219
  default: !1,
215
- observer: (e) => {
216
- this.querySelectorAll("ea-button").forEach((r) => {
217
- r.setAttribute("disabled", e);
220
+ observer: (t) => {
221
+ this.querySelectorAll("ea-button").forEach((o) => {
222
+ o.setAttribute("disabled", t);
218
223
  });
219
224
  }
220
225
  },
221
226
  size: {
222
227
  type: ["small", "normal", "large"],
223
228
  default: "normal",
224
- observer: (e) => {
225
- this.querySelectorAll("ea-button").forEach((r) => {
226
- r.setAttribute("size", e);
229
+ observer: (t) => {
230
+ this.querySelectorAll("ea-button").forEach((o) => {
231
+ o.setAttribute("size", t);
227
232
  });
228
233
  }
229
234
  },
230
235
  type: {
231
236
  type: ["primary", "success", "warning", "danger", "normal"],
232
237
  default: "normal",
233
- observer: (e) => {
234
- this.querySelectorAll("ea-button").forEach((r) => {
235
- r.setAttribute("type", e);
238
+ observer: (t) => {
239
+ this.querySelectorAll("ea-button").forEach((o) => {
240
+ o.setAttribute("type", t);
236
241
  });
237
242
  }
238
243
  }
239
244
  }));
240
- this.stylesheet = v, this.$render();
245
+ this.stylesheet = w, this.$render();
241
246
  }
242
247
  static get observedAttributes() {
243
248
  return [...super.observedAttributes, "disabled", "size", "type"];
@@ -255,6 +260,6 @@ class E extends g {
255
260
  }
256
261
  window.customElements.get("ea-button-group") || window.customElements.define("ea-button-group", E);
257
262
  export {
258
- w as EaButton,
263
+ A as EaButton,
259
264
  E as EaButtonGroup
260
265
  };