@vtable-guild/vtable-guild 2.7.1 → 2.8.0

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 (138) hide show
  1. package/css/presets/antdv.css +36 -0
  2. package/css/presets/element-plus.css +38 -0
  3. package/css/style.css +436 -0
  4. package/css/tailwind3-utilities.css +337 -0
  5. package/css/tailwind3.css +99 -0
  6. package/css/tailwind4.css +99 -0
  7. package/css/transitions.css +25 -0
  8. package/dist/core/src/components/VirtualList/VirtualList.d.ts +3 -0
  9. package/dist/core/src/components/VirtualList/VirtualList.d.ts.map +1 -1
  10. package/dist/core/src/components/VirtualList/VirtualList.mjs +28 -27
  11. package/dist/core/src/components/VirtualList/VirtualScrollBar.d.ts +1 -1
  12. package/dist/core/src/index.d.ts +1 -1
  13. package/dist/core/src/index.d.ts.map +1 -1
  14. package/dist/core/src/utils/types.d.ts +18 -0
  15. package/dist/core/src/utils/types.d.ts.map +1 -1
  16. package/dist/css/presets/antdv.css +36 -0
  17. package/dist/css/presets/element-plus.css +38 -0
  18. package/dist/css/style.css +436 -0
  19. package/dist/css/tailwind3-utilities.css +337 -0
  20. package/dist/css/tailwind3.css +99 -0
  21. package/dist/css/tailwind4.css +99 -0
  22. package/dist/css/transitions.css +25 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.full.mjs +5229 -3895
  25. package/dist/index.mjs +85 -75
  26. package/dist/table/src/components/ColGroup.d.ts.map +1 -1
  27. package/dist/table/src/components/ColGroup.mjs +10 -10
  28. package/dist/table/src/components/ColumnWidthRow.d.ts +4 -0
  29. package/dist/table/src/components/ColumnWidthRow.d.ts.map +1 -0
  30. package/dist/table/src/components/ColumnWidthRow.mjs +23 -0
  31. package/dist/table/src/components/PaginationSizeSelect.d.ts +57 -0
  32. package/dist/table/src/components/PaginationSizeSelect.d.ts.map +1 -0
  33. package/dist/table/src/components/PaginationSizeSelect.mjs +138 -0
  34. package/dist/table/src/components/SelectionDropdown.d.ts +9 -0
  35. package/dist/table/src/components/SelectionDropdown.d.ts.map +1 -1
  36. package/dist/table/src/components/SelectionDropdown.mjs +32 -26
  37. package/dist/table/src/components/Table.d.ts +13 -2
  38. package/dist/table/src/components/Table.d.ts.map +1 -1
  39. package/dist/table/src/components/Table.mjs +497 -403
  40. package/dist/table/src/components/TableCell.d.ts.map +1 -1
  41. package/dist/table/src/components/TableCell.mjs +80 -74
  42. package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
  43. package/dist/table/src/components/TableHeaderCell.mjs +85 -83
  44. package/dist/table/src/components/TablePagination.d.ts +74 -0
  45. package/dist/table/src/components/TablePagination.d.ts.map +1 -0
  46. package/dist/table/src/components/TablePagination.mjs +350 -0
  47. package/dist/table/src/components/TablePagination.test.d.ts +2 -0
  48. package/dist/table/src/components/TablePagination.test.d.ts.map +1 -0
  49. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts +2 -0
  50. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts.map +1 -0
  51. package/dist/table/src/components/TablePaginationLayout.test.d.ts +2 -0
  52. package/dist/table/src/components/TablePaginationLayout.test.d.ts.map +1 -0
  53. package/dist/table/src/components/VTable.vue.d.ts.map +1 -1
  54. package/dist/table/src/components/VTable.vue.mjs +34 -26
  55. package/dist/table/src/components/VTableMinWidth.test.d.ts +2 -0
  56. package/dist/table/src/components/VTableMinWidth.test.d.ts.map +1 -0
  57. package/dist/table/src/components/VTableSummaryCell.d.ts.map +1 -1
  58. package/dist/table/src/components/VTableSummaryCell.mjs +26 -24
  59. package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
  60. package/dist/table/src/components/VirtualTableBody.mjs +106 -93
  61. package/dist/table/src/composables/useColumnLayout.d.ts +28 -0
  62. package/dist/table/src/composables/useColumnLayout.d.ts.map +1 -0
  63. package/dist/table/src/composables/useColumnLayout.mjs +259 -0
  64. package/dist/table/src/composables/useColumnLayout.test.d.ts +2 -0
  65. package/dist/table/src/composables/useColumnLayout.test.d.ts.map +1 -0
  66. package/dist/table/src/composables/useColumnMetrics.d.ts +5 -3
  67. package/dist/table/src/composables/useColumnMetrics.d.ts.map +1 -1
  68. package/dist/table/src/composables/useColumnMetrics.mjs +64 -55
  69. package/dist/table/src/composables/useExpand.d.ts +2 -0
  70. package/dist/table/src/composables/useExpand.d.ts.map +1 -1
  71. package/dist/table/src/composables/useExpand.mjs +44 -20
  72. package/dist/table/src/composables/usePagination.d.ts +15 -0
  73. package/dist/table/src/composables/usePagination.d.ts.map +1 -0
  74. package/dist/table/src/composables/usePagination.mjs +65 -0
  75. package/dist/table/src/composables/usePagination.test.d.ts +2 -0
  76. package/dist/table/src/composables/usePagination.test.d.ts.map +1 -0
  77. package/dist/table/src/composables/useResize.d.ts +1 -0
  78. package/dist/table/src/composables/useResize.d.ts.map +1 -1
  79. package/dist/table/src/composables/useResize.mjs +67 -39
  80. package/dist/table/src/composables/useScroll.d.ts +3 -0
  81. package/dist/table/src/composables/useScroll.d.ts.map +1 -1
  82. package/dist/table/src/composables/useScroll.mjs +43 -41
  83. package/dist/table/src/composables/useSelection.d.ts +2 -1
  84. package/dist/table/src/composables/useSelection.d.ts.map +1 -1
  85. package/dist/table/src/composables/useSelection.mjs +210 -171
  86. package/dist/table/src/composables/useTreeData.d.ts +4 -0
  87. package/dist/table/src/composables/useTreeData.d.ts.map +1 -1
  88. package/dist/table/src/composables/useTreeData.mjs +48 -43
  89. package/dist/table/src/context.d.ts +6 -1
  90. package/dist/table/src/context.d.ts.map +1 -1
  91. package/dist/table/src/index.d.ts +3 -1
  92. package/dist/table/src/index.d.ts.map +1 -1
  93. package/dist/table/src/types/column.d.ts +8 -2
  94. package/dist/table/src/types/column.d.ts.map +1 -1
  95. package/dist/table/src/types/index.d.ts +1 -0
  96. package/dist/table/src/types/index.d.ts.map +1 -1
  97. package/dist/table/src/types/pagination.d.ts +66 -0
  98. package/dist/table/src/types/pagination.d.ts.map +1 -0
  99. package/dist/table/src/types/pagination.typecheck.d.ts +25 -0
  100. package/dist/table/src/types/pagination.typecheck.d.ts.map +1 -0
  101. package/dist/table/src/types/table.d.ts +8 -1
  102. package/dist/table/src/types/table.d.ts.map +1 -1
  103. package/dist/table/src/utils/columnWidth.d.ts +55 -7
  104. package/dist/table/src/utils/columnWidth.d.ts.map +1 -1
  105. package/dist/table/src/utils/columnWidth.mjs +91 -21
  106. package/dist/table/src/utils/paginationLayout.d.ts +13 -0
  107. package/dist/table/src/utils/paginationLayout.d.ts.map +1 -0
  108. package/dist/table/src/utils/paginationLayout.mjs +55 -0
  109. package/dist/table/src/utils/paginationLayout.test.d.ts +2 -0
  110. package/dist/table/src/utils/paginationLayout.test.d.ts.map +1 -0
  111. package/dist/table/src/utils/popupPosition.d.ts +4 -1
  112. package/dist/table/src/utils/popupPosition.d.ts.map +1 -1
  113. package/dist/table/src/utils/popupPosition.mjs +34 -15
  114. package/dist/theme/src/augment.d.ts +2 -0
  115. package/dist/theme/src/augment.d.ts.map +1 -1
  116. package/dist/theme/src/compat/antdv-pagination.d.ts +4 -0
  117. package/dist/theme/src/compat/antdv-pagination.d.ts.map +1 -0
  118. package/dist/theme/src/compat/antdv-pagination.mjs +29 -0
  119. package/dist/theme/src/index.d.ts +5 -0
  120. package/dist/theme/src/index.d.ts.map +1 -1
  121. package/dist/theme/src/pagination.d.ts +153 -0
  122. package/dist/theme/src/pagination.d.ts.map +1 -0
  123. package/dist/theme/src/pagination.mjs +144 -0
  124. package/dist/theme/src/presets/antdv/table-locale.d.ts +2 -2
  125. package/dist/theme/src/presets/antdv/table-locale.mjs +2 -2
  126. package/dist/theme/src/presets/antdv/table.d.ts +3 -0
  127. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  128. package/dist/theme/src/presets/antdv/table.mjs +3 -0
  129. package/dist/theme/src/presets/element-plus/table-locale.d.ts +2 -2
  130. package/dist/theme/src/presets/element-plus/table-locale.mjs +2 -2
  131. package/dist/theme/src/presets/element-plus/table.d.ts +3 -0
  132. package/dist/theme/src/presets/element-plus/table.d.ts.map +1 -1
  133. package/dist/theme/src/presets/element-plus/table.mjs +3 -0
  134. package/dist/theme/src/presets/index.d.ts.map +1 -1
  135. package/dist/theme/src/presets/index.mjs +60 -57
  136. package/dist/theme/src/presets/types.d.ts +1 -0
  137. package/dist/theme/src/presets/types.d.ts.map +1 -1
  138. package/package.json +1 -1
@@ -1,245 +1,284 @@
1
- import { ref as V, watch as H, computed as w } from "vue";
2
- function te(K) {
3
- const { data: o, childrenColumnName: u, getRowKey: N } = K, C = [];
4
- let E = 0;
5
- function x(h, k, y) {
6
- h.forEach((m) => {
7
- const A = E, f = N(m, A), d = m[u], I = {
8
- key: f,
9
- record: m,
10
- index: A,
11
- level: k,
12
- parentKey: y?.key,
1
+ import { ref as _, watch as P, computed as k } from "vue";
2
+ function ne(w) {
3
+ const { data: c, childrenColumnName: d, getRowKey: R } = w, b = [];
4
+ let N = 0;
5
+ function I(y, C, h) {
6
+ y.forEach((f) => {
7
+ const p = N, z = R(f, p), a = f[d], S = {
8
+ key: z,
9
+ record: f,
10
+ index: p,
11
+ level: C,
12
+ parentKey: h?.key,
13
13
  childrenKeys: []
14
14
  };
15
- C.push(I), y?.childrenKeys.push(f), E += 1, Array.isArray(d) && d.length > 0 && x(d, k + 1, I);
15
+ b.push(S), h?.childrenKeys.push(z), N += 1, Array.isArray(a) && a.length > 0 && I(a, C + 1, S);
16
16
  });
17
17
  }
18
- return x(o, 0), C;
18
+ return I(c, 0), b;
19
19
  }
20
- const ne = Object.freeze([]);
21
- function le(K) {
22
- return K.data.map((o, u) => ({
23
- key: K.getRowKey(o, u),
24
- record: o,
25
- index: u,
20
+ const se = Object.freeze([]);
21
+ function le(w) {
22
+ return w.data.map((c, d) => ({
23
+ key: w.getRowKey(c, d),
24
+ record: c,
25
+ index: d,
26
26
  level: 0,
27
- childrenKeys: ne
27
+ childrenKeys: se
28
28
  }));
29
29
  }
30
- function se(K) {
31
- const { rowSelection: o, getRowKey: u, data: N, visibleData: C, childrenColumnName: E, onSelectionChange: x } = K, h = V(/* @__PURE__ */ new Set()), k = V(!1), y = V(null);
32
- H(
33
- () => o()?.defaultSelectedRowKeys,
30
+ function oe(w) {
31
+ const { rowSelection: c, getRowKey: d, data: R, visibleData: b, childrenColumnName: N, onSelectionChange: I } = w, y = _(/* @__PURE__ */ new Set()), C = _(!1), h = _(null), f = /* @__PURE__ */ new Map();
32
+ P(
33
+ () => c()?.defaultSelectedRowKeys,
34
34
  (e) => {
35
- k.value || !e?.length || (h.value = new Set(e), k.value = !0);
35
+ C.value || !e?.length || (y.value = new Set(e), C.value = !0);
36
36
  },
37
37
  { immediate: !0 }
38
38
  );
39
- function m() {
40
- return o()?.selectedRowKeys !== void 0;
39
+ function p() {
40
+ return c()?.selectedRowKeys !== void 0;
41
41
  }
42
- const A = w(() => o()?.checkStrictly === !1), f = w(() => o() ? A.value ? te({
43
- data: N(),
44
- childrenColumnName: E?.() ?? "children",
45
- getRowKey: u
42
+ const z = k(() => c()?.checkStrictly === !1), a = k(() => c() ? z.value || w.paginate?.() && R().some((e) => Array.isArray(e[N?.() ?? "children"])) ? ne({
43
+ data: R(),
44
+ childrenColumnName: N?.() ?? "children",
45
+ getRowKey: d
46
46
  }) : le({
47
- data: N(),
48
- getRowKey: u
49
- }) : []), d = w(() => {
47
+ data: R(),
48
+ getRowKey: d
49
+ }) : []), S = k(() => {
50
50
  const e = /* @__PURE__ */ new Map();
51
- return f.value.forEach((t) => e.set(t.key, t)), e;
52
- }), I = w(
53
- () => f.value.filter((e) => e.parentKey === void 0).map((e) => e.key)
51
+ return a.value.forEach((t) => e.set(t.key, t)), e;
52
+ });
53
+ P(
54
+ [
55
+ a,
56
+ () => c()?.preserveSelectedRowKeys,
57
+ () => c()?.selectedRowKeys
58
+ ],
59
+ () => {
60
+ if (!c()?.preserveSelectedRowKeys) {
61
+ f.clear();
62
+ return;
63
+ }
64
+ const e = new Set(c()?.selectedRowKeys ?? y.value);
65
+ for (const t of f.keys()) e.has(t) || f.delete(t);
66
+ for (const t of a.value)
67
+ e.has(t.key) && f.set(t.key, t.record);
68
+ },
69
+ { immediate: !0, flush: "sync" }
70
+ ), P(
71
+ () => b(),
72
+ () => {
73
+ h.value = null;
74
+ }
75
+ );
76
+ const L = k(
77
+ () => a.value.filter((e) => e.parentKey === void 0).map((e) => e.key)
54
78
  );
55
- function S(e) {
56
- return o()?.getCheckboxProps?.(e)?.disabled ?? !1;
79
+ function v(e) {
80
+ return c()?.getCheckboxProps?.(e)?.disabled ?? !1;
57
81
  }
58
- function Y(e) {
59
- return d.value.get(e)?.childrenKeys ?? [];
82
+ function j(e) {
83
+ return S.value.get(e)?.childrenKeys ?? [];
60
84
  }
61
- const L = w(() => {
62
- const e = d.value, t = /* @__PURE__ */ new Map(), l = f.value;
63
- for (let n = l.length - 1; n >= 0; n -= 1) {
64
- const c = l[n], s = [];
65
- for (const r of c.childrenKeys) {
85
+ const O = k(() => {
86
+ const e = S.value, t = /* @__PURE__ */ new Map(), n = a.value;
87
+ for (let s = n.length - 1; s >= 0; s -= 1) {
88
+ const l = n[s], o = [];
89
+ for (const r of l.childrenKeys) {
66
90
  const i = e.get(r);
67
- if (!i || S(i.record)) continue;
68
- s.push(r);
69
- const a = t.get(r);
70
- a && s.push(...a);
91
+ if (!i || v(i.record)) continue;
92
+ o.push(r);
93
+ const u = t.get(r);
94
+ u && o.push(...u);
71
95
  }
72
- t.set(c.key, s);
96
+ t.set(l.key, o);
73
97
  }
74
98
  return t;
75
99
  });
76
- function P(e) {
77
- if (o()?.checkStrictly !== !1)
100
+ function V(e) {
101
+ if (c()?.checkStrictly !== !1)
78
102
  return new Set(e);
79
- const t = new Set(e), l = (n) => {
80
- const c = Y(n);
81
- c.forEach(l);
82
- const s = d.value.get(n);
83
- if (!s || S(s.record)) return;
84
- const r = c.map((a) => d.value.get(a)).filter((a) => !!a && !S(a.record));
103
+ const t = new Set(e), n = (s) => {
104
+ const l = j(s);
105
+ l.forEach(n);
106
+ const o = S.value.get(s);
107
+ if (!o || v(o.record)) return;
108
+ const r = l.map((u) => S.value.get(u)).filter((u) => !!u && !v(u.record));
85
109
  if (r.length === 0) return;
86
- r.every((a) => t.has(a.key)) ? t.add(n) : t.delete(n);
110
+ r.every((u) => t.has(u.key)) ? t.add(s) : t.delete(s);
87
111
  };
88
- return I.value.forEach(l), t;
112
+ return L.value.forEach(n), t;
89
113
  }
90
- const v = w(() => {
91
- const e = o(), t = e?.selectedRowKeys !== void 0 ? new Set(e.selectedRowKeys) : h.value;
92
- return P(t);
114
+ const g = k(() => {
115
+ const e = c(), t = e?.selectedRowKeys !== void 0 ? new Set(e.selectedRowKeys) : y.value;
116
+ return V(t);
93
117
  });
94
- H(
95
- [f, () => o()?.preserveSelectedRowKeys],
118
+ P(
119
+ [a, () => c()?.preserveSelectedRowKeys],
96
120
  () => {
97
- if (m() || o()?.preserveSelectedRowKeys || h.value.size === 0) return;
98
- const e = new Set(f.value.map((l) => l.key)), t = new Set(
99
- Array.from(h.value).filter((l) => e.has(l))
121
+ if (p() || c()?.preserveSelectedRowKeys || y.value.size === 0) return;
122
+ const e = new Set(a.value.map((n) => n.key)), t = new Set(
123
+ Array.from(y.value).filter((n) => e.has(n))
100
124
  );
101
- t.size !== h.value.size && (h.value = t);
125
+ t.size !== y.value.size && (y.value = t);
102
126
  },
103
127
  { immediate: !0 }
104
128
  );
105
- function z(e) {
106
- return v.value.has(e);
129
+ function M(e) {
130
+ return g.value.has(e);
107
131
  }
108
- function p(e) {
109
- return f.value.filter((t) => e.has(t.key)).map((t) => t.record);
132
+ function m(e) {
133
+ const t = a.value.filter((n) => e.has(n.key)).map((n) => n.record);
134
+ if (c()?.preserveSelectedRowKeys)
135
+ for (const n of e)
136
+ !S.value.has(n) && f.has(n) && t.push(f.get(n));
137
+ return t;
110
138
  }
111
- function O() {
112
- return C().map((e, t) => d.value.get(u(e, t)) ?? null).filter((e) => e !== null);
139
+ function q() {
140
+ return b().map((e, t) => S.value.get(d(e, t)) ?? null).filter((e) => e !== null);
113
141
  }
114
- function D() {
115
- return O().filter((e) => !S(e.record));
142
+ function E() {
143
+ return q().filter((e) => !v(e.record));
116
144
  }
117
- function q() {
118
- return f.value.filter((e) => !S(e.record));
145
+ function B() {
146
+ return a.value.filter((e) => !v(e.record));
119
147
  }
120
- function B(e, t) {
121
- const l = u(e, t), n = z(l), c = S(e);
122
- if (o()?.checkStrictly !== !1)
148
+ function F(e, t) {
149
+ const n = d(e, t), s = M(n), l = v(e);
150
+ if (c()?.checkStrictly !== !1)
123
151
  return {
124
- checked: n,
152
+ checked: s,
125
153
  indeterminate: !1,
126
- disabled: c
154
+ disabled: l
127
155
  };
128
- const s = L.value.get(l) ?? [];
129
- if (s.length === 0)
156
+ const o = O.value.get(n) ?? [];
157
+ if (o.length === 0)
130
158
  return {
131
- checked: n,
159
+ checked: s,
132
160
  indeterminate: !1,
133
- disabled: c
161
+ disabled: l
134
162
  };
135
- const r = s.filter((i) => v.value.has(i)).length;
163
+ const r = o.filter((i) => g.value.has(i)).length;
136
164
  return {
137
- checked: n,
138
- indeterminate: r > 0 && r < s.length,
139
- disabled: c
165
+ checked: s,
166
+ indeterminate: r > 0 && r < o.length,
167
+ disabled: l
140
168
  };
141
169
  }
142
- function g(e, t) {
143
- const l = P(e);
144
- m() || (h.value = l);
170
+ function K(e, t) {
171
+ const n = V(e);
172
+ if (c()?.preserveSelectedRowKeys) {
173
+ if (!p())
174
+ for (const s of f.keys())
175
+ n.has(s) || f.delete(s);
176
+ for (const s of a.value)
177
+ n.has(s.key) && f.set(s.key, s.record);
178
+ }
179
+ p() || (y.value = n);
145
180
  {
146
- const n = Array.from(l), c = p(l);
147
- o()?.onChange?.(n, c), x?.();
181
+ const s = Array.from(n), l = m(n);
182
+ c()?.onChange?.(s, l), I?.();
148
183
  }
149
184
  }
150
- function _(e, t, l, n) {
151
- const c = d.value.get(e);
152
- if (!c || S(c.record)) return;
153
- const s = t.has(e);
154
- l ? t.add(e) : t.delete(e), s !== l && n.push(c.record), Y(e).forEach(
155
- (r) => _(r, t, l, n)
185
+ function Y(e, t, n, s) {
186
+ const l = S.value.get(e);
187
+ if (!l || v(l.record)) return;
188
+ const o = t.has(e);
189
+ n ? t.add(e) : t.delete(e), o !== n && s.push(l.record), j(e).forEach(
190
+ (r) => Y(r, t, n, s)
156
191
  );
157
192
  }
158
- function F(e, t, l) {
159
- const n = o();
160
- if (!n) return;
161
- const c = u(e, t), s = !z(c);
162
- if (n.type !== "radio" && l?.shiftKey && y.value !== null && o()?.checkStrictly !== !1) {
163
- const i = D(), a = i.findIndex((b) => b.key === c), M = i.findIndex(
164
- (b) => b.key === y.value
193
+ function G(e, t, n) {
194
+ const s = c();
195
+ if (!s) return;
196
+ const l = d(e, t), o = !M(l);
197
+ if (s.type !== "radio" && n?.shiftKey && h.value !== null && c()?.checkStrictly !== !1) {
198
+ const i = E(), u = i.findIndex((x) => x.key === l), D = i.findIndex(
199
+ (x) => x.key === h.value
165
200
  );
166
- if (a !== -1 && M !== -1) {
167
- const [b, $] = a > M ? [M, a] : [a, M], R = new Set(v.value), j = [];
168
- i.slice(b, $ + 1).forEach((T) => {
169
- const ee = R.has(T.key);
170
- s ? R.add(T.key) : R.delete(T.key), ee !== s && j.push(T.record);
171
- }), g(R), n.onSelectMultiple?.(s, p(R), j), y.value = c;
201
+ if (u !== -1 && D !== -1) {
202
+ const [x, ee] = u > D ? [D, u] : [u, D], A = new Set(g.value), H = [];
203
+ i.slice(x, ee + 1).forEach((T) => {
204
+ const te = A.has(T.key);
205
+ o ? A.add(T.key) : A.delete(T.key), te !== o && H.push(T.record);
206
+ }), K(A), s.onSelectMultiple?.(o, m(A), H), h.value = l;
172
207
  return;
173
208
  }
174
209
  }
175
- if (n.type === "radio") {
176
- const i = s ? /* @__PURE__ */ new Set([c]) : /* @__PURE__ */ new Set();
177
- g(i), n.onSelect?.(e, s, p(i)), y.value = c;
210
+ if (s.type === "radio") {
211
+ const i = o ? /* @__PURE__ */ new Set([l]) : /* @__PURE__ */ new Set();
212
+ K(i), s.onSelect?.(e, o, m(i)), h.value = l;
178
213
  return;
179
214
  }
180
- const r = new Set(v.value);
181
- s ? r.add(c) : r.delete(c), g(r), n.onSelect?.(e, s, p(r)), y.value = c;
182
- }
183
- function G(e, t) {
184
- const l = o();
185
- if (!l) return;
186
- const n = u(e, t), c = !z(n), s = new Set(v.value);
187
- _(n, s, c, []), g(s), l.onSelect?.(e, c, p(s)), y.value = n;
188
- }
189
- function J(e, t, l) {
190
- if (S(e)) return;
191
- const n = o();
192
- if (n) {
193
- if (n.checkStrictly === !1 && n.type !== "radio") {
194
- G(e, t);
215
+ const r = new Set(g.value);
216
+ o ? r.add(l) : r.delete(l), K(r), s.onSelect?.(e, o, m(r)), h.value = l;
217
+ }
218
+ function J(e, t) {
219
+ const n = c();
220
+ if (!n) return;
221
+ const s = d(e, t), l = !M(s), o = new Set(g.value);
222
+ Y(s, o, l, []), K(o), n.onSelect?.(e, l, m(o)), h.value = s;
223
+ }
224
+ function Q(e, t, n) {
225
+ if (v(e)) return;
226
+ const s = c();
227
+ if (s) {
228
+ if (s.checkStrictly === !1 && s.type !== "radio") {
229
+ J(e, t);
195
230
  return;
196
231
  }
197
- F(e, t, l);
232
+ G(e, t, n);
198
233
  }
199
234
  }
200
- function Q(e) {
201
- const t = o();
202
- if (!t) return;
203
- const l = q(), n = new Set(v.value), c = [];
204
- l.forEach((s) => {
205
- const r = n.has(s.key);
206
- e ? n.add(s.key) : n.delete(s.key), r !== e && c.push(s.record);
207
- }), g(n), t.onSelectAll?.(e, p(n), c);
208
- }
209
- const U = w(() => {
210
- const e = D();
235
+ function U(e, t = !1) {
236
+ const n = c();
237
+ if (!n) return;
238
+ const s = w.paginate?.() && !t ? E() : B(), l = new Set(g.value), o = [];
239
+ s.forEach((r) => {
240
+ if (n.checkStrictly === !1) {
241
+ Y(r.key, l, e, o);
242
+ return;
243
+ }
244
+ const i = l.has(r.key);
245
+ e ? l.add(r.key) : l.delete(r.key), i !== e && o.push(r.record);
246
+ }), K(l), n.onSelectAll?.(e, m(l), o);
247
+ }
248
+ const W = k(() => {
249
+ const e = E();
211
250
  if (e.length === 0) return "none";
212
- const t = e.filter((l) => v.value.has(l.key)).length;
251
+ const t = e.filter((n) => g.value.has(n.key)).length;
213
252
  return t === 0 ? "none" : t === e.length ? "all" : "partial";
214
253
  });
215
- function W() {
216
- const e = o();
217
- if (!e) return;
218
- const t = D(), l = new Set(v.value);
219
- t.forEach((n) => {
220
- l.has(n.key) ? l.delete(n.key) : l.add(n.key);
221
- }), g(l), e.onSelectInvert?.(Array.from(P(l)));
222
- }
223
254
  function X() {
224
- const e = o();
225
- e && (g(/* @__PURE__ */ new Set()), e.onSelectNone?.());
255
+ const e = c();
256
+ if (!e) return;
257
+ const t = E(), n = new Set(g.value);
258
+ t.forEach((s) => {
259
+ n.has(s.key) ? n.delete(s.key) : n.add(s.key);
260
+ }), K(n), e.onSelectInvert?.(Array.from(V(n)));
226
261
  }
227
262
  function Z() {
228
- return D().map((e) => e.key);
263
+ const e = c();
264
+ e && (K(/* @__PURE__ */ new Set()), e.onSelectNone?.());
265
+ }
266
+ function $() {
267
+ return E().map((e) => e.key);
229
268
  }
230
269
  return {
231
- selectedKeySet: v,
232
- isSelected: z,
233
- isDisabled: S,
234
- getSelectionState: B,
235
- toggleRow: J,
236
- toggleAll: Q,
237
- allCheckedState: U,
238
- invertSelection: W,
239
- clearSelection: X,
240
- getChangeableRowKeys: Z
270
+ selectedKeySet: g,
271
+ isSelected: M,
272
+ isDisabled: v,
273
+ getSelectionState: F,
274
+ toggleRow: Q,
275
+ toggleAll: U,
276
+ allCheckedState: W,
277
+ invertSelection: X,
278
+ clearSelection: Z,
279
+ getChangeableRowKeys: $
241
280
  };
242
281
  }
243
282
  export {
244
- se as useSelection
283
+ oe as useSelection
245
284
  };
@@ -15,6 +15,10 @@ export interface FlattenRow<TRecord = Record<string, unknown>> {
15
15
  export interface UseTreeDataOptions<TRecord = Record<string, unknown>> {
16
16
  /** Data source accessor */
17
17
  data: () => TRecord[];
18
+ /** Optional page roots; state initialization still uses the complete data. */
19
+ pageData?: () => TRecord[];
20
+ /** Keep user choices when a remote page replaces the loaded roots. */
21
+ preserveStateOnDataChange?: () => boolean;
18
22
  /** Field name for children, defaults to 'children' */
19
23
  childrenColumnName?: () => string | undefined;
20
24
  /** Indent size in pixels, defaults to 15 */
@@ -1 +1 @@
1
- {"version":3,"file":"useTreeData.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useTreeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC,MAAM,WAAW,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,2BAA2B;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,WAAW,EAAE,OAAO,CAAA;IACpB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnE,2BAA2B;IAC3B,IAAI,EAAE,MAAM,OAAO,EAAE,CAAA;IACrB,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC7C,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACrC,uBAAuB;IACvB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAA;IAClD,2CAA2C;IAC3C,sBAAsB,CAAC,EAAE,MAAM,GAAG,EAAE,GAAG,SAAS,CAAA;IAChD,+BAA+B;IAC/B,eAA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BAA+B;IAC/B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,oCAAoC;IACpC,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CACrD;AAED,MAAM,WAAW,iBAAiB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC/C,6DAA6D;IAC7D,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC1D,sDAAsD;IACtD,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAChC,oCAAoC;IACpC,gBAAgB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1D,iCAAiC;IACjC,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAA;IACrC,4BAA4B;IAC5B,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3B,wBAAwB;IACxB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAChC;AAED,wBAAgB,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3F,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACnC,iBAAiB,CAAC,OAAO,CAAC,CAmK5B"}
@@ -1,92 +1,97 @@
1
- import { computed as s, ref as S, watch as C } from "vue";
2
- function D(e) {
3
- const o = s(() => e.childrenColumnName?.() ?? "children"), m = s(() => e.indentSize?.() ?? 15), h = s(() => {
1
+ import { computed as s, ref as k, watch as z } from "vue";
2
+ function M(e) {
3
+ const o = s(() => e.childrenColumnName?.() ?? "children"), R = s(() => e.indentSize?.() ?? 15), v = s(() => {
4
4
  const a = o.value;
5
5
  return e.data().some(
6
6
  (t) => Array.isArray(t[a]) && t[a].length > 0
7
7
  );
8
- }), r = S(/* @__PURE__ */ new Set()), y = s(() => e.expandedRowKeys?.() !== void 0);
9
- C(
8
+ }), r = k(/* @__PURE__ */ new Set()), E = /* @__PURE__ */ new Set();
9
+ let g = !1;
10
+ const x = s(() => e.expandedRowKeys?.() !== void 0);
11
+ z(
10
12
  [
11
13
  () => e.data(),
12
14
  () => e.defaultExpandAllRows?.(),
13
15
  () => e.defaultExpandedRowKeys?.()
14
16
  ],
15
17
  () => {
16
- if (!y.value)
18
+ if (!x.value)
17
19
  if (e.defaultExpandAllRows?.()) {
18
- let a = function(l) {
19
- l.forEach((n) => {
20
- const u = n[d], i = f++;
21
- Array.isArray(u) && u.length > 0 && (t.add(e.getRowKey(n, i)), a(u));
20
+ let a = function(n) {
21
+ n.forEach((u) => {
22
+ const c = u[w], f = l++;
23
+ if (Array.isArray(c) && c.length > 0) {
24
+ const y = e.getRowKey(u, f);
25
+ (!t || !E.has(y)) && d.add(y), E.add(y), a(c);
26
+ }
22
27
  });
23
28
  };
24
- const t = /* @__PURE__ */ new Set(), d = o.value;
25
- let f = 0;
26
- a(e.data()), r.value = t;
27
- } else e.defaultExpandedRowKeys?.() && (r.value = new Set(e.defaultExpandedRowKeys()));
29
+ const t = e.preserveStateOnDataChange?.() === !0, d = t ? new Set(r.value) : /* @__PURE__ */ new Set(), w = o.value;
30
+ let l = 0;
31
+ a(e.data()), r.value = d;
32
+ } else e.defaultExpandedRowKeys?.() && (!e.preserveStateOnDataChange?.() || !g) && (r.value = new Set(e.defaultExpandedRowKeys()), g = !0);
28
33
  },
29
34
  { immediate: !0 }
30
35
  );
31
- const c = s({
32
- get: () => y.value ? new Set(e.expandedRowKeys()) : r.value,
36
+ const i = s({
37
+ get: () => x.value ? new Set(e.expandedRowKeys()) : r.value,
33
38
  set: (a) => {
34
39
  r.value = a;
35
40
  }
36
41
  });
37
- function R(a) {
38
- return c.value.has(a);
42
+ function A(a) {
43
+ return i.value.has(a);
39
44
  }
40
- function p(a, t) {
41
- const d = e.getRowKey(a, t), l = !c.value.has(d);
42
- if (y.value) {
45
+ function C(a, t) {
46
+ const d = e.getRowKey(a, t), l = !i.value.has(d);
47
+ if (x.value) {
43
48
  e.onExpand?.(l, a);
44
- const n = new Set(c.value);
49
+ const n = new Set(i.value);
45
50
  l ? n.add(d) : n.delete(d), e.onExpandedRowsChange?.(Array.from(n));
46
51
  } else {
47
52
  const n = new Set(r.value);
48
53
  l ? n.add(d) : n.delete(d), r.value = n, e.onExpand?.(l, a), e.onExpandedRowsChange?.(Array.from(n));
49
54
  }
50
55
  }
51
- const v = s(() => {
52
- const a = e.data();
53
- if (!h.value)
56
+ const K = s(() => {
57
+ const a = e.pageData?.() ?? e.data();
58
+ if (!v.value)
54
59
  return a.map((n) => ({
55
60
  record: n,
56
61
  level: 0,
57
62
  expanded: !1,
58
63
  hasChildren: !1
59
64
  }));
60
- const t = o.value, d = [], f = c.value;
61
- function l(n, u, i) {
62
- n.forEach((x, k) => {
63
- const w = x[t], E = Array.isArray(w) && w.length > 0, K = e.getRowKey(x, d.length), g = E && f.has(K);
65
+ const t = o.value, d = [], w = i.value;
66
+ function l(n, u, c) {
67
+ n.forEach((f, y) => {
68
+ const h = f[t], S = Array.isArray(h) && h.length > 0, m = e.getRowKey(f, d.length), p = S && w.has(m);
64
69
  d.push({
65
- record: x,
70
+ record: f,
66
71
  level: u,
67
- expanded: g,
68
- hasChildren: E,
69
- parentKey: i
70
- }), g && w && l(w, u + 1, K);
72
+ expanded: p,
73
+ hasChildren: S,
74
+ parentKey: c
75
+ }), p && h && l(h, u + 1, m);
71
76
  });
72
77
  }
73
78
  return l(a, 0), d;
74
- }), A = s(() => {
79
+ }), D = s(() => {
75
80
  const a = /* @__PURE__ */ new Map();
76
- for (const t of v.value)
81
+ for (const t of K.value)
77
82
  a.set(t.record, t);
78
83
  return a;
79
84
  });
80
85
  return {
81
- flattenData: v,
82
- rowMetaMap: A,
83
- isTreeData: h,
84
- toggleTreeExpand: p,
85
- isTreeExpanded: R,
86
+ flattenData: K,
87
+ rowMetaMap: D,
88
+ isTreeData: v,
89
+ toggleTreeExpand: C,
90
+ isTreeExpanded: A,
86
91
  expandedKeys: r,
87
- indentSize: m
92
+ indentSize: R
88
93
  };
89
94
  }
90
95
  export {
91
- D as useTreeData
96
+ M as useTreeData
92
97
  };
@@ -8,6 +8,7 @@ import { FlattenRow } from './composables/useTreeData';
8
8
  import { SelectionState } from './composables/useSelection';
9
9
  import { RowDragBindings, RowDragDropTarget } from './composables/useRowDragSort';
10
10
  import { SummaryFixed } from './components/VTableSummary';
11
+ import { ColumnLayout } from './composables/useColumnLayout';
11
12
  /**
12
13
  * 子组件主题 slot class 映射。
13
14
  *
@@ -16,6 +17,9 @@ import { SummaryFixed } from './components/VTableSummary';
16
17
  * 中调用具体字段才建立细粒度依赖,避免任一 variant 变化让全表失效。
17
18
  */
18
19
  export interface SubThemeSlots {
20
+ widthConstraintCell: () => string;
21
+ widthConstraintInner: () => string;
22
+ widthLayoutCell: () => string;
19
23
  thSortable: () => string;
20
24
  thSorted: () => string;
21
25
  tdSorted: () => string;
@@ -106,6 +110,7 @@ export interface SubThemeSlots {
106
110
  * 所有后代组件(TableCell、TableHeaderCell 等)通过 inject 获取。
107
111
  */
108
112
  export interface TableContext {
113
+ columnLayout?: ColumnLayout;
109
114
  /**
110
115
  * 用户定义的 bodyCell slot 函数。
111
116
  * 来自 Table.vue 的 useSlots().bodyCell。
@@ -174,7 +179,7 @@ export interface TableContext {
174
179
  /** 切换某行选中状态 */
175
180
  toggleRow?: (record: Record<string, unknown>, index: number, nativeEvent?: MouseEvent) => void;
176
181
  /** 全选/取消全选 */
177
- toggleAll?: (selected: boolean) => void;
182
+ toggleAll?: (selected: boolean, allData?: boolean) => void;
178
183
  /** 全选状态 */
179
184
  allCheckedState?: () => 'all' | 'partial' | 'none';
180
185
  /** 获取行 key */