easy-component-ui 3.0.5 → 3.0.7

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,19 +1,19 @@
1
- var f = Object.defineProperty;
1
+ var m = Object.defineProperty;
2
2
  var n = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var m = (t, s, e) => s in t ? f(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
6
- var o = (t, s, e) => m(t, typeof s != "symbol" ? s + "" : s, e), p = (t, s, e) => s.has(t) || n("Cannot " + e);
7
- var i = (t, s, e) => (p(t, s, "read from private field"), e ? e.call(t) : s.get(t)), c = (t, s, e) => s.has(t) ? n("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(t) : s.set(t, e), d = (t, s, e, r) => (p(t, s, "write to private field"), r ? r.call(t, e) : s.set(t, e), e);
8
- import { B as y } from "./Base.js";
9
- import { s as g } from "../css/ea-space.style.js";
10
- var a;
11
- class v extends y {
5
+ var b = (t, s, e) => s in t ? m(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
6
+ var p = (t, s, e) => b(t, typeof s != "symbol" ? s + "" : s, e), c = (t, s, e) => s.has(t) || n("Cannot " + e);
7
+ var u = (t, s, e) => (c(t, s, "read from private field"), e ? e.call(t) : s.get(t)), d = (t, s, e) => s.has(t) ? n("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(t) : s.set(t, e), h = (t, s, e, a) => (c(t, s, "write to private field"), a ? a.call(t, e) : s.set(t, e), e);
8
+ import { B as g } from "./Base.js";
9
+ import { s as y } from "../css/ea-space.style.js";
10
+ var r;
11
+ class v extends g {
12
12
  constructor() {
13
13
  super();
14
14
  /** @type {HTMLElement} */
15
- c(this, a);
16
- o(this, "state", this.properties({
15
+ d(this, r);
16
+ p(this, "state", this.properties({
17
17
  wrap: {
18
18
  type: Boolean,
19
19
  default: !1,
@@ -22,18 +22,19 @@ class v extends y {
22
22
  }
23
23
  },
24
24
  alignment: {
25
- type: String,
25
+ type: ["", "center", "flex-start", "flex-end", "baseline", "stretch"],
26
26
  default: "",
27
27
  observer: (e) => {
28
- if (!CSS.supports("align-items", e)) return console.warn(`[ea-space] Invalid alignment value ${e}`);
28
+ if (!CSS.supports("align-items", e))
29
+ return console.warn(`[ea-space] Invalid alignment value ${e}`);
29
30
  this.style.setProperty("--ea-space-alignment", e);
30
31
  }
31
32
  },
32
33
  direction: {
33
34
  type: ["vertical", "horizontal"],
34
35
  default: "horizontal",
35
- observer: (e) => {
36
- i(this, a).className = this.updateContainerClasslist();
36
+ observer: () => {
37
+ this.updateContainerClasslist();
37
38
  }
38
39
  },
39
40
  size: {
@@ -41,9 +42,10 @@ class v extends y {
41
42
  default: "default",
42
43
  observer: (e) => {
43
44
  if (["large", "small", "default"].includes(e))
44
- i(this, a).className = `${this.updateContainerClasslist()} ea-space--${e}`;
45
+ this.updateContainerClasslist();
45
46
  else {
46
- if (!CSS.supports("gap", e)) return console.warn("[ea-space] Invalid size value");
47
+ if (!CSS.supports("gap", e))
48
+ return console.warn("[ea-space] Invalid size value");
47
49
  this.style.setProperty("--ea-space-gap", e);
48
50
  }
49
51
  }
@@ -52,11 +54,12 @@ class v extends y {
52
54
  type: String,
53
55
  default: "",
54
56
  observer: (e) => {
55
- const r = [...this.children];
56
- r.forEach((h, u) => {
57
- if (u < r.length - 1) {
57
+ if (this.querySelectorAll('[part="spacer"]').forEach((i) => i.remove()), !e) return;
58
+ const o = [...this.children];
59
+ o.forEach((i, f) => {
60
+ if (f < o.length - 1) {
58
61
  const l = document.createElement("span");
59
- l.innerText = e, l.part = "spacer", this.insertBefore(l, h.nextSibling);
62
+ l.innerText = e, l.part = "spacer", this.insertBefore(l, i.nextSibling);
60
63
  }
61
64
  });
62
65
  }
@@ -64,45 +67,56 @@ class v extends y {
64
67
  fill: {
65
68
  type: Boolean,
66
69
  default: !1,
67
- observer: (e) => {
68
- i(this, a).className = this.updateContainerClasslist();
70
+ observer: () => {
71
+ this.updateContainerClasslist();
69
72
  }
70
73
  },
71
74
  "fill-ratio": {
72
75
  type: Number,
73
76
  default: 100,
74
77
  observer: (e) => {
75
- this.style.setProperty("--ea-space-fill-ratio", `${e}%`);
78
+ Number.isNaN(Number(e)) || this.toggleAttribute("fill", !0), this.style.setProperty("--ea-space-fill-ratio", `${e}%`);
76
79
  }
77
80
  }
78
81
  }));
79
- this.stylesheet = g, this.$render();
82
+ this.stylesheet = y, this.$render();
80
83
  }
81
84
  static get observedAttributes() {
82
- return ["wrap", "direction", "size", "spacer", "alignment", "fill", "fill-ratio"];
85
+ return [
86
+ ...super.observedAttributes,
87
+ "wrap",
88
+ "direction",
89
+ "size",
90
+ "spacer",
91
+ "alignment",
92
+ "fill",
93
+ "fill-ratio"
94
+ ];
83
95
  }
84
96
  /**
85
97
  * 获取 classlist 列表
86
98
  * @return {string} 属性值
87
99
  */
88
100
  updateContainerClasslist() {
89
- return this.computedClasslist("ea-space", {
101
+ const e = this.computedClasslist("ea-space", {
102
+ [`--${this.size}`]: !CSS.supports("gap", this.size),
90
103
  ["--" + this.direction]: this.direction,
91
104
  "--fill": this.fill
92
105
  });
106
+ return u(this, r).className = e, e;
93
107
  }
94
108
  $render() {
95
109
  this.shadowRoot.innerHTML = `
96
- <div class="ea-space" part="container">
97
- <slot></slot>
98
- </div>
99
- `, d(this, a, this.shadowRoot.querySelector(".ea-space"));
110
+ <div class="ea-space" part="container">
111
+ <slot></slot>
112
+ </div>
113
+ `, h(this, r, this.shadowRoot.querySelector(".ea-space")), this.updateContainerClasslist();
100
114
  }
101
115
  connectedCallback() {
102
116
  super.connectedCallback();
103
117
  }
104
118
  }
105
- a = new WeakMap();
119
+ r = new WeakMap();
106
120
  window.customElements.get("ea-space") || window.customElements.define("ea-space", v);
107
121
  export {
108
122
  v as EaSpace
@@ -1,29 +1,37 @@
1
- var p = Object.defineProperty;
2
- var r = (e) => {
1
+ var y = Object.defineProperty;
2
+ var p = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
- var d = (e, s, t) => s in e ? p(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
6
- var n = (e, s, t) => d(e, typeof s != "symbol" ? s + "" : s, t), h = (e, s, t) => s.has(e) || r("Cannot " + t);
7
- var a = (e, s, t) => (h(e, s, "read from private field"), t ? t.call(e) : s.get(e)), o = (e, s, t) => s.has(e) ? r("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), c = (e, s, t, l) => (h(e, s, "write to private field"), l ? l.call(e, t) : s.set(e, t), t);
8
- import { B as u } from "./Base.js";
9
- import { s as m } from "../css/ea-text.style.js";
10
- var i;
11
- class y extends u {
5
+ var w = (e, s, t) => s in e ? y(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
6
+ var u = (e, s, t) => w(e, typeof s != "symbol" ? s + "" : s, t), m = (e, s, t) => s.has(e) || p("Cannot " + t);
7
+ var i = (e, s, t) => (m(e, s, "read from private field"), t ? t.call(e) : s.get(e)), o = (e, s, t) => s.has(e) ? p("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), h = (e, s, t, l) => (m(e, s, "write to private field"), l ? l.call(e, t) : s.set(e, t), t);
8
+ import { B as f } from "./Base.js";
9
+ import { s as C } from "../css/ea-text.style.js";
10
+ var a, n, r;
11
+ class g extends f {
12
12
  constructor() {
13
13
  super();
14
14
  /** @type {HTMLElement} */
15
- o(this, i);
16
- /**
15
+ o(this, a);
16
+ o(this, n, {
17
+ isOriginalRendered: !1
18
+ });
19
+ o(this, r, new Promise((t) => {
20
+ h(this, n, new Proxy(i(this, n), {
21
+ set: (l, d, c) => (d === "isOriginalRendered" && c && t(!0), Reflect.set(l, d, c))
22
+ }));
23
+ }));
24
+ /**
17
25
  * @typedef {Object} State
18
26
  * @property {string} title - 标题
19
27
  * @property {string} type - 文本类型
20
28
  * @property {string} size - 文本大小
21
29
  * @property {boolean} truncated - 文本是否截断
22
30
  * @property {number} line-clamp - 截断的行数
23
- * @property {string} tag - 文本标签
31
+ * @property {string} tag - 文本标签
24
32
  */
25
33
  /** @type {State} */
26
- n(this, "state", this.properties({
34
+ u(this, "state", this.properties({
27
35
  title: {
28
36
  type: String,
29
37
  default: "",
@@ -33,39 +41,43 @@ class y extends u {
33
41
  type: {
34
42
  type: ["normal", "primary", "success", "warning", "danger", "info"],
35
43
  default: "normal",
36
- observer: (t) => {
37
- a(this, i).className = this.updateContainerClasslist();
44
+ observer: async (t) => {
45
+ await i(this, r), this.updateContainerClasslist();
38
46
  }
39
47
  },
40
48
  size: {
41
49
  type: ["large", "medium", "small"],
42
50
  default: "medium",
43
- observer: (t) => {
44
- a(this, i).className = this.updateContainerClasslist();
51
+ observer: async (t) => {
52
+ await i(this, r), this.updateContainerClasslist();
45
53
  }
46
54
  },
47
55
  truncated: {
48
56
  type: Boolean,
49
57
  default: !1,
50
- observer: (t) => {
51
- this.title = this.innerText || "", a(this, i).className = this.updateContainerClasslist();
58
+ observer: async (t) => {
59
+ await i(this, r), this.title = this.innerText || "", this.updateContainerClasslist();
52
60
  }
53
61
  },
54
62
  "line-clamp": {
55
63
  type: Number,
56
64
  default: 0,
57
- observer: (t) => {
58
- t > 0 && this.style.setProperty("--ea-text-line-clamp", t), a(this, i).className = this.updateContainerClasslist(), this.title = this.innerText || "";
65
+ observer: async (t) => {
66
+ await i(this, r), i(this, a).style.setProperty("--ea-text-line-clamp", t), this.title = this.innerText || "", this.updateContainerClasslist();
59
67
  }
60
68
  },
61
69
  tag: {
62
70
  type: String,
63
71
  default: "span",
64
72
  observer: (t) => {
73
+ this.$render(), this.hasAttribute("line-clamp") && i(this, a).style.setProperty(
74
+ "--ea-text-line-clamp",
75
+ this["line-clamp"]
76
+ ), (this.hasAttribute("truncated") || this.hasAttribute("line-clamp")) && (this.title = this.innerText || ""), this.updateContainerClasslist();
65
77
  }
66
78
  }
67
79
  }));
68
- this.isMounted = !1, this.stylesheet = m;
80
+ this.stylesheet = C;
69
81
  }
70
82
  static get observedAttributes() {
71
83
  return ["title", "type", "size", "truncated", "line-clamp", "tag"];
@@ -75,29 +87,27 @@ class y extends u {
75
87
  * @return {string} 属性值
76
88
  */
77
89
  updateContainerClasslist() {
78
- return this.computedClasslist(
79
- "ea-text",
80
- {
81
- ["--" + this.type]: this.type,
82
- ["--" + this.size]: this.size,
83
- "--truncated": this.truncated,
84
- "--line-clamp": this["line-clamp"] > 0
85
- }
86
- );
90
+ const t = this.computedClasslist("ea-text", {
91
+ ["--" + this.type]: this.type,
92
+ ["--" + this.size]: this.size,
93
+ "--truncated": this.truncated,
94
+ "--line-clamp": this["line-clamp"] > 0
95
+ });
96
+ return i(this, a).className = t, t;
87
97
  }
88
98
  $render() {
89
99
  this.shadowRoot.innerHTML = `
90
- <${this.tag} class="ea-text" part="container">
91
- <slot></slot>
92
- </${this.tag}>
93
- `, c(this, i, this.shadowRoot.querySelector(".ea-text")), this.isMounted = !0;
100
+ <${this.tag} class="ea-text" part="container">
101
+ <slot></slot>
102
+ </${this.tag}>
103
+ `, h(this, a, this.shadowRoot.querySelector(".ea-text")), this.updateContainerClasslist(), i(this, n).isOriginalRendered = !0;
94
104
  }
95
105
  connectedCallback() {
96
- super.connectedCallback(), this.$render(), this.tag = this.tag, this.title = this.title, this.type = this.type, this.size = this.size, this.truncated = this.truncated, this["line-clamp"] = this["line-clamp"];
106
+ super.connectedCallback(), this.$render();
97
107
  }
98
108
  }
99
- i = new WeakMap();
100
- window.customElements.get("ea-text") || window.customElements.define("ea-text", y);
109
+ a = new WeakMap(), n = new WeakMap(), r = new WeakMap();
110
+ window.customElements.get("ea-text") || window.customElements.define("ea-text", g);
101
111
  export {
102
- y as EaText
112
+ g as EaText
103
113
  };