@vtable-guild/vtable-guild 2.7.1 → 2.8.1

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 (162) 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 +6 -3
  9. package/dist/core/src/components/VirtualList/VirtualList.d.ts.map +1 -1
  10. package/dist/core/src/components/VirtualList/VirtualList.mjs +187 -180
  11. package/dist/core/src/components/VirtualList/VirtualScrollBar.d.ts +1 -1
  12. package/dist/core/src/components/VirtualList/hooks/useChildren.d.ts +2 -2
  13. package/dist/core/src/components/VirtualList/hooks/useChildren.d.ts.map +1 -1
  14. package/dist/core/src/components/VirtualList/hooks/useChildren.mjs +12 -12
  15. package/dist/core/src/components/VirtualList/hooks/useGetSize.d.ts +1 -1
  16. package/dist/core/src/components/VirtualList/hooks/useGetSize.d.ts.map +1 -1
  17. package/dist/core/src/components/VirtualList/hooks/useGetSize.mjs +1 -1
  18. package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts +2 -2
  19. package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts.map +1 -1
  20. package/dist/core/src/components/VirtualList/hooks/useHeights.mjs +36 -36
  21. package/dist/core/src/components/VirtualList/hooks/useMobileTouchMove.d.ts.map +1 -1
  22. package/dist/core/src/components/VirtualList/hooks/useMobileTouchMove.mjs +11 -11
  23. package/dist/core/src/components/VirtualList/hooks/useMobileTouchMove.test.d.ts +2 -0
  24. package/dist/core/src/components/VirtualList/hooks/useMobileTouchMove.test.d.ts.map +1 -0
  25. package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts +1 -1
  26. package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts.map +1 -1
  27. package/dist/core/src/components/VirtualList/hooks/useScrollTo.mjs +30 -30
  28. package/dist/core/src/index.d.ts +1 -1
  29. package/dist/core/src/index.d.ts.map +1 -1
  30. package/dist/core/src/utils/types.d.ts +18 -0
  31. package/dist/core/src/utils/types.d.ts.map +1 -1
  32. package/dist/css/presets/antdv.css +36 -0
  33. package/dist/css/presets/element-plus.css +38 -0
  34. package/dist/css/style.css +436 -0
  35. package/dist/css/tailwind3-utilities.css +337 -0
  36. package/dist/css/tailwind3.css +99 -0
  37. package/dist/css/tailwind4.css +99 -0
  38. package/dist/css/transitions.css +25 -0
  39. package/dist/index.d.ts +0 -26
  40. package/dist/index.full.mjs +5116 -3769
  41. package/dist/index.mjs +85 -75
  42. package/dist/table/src/components/ColGroup.d.ts.map +1 -1
  43. package/dist/table/src/components/ColGroup.mjs +10 -10
  44. package/dist/table/src/components/ColumnWidthRow.d.ts +4 -0
  45. package/dist/table/src/components/ColumnWidthRow.d.ts.map +1 -0
  46. package/dist/table/src/components/ColumnWidthRow.mjs +23 -0
  47. package/dist/table/src/components/PaginationSizeSelect.d.ts +57 -0
  48. package/dist/table/src/components/PaginationSizeSelect.d.ts.map +1 -0
  49. package/dist/table/src/components/PaginationSizeSelect.mjs +138 -0
  50. package/dist/table/src/components/SelectionDropdown.d.ts +9 -0
  51. package/dist/table/src/components/SelectionDropdown.d.ts.map +1 -1
  52. package/dist/table/src/components/SelectionDropdown.mjs +32 -26
  53. package/dist/table/src/components/Table.d.ts +13 -2
  54. package/dist/table/src/components/Table.d.ts.map +1 -1
  55. package/dist/table/src/components/Table.mjs +496 -403
  56. package/dist/table/src/components/TableCell.d.ts.map +1 -1
  57. package/dist/table/src/components/TableCell.mjs +80 -74
  58. package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
  59. package/dist/table/src/components/TableHeaderCell.mjs +85 -83
  60. package/dist/table/src/components/TablePagination.d.ts +74 -0
  61. package/dist/table/src/components/TablePagination.d.ts.map +1 -0
  62. package/dist/table/src/components/TablePagination.mjs +350 -0
  63. package/dist/table/src/components/TablePagination.test.d.ts +2 -0
  64. package/dist/table/src/components/TablePagination.test.d.ts.map +1 -0
  65. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts +2 -0
  66. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts.map +1 -0
  67. package/dist/table/src/components/TablePaginationLayout.test.d.ts +2 -0
  68. package/dist/table/src/components/TablePaginationLayout.test.d.ts.map +1 -0
  69. package/dist/table/src/components/VTable.vue.d.ts.map +1 -1
  70. package/dist/table/src/components/VTable.vue.mjs +34 -26
  71. package/dist/table/src/components/VTableMinWidth.test.d.ts +2 -0
  72. package/dist/table/src/components/VTableMinWidth.test.d.ts.map +1 -0
  73. package/dist/table/src/components/VTableSummary.d.ts +15 -75
  74. package/dist/table/src/components/VTableSummary.d.ts.map +1 -1
  75. package/dist/table/src/components/VTableSummary.mjs +7 -7
  76. package/dist/table/src/components/VTableSummaryCell.d.ts.map +1 -1
  77. package/dist/table/src/components/VTableSummaryCell.mjs +26 -24
  78. package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
  79. package/dist/table/src/components/VirtualTableBody.mjs +107 -95
  80. package/dist/table/src/composables/useColumnLayout.d.ts +28 -0
  81. package/dist/table/src/composables/useColumnLayout.d.ts.map +1 -0
  82. package/dist/table/src/composables/useColumnLayout.mjs +259 -0
  83. package/dist/table/src/composables/useColumnLayout.test.d.ts +2 -0
  84. package/dist/table/src/composables/useColumnLayout.test.d.ts.map +1 -0
  85. package/dist/table/src/composables/useColumnMetrics.d.ts +5 -3
  86. package/dist/table/src/composables/useColumnMetrics.d.ts.map +1 -1
  87. package/dist/table/src/composables/useColumnMetrics.mjs +64 -55
  88. package/dist/table/src/composables/useExpand.d.ts +2 -0
  89. package/dist/table/src/composables/useExpand.d.ts.map +1 -1
  90. package/dist/table/src/composables/useExpand.mjs +42 -20
  91. package/dist/table/src/composables/usePagination.d.ts +15 -0
  92. package/dist/table/src/composables/usePagination.d.ts.map +1 -0
  93. package/dist/table/src/composables/usePagination.mjs +65 -0
  94. package/dist/table/src/composables/usePagination.test.d.ts +2 -0
  95. package/dist/table/src/composables/usePagination.test.d.ts.map +1 -0
  96. package/dist/table/src/composables/useResize.d.ts +1 -0
  97. package/dist/table/src/composables/useResize.d.ts.map +1 -1
  98. package/dist/table/src/composables/useResize.mjs +67 -39
  99. package/dist/table/src/composables/useScroll.d.ts +3 -0
  100. package/dist/table/src/composables/useScroll.d.ts.map +1 -1
  101. package/dist/table/src/composables/useScroll.mjs +43 -41
  102. package/dist/table/src/composables/useSelection.d.ts +2 -1
  103. package/dist/table/src/composables/useSelection.d.ts.map +1 -1
  104. package/dist/table/src/composables/useSelection.mjs +204 -155
  105. package/dist/table/src/composables/useTreeData.d.ts +4 -0
  106. package/dist/table/src/composables/useTreeData.d.ts.map +1 -1
  107. package/dist/table/src/composables/useTreeData.mjs +48 -43
  108. package/dist/table/src/context.d.ts +6 -1
  109. package/dist/table/src/context.d.ts.map +1 -1
  110. package/dist/table/src/index.d.ts +10 -87
  111. package/dist/table/src/index.d.ts.map +1 -1
  112. package/dist/table/src/index.mjs +12 -12
  113. package/dist/table/src/types/column.d.ts +8 -2
  114. package/dist/table/src/types/column.d.ts.map +1 -1
  115. package/dist/table/src/types/index.d.ts +1 -0
  116. package/dist/table/src/types/index.d.ts.map +1 -1
  117. package/dist/table/src/types/pagination.d.ts +66 -0
  118. package/dist/table/src/types/pagination.d.ts.map +1 -0
  119. package/dist/table/src/types/pagination.typecheck.d.ts +25 -0
  120. package/dist/table/src/types/pagination.typecheck.d.ts.map +1 -0
  121. package/dist/table/src/types/table.d.ts +8 -1
  122. package/dist/table/src/types/table.d.ts.map +1 -1
  123. package/dist/table/src/utils/columnWidth.d.ts +55 -7
  124. package/dist/table/src/utils/columnWidth.d.ts.map +1 -1
  125. package/dist/table/src/utils/columnWidth.mjs +91 -21
  126. package/dist/table/src/utils/paginationLayout.d.ts +13 -0
  127. package/dist/table/src/utils/paginationLayout.d.ts.map +1 -0
  128. package/dist/table/src/utils/paginationLayout.mjs +55 -0
  129. package/dist/table/src/utils/paginationLayout.test.d.ts +2 -0
  130. package/dist/table/src/utils/paginationLayout.test.d.ts.map +1 -0
  131. package/dist/table/src/utils/popupPosition.d.ts +4 -1
  132. package/dist/table/src/utils/popupPosition.d.ts.map +1 -1
  133. package/dist/table/src/utils/popupPosition.mjs +34 -15
  134. package/dist/theme/src/augment.d.ts +2 -0
  135. package/dist/theme/src/augment.d.ts.map +1 -1
  136. package/dist/theme/src/compat/antdv-pagination.d.ts +4 -0
  137. package/dist/theme/src/compat/antdv-pagination.d.ts.map +1 -0
  138. package/dist/theme/src/compat/antdv-pagination.mjs +29 -0
  139. package/dist/theme/src/index.d.ts +5 -0
  140. package/dist/theme/src/index.d.ts.map +1 -1
  141. package/dist/theme/src/pagination.d.ts +153 -0
  142. package/dist/theme/src/pagination.d.ts.map +1 -0
  143. package/dist/theme/src/pagination.mjs +144 -0
  144. package/dist/theme/src/presets/antdv/table-locale.d.ts +2 -2
  145. package/dist/theme/src/presets/antdv/table-locale.mjs +2 -2
  146. package/dist/theme/src/presets/antdv/table.d.ts +3 -0
  147. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  148. package/dist/theme/src/presets/antdv/table.mjs +3 -0
  149. package/dist/theme/src/presets/element-plus/table-locale.d.ts +2 -2
  150. package/dist/theme/src/presets/element-plus/table-locale.mjs +2 -2
  151. package/dist/theme/src/presets/element-plus/table.d.ts +3 -0
  152. package/dist/theme/src/presets/element-plus/table.d.ts.map +1 -1
  153. package/dist/theme/src/presets/element-plus/table.mjs +3 -0
  154. package/dist/theme/src/presets/index.d.ts.map +1 -1
  155. package/dist/theme/src/presets/index.mjs +60 -57
  156. package/dist/theme/src/presets/types.d.ts +1 -0
  157. package/dist/theme/src/presets/types.d.ts.map +1 -1
  158. package/dist/vtable-guild/src/augment.d.ts +15 -0
  159. package/dist/vtable-guild/src/augment.d.ts.map +1 -0
  160. package/dist/vtable-guild/src/index.d.ts +1 -0
  161. package/dist/vtable-guild/src/index.d.ts.map +1 -1
  162. package/package.json +4 -3
@@ -1,245 +1,294 @@
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 = {
1
+ import { ref as _, watch as P, computed as m } from "vue";
2
+ function ne(w) {
3
+ const { data: o, childrenColumnName: d, getRowKey: R } = w, b = [];
4
+ let A = 0;
5
+ function E(y, N, S) {
6
+ y.forEach((u) => {
7
+ const k = A, f = R(u, k), h = u[d], I = {
8
8
  key: f,
9
- record: m,
10
- index: A,
11
- level: k,
12
- parentKey: y?.key,
9
+ record: u,
10
+ index: k,
11
+ level: N,
12
+ parentKey: S?.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(I), S?.childrenKeys.push(f), A += 1, Array.isArray(h) && h.length > 0 && E(h, N + 1, I);
16
16
  });
17
17
  }
18
- return x(o, 0), C;
18
+ return E(o, 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),
20
+ const se = Object.freeze([]);
21
+ function le(w) {
22
+ return w.data.map((o, d) => ({
23
+ key: w.getRowKey(o, d),
24
24
  record: o,
25
- index: u,
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(
30
+ function ce(w) {
31
+ const { rowSelection: o, getRowKey: d, data: R, visibleData: b, childrenColumnName: A, onSelectionChange: E } = w, y = _(/* @__PURE__ */ new Set()), N = _(!1), S = _(null), u = /* @__PURE__ */ new Map();
32
+ P(
33
33
  () => o()?.defaultSelectedRowKeys,
34
34
  (e) => {
35
- k.value || !e?.length || (h.value = new Set(e), k.value = !0);
35
+ N.value || !e?.length || (y.value = new Set(e), N.value = !0);
36
36
  },
37
37
  { immediate: !0 }
38
38
  );
39
- function m() {
39
+ function k() {
40
40
  return o()?.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
46
- }) : le({
47
- data: N(),
48
- getRowKey: u
49
- }) : []), d = w(() => {
42
+ const f = m(() => {
43
+ if (!o()) return [];
44
+ const e = A?.() ?? "children";
45
+ return R().some((n) => {
46
+ const s = n[e];
47
+ return Array.isArray(s) && s.length > 0;
48
+ }) ? ne({
49
+ data: R(),
50
+ childrenColumnName: e,
51
+ getRowKey: d
52
+ }) : le({
53
+ data: R(),
54
+ getRowKey: d
55
+ });
56
+ }), h = m(() => {
50
57
  const e = /* @__PURE__ */ new Map();
51
58
  return f.value.forEach((t) => e.set(t.key, t)), e;
52
- }), I = w(
59
+ });
60
+ P(
61
+ [
62
+ f,
63
+ () => o()?.preserveSelectedRowKeys,
64
+ () => o()?.selectedRowKeys
65
+ ],
66
+ () => {
67
+ if (!o()?.preserveSelectedRowKeys) {
68
+ u.clear();
69
+ return;
70
+ }
71
+ const e = new Set(o()?.selectedRowKeys ?? y.value);
72
+ for (const t of u.keys()) e.has(t) || u.delete(t);
73
+ for (const t of f.value)
74
+ e.has(t.key) && u.set(t.key, t.record);
75
+ },
76
+ { immediate: !0, flush: "sync" }
77
+ ), P(
78
+ () => b(),
79
+ () => {
80
+ S.value = null;
81
+ }
82
+ );
83
+ const I = m(
53
84
  () => f.value.filter((e) => e.parentKey === void 0).map((e) => e.key)
54
85
  );
55
- function S(e) {
86
+ function v(e) {
56
87
  return o()?.getCheckboxProps?.(e)?.disabled ?? !1;
57
88
  }
58
- function Y(e) {
59
- return d.value.get(e)?.childrenKeys ?? [];
60
- }
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) {
66
- 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);
89
+ function j(e) {
90
+ return h.value.get(e)?.childrenKeys ?? [];
91
+ }
92
+ const L = m(() => {
93
+ const e = h.value, t = /* @__PURE__ */ new Map(), n = f.value;
94
+ for (let s = n.length - 1; s >= 0; s -= 1) {
95
+ const l = n[s], c = [];
96
+ for (const r of l.childrenKeys) {
97
+ const a = e.get(r);
98
+ if (!a || v(a.record)) continue;
99
+ c.push(r);
100
+ const i = t.get(r);
101
+ i && c.push(...i);
71
102
  }
72
- t.set(c.key, s);
103
+ t.set(l.key, c);
73
104
  }
74
105
  return t;
75
106
  });
76
- function P(e) {
107
+ function V(e) {
77
108
  if (o()?.checkStrictly !== !1)
78
109
  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));
110
+ const t = new Set(e), n = (s) => {
111
+ const l = j(s);
112
+ l.forEach(n);
113
+ const c = h.value.get(s);
114
+ if (!c || v(c.record)) return;
115
+ const r = l.map((i) => h.value.get(i)).filter((i) => !!i && !v(i.record));
85
116
  if (r.length === 0) return;
86
- r.every((a) => t.has(a.key)) ? t.add(n) : t.delete(n);
117
+ r.every((i) => t.has(i.key)) ? t.add(s) : t.delete(s);
87
118
  };
88
- return I.value.forEach(l), t;
119
+ return I.value.forEach(n), t;
89
120
  }
90
- const v = w(() => {
91
- const e = o(), t = e?.selectedRowKeys !== void 0 ? new Set(e.selectedRowKeys) : h.value;
92
- return P(t);
121
+ const g = m(() => {
122
+ const e = o(), t = e?.selectedRowKeys !== void 0 ? new Set(e.selectedRowKeys) : y.value;
123
+ return V(t);
93
124
  });
94
- H(
125
+ P(
95
126
  [f, () => o()?.preserveSelectedRowKeys],
96
127
  () => {
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))
128
+ if (k() || o()?.preserveSelectedRowKeys || y.value.size === 0) return;
129
+ const e = new Set(f.value.map((n) => n.key)), t = new Set(
130
+ Array.from(y.value).filter((n) => e.has(n))
100
131
  );
101
- t.size !== h.value.size && (h.value = t);
132
+ t.size !== y.value.size && (y.value = t);
102
133
  },
103
134
  { immediate: !0 }
104
135
  );
105
136
  function z(e) {
106
- return v.value.has(e);
137
+ return g.value.has(e);
107
138
  }
108
139
  function p(e) {
109
- return f.value.filter((t) => e.has(t.key)).map((t) => t.record);
140
+ const t = f.value.filter((n) => e.has(n.key)).map((n) => n.record);
141
+ if (o()?.preserveSelectedRowKeys)
142
+ for (const n of e)
143
+ !h.value.has(n) && u.has(n) && t.push(u.get(n));
144
+ return t;
110
145
  }
111
146
  function O() {
112
- return C().map((e, t) => d.value.get(u(e, t)) ?? null).filter((e) => e !== null);
147
+ return b().map((e, t) => h.value.get(d(e, t)) ?? null).filter((e) => e !== null);
113
148
  }
114
- function D() {
115
- return O().filter((e) => !S(e.record));
149
+ function M() {
150
+ return O().filter((e) => !v(e.record));
116
151
  }
117
152
  function q() {
118
- return f.value.filter((e) => !S(e.record));
153
+ return f.value.filter((e) => !v(e.record));
119
154
  }
120
- function B(e, t) {
121
- const l = u(e, t), n = z(l), c = S(e);
155
+ function B(e = !1) {
156
+ return w.paginate?.() && !e ? M() : q();
157
+ }
158
+ function F(e, t) {
159
+ const n = d(e, t), s = z(n), l = v(e);
122
160
  if (o()?.checkStrictly !== !1)
123
161
  return {
124
- checked: n,
162
+ checked: s,
125
163
  indeterminate: !1,
126
- disabled: c
164
+ disabled: l
127
165
  };
128
- const s = L.value.get(l) ?? [];
129
- if (s.length === 0)
166
+ const c = L.value.get(n) ?? [];
167
+ if (c.length === 0)
130
168
  return {
131
- checked: n,
169
+ checked: s,
132
170
  indeterminate: !1,
133
- disabled: c
171
+ disabled: l
134
172
  };
135
- const r = s.filter((i) => v.value.has(i)).length;
173
+ const r = c.filter((a) => g.value.has(a)).length;
136
174
  return {
137
- checked: n,
138
- indeterminate: r > 0 && r < s.length,
139
- disabled: c
175
+ checked: s,
176
+ indeterminate: r > 0 && r < c.length,
177
+ disabled: l
140
178
  };
141
179
  }
142
- function g(e, t) {
143
- const l = P(e);
144
- m() || (h.value = l);
180
+ function K(e, t) {
181
+ const n = V(e);
182
+ if (o()?.preserveSelectedRowKeys) {
183
+ if (!k())
184
+ for (const s of u.keys())
185
+ n.has(s) || u.delete(s);
186
+ for (const s of f.value)
187
+ n.has(s.key) && u.set(s.key, s.record);
188
+ }
189
+ k() || (y.value = n);
145
190
  {
146
- const n = Array.from(l), c = p(l);
147
- o()?.onChange?.(n, c), x?.();
191
+ const s = Array.from(n), l = p(n);
192
+ o()?.onChange?.(s, l), E?.();
148
193
  }
149
194
  }
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)
195
+ function Y(e, t, n, s) {
196
+ const l = h.value.get(e);
197
+ if (!l || v(l.record)) return;
198
+ const c = t.has(e);
199
+ n ? t.add(e) : t.delete(e), c !== n && s.push(l.record), j(e).forEach(
200
+ (r) => Y(r, t, n, s)
156
201
  );
157
202
  }
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
203
+ function G(e, t, n) {
204
+ const s = o();
205
+ if (!s) return;
206
+ const l = d(e, t), c = !z(l);
207
+ if (s.type !== "radio" && n?.shiftKey && S.value !== null && o()?.checkStrictly !== !1) {
208
+ const a = M(), i = a.findIndex((C) => C.key === l), D = a.findIndex(
209
+ (C) => C.key === S.value
165
210
  );
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;
211
+ if (i !== -1 && D !== -1) {
212
+ const [C, ee] = i > D ? [D, i] : [i, D], x = new Set(g.value), H = [];
213
+ a.slice(C, ee + 1).forEach((T) => {
214
+ const te = x.has(T.key);
215
+ c ? x.add(T.key) : x.delete(T.key), te !== c && H.push(T.record);
216
+ }), K(x), s.onSelectMultiple?.(c, p(x), H), S.value = l;
172
217
  return;
173
218
  }
174
219
  }
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;
220
+ if (s.type === "radio") {
221
+ const a = c ? /* @__PURE__ */ new Set([l]) : /* @__PURE__ */ new Set();
222
+ K(a), s.onSelect?.(e, c, p(a)), S.value = l;
178
223
  return;
179
224
  }
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;
225
+ const r = new Set(g.value);
226
+ c ? r.add(l) : r.delete(l), K(r), s.onSelect?.(e, c, p(r)), S.value = l;
188
227
  }
189
- function J(e, t, l) {
190
- if (S(e)) return;
228
+ function J(e, t) {
191
229
  const n = o();
192
- if (n) {
193
- if (n.checkStrictly === !1 && n.type !== "radio") {
194
- G(e, t);
230
+ if (!n) return;
231
+ const s = d(e, t), l = !z(s), c = new Set(g.value);
232
+ Y(s, c, l, []), K(c), n.onSelect?.(e, l, p(c)), S.value = s;
233
+ }
234
+ function Q(e, t, n) {
235
+ if (v(e)) return;
236
+ const s = o();
237
+ if (s) {
238
+ if (s.checkStrictly === !1 && s.type !== "radio") {
239
+ J(e, t);
195
240
  return;
196
241
  }
197
- F(e, t, l);
242
+ G(e, t, n);
198
243
  }
199
244
  }
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();
245
+ function U(e, t = !1) {
246
+ const n = o();
247
+ if (!n) return;
248
+ const s = B(t), l = new Set(g.value), c = [];
249
+ s.forEach((r) => {
250
+ if (n.checkStrictly === !1) {
251
+ Y(r.key, l, e, c);
252
+ return;
253
+ }
254
+ const a = l.has(r.key);
255
+ e ? l.add(r.key) : l.delete(r.key), a !== e && c.push(r.record);
256
+ }), K(l), n.onSelectAll?.(e, p(l), c);
257
+ }
258
+ const W = m(() => {
259
+ const e = B();
211
260
  if (e.length === 0) return "none";
212
- const t = e.filter((l) => v.value.has(l.key)).length;
261
+ const t = e.filter((n) => g.value.has(n.key)).length;
213
262
  return t === 0 ? "none" : t === e.length ? "all" : "partial";
214
263
  });
215
- function W() {
264
+ function X() {
216
265
  const e = o();
217
266
  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)));
267
+ const t = M(), n = new Set(g.value);
268
+ t.forEach((s) => {
269
+ n.has(s.key) ? n.delete(s.key) : n.add(s.key);
270
+ }), K(n), e.onSelectInvert?.(Array.from(V(n)));
222
271
  }
223
- function X() {
272
+ function Z() {
224
273
  const e = o();
225
- e && (g(/* @__PURE__ */ new Set()), e.onSelectNone?.());
274
+ e && (K(/* @__PURE__ */ new Set()), e.onSelectNone?.());
226
275
  }
227
- function Z() {
228
- return D().map((e) => e.key);
276
+ function $() {
277
+ return M().map((e) => e.key);
229
278
  }
230
279
  return {
231
- selectedKeySet: v,
280
+ selectedKeySet: g,
232
281
  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
282
+ isDisabled: v,
283
+ getSelectionState: F,
284
+ toggleRow: Q,
285
+ toggleAll: U,
286
+ allCheckedState: W,
287
+ invertSelection: X,
288
+ clearSelection: Z,
289
+ getChangeableRowKeys: $
241
290
  };
242
291
  }
243
292
  export {
244
- se as useSelection
293
+ ce as useSelection
245
294
  };
@@ -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,GA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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 */