easy-component-ui 3.0.4 → 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
@@ -30,113 +32,109 @@ class w extends y {
30
32
  * @property {string} size
31
33
  * @property {boolean} loading
32
34
  * @property {string} icon
33
- * @property {boolean} loading
34
35
  */
35
36
  /** @type {state} */
36
37
  d(this, "state", this.properties({
37
38
  disabled: {
38
39
  type: Boolean,
39
40
  default: !1,
40
- observer: (e) => {
41
- s(this, a).className = this.updateContainerClasslist();
41
+ observer: (t) => {
42
+ e(this, a).className = this.updateContainerClasslist();
42
43
  }
43
44
  },
44
45
  type: {
45
46
  type: ["normal", "primary", "success", "warning", "danger"],
46
47
  default: "normal",
47
- observer: (e) => {
48
- s(this, a).className = this.updateContainerClasslist();
48
+ observer: (t) => {
49
+ e(this, a).className = this.updateContainerClasslist();
49
50
  }
50
51
  },
51
52
  text: {
52
53
  type: Boolean,
53
54
  default: !1,
54
- observer: (e) => {
55
- s(this, a).className = this.updateContainerClasslist();
55
+ observer: (t) => {
56
+ e(this, a).className = this.updateContainerClasslist();
56
57
  }
57
58
  },
58
59
  plain: {
59
60
  type: Boolean,
60
61
  default: !1,
61
- observer: (e) => {
62
- s(this, a).className = this.updateContainerClasslist();
62
+ observer: (t) => {
63
+ e(this, a).className = this.updateContainerClasslist();
63
64
  }
64
65
  },
65
66
  round: {
66
67
  type: Boolean,
67
68
  default: !1,
68
- observer: (e) => {
69
- s(this, a).className = this.updateContainerClasslist();
69
+ observer: (t) => {
70
+ e(this, a).className = this.updateContainerClasslist();
70
71
  }
71
72
  },
72
73
  circle: {
73
74
  type: Boolean,
74
75
  default: !1,
75
- observer: (e) => {
76
- s(this, a).className = this.updateContainerClasslist();
76
+ observer: (t) => {
77
+ e(this, a).className = this.updateContainerClasslist();
77
78
  }
78
79
  },
79
80
  link: {
80
81
  type: Boolean,
81
82
  default: !1,
82
- observer: (e) => {
83
- 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();
84
85
  }
85
86
  },
86
87
  href: {
87
88
  type: String,
88
89
  default: "",
89
- observer: (e) => {
90
- 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);
91
92
  }
92
93
  },
93
94
  size: {
94
95
  type: ["small", "medium", "large"],
95
96
  default: "medium",
96
- observer: (e) => {
97
- s(this, a).className = this.updateContainerClasslist();
97
+ observer: (t) => {
98
+ e(this, a).className = this.updateContainerClasslist();
98
99
  }
99
100
  },
100
101
  loading: {
101
102
  type: Boolean,
102
103
  default: !1,
103
- observer: (e) => {
104
- var r;
105
- if (e = e === "true" || e === !0, this.toggleAttribute("disabled", e), e) {
106
- const o = document.createElement("ea-icon");
107
- o.id = "ea-loading-icon", o.icon = "icon-spin6 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);
108
109
  } else {
109
- const o = (r = s(this, a)) == null ? void 0 : r.querySelectorAll("#ea-loading-icon");
110
- (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()));
111
112
  }
112
- s(this, a).className = this.updateContainerClasslist();
113
+ e(this, a).className = this.updateContainerClasslist();
113
114
  }
114
115
  },
115
116
  icon: {
116
117
  type: String,
117
118
  default: "",
118
- observer: (e) => {
119
- if (e && !s(this, a).querySelector("ea-icon")) {
120
- const r = document.createElement("ea-icon");
121
- r.size = this.size, r.icon = e, r.part = "icon", s(this, a).insertBefore(r, s(this, a).firstChild);
122
- }
119
+ observer: (t) => {
120
+ e(this, l).setAttribute("icon", t), e(this, l).setAttribute("size", this.size), e(this, a).className = this.updateContainerClasslist();
123
121
  }
124
122
  },
125
123
  "button-type": {
126
124
  type: ["button", "submit", "reset"],
127
125
  default: "button",
128
- observer: (e) => {
129
- s(this, a).type = e;
126
+ observer: (t) => {
127
+ e(this, a).type = t;
130
128
  }
131
129
  }
132
130
  }));
133
131
  /**
134
132
  * @param {KeyboardEvent} e
135
133
  */
136
- l(this, u, (e) => {
137
- e.key === "Enter" && this.click();
134
+ u(this, c, (t) => {
135
+ t.key === "Enter" && this.click();
138
136
  });
139
- this.stylesheet = C, this.$render();
137
+ this.stylesheet = g, this.$render();
140
138
  }
141
139
  static get observedAttributes() {
142
140
  return [
@@ -160,46 +158,52 @@ class w extends y {
160
158
  * @return {string} 属性值
161
159
  */
162
160
  updateContainerClasslist() {
163
- return this.computedClasslist("ea-button", {
164
- ["--" + this.type]: this.type,
165
- "--disabled": this.disabled || this.loading,
166
- "--text": this.text || this.link,
167
- "--plain": this.plain,
168
- "--round": this.round,
169
- "--circle": this.circle,
170
- ["--" + this.size]: this.size
171
- });
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
+ );
172
175
  }
173
176
  $render() {
174
- const e = this.getAttrBoolean("link") ? "a" : "button";
177
+ const t = this.getAttrBoolean("link") ? "a" : "button";
175
178
  this.shadowRoot.innerHTML = `
176
- <${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>
177
181
  <slot></slot>
178
- </${e}>
179
- `, 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();
180
184
  }
181
185
  connectedCallback() {
182
- var e;
183
- super.connectedCallback(), (e = s(this, n)) == null || e.abort(), h(this, n, new AbortController()), this.addEventListener("keypress", s(this, u), {
184
- signal: s(this, n).signal
185
- }), 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) => {
186
190
  if (this["button-type"] === "submit") {
187
- const o = this.getForm();
188
- o && (r.preventDefault(), o.dispatchEvent(new Event("submit")));
191
+ const r = this.getForm();
192
+ r && (o.preventDefault(), r.dispatchEvent(new Event("submit")));
189
193
  } else if (this["button-type"] === "reset") {
190
- const o = this.getForm();
191
- o && (r.preventDefault(), o.reset());
194
+ const r = this.getForm();
195
+ r && (o.preventDefault(), r.reset());
192
196
  }
193
- }), this.emit("ea-button-ready");
197
+ });
194
198
  }
195
199
  $beforeUnmounted() {
196
- var e;
197
- (e = s(this, n)) == null || e.abort();
200
+ var t;
201
+ (t = e(this, n)) == null || t.abort();
198
202
  }
199
203
  }
200
- a = new WeakMap(), n = new WeakMap(), u = new WeakMap();
201
- window.customElements.get("ea-button") || window.customElements.define("ea-button", w);
202
- 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 {
203
207
  constructor() {
204
208
  super();
205
209
  /**
@@ -213,32 +217,32 @@ class E extends g {
213
217
  disabled: {
214
218
  type: Boolean,
215
219
  default: !1,
216
- observer: (e) => {
217
- this.querySelectorAll("ea-button").forEach((r) => {
218
- r.setAttribute("disabled", e);
220
+ observer: (t) => {
221
+ this.querySelectorAll("ea-button").forEach((o) => {
222
+ o.setAttribute("disabled", t);
219
223
  });
220
224
  }
221
225
  },
222
226
  size: {
223
227
  type: ["small", "normal", "large"],
224
228
  default: "normal",
225
- observer: (e) => {
226
- this.querySelectorAll("ea-button").forEach((r) => {
227
- r.setAttribute("size", e);
229
+ observer: (t) => {
230
+ this.querySelectorAll("ea-button").forEach((o) => {
231
+ o.setAttribute("size", t);
228
232
  });
229
233
  }
230
234
  },
231
235
  type: {
232
236
  type: ["primary", "success", "warning", "danger", "normal"],
233
237
  default: "normal",
234
- observer: (e) => {
235
- this.querySelectorAll("ea-button").forEach((r) => {
236
- r.setAttribute("type", e);
238
+ observer: (t) => {
239
+ this.querySelectorAll("ea-button").forEach((o) => {
240
+ o.setAttribute("type", t);
237
241
  });
238
242
  }
239
243
  }
240
244
  }));
241
- this.stylesheet = v, this.$render();
245
+ this.stylesheet = w, this.$render();
242
246
  }
243
247
  static get observedAttributes() {
244
248
  return [...super.observedAttributes, "disabled", "size", "type"];
@@ -256,6 +260,6 @@ class E extends g {
256
260
  }
257
261
  window.customElements.get("ea-button-group") || window.customElements.define("ea-button-group", E);
258
262
  export {
259
- w as EaButton,
263
+ A as EaButton,
260
264
  E as EaButtonGroup
261
265
  };