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.
Files changed (167) hide show
  1. package/dist/assets/icon.css +1 -0
  2. package/dist/components/Base.js +941 -0
  3. package/dist/components/ea-alert.js +213 -0
  4. package/dist/components/ea-avatar.js +164 -0
  5. package/dist/components/ea-backtop.js +136 -0
  6. package/dist/components/ea-badge.js +144 -0
  7. package/dist/components/ea-breadcrumb.js +148 -0
  8. package/dist/components/ea-button.js +266 -0
  9. package/dist/components/ea-calendar.js +10 -0
  10. package/dist/components/ea-calendar2.js +673 -0
  11. package/dist/components/ea-card.js +121 -0
  12. package/dist/components/ea-carousel.js +415 -0
  13. package/dist/components/ea-checkbox.js +446 -0
  14. package/dist/components/ea-collapse.js +313 -0
  15. package/dist/components/ea-color-picker.js +888 -0
  16. package/dist/components/ea-container.js +206 -0
  17. package/dist/components/ea-countdown.js +142 -0
  18. package/dist/components/ea-date-picker.js +649 -0
  19. package/dist/components/ea-descriptions.js +474 -0
  20. package/dist/components/ea-dialog.js +249 -0
  21. package/dist/components/ea-drawer.js +216 -0
  22. package/dist/components/ea-dropdown.js +228 -0
  23. package/dist/components/ea-empty.js +93 -0
  24. package/dist/components/ea-icon.js +159 -0
  25. package/dist/components/ea-image-preview.js +532 -0
  26. package/dist/components/ea-image.js +327 -0
  27. package/dist/components/ea-infinite-scroll.js +109 -0
  28. package/dist/components/ea-input-number.js +367 -0
  29. package/dist/components/ea-input.js +588 -0
  30. package/dist/components/ea-layout.js +132 -0
  31. package/dist/components/ea-link.js +101 -0
  32. package/dist/components/ea-menu.js +433 -0
  33. package/dist/components/ea-message-box.js +624 -0
  34. package/dist/components/ea-message.js +313 -0
  35. package/dist/components/ea-notification.js +331 -0
  36. package/dist/components/ea-overlay.js +168 -0
  37. package/dist/components/ea-page-header.js +108 -0
  38. package/dist/components/ea-pagination.js +481 -0
  39. package/dist/components/ea-popconfirm.js +275 -0
  40. package/dist/components/ea-popover.js +147 -0
  41. package/dist/components/ea-popper.js +203 -0
  42. package/dist/components/ea-progress.js +286 -0
  43. package/dist/components/ea-radio.js +364 -0
  44. package/dist/components/ea-rate.js +241 -0
  45. package/dist/components/ea-result.js +100 -0
  46. package/dist/components/ea-scrollbar.js +235 -0
  47. package/dist/components/ea-segmented.js +215 -0
  48. package/dist/components/ea-select.js +609 -0
  49. package/dist/components/ea-skeleton.js +263 -0
  50. package/dist/components/ea-slider.js +430 -0
  51. package/dist/components/ea-space.js +123 -0
  52. package/dist/components/ea-splitter.js +233 -0
  53. package/dist/components/ea-statistic.js +74 -0
  54. package/dist/components/ea-steps.js +346 -0
  55. package/dist/components/ea-switch.js +271 -0
  56. package/dist/components/ea-table.js +1137 -0
  57. package/dist/components/ea-tabs.js +503 -0
  58. package/dist/components/ea-tag.js +228 -0
  59. package/dist/components/ea-text.js +113 -0
  60. package/dist/components/ea-time-picker.js +510 -0
  61. package/dist/components/ea-timeline.js +185 -0
  62. package/dist/components/ea-tooltip.js +161 -0
  63. package/dist/components/ea-tour.js +544 -0
  64. package/dist/components/ea-transfer.js +949 -0
  65. package/dist/components/ea-tree.js +1125 -0
  66. package/dist/components/index.js +60 -0
  67. package/dist/core/FormBase.js +238 -0
  68. package/dist/css/ea-alert.style.js +4 -0
  69. package/dist/css/ea-aside.style.js +4 -0
  70. package/dist/css/ea-avatar.style.js +4 -0
  71. package/dist/css/ea-backtop.style.js +4 -0
  72. package/dist/css/ea-badge.style.js +4 -0
  73. package/dist/css/ea-breadcrumb-item.style.js +4 -0
  74. package/dist/css/ea-breadcrumb.style.js +4 -0
  75. package/dist/css/ea-button-group.style.js +4 -0
  76. package/dist/css/ea-button.style.js +4 -0
  77. package/dist/css/ea-calendar.style.js +4 -0
  78. package/dist/css/ea-card.style.js +4 -0
  79. package/dist/css/ea-carousel-item.style.js +4 -0
  80. package/dist/css/ea-carousel.style.js +4 -0
  81. package/dist/css/ea-check-tag.style.js +4 -0
  82. package/dist/css/ea-checkbox-group.style.js +4 -0
  83. package/dist/css/ea-checkbox.style.js +4 -0
  84. package/dist/css/ea-col.style.js +4 -0
  85. package/dist/css/ea-collapse-item.style.js +4 -0
  86. package/dist/css/ea-collapse.style.js +4 -0
  87. package/dist/css/ea-color-picker-panel.style.js +4 -0
  88. package/dist/css/ea-color-picker.style.js +4 -0
  89. package/dist/css/ea-container.style.js +4 -0
  90. package/dist/css/ea-date-picker.style.js +4 -0
  91. package/dist/css/ea-descriptions-item.style.js +4 -0
  92. package/dist/css/ea-descriptions.style.js +4 -0
  93. package/dist/css/ea-dialog.style.js +4 -0
  94. package/dist/css/ea-drawer.style.js +4 -0
  95. package/dist/css/ea-dropdown-item.style.js +4 -0
  96. package/dist/css/ea-dropdown-menu.style.js +4 -0
  97. package/dist/css/ea-dropdown.style.js +4 -0
  98. package/dist/css/ea-empty.style.js +4 -0
  99. package/dist/css/ea-footer.style.js +4 -0
  100. package/dist/css/ea-header.style.js +4 -0
  101. package/dist/css/ea-icon.style.js +4 -0
  102. package/dist/css/ea-image-preview.style.js +4 -0
  103. package/dist/css/ea-image.style.js +4 -0
  104. package/dist/css/ea-infinite-scroll.style.js +4 -0
  105. package/dist/css/ea-input-number.style.js +4 -0
  106. package/dist/css/ea-input.style.js +4 -0
  107. package/dist/css/ea-link.style.js +4 -0
  108. package/dist/css/ea-main.style.js +4 -0
  109. package/dist/css/ea-menu-item-group.style.js +4 -0
  110. package/dist/css/ea-menu-item.style.js +4 -0
  111. package/dist/css/ea-menu.style.js +4 -0
  112. package/dist/css/ea-message-box.style.js +4 -0
  113. package/dist/css/ea-message.style.js +4 -0
  114. package/dist/css/ea-notification.style.js +4 -0
  115. package/dist/css/ea-option-gropu.style.js +4 -0
  116. package/dist/css/ea-option.style.js +4 -0
  117. package/dist/css/ea-overlay.style.js +4 -0
  118. package/dist/css/ea-page-header.style.js +4 -0
  119. package/dist/css/ea-pagination.style.js +4 -0
  120. package/dist/css/ea-popconfirm.style.js +4 -0
  121. package/dist/css/ea-popover.style.js +4 -0
  122. package/dist/css/ea-popper.style.js +4 -0
  123. package/dist/css/ea-progress.style.js +4 -0
  124. package/dist/css/ea-radio-group.style.js +4 -0
  125. package/dist/css/ea-radio.style.js +4 -0
  126. package/dist/css/ea-rate.style.js +4 -0
  127. package/dist/css/ea-result.style.js +4 -0
  128. package/dist/css/ea-row.style.js +4 -0
  129. package/dist/css/ea-scrollbar.style.js +4 -0
  130. package/dist/css/ea-segmented.style.js +4 -0
  131. package/dist/css/ea-select.style.js +4 -0
  132. package/dist/css/ea-skeleton-item.style.js +4 -0
  133. package/dist/css/ea-skeleton.style.js +4 -0
  134. package/dist/css/ea-slider.style.js +4 -0
  135. package/dist/css/ea-space.style.js +4 -0
  136. package/dist/css/ea-splitter-bar.style.js +4 -0
  137. package/dist/css/ea-splitter-panel.style.js +4 -0
  138. package/dist/css/ea-splitter.style.js +4 -0
  139. package/dist/css/ea-statistic.style.js +4 -0
  140. package/dist/css/ea-step.style.js +4 -0
  141. package/dist/css/ea-steps.style.js +4 -0
  142. package/dist/css/ea-sub-menu.style.js +4 -0
  143. package/dist/css/ea-switch.style.js +4 -0
  144. package/dist/css/ea-tab-panel.style.js +4 -0
  145. package/dist/css/ea-tab.style.js +4 -0
  146. package/dist/css/ea-table-column.style.js +4 -0
  147. package/dist/css/ea-table.style.js +4 -0
  148. package/dist/css/ea-tabs.style.js +4 -0
  149. package/dist/css/ea-tag.style.js +4 -0
  150. package/dist/css/ea-text.style.js +4 -0
  151. package/dist/css/ea-time-picker.style.js +4 -0
  152. package/dist/css/ea-timeline-item.style.js +4 -0
  153. package/dist/css/ea-timeline.style.js +4 -0
  154. package/dist/css/ea-tooltip.style.js +4 -0
  155. package/dist/css/ea-tour-step.style.js +4 -0
  156. package/dist/css/ea-tour.style.js +4 -0
  157. package/dist/css/ea-transfer.style.js +5 -0
  158. package/dist/css/ea-tree.style.js +6 -0
  159. package/dist/css/ea-ui-component.style.js +4 -0
  160. package/dist/favicon.ico +0 -0
  161. package/dist/utils/Color.js +439 -0
  162. package/dist/utils/I18nManager.js +218 -0
  163. package/dist/utils/Utils.js +65 -0
  164. package/dist/utils/Variables.js +12 -0
  165. package/dist/utils/parseTime.js +73 -0
  166. package/dist/utils/timeout.js +9 -0
  167. package/package.json +1 -1
@@ -0,0 +1,313 @@
1
+ var U = Object.defineProperty;
2
+ var $ = (i) => {
3
+ throw TypeError(i);
4
+ };
5
+ var k = (i, t, e) => t in i ? U(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
+ var T = (i, t, e) => k(i, typeof t != "symbol" ? t + "" : t, e), R = (i, t, e) => t.has(i) || $("Cannot " + e);
7
+ var s = (i, t, e) => (R(i, t, "read from private field"), e ? e.call(i) : t.get(i)), o = (i, t, e) => t.has(i) ? $("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), h = (i, t, e, n) => (R(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e);
8
+ import { n as A } from "./ea-calendar2.js";
9
+ import { B, h as P } from "./Base.js";
10
+ import { s as I } from "../css/ea-message.style.js";
11
+ import { t as N } from "../utils/timeout.js";
12
+ var r, u, m, f, d, a, b, l, C, w, v;
13
+ class j extends B {
14
+ constructor() {
15
+ super();
16
+ /** @type {HTMLElement} */
17
+ o(this, r);
18
+ /** @type {HTMLElement} */
19
+ o(this, u);
20
+ /** @type {HTMLElement} */
21
+ o(this, m);
22
+ /** @type {HTMLElement} */
23
+ o(this, f);
24
+ /** @type {AbortController} */
25
+ o(this, d);
26
+ /** @type {AbortController} */
27
+ o(this, a);
28
+ o(this, b, {
29
+ dangerouslyUseHTMLString: !1
30
+ });
31
+ T(this, "state", this.properties({
32
+ type: {
33
+ props: !0,
34
+ type: ["primary", "success", "warning", "info", "error"],
35
+ default: "info",
36
+ observer: (e) => {
37
+ const n = {
38
+ success: "circle-check",
39
+ error: "circle-xmark",
40
+ warning: "triangle-exclamation",
41
+ info: "circle-info",
42
+ primary: "circle-info"
43
+ };
44
+ s(this, u).name = n[e], this.updateContainerClasslist();
45
+ }
46
+ },
47
+ visible: {
48
+ props: !0,
49
+ type: Boolean,
50
+ default: !1,
51
+ observer: async (e) => {
52
+ var n;
53
+ (n = s(this, a)) == null || n.abort(), h(this, a, new AbortController()), e ? (s(this, w).call(this), this.updateContainerClasslist(), s(this, l).call(this, "show"), s(this, r).offsetWidth, s(this, r).classList.add(this.ns.m("is-show")), s(this, r).addEventListener(
54
+ "transitionend",
55
+ () => {
56
+ s(this, l).call(this, "shown");
57
+ },
58
+ { once: !0, signal: s(this, a).signal }
59
+ )) : (s(this, v).call(this), s(this, r).classList.add(this.ns.m("before-hide")), s(this, l).call(this, "hide"), s(this, r).addEventListener(
60
+ "transitionend",
61
+ () => {
62
+ this.updateContainerClasslist(), s(this, l).call(this, "hidden");
63
+ },
64
+ { once: !0, signal: s(this, a).signal }
65
+ ));
66
+ }
67
+ },
68
+ message: {
69
+ props: !0,
70
+ type: String,
71
+ default: "",
72
+ observer: (e) => {
73
+ this.dangerouslyUseHTMLString ? s(this, m).innerHTML = e : s(this, m).innerText = e;
74
+ }
75
+ },
76
+ showClose: {
77
+ props: !0,
78
+ type: Boolean,
79
+ default: !1,
80
+ observer: (e) => {
81
+ var n;
82
+ this.updateContainerClasslist(), (n = s(this, d)) == null || n.abort(), e && (h(this, d, new AbortController()), s(this, f).addEventListener("click", s(this, C), {
83
+ signal: s(this, d).signal
84
+ }));
85
+ }
86
+ },
87
+ placement: {
88
+ type: [
89
+ "top",
90
+ "top-left",
91
+ "top-right",
92
+ "bottom",
93
+ "bottom-left",
94
+ "bottom-right",
95
+ "middle"
96
+ ],
97
+ default: "top",
98
+ observer: () => {
99
+ this.updateContainerClasslist();
100
+ }
101
+ },
102
+ icon: {
103
+ props: !0,
104
+ type: String,
105
+ default: "",
106
+ observer: (e) => {
107
+ s(this, u).name = e, this.updateContainerClasslist();
108
+ }
109
+ }
110
+ }));
111
+ /**
112
+ * 触发冒泡事件
113
+ * @param {string} customEventName - 自定义事件名称
114
+ * @param {string} detail - 事件详情
115
+ */
116
+ o(this, l, (e, n) => {
117
+ this.emit(e, {
118
+ detail: n,
119
+ bubbles: !0,
120
+ composed: !0
121
+ });
122
+ });
123
+ /**
124
+ * 关闭消息(公共方法)
125
+ */
126
+ T(this, "close", () => {
127
+ this.visible = !1, s(this, l).call(this, "close");
128
+ });
129
+ /**
130
+ * 关闭按钮点击事件处理
131
+ */
132
+ o(this, C, () => {
133
+ this.close();
134
+ });
135
+ /**
136
+ * 初始化消息位置
137
+ */
138
+ o(this, w, () => {
139
+ const e = document.querySelectorAll(
140
+ `ea-message[placement="${this.placement}"]`
141
+ );
142
+ if (e.length <= 1) return;
143
+ const n = e[e.length - 2], c = n.style.getPropertyValue("--ea-message-y"), p = n.shadowRoot.querySelector(this.ns.cb()).getBoundingClientRect();
144
+ this.style.setProperty(
145
+ "--ea-message-y",
146
+ `${Number(c.replace("px", "")) + p.height + 8}px`
147
+ );
148
+ });
149
+ /**
150
+ * 隐藏消息
151
+ */
152
+ o(this, v, () => {
153
+ const e = [
154
+ ...document.querySelectorAll(`ea-message[placement="${this.placement}"]`)
155
+ ], n = e.findIndex((p) => p === this), c = e.slice(n + 1), x = s(this, r).getBoundingClientRect().height;
156
+ c.forEach((p) => {
157
+ const q = Number(
158
+ p.style.getPropertyValue("--ea-message-y").replace("px", "")
159
+ );
160
+ p.style.setProperty("--ea-message-y", `${q - x - 8}px`);
161
+ });
162
+ });
163
+ this.stylesheet = I, this.$render();
164
+ }
165
+ // ------- dangerouslyUseHTMLString -------
166
+ // #region
167
+ get dangerouslyUseHTMLString() {
168
+ return s(this, b).dangerouslyUseHTMLString;
169
+ }
170
+ set dangerouslyUseHTMLString(e) {
171
+ s(this, b).dangerouslyUseHTMLString = e;
172
+ }
173
+ // #endregion
174
+ // ------- end -------
175
+ static get observedAttributes() {
176
+ return [...super.observedAttributes, "placement"];
177
+ }
178
+ /**
179
+ * 获取 classlist 列表
180
+ * @return {string} 属性值
181
+ */
182
+ updateContainerClasslist() {
183
+ const e = this.computedClasslist(
184
+ this.ns.b(),
185
+ {
186
+ ["--" + this.type]: this.type,
187
+ ["--" + this.placement]: this.placement,
188
+ "--visible": this.visible,
189
+ "--show-close": this.showClose
190
+ },
191
+ {}
192
+ );
193
+ return s(this, r) && (s(this, r).className = e), e;
194
+ }
195
+ $render() {
196
+ const e = A("message");
197
+ this.ns = e, this.shadowRoot.innerHTML = P(`
198
+ <div class="${e.b()}" part="container">
199
+ <ea-icon class="${e.e("icon")}" part="icon"></ea-icon>
200
+ <div class="${e.e("content")}" part="content-wrap"></div>
201
+ <ea-icon class="${e.e("icon-close")}" name="xmark" part="close-icon"></ea-icon>
202
+ </div>
203
+ `), h(this, r, this.shadowRoot.querySelector(e.cb())), h(this, u, this.shadowRoot.querySelector(e.ce("icon"))), h(this, m, this.shadowRoot.querySelector(e.ce("content"))), h(this, f, this.shadowRoot.querySelector(e.ce("icon-close")));
204
+ }
205
+ connectedCallback() {
206
+ super.connectedCallback();
207
+ }
208
+ $beforeUnmounted() {
209
+ var e, n;
210
+ (e = s(this, d)) == null || e.abort(), (n = s(this, a)) == null || n.abort();
211
+ }
212
+ }
213
+ r = new WeakMap(), u = new WeakMap(), m = new WeakMap(), f = new WeakMap(), d = new WeakMap(), a = new WeakMap(), b = new WeakMap(), l = new WeakMap(), C = new WeakMap(), w = new WeakMap(), v = new WeakMap();
214
+ window.customElements.get("ea-message") || window.customElements.define("ea-message", j);
215
+ var E, M, L, S, H;
216
+ class g {
217
+ /**
218
+ * @param {EaMessageOptions} options
219
+ */
220
+ constructor(t) {
221
+ o(this, E, [
222
+ "dangerouslyUseHTMLString",
223
+ "message",
224
+ "placement",
225
+ "type",
226
+ "showClose",
227
+ "duration",
228
+ "offset",
229
+ "icon"
230
+ ]);
231
+ /**
232
+ * 渲染消息实例
233
+ * @param {EaMessageOptions} options
234
+ * @return {HTMLElement}
235
+ */
236
+ o(this, M, (t) => {
237
+ const e = document.createElement("ea-message");
238
+ if (t instanceof String)
239
+ e.message = t;
240
+ else if (t instanceof Object)
241
+ for (const n in t)
242
+ e[n] = t[n];
243
+ else
244
+ console.warn(
245
+ "[EaMessage] TypeError: options must be a string or an object."
246
+ );
247
+ return e;
248
+ });
249
+ /**
250
+ * 处理 duration 属性
251
+ */
252
+ o(this, L, (t, e = 3e3) => {
253
+ e <= 0 || N(() => {
254
+ t.visible = !1;
255
+ }, e);
256
+ });
257
+ /**
258
+ * 处理 appendTo 属性
259
+ */
260
+ o(this, S, (t, e) => {
261
+ if (e instanceof HTMLElement)
262
+ e.appendChild(t);
263
+ else {
264
+ const n = document.querySelector(e);
265
+ n ? n.appendChild(t) : document.body.appendChild(t);
266
+ }
267
+ });
268
+ /**
269
+ * 处理 hide 属性
270
+ */
271
+ o(this, H, (t, e) => {
272
+ t.addEventListener(
273
+ "hidden",
274
+ (n) => {
275
+ e == null || e(n), t.remove();
276
+ },
277
+ { once: !0 }
278
+ );
279
+ });
280
+ this.options = s(this, E).reduce((n, c) => (t[c] && (n[c] = t[c]), n), {}), this.options.placement = this.options.placement || "top";
281
+ const e = s(this, M).call(this, this.options);
282
+ s(this, S).call(this, e, t.appendTo), s(this, L).call(this, e, t.duration), s(this, H).call(this, e, t.onClose), e.visible = !0;
283
+ }
284
+ }
285
+ E = new WeakMap(), M = new WeakMap(), L = new WeakMap(), S = new WeakMap(), H = new WeakMap();
286
+ const y = (i) => {
287
+ new g(i);
288
+ };
289
+ y.primary = (i) => new g({
290
+ message: i,
291
+ type: "primary"
292
+ });
293
+ y.success = (i) => new g({
294
+ message: i,
295
+ type: "success"
296
+ });
297
+ y.warning = (i) => new g({
298
+ message: i,
299
+ type: "warning"
300
+ });
301
+ y.info = (i) => new g({
302
+ message: i,
303
+ type: "info"
304
+ });
305
+ y.error = (i) => new g({
306
+ message: i,
307
+ type: "error"
308
+ });
309
+ window.$message = y;
310
+ export {
311
+ y as EaMessage,
312
+ j as EaMessageElement
313
+ };
@@ -0,0 +1,331 @@
1
+ var k = Object.defineProperty;
2
+ var I = (s) => {
3
+ throw TypeError(s);
4
+ };
5
+ var $ = (s, i, e) => i in s ? k(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
6
+ var C = (s, i, e) => $(s, typeof i != "symbol" ? i + "" : i, e), R = (s, i, e) => i.has(s) || I("Cannot " + e);
7
+ var t = (s, i, e) => (R(s, i, "read from private field"), e ? e.call(s) : i.get(s)), n = (s, i, e) => i.has(s) ? I("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(s) : i.set(s, e), l = (s, i, e, o) => (R(s, i, "write to private field"), o ? o.call(s, e) : i.set(s, e), e);
8
+ import { t as A } from "../utils/timeout.js";
9
+ import { E as q } from "../utils/Utils.js";
10
+ import { B } from "./Base.js";
11
+ import { s as P } from "../css/ea-notification.style.js";
12
+ var v, E, _, L, S, x;
13
+ class z {
14
+ /**
15
+ * @param {EaNotificationOptions} options
16
+ */
17
+ constructor(i) {
18
+ n(this, v, ["dangerouslyUseHTMLString", "message"]);
19
+ n(this, E, ["appendTo"]);
20
+ n(this, _, {
21
+ title: "",
22
+ dangerouslyUseHTMLString: !1,
23
+ message: "",
24
+ icon: "",
25
+ type: "info",
26
+ duration: 3e3,
27
+ placement: "top-right",
28
+ zIndex: 0,
29
+ showClose: !0,
30
+ closeIcon: "xmark",
31
+ appendTo: "body"
32
+ });
33
+ /**
34
+ *
35
+ * @param {HTMLElement} el
36
+ * @param {EaNotificationOptions} options
37
+ * @returns
38
+ */
39
+ n(this, L, (i) => {
40
+ const e = document.createElement("ea-notification");
41
+ for (const o in i) {
42
+ if (t(this, E).includes(o)) continue;
43
+ const p = i[o];
44
+ if (t(this, v).includes(o))
45
+ e[o] = p;
46
+ else {
47
+ const w = q.String.toLowerCamelCase(o);
48
+ e.setAttribute(w, p);
49
+ }
50
+ }
51
+ return e;
52
+ });
53
+ /**
54
+ *
55
+ * @param {HTMLElement} el
56
+ * @param {HTMLElement | String} appendTo
57
+ * @returns
58
+ */
59
+ n(this, S, (i, e) => {
60
+ if (!e) return document.body.appendChild(i);
61
+ if (e instanceof HTMLElement)
62
+ e.appendChild(i);
63
+ else if (typeof e == "string") {
64
+ const o = document.querySelector(e);
65
+ o ? o.appendChild(i) : document.body.appendChild(i);
66
+ } else
67
+ console.warn(
68
+ `[EaNotification] TypeError: ${e} is not a valid element or selector.`
69
+ );
70
+ });
71
+ /**
72
+ *
73
+ * @param {HTMLElement} el
74
+ * @param {number} duration
75
+ * @returns
76
+ */
77
+ n(this, x, (i, e = 3e3) => {
78
+ i.visible = !0, i.addEventListener("hidden", () => i.remove()), e > 0 && A(() => {
79
+ i.visible = !1;
80
+ }, e);
81
+ });
82
+ C(this, "close", () => {
83
+ this.instance.close();
84
+ });
85
+ i = Object.assign({}, t(this, _), i);
86
+ const e = t(this, L).call(this, i);
87
+ this.instance = e, t(this, S).call(this, e, i.appendTo), t(this, x).call(this, e, i.duration);
88
+ }
89
+ }
90
+ v = new WeakMap(), E = new WeakMap(), _ = new WeakMap(), L = new WeakMap(), S = new WeakMap(), x = new WeakMap();
91
+ const r = (s) => new z(s);
92
+ r.primary = (s) => r({
93
+ ...s,
94
+ type: "primary"
95
+ });
96
+ r.success = (s) => r({
97
+ ...s,
98
+ type: "success"
99
+ });
100
+ r.warning = (s) => r({
101
+ ...s,
102
+ type: "warning"
103
+ });
104
+ r.info = (s) => r({
105
+ ...s,
106
+ type: "info"
107
+ });
108
+ r.error = (s) => r({
109
+ ...s,
110
+ type: "error"
111
+ });
112
+ var a, M, y, g, d, m, c, b, f, h, N, T, H;
113
+ class V extends B {
114
+ constructor() {
115
+ super();
116
+ /** @type {HTMLElement} */
117
+ n(this, a);
118
+ /** @type {HTMLElement} */
119
+ n(this, M);
120
+ /** @type {HTMLElement} */
121
+ n(this, y);
122
+ /** @type {HTMLElement} */
123
+ n(this, g);
124
+ /** @type {HTMLElement} */
125
+ n(this, d);
126
+ /** @type {HTMLElement} */
127
+ n(this, m);
128
+ /** @type {AbortController} */
129
+ n(this, c);
130
+ /** @type {AbortController} */
131
+ n(this, b);
132
+ n(this, f, {
133
+ dangerouslyUseHTMLString: !1,
134
+ message: ""
135
+ });
136
+ C(this, "state", this.properties({
137
+ type: {
138
+ type: ["primary", "success", "warning", "info", "error"],
139
+ default: "info",
140
+ observer: (e) => {
141
+ const o = {
142
+ success: "circle-check",
143
+ error: "circle-xmark",
144
+ warning: "triangle-exclamation",
145
+ info: "circle-info",
146
+ primary: "circle-info"
147
+ };
148
+ t(this, y).name = o[e], t(this, a).className = this.updateContainerClasslist();
149
+ }
150
+ },
151
+ title: {
152
+ type: String,
153
+ default: "",
154
+ observer: (e) => {
155
+ t(this, g).textContent = e;
156
+ }
157
+ },
158
+ visible: {
159
+ type: Boolean,
160
+ default: !1,
161
+ observer: async (e) => {
162
+ var o;
163
+ (o = t(this, c)) == null || o.abort(), l(this, c, new AbortController()), e ? (t(this, N).call(this), t(this, a).className = this.updateContainerClasslist(), t(this, h).call(this, "show"), t(this, a).offsetWidth, t(this, a).classList.add("is-show"), t(this, a).addEventListener(
164
+ "transitionend",
165
+ () => {
166
+ t(this, h).call(this, "shown");
167
+ },
168
+ { once: !0, signal: t(this, c).signal }
169
+ )) : (t(this, T).call(this), t(this, a).classList.add("is-before-hide"), t(this, h).call(this, "hide"), t(this, a).addEventListener(
170
+ "transitionend",
171
+ () => {
172
+ t(this, a).className = this.updateContainerClasslist(), t(this, h).call(this, "hidden");
173
+ },
174
+ { once: !0, signal: t(this, c).signal }
175
+ ));
176
+ }
177
+ },
178
+ showClose: {
179
+ type: Boolean,
180
+ default: !1,
181
+ observer: (e) => {
182
+ t(this, a).className = this.updateContainerClasslist(), t(this, d).name = this["close-icon"];
183
+ }
184
+ },
185
+ closeIcon: {
186
+ type: String,
187
+ default: "xmark",
188
+ observer: (e) => {
189
+ this["show-close"] && (t(this, d).name = e);
190
+ }
191
+ },
192
+ placement: {
193
+ type: ["top-right", "top-left", "bottom-right", "bottom-left"],
194
+ default: "top-right",
195
+ observer: (e) => {
196
+ t(this, a).className = this.updateContainerClasslist();
197
+ }
198
+ },
199
+ zIndex: {
200
+ type: Number,
201
+ default: 0,
202
+ observer: (e) => {
203
+ t(this, a).style.setProperty("--z-index", e);
204
+ }
205
+ }
206
+ }));
207
+ n(this, h, (e, o) => {
208
+ this.emit(e, {
209
+ detail: o,
210
+ bubbles: !0,
211
+ composed: !0
212
+ });
213
+ });
214
+ C(this, "close", () => {
215
+ this.visible = !1, t(this, h).call(this, "close");
216
+ });
217
+ n(this, N, () => {
218
+ const e = document.querySelectorAll(
219
+ `ea-notification[placement="${this.placement}"]`
220
+ );
221
+ if (e.length <= 1) return;
222
+ const o = e[e.length - 2], p = o.style.getPropertyValue("--ea-notification-y"), u = o.shadowRoot.querySelector(".ea-notification").getBoundingClientRect();
223
+ this.style.setProperty(
224
+ "--ea-notification-y",
225
+ `${Number(p.replace("px", "")) + u.height + 8}px`
226
+ );
227
+ });
228
+ n(this, T, () => {
229
+ const e = [
230
+ ...document.querySelectorAll(
231
+ `ea-notification[placement="${this.placement}"]`
232
+ )
233
+ ], o = e.findIndex((u) => u === this), p = e.slice(o + 1), w = t(this, a).getBoundingClientRect().height;
234
+ p.forEach((u, O) => {
235
+ const U = Number(
236
+ u.style.getPropertyValue("--ea-notification-y").replace("px", "")
237
+ );
238
+ u.style.setProperty(
239
+ "--ea-notification-y",
240
+ `${U - w - 8}px`
241
+ );
242
+ });
243
+ });
244
+ n(this, H, () => {
245
+ this.visible = !1;
246
+ });
247
+ this.stylesheet = P, this.$render();
248
+ }
249
+ // ------- dangerouslyUseHTMLString -------
250
+ // #region
251
+ get dangerouslyUseHTMLString() {
252
+ return t(this, f).dangerouslyUseHTMLString;
253
+ }
254
+ set dangerouslyUseHTMLString(e) {
255
+ t(this, f).dangerouslyUseHTMLString = e;
256
+ }
257
+ // #endregion
258
+ // ------- end -------
259
+ // ------- message -------
260
+ // #region
261
+ get message() {
262
+ return t(this, f).message;
263
+ }
264
+ set message(e) {
265
+ t(this, f).message = e, this.dangerouslyUseHTMLString ? t(this, m).innerHTML = e : t(this, m).innerText = e;
266
+ }
267
+ // #endregion
268
+ // ------- end -------
269
+ static get observedAttributes() {
270
+ return q.Array.toLowerCamelCase([
271
+ "visible",
272
+ "title",
273
+ "message",
274
+ "type",
275
+ "icon",
276
+ "duration",
277
+ "placement",
278
+ "showClose",
279
+ "zIndex",
280
+ "closeIcon"
281
+ ]);
282
+ }
283
+ /**
284
+ * 获取 classlist 列表
285
+ * @return {string} 属性值
286
+ */
287
+ updateContainerClasslist() {
288
+ return this.computedClasslist("ea-notification", {
289
+ "--visible": this.visible,
290
+ ["--" + this.type]: this.type,
291
+ "--show-close": this["show-close"],
292
+ ["--" + this.placement]: this.placement
293
+ });
294
+ }
295
+ $render() {
296
+ this.shadowRoot.innerHTML = `
297
+ <div class="ea-notification" part='container'>
298
+ <ea-icon class="ea-notification__icon" part="icon"></ea-icon>
299
+ <div class="ea-notification__content">
300
+ <header class="ea-notification__header" part='header'>
301
+ <h2 class="ea-notification__title" part="title"> </h2>
302
+ <ea-icon class="ea-notification__close-icon" name="xmark" part='close-icon'></ea-icon>
303
+ </header>
304
+ <main class="ea-notification__main" part='main'> </main>
305
+ </div>
306
+ </div>
307
+ `, l(this, a, this.shadowRoot.querySelector(".ea-notification")), l(this, M, this.shadowRoot.querySelector(".ea-notification__header")), l(this, y, this.shadowRoot.querySelector(
308
+ ".ea-notification__icon"
309
+ )), l(this, g, this.shadowRoot.querySelector(".ea-notification__title")), l(this, d, this.shadowRoot.querySelector(
310
+ ".ea-notification__close-icon"
311
+ )), l(this, m, this.shadowRoot.querySelector(".ea-notification__main"));
312
+ }
313
+ connectedCallback() {
314
+ super.connectedCallback();
315
+ const e = new AbortController();
316
+ l(this, b, e), this["show-close"] && t(this, d).addEventListener("click", t(this, H), {
317
+ signal: e.signal
318
+ });
319
+ }
320
+ $beforeUnmounted() {
321
+ var e, o;
322
+ (e = t(this, c)) == null || e.abort(), (o = t(this, b)) == null || o.abort();
323
+ }
324
+ }
325
+ a = new WeakMap(), M = new WeakMap(), y = new WeakMap(), g = new WeakMap(), d = new WeakMap(), m = new WeakMap(), c = new WeakMap(), b = new WeakMap(), f = new WeakMap(), h = new WeakMap(), N = new WeakMap(), T = new WeakMap(), H = new WeakMap();
326
+ window.customElements.get("ea-notification") || window.customElements.define("ea-notification", V);
327
+ window.$notify = r;
328
+ export {
329
+ r as EaNotification,
330
+ V as EaNotificationElement
331
+ };