easy-component-ui 3.0.12 → 3.0.14

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 (168) hide show
  1. package/package.json +308 -304
  2. package/dist/assets/icon.css +0 -1
  3. package/dist/components/Base.js +0 -873
  4. package/dist/components/ea-alert.js +0 -196
  5. package/dist/components/ea-avatar.js +0 -159
  6. package/dist/components/ea-backtop.js +0 -136
  7. package/dist/components/ea-badge.js +0 -144
  8. package/dist/components/ea-breadcrumb.js +0 -148
  9. package/dist/components/ea-button.js +0 -265
  10. package/dist/components/ea-calendar.js +0 -10
  11. package/dist/components/ea-calendar2.js +0 -671
  12. package/dist/components/ea-card.js +0 -85
  13. package/dist/components/ea-carousel.js +0 -415
  14. package/dist/components/ea-checkbox.js +0 -446
  15. package/dist/components/ea-collapse.js +0 -313
  16. package/dist/components/ea-color-picker.js +0 -891
  17. package/dist/components/ea-container.js +0 -177
  18. package/dist/components/ea-countdown.js +0 -142
  19. package/dist/components/ea-date-picker.js +0 -649
  20. package/dist/components/ea-descriptions.js +0 -474
  21. package/dist/components/ea-dialog.js +0 -249
  22. package/dist/components/ea-drawer.js +0 -211
  23. package/dist/components/ea-dropdown.js +0 -228
  24. package/dist/components/ea-empty.js +0 -93
  25. package/dist/components/ea-icon.js +0 -68
  26. package/dist/components/ea-image-preview.js +0 -488
  27. package/dist/components/ea-image.js +0 -302
  28. package/dist/components/ea-infinite-scroll.js +0 -109
  29. package/dist/components/ea-input-number.js +0 -367
  30. package/dist/components/ea-input.js +0 -588
  31. package/dist/components/ea-layout.js +0 -125
  32. package/dist/components/ea-link.js +0 -101
  33. package/dist/components/ea-loading.js +0 -151
  34. package/dist/components/ea-menu.js +0 -433
  35. package/dist/components/ea-message-box.js +0 -624
  36. package/dist/components/ea-message.js +0 -251
  37. package/dist/components/ea-notification.js +0 -331
  38. package/dist/components/ea-overlay.js +0 -167
  39. package/dist/components/ea-page-header.js +0 -108
  40. package/dist/components/ea-pagination.js +0 -481
  41. package/dist/components/ea-popconfirm.js +0 -275
  42. package/dist/components/ea-popover.js +0 -123
  43. package/dist/components/ea-popper.js +0 -203
  44. package/dist/components/ea-progress.js +0 -286
  45. package/dist/components/ea-radio.js +0 -364
  46. package/dist/components/ea-rate.js +0 -241
  47. package/dist/components/ea-result.js +0 -100
  48. package/dist/components/ea-scrollbar.js +0 -235
  49. package/dist/components/ea-segmented.js +0 -215
  50. package/dist/components/ea-select.js +0 -609
  51. package/dist/components/ea-skeleton.js +0 -263
  52. package/dist/components/ea-slider.js +0 -421
  53. package/dist/components/ea-space.js +0 -123
  54. package/dist/components/ea-splitter.js +0 -217
  55. package/dist/components/ea-statistic.js +0 -74
  56. package/dist/components/ea-steps.js +0 -346
  57. package/dist/components/ea-switch.js +0 -271
  58. package/dist/components/ea-table.js +0 -1124
  59. package/dist/components/ea-tabs.js +0 -501
  60. package/dist/components/ea-tag.js +0 -228
  61. package/dist/components/ea-text.js +0 -113
  62. package/dist/components/ea-time-picker.js +0 -514
  63. package/dist/components/ea-timeline.js +0 -185
  64. package/dist/components/ea-tooltip.js +0 -121
  65. package/dist/components/ea-tour.js +0 -544
  66. package/dist/components/ea-transfer.js +0 -949
  67. package/dist/components/ea-tree.js +0 -1125
  68. package/dist/components/index.js +0 -61
  69. package/dist/core/FormBase.js +0 -238
  70. package/dist/css/ea-alert.style.js +0 -4
  71. package/dist/css/ea-aside.style.js +0 -4
  72. package/dist/css/ea-avatar.style.js +0 -4
  73. package/dist/css/ea-backtop.style.js +0 -4
  74. package/dist/css/ea-badge.style.js +0 -4
  75. package/dist/css/ea-breadcrumb-item.style.js +0 -4
  76. package/dist/css/ea-breadcrumb.style.js +0 -4
  77. package/dist/css/ea-button-group.style.js +0 -4
  78. package/dist/css/ea-button.style.js +0 -4
  79. package/dist/css/ea-calendar.style.js +0 -4
  80. package/dist/css/ea-card.style.js +0 -4
  81. package/dist/css/ea-carousel-item.style.js +0 -4
  82. package/dist/css/ea-carousel.style.js +0 -4
  83. package/dist/css/ea-check-tag.style.js +0 -4
  84. package/dist/css/ea-checkbox-group.style.js +0 -4
  85. package/dist/css/ea-checkbox.style.js +0 -4
  86. package/dist/css/ea-col.style.js +0 -4
  87. package/dist/css/ea-collapse-item.style.js +0 -4
  88. package/dist/css/ea-collapse.style.js +0 -4
  89. package/dist/css/ea-color-picker-panel.style.js +0 -4
  90. package/dist/css/ea-color-picker.style.js +0 -4
  91. package/dist/css/ea-container.style.js +0 -4
  92. package/dist/css/ea-date-picker.style.js +0 -4
  93. package/dist/css/ea-descriptions-item.style.js +0 -4
  94. package/dist/css/ea-descriptions.style.js +0 -4
  95. package/dist/css/ea-dialog.style.js +0 -4
  96. package/dist/css/ea-drawer.style.js +0 -4
  97. package/dist/css/ea-dropdown-item.style.js +0 -4
  98. package/dist/css/ea-dropdown-menu.style.js +0 -4
  99. package/dist/css/ea-dropdown.style.js +0 -4
  100. package/dist/css/ea-empty.style.js +0 -4
  101. package/dist/css/ea-footer.style.js +0 -4
  102. package/dist/css/ea-header.style.js +0 -4
  103. package/dist/css/ea-icon.style.js +0 -4
  104. package/dist/css/ea-image-preview.style.js +0 -4
  105. package/dist/css/ea-image.style.js +0 -4
  106. package/dist/css/ea-infinite-scroll.style.js +0 -4
  107. package/dist/css/ea-input-number.style.js +0 -4
  108. package/dist/css/ea-input.style.js +0 -4
  109. package/dist/css/ea-link.style.js +0 -4
  110. package/dist/css/ea-main.style.js +0 -4
  111. package/dist/css/ea-menu-item-group.style.js +0 -4
  112. package/dist/css/ea-menu-item.style.js +0 -4
  113. package/dist/css/ea-menu.style.js +0 -4
  114. package/dist/css/ea-message-box.style.js +0 -4
  115. package/dist/css/ea-message.style.js +0 -4
  116. package/dist/css/ea-notification.style.js +0 -4
  117. package/dist/css/ea-option-gropu.style.js +0 -4
  118. package/dist/css/ea-option.style.js +0 -4
  119. package/dist/css/ea-overlay.style.js +0 -4
  120. package/dist/css/ea-page-header.style.js +0 -4
  121. package/dist/css/ea-pagination.style.js +0 -4
  122. package/dist/css/ea-popconfirm.style.js +0 -4
  123. package/dist/css/ea-popover.style.js +0 -4
  124. package/dist/css/ea-popper.style.js +0 -4
  125. package/dist/css/ea-progress.style.js +0 -4
  126. package/dist/css/ea-radio-group.style.js +0 -4
  127. package/dist/css/ea-radio.style.js +0 -4
  128. package/dist/css/ea-rate.style.js +0 -4
  129. package/dist/css/ea-result.style.js +0 -4
  130. package/dist/css/ea-row.style.js +0 -4
  131. package/dist/css/ea-scrollbar.style.js +0 -4
  132. package/dist/css/ea-segmented.style.js +0 -4
  133. package/dist/css/ea-select.style.js +0 -4
  134. package/dist/css/ea-skeleton-item.style.js +0 -4
  135. package/dist/css/ea-skeleton.style.js +0 -4
  136. package/dist/css/ea-slider.style.js +0 -4
  137. package/dist/css/ea-space.style.js +0 -4
  138. package/dist/css/ea-splitter-bar.style.js +0 -4
  139. package/dist/css/ea-splitter-panel.style.js +0 -4
  140. package/dist/css/ea-splitter.style.js +0 -4
  141. package/dist/css/ea-statistic.style.js +0 -4
  142. package/dist/css/ea-step.style.js +0 -4
  143. package/dist/css/ea-steps.style.js +0 -4
  144. package/dist/css/ea-sub-menu.style.js +0 -4
  145. package/dist/css/ea-switch.style.js +0 -4
  146. package/dist/css/ea-tab-panel.style.js +0 -4
  147. package/dist/css/ea-tab.style.js +0 -4
  148. package/dist/css/ea-table-column.style.js +0 -4
  149. package/dist/css/ea-table.style.js +0 -4
  150. package/dist/css/ea-tabs.style.js +0 -4
  151. package/dist/css/ea-tag.style.js +0 -4
  152. package/dist/css/ea-text.style.js +0 -4
  153. package/dist/css/ea-time-picker.style.js +0 -4
  154. package/dist/css/ea-timeline-item.style.js +0 -4
  155. package/dist/css/ea-timeline.style.js +0 -4
  156. package/dist/css/ea-tooltip.style.js +0 -4
  157. package/dist/css/ea-tour-step.style.js +0 -4
  158. package/dist/css/ea-tour.style.js +0 -4
  159. package/dist/css/ea-transfer.style.js +0 -5
  160. package/dist/css/ea-tree.style.js +0 -6
  161. package/dist/css/ea-ui-component.style.js +0 -4
  162. package/dist/favicon.ico +0 -0
  163. package/dist/utils/Color.js +0 -439
  164. package/dist/utils/I18nManager.js +0 -218
  165. package/dist/utils/Utils.js +0 -65
  166. package/dist/utils/Variables.js +0 -12
  167. package/dist/utils/parseTime.js +0 -73
  168. package/dist/utils/timeout.js +0 -9
@@ -1,1124 +0,0 @@
1
- var it = Object.defineProperty;
2
- var ot = (r) => {
3
- throw TypeError(r);
4
- };
5
- var ct = (r, o, e) => o in r ? it(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e;
6
- var x = (r, o, e) => ct(r, typeof o != "symbol" ? o + "" : o, e), at = (r, o, e) => o.has(r) || ot("Cannot " + e);
7
- var t = (r, o, e) => (at(r, o, "read from private field"), e ? e.call(r) : o.get(r)), p = (r, o, e) => o.has(r) ? ot("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(r) : o.set(r, e), C = (r, o, e, s) => (at(r, o, "write to private field"), s ? s.call(r, e) : o.set(r, e), e), S = (r, o, e) => (at(r, o, "access private method"), e);
8
- import { E } from "../utils/Utils.js";
9
- import { B as rt } from "./Base.js";
10
- import "./ea-empty.js";
11
- import { s as ht } from "../css/ea-table.style.js";
12
- import { s as dt } from "../css/ea-table-column.style.js";
13
- class ut extends Event {
14
- constructor(o) {
15
- super("ea-cell-click", { bubbles: !0, composed: !0 }), this.detail = o;
16
- }
17
- }
18
- class pt extends Event {
19
- constructor(o) {
20
- super("ea-current-change", { bubbles: !0, composed: !0 }), this.detail = o;
21
- }
22
- }
23
- class bt extends Event {
24
- constructor(o) {
25
- super("ea-row-click", { bubbles: !0, composed: !0 }), this.detail = o;
26
- }
27
- }
28
- class mt extends Event {
29
- constructor(o) {
30
- super("ea-select-all", { bubbles: !0, composed: !0 }), this.detail = o;
31
- }
32
- }
33
- class ft extends Event {
34
- constructor(o) {
35
- super("ea-select", { bubbles: !0, composed: !0 }), this.detail = o;
36
- }
37
- }
38
- class gt extends Event {
39
- constructor(o) {
40
- super("ea-selection-change", { bubbles: !0, composed: !0 }), this.detail = o;
41
- }
42
- }
43
- const Et = (r) => E.EaElement.h(
44
- "colgroup",
45
- "ea-table__colgroup",
46
- {
47
- part: "colgroup"
48
- },
49
- r.map(
50
- (o) => E.EaElement.h("col", "ea-table__col", {
51
- width: o.width,
52
- part: "col"
53
- })
54
- )
55
- ), yt = (r) => E.EaElement.h(
56
- "tfoot",
57
- "ea-table__tfoot",
58
- {
59
- part: "tfoot"
60
- },
61
- E.EaElement.h(
62
- "tr",
63
- "ea-table__tr",
64
- {
65
- part: "tfoot-tr"
66
- },
67
- r.map(
68
- (o) => E.EaElement.h(
69
- "td",
70
- `ea-table__td ${o.fixed ? ` is-fixed fixed-${o.fixed}` : ""}`,
71
- {
72
- part: "tfoot-td",
73
- "data-scope": o.prop
74
- }
75
- )
76
- )
77
- )
78
- ), vt = (r) => E.EaElement.h("span", "ea-table__sort-wrapper", {}, [
79
- E.EaElement.h("span", null, {}, r),
80
- E.EaElement.h(
81
- "span",
82
- "ea-table__sort",
83
- {},
84
- [
85
- E.EaElement.h("ea-icon", "ea-table__sort-icon", {
86
- part: "asc-icon",
87
- icon: "icon-angle-up"
88
- }),
89
- E.EaElement.h("ea-icon", "ea-table__sort-icon", {
90
- part: "desc-icon",
91
- icon: "icon-angle-down"
92
- })
93
- ].join("")
94
- )
95
- ]), wt = () => E.EaElement.h(
96
- "ea-checkbox",
97
- "ea-table__checkbox",
98
- {
99
- "data-type": "selection",
100
- part: "checkbox"
101
- },
102
- null
103
- ), xt = () => "", Ct = (r) => {
104
- const o = (h) => h === "selection" ? wt() : h === "index" ? xt() : null, e = (h, u) => h ? vt(u) : null;
105
- let s = null;
106
- const l = r.label || r.prop || "", n = o(r.type), i = e(r.sortable, l);
107
- return n ? s = n : i ? s = i : r.header ? s = r.header : s = l, E.EaElement.h(
108
- "th",
109
- `ea-table__th${r.fixed ? ` is-fixed fixed-${r.fixed}` : ""}${r.sortable ? " is-sortable" : ""}${r.width ? " is-width" : ""}`.trim(),
110
- {
111
- part: "thead-th",
112
- colspan: r.colspan,
113
- rowspan: r.rowspan,
114
- style: [r.width ? `--ea-table-cell-width: ${r.width}` : ""],
115
- "data-scope": r.prop || ""
116
- },
117
- s
118
- );
119
- }, St = (r) => r.map(
120
- (o) => E.EaElement.h(
121
- "tr",
122
- "ea-table__tr is-thead",
123
- {
124
- part: "thead-tr"
125
- },
126
- o.map(Ct)
127
- )
128
- ), _t = (r) => {
129
- const o = r.reduce((e, s) => (e[s.depth] || (e[s.depth] = []), e[s.depth].push(s), e), []);
130
- return E.EaElement.h(
131
- "thead",
132
- "ea-table__thead",
133
- {
134
- part: "thead"
135
- },
136
- St(o)
137
- );
138
- };
139
- class kt extends Event {
140
- constructor(o) {
141
- super("ea-sort-change", { bubbles: !0, composed: !0 }), this.detail = o;
142
- }
143
- }
144
- class At extends Event {
145
- constructor(o) {
146
- super("ea-cell-mouse-enter", { bubbles: !0, composed: !0 }), this.detail = o;
147
- }
148
- }
149
- class Lt extends Event {
150
- constructor(o) {
151
- super("ea-cell-mouse-leave", { bubbles: !0, composed: !0 }), this.detail = o;
152
- }
153
- }
154
- class Tt extends Event {
155
- constructor(o) {
156
- super("ea-cell-dblclick", { bubbles: !0, composed: !0 }), this.detail = o;
157
- }
158
- }
159
- class Rt extends Event {
160
- constructor(o) {
161
- super("ea-row-dblclick", { bubbles: !0, composed: !0 }), this.detail = o;
162
- }
163
- }
164
- class qt extends Event {
165
- constructor(o) {
166
- super("ea-row-contextmenu", { bubbles: !0, composed: !0 }), this.detail = o;
167
- }
168
- }
169
- class Dt extends Event {
170
- constructor(o) {
171
- super("ea-cell-contextmenu", { bubbles: !0, composed: !0 }), this.detail = o;
172
- }
173
- }
174
- class $t extends Event {
175
- constructor(o) {
176
- super("ea-header-contextmenu", { bubbles: !0, composed: !0 }), this.detail = o;
177
- }
178
- }
179
- class Mt extends Event {
180
- constructor(o) {
181
- super("ea-header-click", { bubbles: !0, composed: !0 }), this.detail = o;
182
- }
183
- }
184
- class Nt extends Event {
185
- constructor(o) {
186
- super("ea-template-cell-click", { bubbles: !0, composed: !0 }), this.detail = o;
187
- }
188
- }
189
- var f, T, w, I, F, B, g, k, c, K, P, D, j, W, $, U, M, G, L, z, J, O, Q, V, X, Y, Z, tt, et;
190
- class Ht extends rt {
191
- constructor() {
192
- super();
193
- /** @type {HTMLElement} */
194
- p(this, f);
195
- /** @type {HTMLElement} */
196
- p(this, T);
197
- /** @type {HTMLElement} */
198
- p(this, w);
199
- /** @type {HTMLElement} */
200
- p(this, I);
201
- /** @type {HTMLSlotElement} */
202
- p(this, F);
203
- /** @type {HTMLElement} */
204
- p(this, B);
205
- /** @type {AbortController} */
206
- p(this, g);
207
- p(this, k, {
208
- /** @type {AbortController | null} */
209
- selectionChangeAbortController: null,
210
- /** @type {AbortController | null} */
211
- selectAbortController: null
212
- });
213
- p(this, c, {
214
- isDataRendered: !1,
215
- currentRow: {
216
- target: null,
217
- value: {}
218
- },
219
- /** @type {import("../ea-table-column/index.js").TableColumnCtx[]} */
220
- columns: [],
221
- originData: [],
222
- dataSource: /* @__PURE__ */ new WeakMap(),
223
- dataIndex: /* @__PURE__ */ new WeakMap()
224
- });
225
- x(this, "state", this.properties({
226
- stripe: {
227
- type: Boolean,
228
- default: !1,
229
- observer: () => {
230
- this.updateContainerClasslist();
231
- }
232
- },
233
- border: {
234
- type: Boolean,
235
- default: !1,
236
- observer: () => {
237
- this.updateContainerClasslist();
238
- }
239
- },
240
- height: {
241
- type: String,
242
- default: null,
243
- observer: (e) => {
244
- this.style.setProperty("--ea-table-height", e), this.updateContainerClasslist();
245
- }
246
- },
247
- "max-height": {
248
- type: String,
249
- default: null,
250
- observer: (e) => {
251
- this.style.setProperty("--ea-table-max-height", e), this.updateContainerClasslist();
252
- }
253
- },
254
- "highlight-current-row": {
255
- type: Boolean,
256
- default: !1,
257
- observer: () => {
258
- }
259
- },
260
- "show-summary": {
261
- type: Boolean,
262
- default: !1,
263
- observer: () => {
264
- }
265
- }
266
- }));
267
- x(this, "propStates", this.properties({
268
- data: {
269
- props: !0,
270
- type: Array,
271
- default: () => t(this, c).originData,
272
- observer: (e) => {
273
- t(this, c).originData = e, this.setData(e);
274
- }
275
- }
276
- }));
277
- x(this, "funcStates", this.properties({
278
- selectable: {
279
- props: !0,
280
- type: Function,
281
- rawFunction: !0,
282
- default: null
283
- },
284
- indexMethod: {
285
- props: !0,
286
- type: Function,
287
- rawFunction: !0,
288
- default: () => (e) => e
289
- },
290
- summaryMethod: {
291
- props: !0,
292
- type: Function,
293
- rawFunction: !0,
294
- default: () => (
295
- /** @param {{columns: ColumnOption, data: any[]}} param */
296
- (e) => {
297
- const { columns: s, data: l } = e, n = [];
298
- return s.forEach((i, h) => {
299
- if (h === 0) {
300
- n[h] = "Sum";
301
- return;
302
- }
303
- const u = l.map((a) => Number(a[i.prop]));
304
- u.every((a) => Number.isNaN(a)) ? n[h] = "" : n[h] = u.reduce((a, b) => {
305
- const m = Number(b);
306
- return Number.isNaN(m) ? a : a + b;
307
- }, 0);
308
- }), n;
309
- }
310
- )
311
- }
312
- }));
313
- /**
314
- * 渲染表格的基本结构
315
- */
316
- p(this, K, () => {
317
- const e = [...this.querySelectorAll("ea-table-column")].map(
318
- (a) => a.getColumnTree
319
- );
320
- t(this, c).columns = e;
321
- const s = Et(e), l = _t(e), n = yt(e), i = this.shadowRoot.querySelector(".ea-table__colgroup"), h = this.shadowRoot.querySelector(".ea-table__thead"), u = this.shadowRoot.querySelector(".ea-table__tfoot");
322
- i && (i.innerHTML = s), h && (h.innerHTML = l), u && (u.innerHTML = n);
323
- });
324
- /**
325
- * 初始化带有筛选的列
326
- */
327
- p(this, P, () => {
328
- if (![
329
- ...t(this, f).querySelectorAll(".ea-table__th.is-sortable")
330
- ].length) return;
331
- const s = (l) => {
332
- const n = l.target.closest(".is-sortable");
333
- if (!n) return;
334
- const { prop: i, order: h } = n.dataset;
335
- if (!i) return;
336
- const u = h === "asc" ? "desc" : "asc", a = {
337
- asc: n.querySelector('[part="asc-icon"]'),
338
- desc: n.querySelector('[part="desc-icon"]')
339
- };
340
- n.setAttribute("data-order", u), n.querySelectorAll(".ea-table__sort-icon").forEach((b) => {
341
- b.classList.toggle("is-active", a[u] === b);
342
- }), this.sort(i, u);
343
- };
344
- t(this, T).addEventListener("click", s, {
345
- signal: t(this, g).signal
346
- });
347
- });
348
- /**
349
- * @param {any[]} dataSource
350
- */
351
- x(this, "setData", async (e) => {
352
- var u;
353
- await customElements.whenDefined("ea-table"), await customElements.whenDefined("ea-table-column"), t(this, c).columns.length === 0 && (t(this, K).call(this), t(this, P).call(this));
354
- const s = document.createDocumentFragment(), l = document.createElement("tr");
355
- l.part = "tbody-tr", l.className = "ea-table__tr";
356
- const n = t(this, c).columns.filter(
357
- (a) => !a.template || a.template instanceof HTMLTemplateElement
358
- ), i = n.some((a) => a.type === "selection"), h = {
359
- selection: () => this.html(
360
- E.EaElement.h(
361
- "ea-checkbox",
362
- "ea-table__selection",
363
- {
364
- "data-type": "selection"
365
- },
366
- null
367
- )
368
- ),
369
- index: () => this.html(
370
- E.EaElement.h(
371
- "span",
372
- "ea-table__index",
373
- {
374
- "data-type": "index"
375
- },
376
- null
377
- )
378
- )
379
- };
380
- for (const a in t(this, k))
381
- (u = t(this, k)[a]) == null || u.abort(), t(this, k)[a] = new AbortController();
382
- if (t(this, c).isDataRendered = !1, t(this, w).innerHTML = "", t(this, c).dataSource = /* @__PURE__ */ new WeakMap(), t(this, c).originData = e, n.forEach((a) => {
383
- var v;
384
- const b = l, { template: m } = a, d = document.createElement("td");
385
- if (d.part = "tbody-td", d.className = "ea-table__td", d.classList.toggle("is-fixed", a.fixed), d.classList.toggle(`fixed-${a.fixed}`, a.fixed), d.classList.toggle(
386
- `ea-table__cell--align-${a.align}`,
387
- a.align
388
- ), a.width && d.style.setProperty("--ea-table-cell-width", a.width), m) {
389
- const A = m.content.cloneNode(!0);
390
- A.querySelectorAll("*").forEach((nt) => {
391
- nt.setAttribute("data-template-cell", "");
392
- }), d.appendChild(A);
393
- } else a.type ? d.innerHTML = (v = h[a.type]) == null ? void 0 : v.call(h) : d.setAttribute("data-scope", a.prop);
394
- b.appendChild(d);
395
- }), e.forEach((a, b) => {
396
- const m = l.cloneNode(!0);
397
- if (m.setAttribute("data-index", b), typeof this.selectable == "function") {
398
- const d = !this.selectable(a);
399
- m.querySelector(
400
- 'ea-checkbox[data-type="selection"]'
401
- ).toggleAttribute("disabled", d);
402
- }
403
- if (n.some((d) => d.type === "index") && typeof this.indexMethod == "function") {
404
- const d = m.querySelector(".ea-table__index");
405
- d.textContent = this.indexMethod(b);
406
- }
407
- m.querySelectorAll("[data-scope]").forEach((d) => {
408
- const v = d.getAttribute("data-scope"), A = n.find((H) => H.prop === v);
409
- A ? d.textContent = a[A.prop] : v in a && (d.textContent = a[v]);
410
- }), s.appendChild(m), t(this, c).dataSource.set(m, a), a && typeof a == "object" && t(this, c).dataIndex.set(a, m);
411
- }), this["show-summary"] && typeof this.summaryMethod == "function") {
412
- const a = t(this, I).querySelectorAll(
413
- ".ea-table__td[data-scope]"
414
- ), b = this.summaryMethod({ columns: n, data: e });
415
- a.forEach((m, d) => {
416
- m.textContent = b[d];
417
- });
418
- }
419
- t(this, w).appendChild(s), i && t(this, f).addEventListener("change", t(this, et), {
420
- signal: t(this, g).signal
421
- }), t(this, W).call(this), t(this, O).call(this), this.updateContainerClasslist(), t(this, c).isDataRendered = !0, this.emit("ea-table-data-rendered");
422
- });
423
- /**
424
- * 排序
425
- * @param {string} prop
426
- * @param {"asc" | "desc"} order
427
- */
428
- x(this, "sort", (e, s = "asc") => {
429
- const l = document.createDocumentFragment(), n = t(this, w).nextElementSibling;
430
- l.appendChild(t(this, w)), [...l.querySelectorAll("tr")].sort((h, u) => {
431
- const a = t(this, c).dataSource.get(h), b = t(this, c).dataSource.get(u);
432
- return s === "asc" ? String(a[e]).localeCompare(b[e]) : String(b[e]).localeCompare(a[e]);
433
- }).forEach((h) => {
434
- t(this, w).appendChild(h);
435
- }), t(this, f).insertBefore(l, n), this.dispatchEvent(
436
- new kt({
437
- prop: e,
438
- order: s
439
- })
440
- );
441
- });
442
- /**
443
- * 设置行样式
444
- * @param {Function | String} handler
445
- */
446
- x(this, "setRowStylePart", (e) => {
447
- if (!t(this, c).isDataRendered)
448
- return console.warn("[EaTable] Please set data first!", this);
449
- const s = [...t(this, w).querySelectorAll("tr")];
450
- if (typeof e == "function")
451
- s.forEach((l, n) => {
452
- const i = e({
453
- row: t(this, c).dataSource.get(l),
454
- rowIndex: n
455
- });
456
- i && l.part.add(i);
457
- });
458
- else if (typeof e == "string") {
459
- if (!e) return;
460
- s.forEach((l) => {
461
- l.part.add(e);
462
- });
463
- }
464
- });
465
- /**
466
- * 设置当前行是否被选中
467
- * @param {any} row
468
- * @param {Boolean} selected
469
- * @param {boolean} [ignoreSelectable]
470
- */
471
- x(this, "toggleRowSelection", (e, s, l = !0) => {
472
- if (!t(this, c).columns.some(
473
- (a) => a.type === "selection"
474
- )) return;
475
- const i = t(this, c).dataIndex.get(e);
476
- if (!i) return;
477
- const h = `ea-checkbox[data-type="selection"]${l ? "" : ":not([disabled])"}`, u = i.querySelector(h);
478
- u && (s ? u.toggleAttribute("checked", s) : u.toggleAttribute("checked", !u.checked), t(this, j).call(this), t(this, M).call(this));
479
- });
480
- /**
481
- * 清空选择
482
- */
483
- x(this, "clearSelection", () => {
484
- [
485
- ...t(this, f).querySelectorAll('ea-checkbox[data-type="selection"]')
486
- ].forEach((s) => {
487
- s.removeAttribute("checked"), s.removeAttribute("indeterminate");
488
- }), t(this, M).call(this);
489
- });
490
- /**
491
- * 获取当前选中的行
492
- * @returns {any[]}
493
- */
494
- p(this, D, () => [
495
- ...t(this, w).querySelectorAll(
496
- 'ea-checkbox[data-type="selection"][checked]'
497
- )
498
- ].map(
499
- (e) => t(this, c).dataSource.get(e.closest('.ea-table__tr[part="tbody-tr"]'))
500
- ));
501
- /**
502
- * 更新选中状态
503
- */
504
- p(this, j, () => {
505
- const e = t(this, T).querySelector(
506
- 'ea-checkbox[data-type="selection"]'
507
- ), s = [
508
- ...t(this, w).querySelectorAll(
509
- 'ea-checkbox[data-type="selection"]:not([disabled])'
510
- )
511
- ].every((n) => n.hasAttribute("checked")), l = [
512
- ...t(this, w).querySelectorAll('ea-checkbox[data-type="selection"]')
513
- ].some((n) => n.hasAttribute("checked"));
514
- s ? (e.toggleAttribute("checked", !0), e.removeAttribute("indeterminate")) : l ? (e.removeAttribute("checked"), e.toggleAttribute("indeterminate", !0)) : (e.removeAttribute("checked"), e.removeAttribute("indeterminate"));
515
- });
516
- /**
517
- * 处理固定列的位置和阴影(box-shadow)
518
- */
519
- p(this, W, () => {
520
- const e = [...t(this, f).querySelectorAll(".is-fixed")], s = e.filter(
521
- (a) => a.classList.contains("fixed-left")
522
- ), l = e.filter(
523
- (a) => a.classList.contains("fixed-right")
524
- ), n = (a) => {
525
- const b = a.filter((d) => d.part.contains("thead-th"));
526
- if (b.length <= 1) return [a];
527
- const m = [];
528
- for (let d = 0; d < a.length; d += b.length)
529
- m.push(a.slice(d, d + b.length));
530
- return m.reduce((d, v) => (v.forEach((A, H) => {
531
- d[H] = [...d[H], A];
532
- }), d), Array(b.length).fill([]));
533
- }, i = (a) => {
534
- if (!a.length) return;
535
- const b = a.slice(-1)[0];
536
- a.forEach((m, d) => {
537
- const v = a[d - 1] || [];
538
- m.forEach((A) => {
539
- b && v[0] && A.style.setProperty(
540
- "--ea-table-fixed-x",
541
- `${d * v[0].offsetWidth}px`
542
- );
543
- });
544
- }), b.forEach((m) => {
545
- m.classList.add("is-last");
546
- });
547
- }, [h, u] = [
548
- n(s),
549
- n(l).reverse()
550
- ];
551
- i(h), i(u);
552
- });
553
- /**
554
- * 设置高亮当前行样式
555
- * @param {HTMLTableRowElement} currentRow
556
- * @param {HTMLTableRowElement} [oldRow]
557
- */
558
- p(this, $, (e, s = t(this, c).currentRow.target) => {
559
- var l, n;
560
- this["highlight-current-row"] && ((l = s == null ? void 0 : s.classList) == null || l.remove("is-current"), (n = e == null ? void 0 : e.classList) == null || n.add("is-current"));
561
- });
562
- /**
563
- * 取消高亮当前行样式
564
- * @param {HTMLTableRowElement} currentRow
565
- */
566
- p(this, U, (e) => {
567
- var s;
568
- !this["highlight-current-row"] || !e || (s = e == null ? void 0 : e.classList) == null || s.remove("is-current");
569
- });
570
- /**
571
- * 派发选择改变事件
572
- */
573
- p(this, M, () => {
574
- const e = t(this, D).call(this);
575
- this.dispatchEvent(
576
- new gt({
577
- newSelection: e
578
- })
579
- );
580
- });
581
- /**
582
- * 点击事件: 行点击, 单元格点击
583
- * @param {MouseEvent} e
584
- */
585
- p(this, G, (e) => {
586
- var i;
587
- const s = e.target.closest("tr[part='tbody-tr']");
588
- if ((i = t(this, k).selectAbortController) == null || i.abort(), !s) return;
589
- const l = () => {
590
- var h;
591
- (h = t(this, k).selectAbortController) == null || h.abort();
592
- }, n = (h) => {
593
- const u = h.target.closest("tr[part='tbody-tr']"), a = h.target.closest("td[part='tbody-td']");
594
- if (l(), u !== s) return;
595
- const b = t(this, c).dataSource.get(s), m = a == null ? void 0 : a.getAttribute("data-scope");
596
- if (t(this, $).call(this, s, t(this, c).currentRow.target), t(this, c).currentRow.target = s, t(this, c).currentRow.value = b, this.dispatchEvent(
597
- new bt({
598
- target: s,
599
- column: m,
600
- row: b
601
- })
602
- ), this.dispatchEvent(
603
- new pt({
604
- target: s,
605
- column: m,
606
- row: b
607
- })
608
- ), a) {
609
- this.dispatchEvent(
610
- new ut({
611
- cell: a,
612
- column: m,
613
- row: b
614
- })
615
- );
616
- const d = h.target.closest("[data-template-cell]");
617
- if (d) {
618
- const v = Number(s.getAttribute("data-index"));
619
- this.dispatchEvent(
620
- new Nt({
621
- target: d,
622
- rowData: b,
623
- rowIndex: v,
624
- originalEvent: h
625
- })
626
- );
627
- }
628
- }
629
- };
630
- t(this, k).selectAbortController = new AbortController(), this.addEventListener("mouseout", l, {
631
- once: !0,
632
- signal: t(this, k).selectAbortController.signal
633
- }), t(this, f).addEventListener("mouseup", n, {
634
- once: !0,
635
- signal: t(this, k).selectAbortController.signal
636
- });
637
- });
638
- /**
639
- * 鼠标相关事件的共同处理逻辑
640
- * @param {MouseEvent} e
641
- * @param {'body' | 'head'} part
642
- * @returns {{
643
- * cell: HTMLTableCellElement;
644
- * row: HTMLTableRowElement;
645
- * data: any;
646
- * columnKey: string;
647
- * } | {
648
- * cell: HTMLTableCellElement;
649
- * columnKey: string;
650
- * }}
651
- */
652
- p(this, L, (e, s) => {
653
- const l = e.target.closest(`tr[part='t${s}-tr']`);
654
- if (!l) return { cell: null, row: null, data: null, columnKey: null };
655
- const n = s === "body" ? "td" : "th", i = e.target.closest(`${n}[part='t${s}-${n}']`), h = t(this, c).dataSource.get(l), u = i == null ? void 0 : i.getAttribute("data-scope");
656
- return s === "body" ? (t(this, $).call(this, l, t(this, c).currentRow.target), t(this, c).currentRow.target = l, t(this, c).currentRow.value = h, {
657
- cell: i,
658
- row: l,
659
- data: h,
660
- columnKey: u
661
- }) : {
662
- cell: i,
663
- columnKey: u
664
- };
665
- });
666
- /**
667
- * 鼠标双击事件: 行双击, 单元格双击
668
- * @param {MouseEvent} e
669
- */
670
- p(this, z, (e) => {
671
- const { row: s, cell: l, data: n, columnKey: i } = t(this, L).call(this, e, "body");
672
- s && (this.dispatchEvent(
673
- new Rt({
674
- target: s,
675
- column: i,
676
- row: n
677
- })
678
- ), this.dispatchEvent(
679
- new Tt({
680
- cell: l,
681
- column: i,
682
- row: n
683
- })
684
- ));
685
- });
686
- /**
687
- * 鼠标右击事件: 行右击, 单元格右击
688
- * @param {MouseEvent} e
689
- */
690
- p(this, J, (e) => {
691
- const { row: s, cell: l, data: n, columnKey: i } = t(this, L).call(this, e, "body");
692
- s && (this.dispatchEvent(
693
- new qt({
694
- target: s,
695
- column: i,
696
- row: n
697
- })
698
- ), this.dispatchEvent(
699
- new Dt({
700
- cell: l,
701
- column: i,
702
- row: n
703
- })
704
- ));
705
- });
706
- /**
707
- * 滚动事件: 固定列样式
708
- */
709
- p(this, O, () => {
710
- const e = [...t(this, f).querySelectorAll(".is-fixed")], { scrollLeft: s } = t(this, f), l = Math.floor(t(this, f).scrollWidth - t(this, f).offsetWidth) - 1;
711
- s < l ? s ? e.forEach((n) => {
712
- n.classList.add("not-origin-position");
713
- }) : e.forEach((n) => {
714
- n.classList.toggle(
715
- "not-origin-position",
716
- !n.classList.contains("fixed-left")
717
- );
718
- }) : e.forEach((n) => {
719
- n.classList.toggle(
720
- "not-origin-position",
721
- !n.classList.contains("fixed-right")
722
- );
723
- });
724
- });
725
- /**
726
- * 鼠标进入单元格事件
727
- * @param {MouseEvent} e
728
- */
729
- p(this, Q, (e) => {
730
- const { row: s, cell: l, data: n, columnKey: i } = t(this, L).call(this, e, "body");
731
- s && this.dispatchEvent(
732
- new At({
733
- column: i,
734
- row: n,
735
- cell: l
736
- })
737
- );
738
- });
739
- /**
740
- * 鼠标进入单元格事件
741
- * @param {MouseEvent} e
742
- */
743
- p(this, V, (e) => {
744
- const { row: s, cell: l, data: n, columnKey: i } = t(this, L).call(this, e, "body");
745
- s && this.dispatchEvent(
746
- new Lt({
747
- column: i,
748
- row: n,
749
- cell: l
750
- })
751
- );
752
- });
753
- /**
754
- * 鼠标点击单元格事件
755
- * @param {MouseEvent} e
756
- */
757
- p(this, X, (e) => {
758
- const { cell: s, columnKey: l } = t(this, L).call(this, e, "head");
759
- s && this.dispatchEvent(
760
- new Mt({
761
- column: l,
762
- cell: s
763
- })
764
- );
765
- });
766
- /**
767
- * 表头鼠标右键事件
768
- * @param {MouseEvent} e
769
- */
770
- p(this, Y, (e) => {
771
- const { cell: s, columnKey: l } = t(this, L).call(this, e, "head");
772
- s && this.dispatchEvent(
773
- new $t({
774
- column: l,
775
- cell: s
776
- })
777
- );
778
- });
779
- /**
780
- * 监听默认插槽变化
781
- */
782
- p(this, Z, () => {
783
- this.$render(), t(this, c).originData.length > 0 && this.setData(t(this, c).originData);
784
- });
785
- /**
786
- * 监听子元素变化
787
- * @param {Event} e
788
- */
789
- p(this, tt, (e) => {
790
- e.stopImmediatePropagation(), this.$render(), t(this, c).originData.length > 0 && this.setData(t(this, c).originData);
791
- });
792
- /**
793
- * 当存在 selection 列时,checkbox 的改变事件
794
- * @param {Event} e
795
- */
796
- p(this, et, (e) => {
797
- if (e.target.getAttribute("data-type") !== "selection") return;
798
- e.stopImmediatePropagation();
799
- const { checked: s } = e.detail;
800
- if (e.target.closest(".ea-table__thead")) {
801
- const n = [
802
- ...t(this, w).querySelectorAll('ea-checkbox[data-type="selection"]')
803
- ];
804
- e.target.toggleAttribute("checked", e.target.hasAttribute("checked")), n.forEach((h) => {
805
- h.hasAttribute("disabled") || h.toggleAttribute("checked", s);
806
- });
807
- const i = t(this, D).call(this);
808
- this.dispatchEvent(new mt({ selection: i }));
809
- } else {
810
- const n = t(this, D).call(this), i = t(this, c).dataSource.get(
811
- e.target.closest('.ea-table__tr[part="tbody-tr"]')
812
- );
813
- t(this, j).call(this), this.dispatchEvent(
814
- new ft({ selection: n, row: i })
815
- );
816
- }
817
- t(this, M).call(this);
818
- });
819
- this.stylesheet = ht, this.shadowRoot.innerHTML = this.html(`
820
- <slot id='defaultSlot' part='default-slot'></slot>
821
- <table class='ea-table' part='container'>
822
- <colgroup class='ea-table__colgroup' part='colgroup'></colgroup>
823
- <thead class='ea-table__thead' part='thead'></thead>
824
- <tbody class='ea-table__tbody' part='tbody'></tbody>
825
- <tfoot class='ea-table__tfoot' part='tfoot'></tfoot>
826
- </table>
827
- <slot class="ea-table__empty" name="empty">No Data</slot>
828
- `), C(this, f, this.shadowRoot.querySelector(".ea-table")), C(this, F, this.shadowRoot.querySelector("#defaultSlot")), C(this, T, this.shadowRoot.querySelector(".ea-table__thead")), C(this, w, this.shadowRoot.querySelector(".ea-table__tbody")), C(this, I, this.shadowRoot.querySelector(".ea-table__tfoot")), C(this, B, this.shadowRoot.querySelector(".ea-table__empty"));
829
- }
830
- static get observedAttributes() {
831
- return [
832
- ...super.observedAttributes,
833
- "stripe",
834
- "border",
835
- "height",
836
- "max-height",
837
- "highlight-current-row",
838
- "show-summary"
839
- ];
840
- }
841
- /**
842
- * 获取 classlist 列表
843
- * @return {string} 属性值
844
- */
845
- updateContainerClasslist() {
846
- const e = this.computedClasslist(
847
- "ea-table",
848
- {},
849
- {
850
- stripe: this.stripe,
851
- border: this.border,
852
- "sticky-header": CSS.supports("height", this.height) || CSS.supports("height", this.maxHeight),
853
- data: t(this, c).originData.length > 0
854
- }
855
- );
856
- return t(this, f).className = e, t(this, B).className = this.computedClasslist(
857
- "ea-table__empty",
858
- {},
859
- {
860
- data: t(this, c).originData.length > 0
861
- }
862
- ), e;
863
- }
864
- async $render() {
865
- var e;
866
- await customElements.whenDefined("ea-table-column"), (e = t(this, g)) == null || e.abort(), C(this, g, new AbortController()), t(this, K).call(this), t(this, P).call(this), this.addEventListener("ea-table-column-change", t(this, tt), {
867
- signal: t(this, g).signal
868
- }), t(this, f).addEventListener("mousedown", t(this, G), {
869
- signal: t(this, g).signal
870
- }), t(this, f).addEventListener("dblclick", t(this, z), {
871
- signal: t(this, g).signal
872
- }), t(this, f).addEventListener("contextmenu", t(this, J), {
873
- signal: t(this, g).signal
874
- }), t(this, T).addEventListener("click", t(this, X), {
875
- signal: t(this, g).signal
876
- }), t(this, T).addEventListener(
877
- "contextmenu",
878
- t(this, Y),
879
- {
880
- signal: t(this, g).signal
881
- }
882
- ), t(this, f).addEventListener("scroll", t(this, O), {
883
- signal: t(this, g).signal
884
- }), t(this, f).addEventListener("mouseover", t(this, Q), {
885
- signal: t(this, g).signal
886
- }), t(this, f).addEventListener("mouseout", t(this, V), {
887
- signal: t(this, g).signal
888
- });
889
- }
890
- /**
891
- * 获取当前行数据
892
- * @returns {Promise<Object>}
893
- */
894
- getCurrentRow() {
895
- return t(this, c).currentRow;
896
- }
897
- /**
898
- * 设置当前行数据
899
- * @param {any} row 当前行数据
900
- */
901
- setCurrentRow(e) {
902
- let s = null, l = null;
903
- e && typeof e == "object" && (s = t(this, c).dataIndex.get(e) || null, l = e), s && l ? (t(this, $).call(this, s, t(this, c).currentRow.target), t(this, c).currentRow.target = s, t(this, c).currentRow.value = l) : (t(this, U).call(this, t(this, c).currentRow.target), t(this, c).currentRow.value = null, t(this, c).currentRow.target = null);
904
- }
905
- connectedCallback() {
906
- var e;
907
- super.connectedCallback(), (e = t(this, g)) == null || e.abort(), C(this, g, new AbortController()), this.$render(), t(this, F).addEventListener("slotchange", t(this, Z), {
908
- signal: t(this, g).signal
909
- });
910
- }
911
- $beforeUnmounted() {
912
- var e;
913
- (e = t(this, g)) == null || e.abort();
914
- for (const s in t(this, c))
915
- t(this, c)[s] = null;
916
- }
917
- }
918
- f = new WeakMap(), T = new WeakMap(), w = new WeakMap(), I = new WeakMap(), F = new WeakMap(), B = new WeakMap(), g = new WeakMap(), k = new WeakMap(), c = new WeakMap(), K = new WeakMap(), P = new WeakMap(), D = new WeakMap(), j = new WeakMap(), W = new WeakMap(), $ = new WeakMap(), U = new WeakMap(), M = new WeakMap(), G = new WeakMap(), L = new WeakMap(), z = new WeakMap(), J = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap();
919
- window.customElements.get("ea-table") || window.customElements.define("ea-table", Ht);
920
- var R, q, N, st, y, _, lt;
921
- class It extends rt {
922
- constructor() {
923
- super();
924
- p(this, y);
925
- /** @type {HTMLSpanElement | null} */
926
- p(this, R);
927
- /** @type {MutationObserver | null} */
928
- p(this, q, null);
929
- x(this, "state", this.properties({
930
- type: {
931
- type: ["selection", "index"],
932
- default: "",
933
- /** @param {"selection" | "index"} newVal */
934
- observer: (e) => {
935
- e === "selection" && !customElements.get("ea-checkbox") && import("./ea-checkbox.js"), S(this, y, _).call(this);
936
- }
937
- },
938
- align: {
939
- type: ["left", "center", "right"],
940
- default: "left",
941
- observer: () => {
942
- S(this, y, _).call(this);
943
- }
944
- },
945
- label: {
946
- type: String,
947
- default: "",
948
- observer: () => {
949
- t(this, R) && (t(this, R).textContent = `${this.label}[$${this.prop}]`), S(this, y, _).call(this);
950
- }
951
- },
952
- prop: {
953
- type: String,
954
- default: "",
955
- observer: () => {
956
- t(this, R) && (t(this, R).textContent = `${this.label}[$${this.prop}]`), S(this, y, _).call(this);
957
- }
958
- },
959
- colspan: {
960
- type: Number,
961
- default: () => this.querySelectorAll("ea-table-column").length || 1,
962
- observer: () => {
963
- S(this, y, _).call(this);
964
- }
965
- },
966
- width: {
967
- type: String,
968
- default: "",
969
- observer: () => {
970
- S(this, y, _).call(this);
971
- }
972
- },
973
- sortable: {
974
- type: Boolean,
975
- default: !1,
976
- observer: () => {
977
- S(this, y, _).call(this);
978
- }
979
- },
980
- fixed: {
981
- type: ["left", "right", "false"],
982
- default: () => this.hasAttribute("fixed") && this.getAttribute("fixed") !== "false" ? this.getAttribute("fixed") || "left" : null,
983
- observer: () => {
984
- S(this, y, _).call(this);
985
- }
986
- }
987
- }));
988
- x(this, "propState", this.properties({
989
- option: {
990
- props: !0,
991
- type: Object,
992
- default: {},
993
- observer: () => {
994
- S(this, y, _).call(this);
995
- }
996
- }
997
- }));
998
- x(this, "funcStates", this.properties({
999
- getColumnTree: {
1000
- props: !0,
1001
- type: Object,
1002
- /**
1003
- * @returns {TableColumnCtx}
1004
- */
1005
- default: () => {
1006
- const e = this.closest("ea-table"), s = [...this.querySelectorAll("& > ea-table-column")], l = this.shadowRoot.querySelector('slot[name="header"]'), n = this.shadowRoot.querySelector("#defaultSlot"), i = ["prop", "label", "width", "fixed", "sortable"];
1007
- let h = null;
1008
- if (s.length)
1009
- h = s.map((u) => u.getColumnTree);
1010
- else {
1011
- const u = Array.from(n.assignedElements() || []).map((a) => {
1012
- var b;
1013
- return (b = a.outerHTML) == null ? void 0 : b.trim();
1014
- }).join("");
1015
- if (u) {
1016
- const a = document.createElement("template");
1017
- a.innerHTML = this.html(u), h = a;
1018
- } else
1019
- h = null;
1020
- }
1021
- return {
1022
- label: this.label,
1023
- prop: this.prop,
1024
- type: this.type,
1025
- colspan: this.colspan,
1026
- rowspan: h ? 1 : t(this, st).call(this, e) - t(this, N).call(this, this, e) + 1,
1027
- align: this.align,
1028
- width: this.width,
1029
- sortable: this.sortable,
1030
- fixed: this.fixed,
1031
- depth: t(this, N).call(this, this, e),
1032
- props: [...this.attributes].filter(
1033
- (u) => !i.includes(u.name)
1034
- ),
1035
- header: l.assignedElements().map((u) => {
1036
- var a;
1037
- return (a = u.outerHTML) == null ? void 0 : a.trim();
1038
- }).join("") || null,
1039
- template: h
1040
- };
1041
- }
1042
- }
1043
- }));
1044
- /**
1045
- * 获取当前组件的深度
1046
- * @param {EaTableColumn} el
1047
- * @param {import("../ea-table/index.js").EaTable} root
1048
- * @returns {number}
1049
- */
1050
- p(this, N, (e, s) => {
1051
- let l = 0;
1052
- for (; e !== s; )
1053
- e = e.parentElement, l++;
1054
- return l;
1055
- });
1056
- /**
1057
- * 获取最大深度
1058
- * @param {import("../ea-table/index.js").EaTable} root
1059
- * @returns {number}
1060
- */
1061
- p(this, st, (e) => {
1062
- let s = 0;
1063
- return e.querySelectorAll("ea-table-column").forEach((l) => {
1064
- s = Math.max(s, t(this, N).call(this, l, e));
1065
- }), s;
1066
- });
1067
- this.stylesheet = dt, this.$render();
1068
- }
1069
- static get observedAttributes() {
1070
- return [
1071
- ...super.observedAttributes,
1072
- "type",
1073
- "align",
1074
- "label",
1075
- "prop",
1076
- "colspan",
1077
- "width",
1078
- "sortable",
1079
- "fixed"
1080
- ];
1081
- }
1082
- $render() {
1083
- this.shadowRoot.innerHTML = `
1084
- <div class='ea-table-column' part='container'>
1085
- <header class='ea-table-column__label' part='label'>${this.label}[$${this.prop}]</header>
1086
- <span class='ea-table-column__content' part='content'>
1087
- <slot name="header"></slot>
1088
- <slot id="defaultSlot" part="default-slot"></slot>
1089
- </span>
1090
- </div>
1091
- `, C(this, R, this.shadowRoot.querySelector(".ea-table-column__label"));
1092
- }
1093
- connectedCallback() {
1094
- super.connectedCallback(), S(this, y, lt).call(this);
1095
- }
1096
- $beforeUnmounted() {
1097
- t(this, q) && (t(this, q).disconnect(), C(this, q, null));
1098
- }
1099
- }
1100
- R = new WeakMap(), q = new WeakMap(), N = new WeakMap(), st = new WeakMap(), y = new WeakSet(), /**
1101
- * 通知父组件更新
1102
- */
1103
- _ = function() {
1104
- this.emit("ea-table-column-change", {
1105
- bubbles: !0,
1106
- composed: !0
1107
- });
1108
- }, /**
1109
- * 监听默认插槽变化
1110
- */
1111
- lt = function() {
1112
- C(this, q, new MutationObserver(() => {
1113
- S(this, y, _).call(this);
1114
- })), t(this, q).observe(this, {
1115
- childList: !0,
1116
- subtree: !0,
1117
- characterData: !0
1118
- });
1119
- };
1120
- window.customElements.get("ea-table-column") || window.customElements.define("ea-table-column", It);
1121
- export {
1122
- Ht as EaTable,
1123
- It as EaTableColumn
1124
- };