easy-component-ui 3.0.11 → 3.0.12

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