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,1125 @@
1
+ var Ee = Object.defineProperty;
2
+ var pe = (d) => {
3
+ throw TypeError(d);
4
+ };
5
+ var ve = (d, o, e) => o in d ? Ee(d, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[o] = e;
6
+ var b = (d, o, e) => ve(d, typeof o != "symbol" ? o + "" : o, e), fe = (d, o, e) => o.has(d) || pe("Cannot " + e);
7
+ var s = (d, o, e) => (fe(d, o, "read from private field"), e ? e.call(d) : o.get(d)), n = (d, o, e) => o.has(d) ? pe("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(d) : o.set(d, e), f = (d, o, e, t) => (fe(d, o, "write to private field"), t ? t.call(d, e) : o.set(d, e), e);
8
+ import { n as ce } from "./ea-calendar2.js";
9
+ import { B as he } from "./Base.js";
10
+ import { s as Ne, a as we, b as Ae } from "../css/ea-tree.style.js";
11
+ import "./ea-checkbox.js";
12
+ import { t as ke } from "../utils/timeout.js";
13
+ class Se extends Event {
14
+ constructor(o) {
15
+ super("ea-node-expand", { bubbles: !0, composed: !0 }), this.detail = o;
16
+ }
17
+ }
18
+ class qe extends Event {
19
+ constructor(o) {
20
+ super("ea-node-collapse", { bubbles: !0, composed: !0 }), this.detail = o;
21
+ }
22
+ }
23
+ class Le extends Event {
24
+ constructor(o) {
25
+ super("ea-node-select", { bubbles: !0, composed: !0 }), this.detail = o;
26
+ }
27
+ }
28
+ class Ce extends Event {
29
+ constructor(o) {
30
+ super("ea-node-click", { bubbles: !0, composed: !0 }), this.detail = o;
31
+ }
32
+ }
33
+ class Pe extends Event {
34
+ constructor(o) {
35
+ super("ea-node-contextmenu", { bubbles: !0, composed: !0 }), this.detail = o;
36
+ }
37
+ }
38
+ class $e extends Event {
39
+ constructor(o) {
40
+ super("ea-check-change", { bubbles: !0, composed: !0 }), this.detail = o;
41
+ }
42
+ }
43
+ class Te extends Event {
44
+ constructor(o) {
45
+ super("ea-check", { bubbles: !0, composed: !0 }), this.detail = o;
46
+ }
47
+ }
48
+ class Ke extends Event {
49
+ constructor(o) {
50
+ super("ea-current-change", { bubbles: !0, composed: !0 }), this.detail = o;
51
+ }
52
+ }
53
+ var v, L, P, k, C, $, T, _, M, W, U;
54
+ class Be extends he {
55
+ constructor() {
56
+ super();
57
+ /** @type {HTMLElement} */
58
+ n(this, v);
59
+ /** @type {HTMLElement} */
60
+ n(this, L);
61
+ /** @type {HTMLElement} */
62
+ n(this, P);
63
+ /** @type {HTMLElement} */
64
+ n(this, k);
65
+ /** @type {AbortController} */
66
+ n(this, C, new AbortController());
67
+ b(this, "state", this.properties({
68
+ path: {
69
+ type: String,
70
+ default: ""
71
+ },
72
+ label: {
73
+ type: String,
74
+ default: "",
75
+ observer: (e) => {
76
+ s(this, L).textContent = e;
77
+ }
78
+ },
79
+ selected: {
80
+ type: Boolean,
81
+ default: !1,
82
+ observer: () => {
83
+ this.updateContainerClasslist();
84
+ }
85
+ },
86
+ expanded: {
87
+ type: Boolean,
88
+ default: !1,
89
+ observer: (e) => {
90
+ if (!this.hasChildren) return;
91
+ this.updateContainerClasslist();
92
+ const t = this.nextElementSibling;
93
+ t && (t.expanded = e);
94
+ }
95
+ },
96
+ checked: {
97
+ type: Boolean,
98
+ default: !1,
99
+ observer: (e) => {
100
+ s(this, $).call(this, e), this.updateContainerClasslist();
101
+ }
102
+ },
103
+ indeterminate: {
104
+ type: Boolean,
105
+ default: !1,
106
+ observer: () => {
107
+ s(this, $).call(this), this.updateContainerClasslist();
108
+ }
109
+ },
110
+ disabled: {
111
+ type: Boolean,
112
+ default: !1,
113
+ observer: () => {
114
+ s(this, T).call(this), this.updateContainerClasslist();
115
+ }
116
+ },
117
+ "show-checkbox": {
118
+ type: Boolean,
119
+ default: !1,
120
+ observer: () => {
121
+ this.updateContainerClasslist();
122
+ }
123
+ }
124
+ }));
125
+ b(this, "propStates", this.properties({
126
+ hasChildren: {
127
+ props: !0,
128
+ type: Boolean,
129
+ default: !1,
130
+ observer: () => {
131
+ this.updateContainerClasslist();
132
+ }
133
+ },
134
+ dataProps: {
135
+ props: !0,
136
+ type: Object,
137
+ default: {
138
+ children: "children",
139
+ label: "label",
140
+ disabled: "disabled"
141
+ },
142
+ observer: () => {
143
+ }
144
+ },
145
+ data: {
146
+ props: !0,
147
+ type: Object,
148
+ default: {},
149
+ observer: (e) => {
150
+ var i;
151
+ const { children: t, label: r, disabled: a } = this.dataProps;
152
+ this.label = (e == null ? void 0 : e[r]) || this.label, this.hasChildren = ((i = e == null ? void 0 : e[t]) == null ? void 0 : i.length) > 0, this.disabled = (e == null ? void 0 : e[a]) || !1;
153
+ }
154
+ }
155
+ }));
156
+ /**
157
+ * 更新 checkbox 状态
158
+ * @param {boolean} checked - 是否选中
159
+ * @param {boolean} indeterminate - 是否不确定
160
+ */
161
+ n(this, $, (e = this.checked, t = this.indeterminate) => {
162
+ s(this, k) && (s(this, k).checked = e, s(this, k).indeterminate = t);
163
+ });
164
+ /**
165
+ * 更新禁用状态
166
+ */
167
+ n(this, T, () => {
168
+ s(this, k) && (s(this, k).disabled = this.disabled);
169
+ });
170
+ /**
171
+ * 处理复选框变化事件
172
+ * @param {Event} e 事件对象
173
+ */
174
+ n(this, _, (e) => {
175
+ e.stopImmediatePropagation(), !this.disabled && (this.checked = e.detail.checked, this.emit("ea-tree-checkbox-click", {
176
+ bubbles: !0,
177
+ composed: !0,
178
+ detail: {
179
+ label: this,
180
+ checked: e.detail.checked
181
+ }
182
+ }));
183
+ });
184
+ /**
185
+ * 处理标签点击事件
186
+ * @param {Event} e 事件对象
187
+ */
188
+ n(this, M, (e) => {
189
+ if (e.stopImmediatePropagation(), e.target.closest(this.ns.ce("checkbox"))) return;
190
+ const r = e.target.closest(this.ns.e("toggle-icon")), a = this.parentElement.querySelector("ea-tree-child");
191
+ this.emit("ea-tree-label-click", {
192
+ bubbles: !0,
193
+ composed: !0,
194
+ detail: {
195
+ label: this,
196
+ child: a,
197
+ isIconClick: !!r
198
+ }
199
+ });
200
+ });
201
+ /**
202
+ * 处理展开/收起图标点击事件
203
+ * @param {Event} e 事件对象
204
+ */
205
+ n(this, W, (e) => {
206
+ if (e.stopImmediatePropagation(), !this.hasChildren) return;
207
+ const t = this.parentElement.querySelector("ea-tree-child");
208
+ this.emit("ea-tree-label-click", {
209
+ bubbles: !0,
210
+ composed: !0,
211
+ detail: {
212
+ label: this,
213
+ child: t,
214
+ isIconClick: !0
215
+ }
216
+ });
217
+ });
218
+ /**
219
+ * 绑定事件监听器
220
+ */
221
+ n(this, U, () => {
222
+ s(this, k).addEventListener(
223
+ "change",
224
+ s(this, _),
225
+ {
226
+ signal: s(this, C).signal
227
+ }
228
+ ), s(this, v).addEventListener("click", s(this, M), {
229
+ signal: s(this, C).signal
230
+ }), s(this, P).addEventListener("click", s(this, W), {
231
+ signal: s(this, C).signal
232
+ });
233
+ });
234
+ /**
235
+ * 获取节点深度
236
+ * @returns {number} 节点深度
237
+ */
238
+ b(this, "getDepth", () => {
239
+ const e = this.path;
240
+ return e ? e.split("-").length : 0;
241
+ });
242
+ /**
243
+ * 判断是否为根节点
244
+ * @returns {boolean} 是否为根节点
245
+ */
246
+ b(this, "isRoot", () => this.getDepth() === 1);
247
+ /**
248
+ * 判断是否为叶子节点
249
+ * @returns {boolean} 是否为叶子节点
250
+ */
251
+ b(this, "isLeaf", () => this.hasChildren ? childTree.querySelectorAll("ea-tree-label").length === 0 : !0);
252
+ this.stylesheet = Ne, this.$render();
253
+ }
254
+ static get observedAttributes() {
255
+ return [
256
+ ...super.observedAttributes,
257
+ "label",
258
+ "expanded",
259
+ "selected",
260
+ "checked",
261
+ "indeterminate",
262
+ "show-checkbox",
263
+ "disabled",
264
+ "path"
265
+ ];
266
+ }
267
+ /**
268
+ * 获取 classlist 列表
269
+ * @return {string} 属性值
270
+ */
271
+ updateContainerClasslist() {
272
+ const e = this.computedClasslist(
273
+ "ea-tree-label",
274
+ {
275
+ // ['--' + this.type]: this.type,
276
+ },
277
+ {
278
+ "has-children": this.hasChildren,
279
+ expanded: this.expanded,
280
+ selected: this.selected,
281
+ checked: this.checked,
282
+ indeterminate: this.indeterminate,
283
+ "show-checkbox": this["show-checkbox"],
284
+ disabled: this.disabled
285
+ }
286
+ );
287
+ return s(this, v).className = e, e;
288
+ }
289
+ $render() {
290
+ const e = ce("tree-label");
291
+ this.ns = e, this.shadowRoot.innerHTML = `
292
+ <div class='${e.b()}' part='container'>
293
+ <ea-icon name="angle-right" class='${e.e("toggle-icon")}' part='toggle'></ea-icon>
294
+ <ea-checkbox class='${e.e("checkbox")}' part='checkbox'></ea-checkbox>
295
+ <span class='${e.e("text")}' part='text'></span>
296
+ </div>
297
+ `, f(this, v, this.shadowRoot.querySelector(`.${e.b()}`)), f(this, L, this.shadowRoot.querySelector(`.${e.e("text")}`)), f(this, k, this.shadowRoot.querySelector(e.ce("checkbox"))), f(this, P, this.shadowRoot.querySelector(
298
+ `.${e.e("toggle-icon")}`
299
+ )), this.updateContainerClasslist(), s(this, T).call(this);
300
+ }
301
+ connectedCallback() {
302
+ var e;
303
+ super.connectedCallback(), (e = s(this, C)) == null || e.abort(), f(this, C, new AbortController()), s(this, U).call(this);
304
+ }
305
+ $beforeUnmounted() {
306
+ var e;
307
+ (e = s(this, C)) == null || e.abort();
308
+ }
309
+ }
310
+ v = new WeakMap(), L = new WeakMap(), P = new WeakMap(), k = new WeakMap(), C = new WeakMap(), $ = new WeakMap(), T = new WeakMap(), _ = new WeakMap(), M = new WeakMap(), W = new WeakMap(), U = new WeakMap();
311
+ window.customElements.get("ea-tree-label") || window.customElements.define("ea-tree-label", Be);
312
+ var y, N, F, w, J, K, z, G, Q, X;
313
+ class Ie extends he {
314
+ constructor() {
315
+ super();
316
+ /** @type {HTMLElement} */
317
+ n(this, y);
318
+ /** @type {AbortController} */
319
+ n(this, N, new AbortController());
320
+ n(this, F, {
321
+ expandedNodes: /* @__PURE__ */ new Set(),
322
+ selectedNode: null
323
+ });
324
+ n(this, w, {
325
+ /** @type {AbortController} */
326
+ dataController: null
327
+ });
328
+ b(this, "propState", this.properties({
329
+ data: {
330
+ props: !0,
331
+ type: Array,
332
+ default: "",
333
+ /** @param {Array} newVal */
334
+ observer: async (e) => {
335
+ var t;
336
+ if (await customElements.whenDefined("ea-tree-label"), (t = s(this, w).dataController) == null || t.abort(), Array.isArray(e)) {
337
+ s(this, w).dataController = new AbortController();
338
+ const r = s(this, K).call(this);
339
+ r.innerHTML = "", s(this, Q).call(this, e);
340
+ }
341
+ }
342
+ },
343
+ dataProps: {
344
+ props: !0,
345
+ type: Object,
346
+ default: {
347
+ children: "children",
348
+ label: "label",
349
+ disabled: "disabled"
350
+ },
351
+ observer: () => {
352
+ }
353
+ },
354
+ "node-key": {
355
+ props: !0,
356
+ type: String,
357
+ default: "id"
358
+ },
359
+ "show-checkbox": {
360
+ type: Boolean,
361
+ default: !1,
362
+ observer: () => {
363
+ s(this, J).call(this);
364
+ }
365
+ },
366
+ checked: {
367
+ type: Boolean,
368
+ default: !1,
369
+ observer: (e) => {
370
+ s(this, X).call(this, e), this.updateContainerClasslist();
371
+ }
372
+ },
373
+ expanded: {
374
+ type: Boolean,
375
+ default: !1,
376
+ observer: (e) => {
377
+ this.hidden = !e, this.updateContainerClasslist();
378
+ }
379
+ }
380
+ }));
381
+ /**
382
+ * 获取 classlist 列表
383
+ * @return {string} 属性值
384
+ */
385
+ /**
386
+ * 更新 checkbox 可见性
387
+ */
388
+ n(this, J, () => {
389
+ s(this, y).querySelectorAll("ea-tree-label").forEach((t) => {
390
+ t["show-checkbox"] = this["show-checkbox"];
391
+ });
392
+ });
393
+ /**
394
+ * 获取或创建子节点插槽元素
395
+ * @return {HTMLElement} 子节点插槽元素
396
+ */
397
+ n(this, K, () => {
398
+ let e = this.querySelector('[slot="children"]');
399
+ if (!e) {
400
+ const t = document.createElement("div");
401
+ t.slot = "children", this.appendChild(t), e = t;
402
+ }
403
+ return e;
404
+ });
405
+ /**
406
+ * 创建树节点路径
407
+ * @param {number} index 节点索引
408
+ * @returns {string} 节点路径
409
+ */
410
+ n(this, z, (e) => {
411
+ var r;
412
+ const t = (r = this.parentElement) == null ? void 0 : r.querySelector("ea-tree-label");
413
+ return t ? `${t.getAttribute("path")}-${e + 1}` : (e + 1).toString();
414
+ });
415
+ /**
416
+ * 创建子节点元素
417
+ * @param {Object} item 数据项
418
+ * @param {number} index 索引
419
+ * @returns {Object} 包含section、treeLabel和tree的对象
420
+ */
421
+ n(this, G, (e, t) => {
422
+ if (!e) return { section: null, treeLabel: null, tree: null };
423
+ const { children: r, disabled: a } = this.dataProps, i = document.createElement("section"), l = document.createElement("ea-tree-child"), c = document.createElement("ea-tree-label");
424
+ return i.className = this.ns.e("children"), i.part = "children-wrapper", l.part = "children", c.part = "label", c.dataProps = this.dataProps, l.dataProps = this.dataProps, c.data = e, l.data = e[r], l.hidden = !0, c["show-checkbox"] = this["show-checkbox"], c.setAttribute("path", s(this, z).call(this, t)), a && e[a] === !0 && c.toggleAttribute("disabled", !0), this["show-checkbox"] && l.toggleAttribute("show-checkbox", !0), e[r] && e[r].length > 0 && (c.hasChildren = !0, l.hidden = !s(this, F).expandedNodes.has(c)), { section: i, treeLabel: c, tree: l };
425
+ });
426
+ /**
427
+ * 渲染树节点
428
+ * @param {Array} treeData 树数据
429
+ */
430
+ n(this, Q, (e) => {
431
+ const t = document.createDocumentFragment(), r = s(this, K).call(this);
432
+ e.forEach((a, i) => {
433
+ const { section: l, treeLabel: c, tree: q } = s(this, G).call(this, a, i);
434
+ l.appendChild(c), l.appendChild(q), t.appendChild(l);
435
+ }), r.appendChild(t);
436
+ });
437
+ n(this, X, (e) => {
438
+ s(this, y).querySelectorAll("ea-tree-label").forEach((t) => {
439
+ t.checked = e;
440
+ }), s(this, y).querySelectorAll("ea-tree-child").forEach((t) => {
441
+ t.checked = e;
442
+ });
443
+ });
444
+ this.stylesheet = we, this.$render();
445
+ }
446
+ static get observedAttributes() {
447
+ return [
448
+ ...super.observedAttributes,
449
+ "show-checkbox",
450
+ "checked",
451
+ "expanded"
452
+ ];
453
+ }
454
+ updateContainerClasslist() {
455
+ const e = this.computedClasslist(
456
+ this.ns.b(),
457
+ {
458
+ // ['--' + this.type]: this.type,
459
+ },
460
+ {}
461
+ );
462
+ return s(this, y).className = e, e;
463
+ }
464
+ $render() {
465
+ const e = ce("tree-child");
466
+ this.ns = e, this.shadowRoot.innerHTML = `
467
+ <div class='${e.b()}' part='container'>
468
+ <slot name="children"></slot>
469
+ </div>
470
+ `, f(this, y, this.shadowRoot.querySelector(e.cb()));
471
+ }
472
+ connectedCallback() {
473
+ var e;
474
+ super.connectedCallback(), (e = s(this, N)) == null || e.abort(), f(this, N, new AbortController()), this.updateContainerClasslist();
475
+ }
476
+ $beforeUnmounted() {
477
+ var e;
478
+ (e = s(this, N)) == null || e.abort();
479
+ for (const t of Object.values(s(this, w)))
480
+ t == null || t.abort();
481
+ }
482
+ }
483
+ y = new WeakMap(), N = new WeakMap(), F = new WeakMap(), w = new WeakMap(), J = new WeakMap(), K = new WeakMap(), z = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), X = new WeakMap();
484
+ customElements.get("ea-tree-child") || customElements.define("ea-tree-child", Ie);
485
+ var u, x, h, m, A, B, g, Y, Z, O, V, ee, te, S, I, E, se, R, re, H, j, D, ae, ie, ne, oe, le, de;
486
+ class Re extends he {
487
+ constructor() {
488
+ super();
489
+ /** @type {HTMLElement} */
490
+ n(this, u);
491
+ /** @type {AbortController} */
492
+ n(this, x, new AbortController());
493
+ n(this, h, {
494
+ expandedNodes: /* @__PURE__ */ new Set(),
495
+ selectedNode: null,
496
+ checkedNodes: /* @__PURE__ */ new Set()
497
+ });
498
+ n(this, m, {
499
+ /** @type {AbortController} */
500
+ dataController: null
501
+ });
502
+ b(this, "attrState", this.properties({
503
+ "show-checkbox": {
504
+ type: Boolean,
505
+ default: !1,
506
+ observer: () => {
507
+ s(this, se).call(this);
508
+ }
509
+ },
510
+ "check-strictly": {
511
+ type: Boolean,
512
+ default: !1
513
+ },
514
+ "node-key": {
515
+ type: String,
516
+ default: null
517
+ },
518
+ "expand-on-icon-click": {
519
+ type: Boolean,
520
+ default: !1
521
+ }
522
+ }));
523
+ b(this, "propState", this.properties({
524
+ data: {
525
+ props: !0,
526
+ type: Array,
527
+ default: "",
528
+ /** @param {Array} newVal */
529
+ observer: async (e) => {
530
+ var t;
531
+ await customElements.whenDefined("ea-tree"), await customElements.whenDefined("ea-tree-label"), (t = s(this, m).dataController) == null || t.abort(), s(this, u).innerHTML = "", e && (s(this, m).dataController = new AbortController(), s(this, Z).call(this, e), s(this, ae).call(this), ke(() => {
532
+ s(this, O).call(this, this.defaultExpandedKeys), s(this, V).call(this, this.defaultCheckedKeys);
533
+ }, 16));
534
+ }
535
+ },
536
+ dataProps: {
537
+ props: !0,
538
+ type: Object,
539
+ default: {
540
+ children: "children",
541
+ label: "label",
542
+ disabled: "disabled"
543
+ }
544
+ },
545
+ defaultExpandedKeys: {
546
+ props: !0,
547
+ type: Array,
548
+ default: [],
549
+ observer: () => {
550
+ }
551
+ },
552
+ defaultCheckedKeys: {
553
+ props: !0,
554
+ type: Array,
555
+ default: [],
556
+ observer: () => {
557
+ }
558
+ }
559
+ }));
560
+ /**
561
+ * 根据节点键值查找标签元素
562
+ * @param {*} key 节点键值
563
+ * @returns {HTMLElement|null} 找到的标签元素或null
564
+ */
565
+ n(this, A, (e) => {
566
+ if (!this["node-key"]) return null;
567
+ const t = this["node-key"];
568
+ return [...s(this, u).querySelectorAll("ea-tree-label")].find((a) => a.data && a.data[t] === e);
569
+ });
570
+ /**
571
+ * 根据节点数据查找标签元素
572
+ * @param {Object} data 节点数据
573
+ * @returns {HTMLElement|null} 找到的标签元素或null
574
+ */
575
+ n(this, B, (e) => this["node-key"] ? [...s(this, u).querySelectorAll("ea-tree-label")].find((r) => r.data ? JSON.stringify(r.data) === JSON.stringify(e) : !1) : null);
576
+ n(this, g, (e) => e ? typeof e == "object" ? s(this, B).call(this, e) : typeof e == "number" || typeof e == "string" ? s(this, A).call(this, e) : null : null);
577
+ /**
578
+ * 创建树节点元素
579
+ * @param {Object} item 数据项
580
+ * @param {number} index 索引
581
+ * @returns {Object} 包含section、treeLabel和tree的对象
582
+ */
583
+ n(this, Y, (e, t) => {
584
+ const { children: r, disabled: a } = this.dataProps, i = document.createElement("section"), l = document.createElement("ea-tree-child"), c = document.createElement("ea-tree-label");
585
+ return i.className = "ea-tree__children", i.part = "children-wrapper", l.part = "children", c.part = "label", c.dataProps = this.dataProps, l.dataProps = this.dataProps, c.data = e, l.data = e[r], c["show-checkbox"] = this["show-checkbox"], c.setAttribute("path", (t + 1).toString().concat("$")), a && e[a] === !0 && c.toggleAttribute("disabled", !0), this["show-checkbox"] && l.setAttribute("show-checkbox", ""), e[r] && e[r].length > 0 && (c.hasChildren = !0, l.hidden = !s(this, h).expandedNodes.has(c)), { section: i, treeLabel: c, tree: l };
586
+ });
587
+ /**
588
+ * 渲染树节点
589
+ * @param {Array} treeData 树数据
590
+ */
591
+ n(this, Z, (e) => {
592
+ const t = document.createDocumentFragment();
593
+ e.forEach((r, a) => {
594
+ const { section: i, treeLabel: l, tree: c } = s(this, Y).call(this, r, a);
595
+ i.appendChild(l), i.appendChild(c), t.appendChild(i);
596
+ }), s(this, u).appendChild(t);
597
+ });
598
+ /**
599
+ * 处理默认展开键
600
+ * @param {Array} expandedKeys 展开键数组
601
+ */
602
+ n(this, O, (e) => {
603
+ const t = this["node-key"];
604
+ if (!t) return;
605
+ const r = [...s(this, u).querySelectorAll("ea-tree-label")];
606
+ e.forEach((a) => {
607
+ const i = r.find((l) => l.data[t] === a);
608
+ i && (s(this, h).expandedNodes.add(i), s(this, S).call(this, i.nextElementSibling, i));
609
+ });
610
+ });
611
+ /**
612
+ * 处理默认选中键
613
+ * @param {Array} checkedKeys 选中键数组
614
+ */
615
+ n(this, V, (e) => {
616
+ const t = this["node-key"];
617
+ if (!t) return;
618
+ const r = [...s(this, u).querySelectorAll("ea-tree-label")];
619
+ e.forEach((a) => {
620
+ const i = r.find((l) => l.data[t] === a);
621
+ i && (i.checked = !0, i.dispatchEvent(
622
+ new CustomEvent("ea-tree-checkbox-click", {
623
+ bubbles: !0,
624
+ composed: !0,
625
+ detail: {
626
+ label: i,
627
+ checked: !0
628
+ }
629
+ })
630
+ ));
631
+ });
632
+ });
633
+ /**
634
+ * 点击标签事件
635
+ * @param {MouseEvent} e 事件对象
636
+ */
637
+ n(this, ee, (e) => {
638
+ e.stopImmediatePropagation();
639
+ const t = e.detail.label, r = e.detail.child, a = e.detail.isIconClick;
640
+ if (t) {
641
+ if (this["expand-on-icon-click"]) {
642
+ a ? t.hasChildren && (s(this, h).expandedNodes.has(t) ? (s(this, h).expandedNodes.delete(t), s(this, I).call(this, r, t)) : (s(this, h).expandedNodes.add(t), s(this, S).call(this, r, t))) : (this.dispatchEvent(
643
+ new Ce({
644
+ data: t.data
645
+ })
646
+ ), s(this, E).call(this, t));
647
+ return;
648
+ }
649
+ this.dispatchEvent(
650
+ new Ce({
651
+ data: t.data
652
+ })
653
+ ), t.hasChildren && (s(this, h).expandedNodes.has(t) ? (s(this, h).expandedNodes.delete(t), s(this, I).call(this, r, t)) : (s(this, h).expandedNodes.add(t), s(this, S).call(this, r, t))), s(this, E).call(this, t);
654
+ }
655
+ });
656
+ /**
657
+ * 右键点击事件
658
+ * @param {MouseEvent} e 事件对象
659
+ */
660
+ n(this, te, (e) => {
661
+ e.preventDefault(), e.stopImmediatePropagation();
662
+ const t = e.target.closest("ea-tree-label");
663
+ !t || t.disabled || this.dispatchEvent(
664
+ new Pe({
665
+ data: t.data,
666
+ node: t
667
+ })
668
+ );
669
+ });
670
+ /**
671
+ * 展开节点
672
+ * @param {HTMLElement} tree 树元素
673
+ * @param {HTMLElement} label 标签元素
674
+ */
675
+ n(this, S, (e, t) => {
676
+ e.toggleAttribute("hidden", !1), t.toggleAttribute("expanded", !0), this.dispatchEvent(
677
+ new Se({
678
+ data: t.data,
679
+ node: t,
680
+ expanded: !0
681
+ })
682
+ );
683
+ });
684
+ /**
685
+ * 收起节点
686
+ * @param {HTMLElement} tree 树元素
687
+ * @param {HTMLElement} label 标签元素
688
+ */
689
+ n(this, I, (e, t) => {
690
+ e.toggleAttribute("hidden", !0), t.toggleAttribute("expanded", !1), this.dispatchEvent(
691
+ new qe({
692
+ data: t.data,
693
+ node: t,
694
+ expanded: !1
695
+ })
696
+ );
697
+ });
698
+ /**
699
+ * 选中节点
700
+ * @param {HTMLElement} label 标签元素
701
+ */
702
+ n(this, E, (e) => {
703
+ s(this, h).selectedNode && (s(this, h).selectedNode.selected = !1), s(this, h).selectedNode = e, e.selected = !0, this.dispatchEvent(
704
+ new Le({
705
+ node: e.data,
706
+ selected: !0
707
+ })
708
+ ), this.dispatchEvent(
709
+ new Ke({
710
+ data: e.data,
711
+ node: e
712
+ })
713
+ );
714
+ });
715
+ /**
716
+ * 更新 checkbox 可见性
717
+ */
718
+ n(this, se, () => {
719
+ s(this, u).querySelectorAll("ea-tree-label").forEach((t) => {
720
+ t["show-checkbox"] = this["show-checkbox"];
721
+ });
722
+ });
723
+ /**
724
+ * 获取相同树路径下的所有节点
725
+ * @param {string} treeRootPath 树路径
726
+ * @returns {Array} 相同树路径的节点数组
727
+ */
728
+ n(this, R, (e) => {
729
+ const t = [], r = e.split("-");
730
+ for (t.push(s(this, u).querySelector(`[path="${r[0]}"]`)); r.length > 1; ) {
731
+ const a = r.join("-");
732
+ r.pop(), t.push(
733
+ ...s(this, u).querySelectorAll(`[path^="${a}"]`)
734
+ );
735
+ }
736
+ return t;
737
+ });
738
+ /**
739
+ * 检查节点状态
740
+ * @param {Array} labelEls 标签元素数组
741
+ * @param {HTMLElement} currentNode 当前节点
742
+ * @returns {Object} 包含isAllChecked和isAnyChecked的对象
743
+ */
744
+ n(this, re, (e, t) => {
745
+ const r = e.every(
746
+ (i) => i.getAttribute("checked") || i === t
747
+ ), a = e.some(
748
+ (i) => i.getAttribute("checked") && i !== t
749
+ );
750
+ return { isAllChecked: r, isAnyChecked: a };
751
+ });
752
+ /**
753
+ * 更新节点复选框状态
754
+ * @param {HTMLElement} node 节点元素
755
+ * @param {boolean} isAllChecked 是否全部选中
756
+ * @param {boolean} isAnyChecked 是否有选中
757
+ */
758
+ n(this, H, (e, t, r) => {
759
+ t ? (e.toggleAttribute("checked", !0), e.toggleAttribute("indeterminate", !1)) : r ? (e.toggleAttribute("checked", !1), e.toggleAttribute("indeterminate", !0)) : (e.toggleAttribute("checked", !1), e.toggleAttribute("indeterminate", !1));
760
+ });
761
+ /**
762
+ * 获取所有标签元素
763
+ * @returns {Array} 所有标签元素数组
764
+ */
765
+ n(this, j, () => [...s(this, u).querySelectorAll("ea-tree-label")]);
766
+ n(this, D, (e) => {
767
+ if (e.disabled) return;
768
+ const t = e.getAttribute("path"), r = s(this, R).call(this, t), a = r.filter(
769
+ (l) => l.getAttribute("path").startsWith(t) && l !== e
770
+ );
771
+ r.filter(
772
+ (l) => !a.includes(l) && l !== e
773
+ ).forEach((l) => {
774
+ l.expanded = !0;
775
+ });
776
+ });
777
+ /**
778
+ * 绑定树组件事件
779
+ */
780
+ n(this, ae, () => {
781
+ s(this, u).addEventListener(
782
+ "ea-tree-label-click",
783
+ s(this, ee),
784
+ {
785
+ signal: s(this, m).dataController.signal
786
+ }
787
+ ), s(this, u).addEventListener(
788
+ "ea-tree-checkbox-click",
789
+ s(this, de),
790
+ {
791
+ signal: s(this, m).dataController.signal
792
+ }
793
+ ), s(this, u).addEventListener("contextmenu", s(this, te), {
794
+ signal: s(this, m).dataController.signal
795
+ });
796
+ });
797
+ /**
798
+ * 绑定复选框状态管理事件
799
+ */
800
+ n(this, ie, () => {
801
+ s(this, u).addEventListener(
802
+ "ea-tree-checkbox-click",
803
+ s(this, le),
804
+ {
805
+ signal: s(this, x).signal
806
+ }
807
+ );
808
+ });
809
+ /**
810
+ * 检查节点子树中是否存在被选中的节点
811
+ * @param {HTMLElement} label 标签元素
812
+ * @returns {boolean} 子树中是否存在被选中的节点
813
+ */
814
+ n(this, ne, (e) => {
815
+ const t = e.getAttribute("path"), r = s(this, u).querySelectorAll(
816
+ `[path^="${t}-"]`
817
+ );
818
+ for (const a of r)
819
+ if (a.hasAttribute("checked"))
820
+ return !0;
821
+ return !1;
822
+ });
823
+ /**
824
+ * 触发 ea-check 事件
825
+ * @param {HTMLElement} label 标签元素
826
+ * @param {boolean} checked 选中状态
827
+ */
828
+ n(this, oe, (e, t) => {
829
+ const r = this.getCheckedNodes(), a = this.getCheckedKeys(), i = this.getHalfCheckedNodes(), l = this.getHalfCheckedKeys();
830
+ this.dispatchEvent(
831
+ new Te({
832
+ data: e.data,
833
+ checkedState: {
834
+ checkedNodes: r,
835
+ checkedKeys: a,
836
+ halfCheckedNodes: i,
837
+ halfCheckedKeys: l
838
+ }
839
+ })
840
+ );
841
+ });
842
+ /**
843
+ * 处理复选框状态变化
844
+ * @param {CustomEvent} e 事件对象
845
+ */
846
+ n(this, le, (e) => {
847
+ var ue;
848
+ e.stopImmediatePropagation();
849
+ const { label: t, checked: r } = e.detail;
850
+ if (t.disabled) return;
851
+ const a = t.getAttribute("path"), i = s(this, R).call(this, a), l = i.filter(
852
+ (p) => p.getAttribute("path").startsWith(a) && p !== t
853
+ ), c = i.filter(
854
+ (p) => p !== t && !l.includes(p)
855
+ );
856
+ l.forEach((p) => {
857
+ p.disabled || (p.checked = r);
858
+ }), c.reverse().forEach((p) => {
859
+ if (p.disabled) return;
860
+ const be = p.closest(".ea-tree-child__children"), me = p.closest(".ea-tree__children"), ye = be ? [...be.querySelectorAll("ea-tree-label")] : [...me.querySelectorAll("ea-tree-label")], { isAllChecked: ge, isAnyChecked: xe } = s(this, re).call(this, ye, p);
861
+ s(this, H).call(this, p, ge, xe);
862
+ }), (ue = t == null ? void 0 : t.isRoot) != null && ue.call(t) && (s(this, H).call(this, t, r, r), s(this, u).querySelectorAll(`[path^="${a}"]`).forEach((p) => {
863
+ p.disabled || (p.checked = r);
864
+ }));
865
+ const q = s(this, ne).call(this, t);
866
+ this.dispatchEvent(
867
+ new $e({
868
+ data: t.data,
869
+ checked: r,
870
+ hasCheckedChildren: q
871
+ })
872
+ ), s(this, oe).call(this, t, r);
873
+ });
874
+ /**
875
+ * 复选框点击事件
876
+ * @param {CustomEvent} e 事件对象
877
+ */
878
+ n(this, de, (e) => {
879
+ e.stopImmediatePropagation();
880
+ const t = e.detail.label, r = e.detail.checked;
881
+ t && this.dispatchEvent(
882
+ new CustomEvent("ea-check-change", {
883
+ detail: {
884
+ node: t.item,
885
+ checked: r,
886
+ checkedNodes: Array.from(s(this, h).checkedNodes).map(
887
+ (a) => a.item
888
+ )
889
+ }
890
+ })
891
+ );
892
+ });
893
+ /**
894
+ * 获取半选中节点数据
895
+ * @returns {Array} 半选中节点数据数组
896
+ */
897
+ b(this, "getHalfCheckedNodes", () => {
898
+ if (!this["show-checkbox"])
899
+ return [];
900
+ const e = [...s(this, u).querySelectorAll("ea-tree-label")], t = [];
901
+ return e.forEach((r) => {
902
+ r.hasAttribute("indeterminate") && t.push(r.data);
903
+ }), t;
904
+ });
905
+ /**
906
+ * 获取半选中节点键值
907
+ * @returns {Array} 半选中节点键值数组
908
+ */
909
+ b(this, "getHalfCheckedKeys", () => {
910
+ if (!this["show-checkbox"] || !this["node-key"])
911
+ return [];
912
+ const e = s(this, u).querySelectorAll("ea-tree-label"), t = [], r = this["node-key"];
913
+ return e.forEach((a) => {
914
+ a.hasAttribute("indeterminate") && a.data && a.data[r] && t.push(a.data[r]);
915
+ }), t;
916
+ });
917
+ /**
918
+ * 获取当前选中节点键值
919
+ * @returns {*} 当前选中节点键值或null
920
+ */
921
+ b(this, "getCurrentKey", () => {
922
+ if (!this["node-key"] || !s(this, h).selectedNode)
923
+ return null;
924
+ const e = this["node-key"], t = s(this, h).selectedNode.data;
925
+ return t && t[e] ? t[e] : null;
926
+ });
927
+ /**
928
+ * 获取当前选中节点数据
929
+ * @returns {*} 当前选中节点数据或null
930
+ */
931
+ b(this, "getCurrentNode", () => s(this, h).selectedNode ? s(this, h).selectedNode.data : null);
932
+ /**
933
+ * 更新节点键值的子节点数据
934
+ * @param {*} key 节点键值
935
+ * @param {Array} data 子节点数据数组
936
+ * @returns {boolean} 是否更新成功
937
+ */
938
+ b(this, "updateKeyChildren", (e, t) => {
939
+ if (!this["node-key"])
940
+ return console.warn("updateKeyChildren requires node-key to be set"), !1;
941
+ const r = s(this, A).call(this, e);
942
+ if (!r)
943
+ return console.warn(`Node with key ${e} not found`), !1;
944
+ const a = r.nextElementSibling;
945
+ if (!a || a.tagName !== "EA-TREE-CHILD")
946
+ return console.warn("Target node is not a parent node"), !1;
947
+ const { children: i } = this.dataProps;
948
+ return r.data = { ...r.data, [i]: t }, a.data = t, ke(() => {
949
+ r.emit("ea-tree-checkbox-click", {
950
+ bubbles: !0,
951
+ composed: !0,
952
+ detail: {
953
+ label: r,
954
+ checked: r.checked
955
+ }
956
+ });
957
+ }, 16), !0;
958
+ });
959
+ /**
960
+ * 获取选中节点数据
961
+ * @param {boolean} leafOnly 是否仅返回叶子节点
962
+ * @param {boolean} includeHalfChecked 是否包含半选中节点
963
+ * @returns {Array} 选中节点数据数组
964
+ */
965
+ b(this, "getCheckedNodes", (e = !1, t = !1) => {
966
+ if (!this["show-checkbox"])
967
+ return [];
968
+ const r = s(this, j).call(this), a = [];
969
+ return r.forEach((i) => {
970
+ const l = i.hasAttribute("checked"), c = i.hasAttribute("indeterminate");
971
+ if (l || t && c) {
972
+ if (e && i.hasChildren)
973
+ return;
974
+ a.push(i.data);
975
+ }
976
+ }), a;
977
+ });
978
+ /**
979
+ * 设置选中节点数据
980
+ * @param {Array} nodes 选中节点数据数组
981
+ * @param {boolean} leafOnly 是否仅选中叶子节点
982
+ * @returns {boolean} 是否设置成功
983
+ */
984
+ b(this, "setCheckedNodes", (e, t = !1) => !this["show-checkbox"] || !this["node-key"] ? (console.warn(
985
+ "setCheckedNodes requires show-checkbox and node-key to be set"
986
+ ), !1) : (e.forEach((r) => {
987
+ const a = s(this, g).call(this, r);
988
+ a && (a.disabled || (a.checked = !0, a.indeterminate = !1, this["check-strictly"] || a.dispatchEvent(
989
+ new CustomEvent("ea-tree-checkbox-click", {
990
+ bubbles: !0,
991
+ composed: !0,
992
+ detail: {
993
+ label: a,
994
+ checked: !0
995
+ }
996
+ })
997
+ )));
998
+ }), !0));
999
+ /**
1000
+ * 获取选中节点键值
1001
+ * @param {boolean} leafOnly 是否仅返回叶子节点
1002
+ * @returns {Array} 选中节点键值数组
1003
+ */
1004
+ b(this, "getCheckedKeys", (e = !1) => {
1005
+ if (!this["show-checkbox"] || !this["node-key"])
1006
+ return [];
1007
+ const t = s(this, j).call(this), r = [], a = this["node-key"];
1008
+ return t.forEach((i) => {
1009
+ if (i.hasAttribute("checked") && i.data && i.data[a]) {
1010
+ if (e && i.hasChildren)
1011
+ return;
1012
+ r.push(i.data[a]);
1013
+ }
1014
+ }), r;
1015
+ });
1016
+ /**
1017
+ * 设置选中节点键值
1018
+ * @param {Array} keys 选中节点键值数组
1019
+ * @param {boolean} leafOnly 是否仅选中叶子节点
1020
+ * @returns {boolean} 是否设置成功
1021
+ */
1022
+ b(this, "setCheckedKeys", (e, t = !1) => !this["show-checkbox"] || !this["node-key"] ? (console.warn(
1023
+ "setCheckedKeys requires show-checkbox and node-key to be set"
1024
+ ), !1) : (e.forEach((r) => {
1025
+ const a = s(this, g).call(this, r);
1026
+ a && (a.disabled || t && a.hasChildren || (a.checked = !0, a.indeterminate = !1, this["check-strictly"] || a.dispatchEvent(
1027
+ new CustomEvent("ea-tree-checkbox-click", {
1028
+ bubbles: !0,
1029
+ composed: !0,
1030
+ detail: {
1031
+ label: a,
1032
+ checked: !0
1033
+ }
1034
+ })
1035
+ )));
1036
+ }), !0));
1037
+ /**
1038
+ * 设置节点选中状态
1039
+ * @param {*} keyOrData 节点键值或数据对象
1040
+ * @param {boolean} checked 是否选中
1041
+ * @returns {boolean} 是否设置成功
1042
+ */
1043
+ b(this, "setChecked", (e, t) => {
1044
+ if (!this["show-checkbox"] || !this["node-key"])
1045
+ return console.warn("setChecked requires show-checkbox and node-key to be set"), !1;
1046
+ let r;
1047
+ return typeof e == "object" ? r = s(this, B).call(this, e) : r = s(this, A).call(this, e), r ? r.disabled ? (console.warn("Cannot set checked state for disabled node"), !1) : (r.checked = t, this["check-strictly"] || r.dispatchEvent(
1048
+ new CustomEvent("ea-tree-checkbox-click", {
1049
+ bubbles: !0,
1050
+ composed: !0,
1051
+ detail: {
1052
+ label: r,
1053
+ checked: t
1054
+ }
1055
+ })
1056
+ ), !0) : (console.warn("Node not found"), !1);
1057
+ });
1058
+ b(this, "setCurrentKey", (e, t = !0) => {
1059
+ if (!this["node-key"])
1060
+ return console.warn("setCurrentKey requires node-key to be set"), !1;
1061
+ if (!e)
1062
+ return s(this, h).selectedNode && (s(this, h).selectedNode.selected = !1, s(this, h).selectedNode = null), !0;
1063
+ const r = s(this, g).call(this, e);
1064
+ return r ? r.disabled ? (console.warn("Cannot select disabled node"), !1) : (s(this, E).call(this, r), t && s(this, D).call(this, r), !0) : (console.warn(`Node with key ${e} not found`), !1);
1065
+ });
1066
+ b(this, "setCurrentNode", (e, t = !0) => {
1067
+ if (!this["node-key"])
1068
+ return console.warn("setCurrentNode requires node-key to be set"), !1;
1069
+ if (!e)
1070
+ return s(this, h).selectedNode && (s(this, h).selectedNode.selected = !1, s(this, h).selectedNode = null), !0;
1071
+ const r = s(this, g).call(this, e);
1072
+ return r ? r.disabled ? (console.warn("Cannot select disabled node"), !1) : (s(this, E).call(this, r), t && s(this, D).call(this, r), !0) : (console.warn("Node not found"), !1);
1073
+ });
1074
+ b(this, "getNode", (e) => {
1075
+ if (!this["node-key"])
1076
+ return console.warn("getNode requires node-key to be set"), null;
1077
+ const t = s(this, g).call(this, e);
1078
+ return t ? {
1079
+ label: t,
1080
+ child: t.nextElementSibling,
1081
+ data: e
1082
+ } : null;
1083
+ });
1084
+ this.stylesheet = Ae, this.$render();
1085
+ }
1086
+ static get observedAttributes() {
1087
+ return [
1088
+ ...super.observedAttributes,
1089
+ "show-checkbox",
1090
+ "check-strictly",
1091
+ "node-key",
1092
+ "expand-on-icon-click"
1093
+ ];
1094
+ }
1095
+ /**
1096
+ * 获取 classlist 列表
1097
+ * @return {string} 属性值
1098
+ */
1099
+ updateContainerClasslist() {
1100
+ const e = this.computedClasslist("ea-tree", {}, {});
1101
+ return s(this, u).className = e, e;
1102
+ }
1103
+ $render() {
1104
+ const e = ce("tree");
1105
+ this.ns = e, this.shadowRoot.innerHTML = `
1106
+ <div class='${e.b("tree")}' part='container'></div>
1107
+ <slot></slot>
1108
+ `, f(this, u, this.shadowRoot.querySelector(e.cb("tree")));
1109
+ }
1110
+ connectedCallback() {
1111
+ var e;
1112
+ super.connectedCallback(), (e = s(this, x)) == null || e.abort(), f(this, x, new AbortController()), s(this, ie).call(this), this.updateContainerClasslist();
1113
+ }
1114
+ $beforeUnmounted() {
1115
+ var e;
1116
+ (e = s(this, x)) == null || e.abort();
1117
+ for (const t of Object.values(s(this, m)))
1118
+ t == null || t.abort();
1119
+ }
1120
+ }
1121
+ u = new WeakMap(), x = new WeakMap(), h = new WeakMap(), m = new WeakMap(), A = new WeakMap(), B = new WeakMap(), g = new WeakMap(), Y = new WeakMap(), Z = new WeakMap(), O = new WeakMap(), V = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), S = new WeakMap(), I = new WeakMap(), E = new WeakMap(), se = new WeakMap(), R = new WeakMap(), re = new WeakMap(), H = new WeakMap(), j = new WeakMap(), D = new WeakMap(), ae = new WeakMap(), ie = new WeakMap(), ne = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), de = new WeakMap();
1122
+ customElements.get("ea-tree") || customElements.define("ea-tree", Re);
1123
+ export {
1124
+ Re as EaTree
1125
+ };