@vtable-guild/vtable-guild 2.6.4 → 2.7.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 (64) hide show
  1. package/css/presets/antdv.css +2 -0
  2. package/css/presets/element-plus.css +2 -0
  3. package/css/style.css +19 -0
  4. package/css/tailwind3-utilities.css +15 -0
  5. package/css/tailwind3.css +4 -0
  6. package/css/tailwind4.css +4 -0
  7. package/dist/css/presets/antdv.css +2 -0
  8. package/dist/css/presets/element-plus.css +2 -0
  9. package/dist/css/style.css +19 -0
  10. package/dist/css/tailwind3-utilities.css +15 -0
  11. package/dist/css/tailwind3.css +4 -0
  12. package/dist/css/tailwind4.css +4 -0
  13. package/dist/index.full.mjs +3712 -3404
  14. package/dist/index.mjs +22 -19
  15. package/dist/table/src/components/ExpandedRowTr.d.ts +90 -0
  16. package/dist/table/src/components/ExpandedRowTr.d.ts.map +1 -0
  17. package/dist/table/src/components/ExpandedRowTr.mjs +61 -0
  18. package/dist/table/src/components/Table.d.ts +23 -3
  19. package/dist/table/src/components/Table.d.ts.map +1 -1
  20. package/dist/table/src/components/Table.mjs +355 -324
  21. package/dist/table/src/components/TableBody.d.ts.map +1 -1
  22. package/dist/table/src/components/TableBody.mjs +67 -58
  23. package/dist/table/src/components/VTable.vue.d.ts +4 -3
  24. package/dist/table/src/components/VTable.vue.d.ts.map +1 -1
  25. package/dist/table/src/components/VTable.vue.mjs +43 -37
  26. package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
  27. package/dist/table/src/components/VirtualTableBody.mjs +110 -104
  28. package/dist/table/src/composables/index.d.ts +3 -0
  29. package/dist/table/src/composables/index.d.ts.map +1 -1
  30. package/dist/table/src/composables/useColumnDisplay.d.ts +26 -0
  31. package/dist/table/src/composables/useColumnDisplay.d.ts.map +1 -0
  32. package/dist/table/src/composables/useColumnDisplay.mjs +46 -0
  33. package/dist/table/src/composables/useColumnDisplay.test.d.ts +2 -0
  34. package/dist/table/src/composables/useColumnDisplay.test.d.ts.map +1 -0
  35. package/dist/table/src/composables/useRowDragSort.d.ts +79 -0
  36. package/dist/table/src/composables/useRowDragSort.d.ts.map +1 -0
  37. package/dist/table/src/composables/useRowDragSort.mjs +146 -0
  38. package/dist/table/src/composables/useRowDragSort.test.d.ts +2 -0
  39. package/dist/table/src/composables/useRowDragSort.test.d.ts.map +1 -0
  40. package/dist/table/src/context.d.ts +14 -0
  41. package/dist/table/src/context.d.ts.map +1 -1
  42. package/dist/table/src/index.d.ts +14 -4
  43. package/dist/table/src/index.d.ts.map +1 -1
  44. package/dist/table/src/types/column.d.ts +6 -0
  45. package/dist/table/src/types/column.d.ts.map +1 -1
  46. package/dist/table/src/types/index.d.ts +1 -1
  47. package/dist/table/src/types/index.d.ts.map +1 -1
  48. package/dist/table/src/types/table.d.ts +23 -8
  49. package/dist/table/src/types/table.d.ts.map +1 -1
  50. package/dist/table/src/utils/columnWidth.d.ts +12 -0
  51. package/dist/table/src/utils/columnWidth.d.ts.map +1 -0
  52. package/dist/table/src/utils/columnWidth.mjs +26 -0
  53. package/dist/table/src/utils/columnWidth.test.d.ts +2 -0
  54. package/dist/table/src/utils/columnWidth.test.d.ts.map +1 -0
  55. package/dist/table/src/utils/rowKey.d.ts +8 -0
  56. package/dist/table/src/utils/rowKey.d.ts.map +1 -0
  57. package/dist/table/src/utils/rowKey.mjs +6 -0
  58. package/dist/theme/src/presets/antdv/table.d.ts +3 -0
  59. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  60. package/dist/theme/src/presets/antdv/table.mjs +4 -0
  61. package/dist/theme/src/presets/element-plus/table.d.ts +3 -0
  62. package/dist/theme/src/presets/element-plus/table.d.ts.map +1 -1
  63. package/dist/theme/src/presets/element-plus/table.mjs +4 -0
  64. package/package.json +1 -1
@@ -1,18 +1,22 @@
1
- import { defineComponent as X, inject as $, ref as g, computed as c, onBeforeUnmount as D, watch as G, createVNode as r, isVNode as U } from "vue";
1
+ import { defineComponent as $, inject as G, ref as C, computed as m, onBeforeUnmount as U, watch as Y, createVNode as r, isVNode as J } from "vue";
2
2
  import "../../../core/src/utils/tv.mjs";
3
- import Y from "./TableRow.mjs";
4
- import J from "./TableCell.mjs";
5
- import Q from "./TableEmpty.mjs";
6
- import Z from "./ColGroup.mjs";
7
- import { TABLE_CONTEXT_KEY as ee } from "../context.mjs";
8
- import { resolveFixedColumnRanges as te, useColumnWindow as le } from "../composables/useColumnWindow.mjs";
9
- import { getRowCompatClass as ne, getExpandedRowCompatClass as oe } from "../utils/compat.mjs";
10
- import ae from "../../../core/src/components/VirtualList/VirtualList.mjs";
11
- import { cn as x } from "tailwind-variants";
12
- function re(e) {
13
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !U(e);
3
+ import Q from "./TableRow.mjs";
4
+ import Z from "./TableCell.mjs";
5
+ import ee from "./TableEmpty.mjs";
6
+ import te from "./ExpandedRowTr.mjs";
7
+ import le from "./ColGroup.mjs";
8
+ import { TABLE_CONTEXT_KEY as ne } from "../context.mjs";
9
+ import { resolveFixedColumnRanges as oe, useColumnWindow as ae } from "../composables/useColumnWindow.mjs";
10
+ import { resolveRowDragClass as re } from "../composables/useRowDragSort.mjs";
11
+ import { getRowCompatClass as ie } from "../utils/compat.mjs";
12
+ import { resolveRowKey as T } from "../utils/rowKey.mjs";
13
+ import { sumDeclaredColumnWidths as se, parseStylePxWidth as de } from "../utils/columnWidth.mjs";
14
+ import ue from "../../../core/src/components/VirtualList/VirtualList.mjs";
15
+ import { cn as ce } from "tailwind-variants";
16
+ function fe(e) {
17
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !J(e);
14
18
  }
15
- const xe = /* @__PURE__ */ X({
19
+ const Te = /* @__PURE__ */ $({
16
20
  name: "VirtualTableBody",
17
21
  props: {
18
22
  dataSource: {
@@ -92,112 +96,108 @@ const xe = /* @__PURE__ */ X({
92
96
  }
93
97
  },
94
98
  setup(e) {
95
- const a = $(ee, {}), w = g(), b = g(0), f = g(0);
96
- function S(t) {
97
- b.value = t.x, e.onVirtualScroll?.({
99
+ const a = G(ne, {}), w = C(), x = C(0), c = C(0);
100
+ function b(t) {
101
+ x.value = t.x, e.onVirtualScroll?.({
98
102
  ...t,
99
103
  maxX: w.value?.getHorizontalRange() ?? 0
100
104
  });
101
105
  }
102
- function O(t, l) {
103
- return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : l;
106
+ function V(t, l) {
107
+ return T(t, l, e.rowKey);
104
108
  }
105
- function T(t) {
106
- return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : e.dataSource.indexOf(t);
109
+ function k(t) {
110
+ const l = e.dataSource.indexOf(t);
111
+ return T(t, l, e.rowKey);
107
112
  }
108
- const V = c(() => {
109
- let t = 0;
110
- for (const l of e.columns) {
111
- const d = typeof l.width == "number" ? l.width : parseInt(String(l.width || "0"), 10);
112
- t += d || 0;
113
- }
114
- return t;
115
- }), k = c(() => {
113
+ const q = m(() => {
116
114
  const t = e.virtualColumn ? e.columnMetrics?.total : void 0;
117
- return t && t > 0 ? t : V.value;
118
- }), m = c(() => te(e.columns)), R = c(() => {
119
- if (!e.virtualColumn || f.value <= 0) return null;
115
+ if (t && t > 0) return t;
116
+ const l = se(e.columns, a.columnWidths), u = de(e.tableStyle?.width);
117
+ return Math.max(l, u);
118
+ }), v = m(() => oe(e.columns)), S = m(() => {
119
+ if (!e.virtualColumn || c.value <= 0) return null;
120
120
  const t = e.columnMetrics;
121
121
  return !t || t.widths.length !== e.columns.length ? null : t.widths;
122
122
  }), {
123
- active: p,
124
- start: q,
125
- end: W,
126
- leftSpacer: E,
127
- rightSpacer: K
128
- } = le({
129
- widths: () => R.value,
130
- leftFixedCount: () => m.value.leftFixedCount,
131
- rightFixedStart: () => m.value.rightFixedStart,
132
- offsetX: () => b.value,
133
- viewportWidth: () => f.value
134
- }), H = c(() => {
123
+ active: R,
124
+ start: O,
125
+ end: H,
126
+ leftSpacer: p,
127
+ rightSpacer: E
128
+ } = ae({
129
+ widths: () => S.value,
130
+ leftFixedCount: () => v.value.leftFixedCount,
131
+ rightFixedStart: () => v.value.rightFixedStart,
132
+ offsetX: () => x.value,
133
+ viewportWidth: () => c.value
134
+ }), _ = m(() => {
135
135
  const t = e.columns.length;
136
- if (!p.value)
136
+ if (!R.value)
137
137
  return Array.from({
138
138
  length: t
139
- }, (o, i) => ({
139
+ }, (n, i) => ({
140
140
  index: i
141
141
  }));
142
142
  const {
143
143
  leftFixedCount: l,
144
- rightFixedStart: d
145
- } = m.value, n = [];
146
- for (let o = 0; o < l; o += 1) n.push({
147
- index: o
144
+ rightFixedStart: u
145
+ } = v.value, o = [];
146
+ for (let n = 0; n < l; n += 1) o.push({
147
+ index: n
148
148
  });
149
- E.value > 0 && n.push({
150
- spacer: E.value
149
+ p.value > 0 && o.push({
150
+ spacer: p.value
151
151
  });
152
- for (let o = q.value; o <= W.value; o += 1) n.push({
153
- index: o
152
+ for (let n = O.value; n <= H.value; n += 1) o.push({
153
+ index: n
154
154
  });
155
- K.value > 0 && n.push({
156
- spacer: K.value
155
+ E.value > 0 && o.push({
156
+ spacer: E.value
157
157
  });
158
- for (let o = d; o < t; o += 1) n.push({
159
- index: o
158
+ for (let n = u; n < t; n += 1) o.push({
159
+ index: n
160
160
  });
161
- return n;
161
+ return o;
162
162
  });
163
- function ie(t) {
163
+ function me(t) {
164
164
  }
165
- let u = null, s = null;
165
+ let s = null, d = null;
166
166
  function B(t) {
167
167
  const l = t ?? null;
168
- l !== s && (u && s && u.unobserve(s), s = l, l && (f.value = l.clientWidth, !u && typeof ResizeObserver < "u" && (u = new ResizeObserver(() => {
169
- s && (f.value = s.clientWidth);
170
- })), u?.observe(l)));
168
+ l !== d && (s && d && s.unobserve(d), d = l, l && (c.value = l.clientWidth, !s && typeof ResizeObserver < "u" && (s = new ResizeObserver(() => {
169
+ d && (c.value = d.clientWidth);
170
+ })), s?.observe(l)));
171
171
  }
172
- return D(() => {
173
- u?.disconnect(), u = null, s = null;
174
- }), G(() => w.value, (t) => {
172
+ return U(() => {
173
+ s?.disconnect(), s = null, d = null;
174
+ }), Y(() => w.value, (t) => {
175
175
  if (t) {
176
176
  const l = t.getScrollInfo();
177
- S(l), t.nativeElement, B(t.nativeElement);
177
+ b(l), t.nativeElement, B(t.nativeElement);
178
178
  } else
179
179
  B(null);
180
180
  }), () => e.dataSource.length === 0 ? r("table", {
181
181
  class: e.tableClass,
182
182
  style: e.tableStyle
183
- }, [r(Z, {
183
+ }, [r(le, {
184
184
  columns: e.columns
185
185
  }, null), r("tbody", {
186
186
  class: e.tbodyClass
187
- }, [r(Q, {
187
+ }, [r(ee, {
188
188
  colSpan: e.columns.length || 1,
189
189
  emptyClass: e.emptyClass,
190
190
  tdClass: e.tdClass
191
- }, null)])]) : r(ae, {
191
+ }, null)])]) : r(ue, {
192
192
  ref: w,
193
193
  data: e.dataSource,
194
194
  height: e.height,
195
195
  itemHeight: e.itemHeight,
196
- itemKey: T,
197
- scrollWidth: k.value || void 0,
196
+ itemKey: k,
197
+ scrollWidth: q.value || void 0,
198
198
  disableHeightMeasure: e.fixedHeight,
199
199
  fullHeight: !1,
200
- onVirtualScroll: S,
200
+ onVirtualScroll: b,
201
201
  showScrollBar: e.showScrollBar,
202
202
  style: {
203
203
  overflow: "hidden"
@@ -207,10 +207,13 @@ const xe = /* @__PURE__ */ X({
207
207
  item: t,
208
208
  index: l
209
209
  }) => {
210
- let d;
211
- const n = l, o = O(t, n), i = a.expandable?.(), _ = a.isExpanded?.(o) ?? !1, I = i?.expandRowByClick ?? !1, j = a.isRowExpandable?.(t) ?? !1, F = a.getRowClassName?.(t, n), A = a.getRowProps?.(t, n), v = (a.isTreeData?.value ? a.getFlattenRow?.(t) : void 0)?.level ?? 0, z = typeof i?.expandedRowClassName == "function" ? i.expandedRowClassName(t, n, v) : i?.expandedRowClassName, L = I ? () => {
212
- j && a.toggleExpand?.(t, n);
213
- } : void 0, N = H.value, M = p.value ? R.value : null;
210
+ let u;
211
+ const o = l, n = V(t, o), i = a.expandable?.(), I = a.isExpanded?.(n) ?? !1, K = i?.expandRowByClick ?? !1, D = a.isRowExpandable?.(t) ?? !1, N = a.getRowClassName?.(t, o), W = a.getRowProps?.(t, o), P = a.rowDrag?.enabled.value ? a.rowDrag.getBindings(t, o, W) : void 0, j = {
212
+ ...W,
213
+ ...P
214
+ }, A = re(a.rowDrag, n, a.subThemeSlots), y = (a.isTreeData?.value ? a.getFlattenRow?.(t) : void 0)?.level ?? 0, M = typeof i?.expandedRowClassName == "function" ? i.expandedRowClassName(t, o, y) : i?.expandedRowClassName, L = K ? () => {
215
+ D && a.toggleExpand?.(t, o);
216
+ } : void 0, F = _.value, X = R.value ? S.value : null;
214
217
  return r("table", {
215
218
  class: e.tableClass,
216
219
  style: {
@@ -220,47 +223,50 @@ const xe = /* @__PURE__ */ X({
220
223
  }, [r("tbody", {
221
224
  class: e.tbodyClass,
222
225
  "data-vtg-preserve-last-border": l < e.dataSource.length - 1 ? "" : void 0
223
- }, [r(Y, {
224
- key: o,
225
- rowClass: x(e.rowClass, F, ne(a, t, n, v)) ?? "",
226
- rowProps: A,
226
+ }, [r(Q, {
227
+ key: n,
228
+ rowClass: ce(e.rowClass, N, A, ie(a, t, o, y)) ?? "",
229
+ rowProps: j,
227
230
  onClick: L
228
- }, re(d = N.map((h, P) => {
229
- if (h.spacer !== void 0)
231
+ }, fe(u = F.map((g, z) => {
232
+ if (g.spacer !== void 0)
230
233
  return r("td", {
231
- key: `__vtg_spacer_${P}`,
234
+ key: `__vtg_spacer_${z}`,
232
235
  style: {
233
- width: `${h.spacer}px`,
236
+ width: `${g.spacer}px`,
234
237
  padding: "0"
235
238
  },
236
239
  "aria-hidden": "true"
237
240
  }, null);
238
- const y = h.index, C = e.columns[y];
239
- return r(J, {
240
- key: C.key ?? String(C.dataIndex ?? y),
241
+ const f = g.index, h = e.columns[f];
242
+ return r(Z, {
243
+ key: h.key ?? String(h.dataIndex ?? f),
241
244
  record: t,
242
- rowIndex: n,
243
- column: C,
244
- colIndex: y,
245
- widthOverride: M?.[y],
245
+ rowIndex: o,
246
+ column: h,
247
+ colIndex: f,
248
+ widthOverride: X?.[f],
246
249
  tdClass: e.tdClass,
247
250
  bodyCellEllipsisClass: e.bodyCellEllipsisClass
248
251
  }, null);
249
- })) ? d : {
250
- default: () => [d]
251
- }), _ && i?.expandedRowRender && r("tr", {
252
- key: `${o}-expanded`,
253
- class: x(e.rowClass, F, a.subThemeSlots?.expandedRow(), oe(a, v), z)
254
- }, [r("td", {
255
- colspan: N.length,
256
- class: x(e.tdClass, a.subThemeSlots?.expandedRowCell())
257
- }, [a.compatClass && (a.fixedOffsets?.value?.size ?? 0) > 0 ? r("div", {
258
- class: a.compatClass("expanded-row-fixed")
259
- }, [i.expandedRowRender(t, n, 0, !0)]) : i.expandedRowRender(t, n, 0, !0)])])])]);
252
+ })) ? u : {
253
+ default: () => [u]
254
+ }), I && i?.expandedRowRender ? r(te, {
255
+ key: `${n}-expanded`,
256
+ record: t,
257
+ rowIndex: o,
258
+ colspan: F.length,
259
+ rowIndent: y,
260
+ rowClass: e.rowClass,
261
+ rowClassName: N,
262
+ expandedRowClassName: M,
263
+ tdClass: e.tdClass,
264
+ expandedRowRender: i.expandedRowRender
265
+ }, null) : null])]);
260
266
  }
261
267
  });
262
268
  }
263
269
  });
264
270
  export {
265
- xe as default
271
+ Te as default
266
272
  };
@@ -1,4 +1,5 @@
1
1
  export { useColumns, getByDataIndex } from './useColumns';
2
+ export { filterVisibleColumns, applyColumnOrder } from './useColumnDisplay';
2
3
  export { useSorter, getColumnKey } from './useSorter';
3
4
  export type { SorterState, SorterResult } from './useSorter';
4
5
  export { useFilter } from './useFilter';
@@ -12,6 +13,8 @@ export { useExpand } from './useExpand';
12
13
  export { useResize } from './useResize';
13
14
  export { useHoverState, isInHoverRange } from './useHoverState';
14
15
  export type { HoverState } from './useHoverState';
16
+ export { useRowDragSort, moveTreeNode, resolveRowDragClass } from './useRowDragSort';
17
+ export type { DropPosition, RowDragBindings, RowDragDropTarget, TreeLocation, UseRowDragSortOptions, } from './useRowDragSort';
15
18
  export { useColumnMetrics } from './useColumnMetrics';
16
19
  export type { ColumnMetrics } from './useColumnMetrics';
17
20
  export { useColumnWindow, computeColumnWindow, resolveFixedColumnRanges, DEFAULT_COLUMN_OVERSCAN, } from './useColumnWindow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACrD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC/D,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB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AAqB,GACtB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { ColumnsType, Key } from '../types';
2
+ /**
3
+ * 过滤不可见列(`column.visible === false`)。
4
+ *
5
+ * 与 filterResponsiveColumns 同构:哨兵(EXPAND_COLUMN / SELECTION_COLUMN)
6
+ * 原样穿过;叶子列 visible 为 false 时丢弃;分组列自身隐藏或子列全部被
7
+ * 过滤掉时整组丢弃。叶子列保持原引用稳定;分组列因需替换 children 数组
8
+ * 会被克隆。
9
+ *
10
+ * 只在显示层(displayColumnTree)调用:数据列(排序/筛选输入)保持全量,
11
+ * 隐藏列的 sorter / filter 内部状态不会被清理,取消隐藏后状态保留。
12
+ */
13
+ export declare function filterVisibleColumns<TRecord extends Record<string, unknown>>(columns: ColumnsType<TRecord>): ColumnsType<TRecord>;
14
+ /**
15
+ * 按表级 `columnOrder` 重排顶层列。
16
+ *
17
+ * 规则:
18
+ * - key 在 order 中出现的列,按 order 中的先后排前(重复 key 取首次下标);
19
+ * - 未出现的列(含无 key 列)保持原相对顺序,排在已匹配列之后;
20
+ * - `pinnedKeys`(选择列 / 展开列)不参与顺序匹配,恒提取到最前(保持原相对顺序);
21
+ * - order 为空时原样返回,不做任何重排。
22
+ *
23
+ * 仅重排传入的这一层数组;分组列作为整体移动。
24
+ */
25
+ export declare function applyColumnOrder<TRecord extends Record<string, unknown>>(columns: ColumnsType<TRecord>, order: Key[] | undefined, pinnedKeys?: readonly string[]): ColumnsType<TRecord>;
26
+ //# sourceMappingURL=useColumnDisplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnDisplay.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAGjE;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1E,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAC5B,WAAW,CAAC,OAAO,CAAC,CAsBtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtE,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAC7B,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,EACxB,UAAU,GAAE,SAAS,MAAM,EAAO,GACjC,WAAW,CAAC,OAAO,CAAC,CAyCtB"}
@@ -0,0 +1,46 @@
1
+ import { getColumnKey as c } from "./useColumns.mjs";
2
+ function y(d) {
3
+ return d.reduce((e, n) => {
4
+ if (typeof n == "symbol")
5
+ return e.push(n), e;
6
+ if (n.visible === !1)
7
+ return e;
8
+ if ("children" in n && Array.isArray(n.children)) {
9
+ const o = y(n.children);
10
+ return o.length === 0 || e.push({ ...n, children: o }), e;
11
+ }
12
+ return e.push(n), e;
13
+ }, []);
14
+ }
15
+ function u(d, e, n = []) {
16
+ if (!e || e.length === 0) return d;
17
+ const o = /* @__PURE__ */ new Map();
18
+ e.forEach((r, i) => {
19
+ const t = String(r);
20
+ o.has(t) || o.set(t, i);
21
+ });
22
+ const a = new Set(n), h = [], s = [], f = [];
23
+ return d.forEach((r, i) => {
24
+ if (typeof r != "symbol") {
25
+ const t = c(r);
26
+ if (t !== void 0 && a.has(String(t))) {
27
+ h.push(r);
28
+ return;
29
+ }
30
+ const p = t !== void 0 ? o.get(String(t)) : void 0;
31
+ if (p !== void 0) {
32
+ s.push({ column: r, order: p, index: i });
33
+ return;
34
+ }
35
+ }
36
+ f.push({ column: r, order: Number.POSITIVE_INFINITY, index: i });
37
+ }), s.sort((r, i) => r.order - i.order || r.index - i.index), f.sort((r, i) => r.index - i.index), [
38
+ ...h,
39
+ ...s.map((r) => r.column),
40
+ ...f.map((r) => r.column)
41
+ ];
42
+ }
43
+ export {
44
+ u as applyColumnOrder,
45
+ y as filterVisibleColumns
46
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useColumnDisplay.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnDisplay.test.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnDisplay.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import { Ref } from 'vue';
2
+ import { Key, RowDragSortInfo } from '../types';
3
+ /** 拖拽放置位置:目标行的前 / 后 */
4
+ export type DropPosition = 'before' | 'after';
5
+ export interface RowDragDropTarget {
6
+ key: Key;
7
+ position: DropPosition;
8
+ }
9
+ /** 行拖拽状态对应的 class(trDragging / trDropAbove / trDropBelow) */
10
+ export declare function resolveRowDragClass(rowDrag: {
11
+ draggingKey: Ref<Key | null>;
12
+ dropTarget: Ref<RowDragDropTarget | null>;
13
+ } | undefined, key: Key, slots: {
14
+ trDragging: () => string;
15
+ trDropAbove: () => string;
16
+ trDropBelow: () => string;
17
+ } | undefined): string;
18
+ export interface UseRowDragSortOptions<TRecord extends Record<string, unknown>> {
19
+ /** 是否启用行拖拽(对应 rowDraggable prop) */
20
+ enabled: () => boolean;
21
+ /** 行 key 解析器(与表格 getRowKey 同源) */
22
+ getRowKey: (record: TRecord, index: number) => Key;
23
+ /** 数据源(拖放后在它上面搬移,重排结果交给外部更新) */
24
+ dataSource: () => TRecord[];
25
+ /** 树形数据子节点字段名;缺省 'children' */
26
+ childrenColumnName?: () => string | undefined;
27
+ /** 拖放完成且顺序有变化时回调 */
28
+ onDrop?: (newData: TRecord[], info: RowDragSortInfo) => void;
29
+ }
30
+ /**
31
+ * 在树结构中按 key 定位节点:返回包含它的数组从根起的下标路径([] 表示顶层)、
32
+ * 在该数组中的下标与节点引用。找不到返回 null。
33
+ */
34
+ export interface TreeLocation<TRecord> {
35
+ listPath: number[];
36
+ index: number;
37
+ node: TRecord;
38
+ }
39
+ /**
40
+ * 树感知的节点搬移:把 draggedKey 节点搬到 targetKey 节点的前 / 后,
41
+ * 即插入到目标节点的**同级位置**——目标在顶层就回到顶层,目标是某父的子节点
42
+ * 就变成该父的子节点(跨父移动)。节点自身携带整棵子树;平铺数据自然退化为
43
+ * 普通的前后插入。
44
+ *
45
+ * 返回 null 表示不需要更新:找不到节点、拖到自己 / 自己的子树里、或插回原位。
46
+ * 纯函数不修改入参;仅拖拽路径上的 children 数组与父节点对象被克隆,其余节点
47
+ * 保持原引用,选择 / 展开等按 record 引用或 key 记录的状态因此不受影响。
48
+ */
49
+ export declare function moveTreeNode<TRecord extends Record<string, unknown>>(records: readonly TRecord[], getKey: (record: TRecord, index: number) => Key, draggedKey: Key, targetKey: Key, position: DropPosition, childrenColumnName?: string): TRecord[] | null;
50
+ /** 拖拽行绑到 <tr> 上的 props。禁用时 draggable 为 false、事件仅透传用户 handler。 */
51
+ export interface RowDragBindings {
52
+ draggable: boolean;
53
+ onDragstart: (event: DragEvent) => void;
54
+ onDragover: (event: DragEvent) => void;
55
+ onDragleave: (event: DragEvent) => void;
56
+ onDrop: (event: DragEvent) => void;
57
+ onDragend: (event: DragEvent) => void;
58
+ }
59
+ /**
60
+ * 行拖拽排序(原生 HTML5 拖放)。
61
+ *
62
+ * 仅负责交互状态与拖放结果计算:drop 时在 dataSource 上搬移行并通过
63
+ * onDrop 交给外部更新(受控模式,与 dataSource 为 prop 的数据流一致)。
64
+ * 拖拽态 class(trDragging / trDropAbove / trDropBelow)由行组件根据
65
+ * draggingKey / dropTarget 拼进 rowClass。
66
+ */
67
+ export declare function useRowDragSort<TRecord extends Record<string, unknown>>(options: UseRowDragSortOptions<TRecord>): {
68
+ draggingKey: Ref<Key | null, Key | null>;
69
+ dropTarget: Ref<{
70
+ key: Key;
71
+ position: DropPosition;
72
+ } | null, RowDragDropTarget | {
73
+ key: Key;
74
+ position: DropPosition;
75
+ } | null>;
76
+ isDragging: import('vue').ComputedRef<boolean>;
77
+ getBindings: (record: TRecord, index: number, userProps?: Record<string, unknown>) => RowDragBindings;
78
+ };
79
+ //# sourceMappingURL=useRowDragSort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRowDragSort.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useRowDragSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,uBAAuB;AACvB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,GAAG,CAAA;IACR,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,6DAA6D;AAC7D,wBAAgB,mBAAmB,CACjC,OAAO,EACH;IACE,WAAW,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;IAC5B,UAAU,EAAE,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;CAC1C,GACD,SAAS,EACb,GAAG,EAAE,GAAG,EACR,KAAK,EACD;IAAE,UAAU,EAAE,MAAM,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,MAAM,CAAA;CAAE,GAClF,SAAS,GACZ,MAAM,CAMR;AAED,MAAM,WAAW,qBAAqB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5E,oCAAoC;IACpC,OAAO,EAAE,MAAM,OAAO,CAAA;IACtB,kCAAkC;IAClC,SAAS,EAAE,CA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O,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC;;;aApNlC,GAAG;kBACE,YAAY;;aADjB,GAAG;kBACE,YAAY;;;0BAqTZ,OAAO,SACR,MAAM,cACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAClC,eAAe;EAwCnB"}
@@ -0,0 +1,146 @@
1
+ import { ref as A, computed as R } from "vue";
2
+ function E(r, n, e) {
3
+ if (!r || !e) return "";
4
+ if (r.draggingKey.value === n) return e.trDragging();
5
+ const l = r.dropTarget.value;
6
+ return !l || l.key !== n ? "" : l.position === "before" ? e.trDropAbove() : e.trDropBelow();
7
+ }
8
+ function w(r, n, e, l) {
9
+ const i = (u, a) => {
10
+ for (let o = 0; o < u.length; o += 1) {
11
+ if (e(u[o], o) === n)
12
+ return { listPath: a, index: o, node: u[o] };
13
+ const d = u[o][l];
14
+ if (Array.isArray(d)) {
15
+ const h = i(d, [...a, o]);
16
+ if (h) return h;
17
+ }
18
+ }
19
+ return null;
20
+ };
21
+ return i(r, []);
22
+ }
23
+ function T(r, n, e, l) {
24
+ const i = r[l];
25
+ return Array.isArray(i) ? i.some(
26
+ (u, a) => e(u, a) === n || T(u, n, e, l)
27
+ ) : !1;
28
+ }
29
+ function k(r, n, e) {
30
+ const l = [], i = (u) => {
31
+ u.forEach((a, o) => {
32
+ l.push(n(a, o));
33
+ const d = a[e];
34
+ Array.isArray(d) && i(d);
35
+ });
36
+ };
37
+ return i(r), l;
38
+ }
39
+ function b(r, n, e, l) {
40
+ if (n.length === 0) return l([...r]);
41
+ const [i, ...u] = n, a = [...r], o = a[i], d = o[e];
42
+ return Array.isArray(d) && (a[i] = {
43
+ ...o,
44
+ [e]: b(
45
+ d,
46
+ u,
47
+ e,
48
+ l
49
+ )
50
+ }), a;
51
+ }
52
+ function x(r, n, e, l, i, u = "children") {
53
+ if (e === l) return null;
54
+ const a = w(r, e, n, u), o = w(r, l, n, u);
55
+ if (!a || !o || T(a.node, l, n, u) || a.listPath.length === o.listPath.length && a.listPath.every((f, t) => f === o.listPath[t]) && (i === "after" && o.index === a.index - 1 || i === "before" && o.index === a.index + 1))
56
+ return null;
57
+ const h = b(
58
+ r,
59
+ a.listPath,
60
+ u,
61
+ (f) => f.filter((t, v) => v !== a.index)
62
+ ), s = w(h, l, n, u);
63
+ return s ? b(h, s.listPath, u, (f) => {
64
+ const t = [...f];
65
+ return t.splice(s.index + (i === "after" ? 1 : 0), 0, a.node), t;
66
+ }) : null;
67
+ }
68
+ function S(r) {
69
+ const n = A(null), e = A(null), l = R(() => n.value !== null);
70
+ function i(s, f, t) {
71
+ r.enabled() && (n.value = r.getRowKey(s, f), t.dataTransfer && (t.dataTransfer.setData("text/plain", String(n.value)), t.dataTransfer.effectAllowed = "move"));
72
+ }
73
+ function u(s, f, t) {
74
+ if (n.value === null) return;
75
+ t.preventDefault(), t.dataTransfer && (t.dataTransfer.dropEffect = "move");
76
+ const v = r.getRowKey(s, f);
77
+ if (v === n.value) {
78
+ e.value = null;
79
+ return;
80
+ }
81
+ const g = t.currentTarget?.getBoundingClientRect(), c = g && t.clientY >= g.top + g.height / 2 ? "after" : "before", y = e.value;
82
+ (!y || y.key !== v || y.position !== c) && (e.value = { key: v, position: c });
83
+ }
84
+ function a(s, f) {
85
+ if (n.value === null) return;
86
+ const t = r.getRowKey(s, f);
87
+ e.value?.key === t && (e.value = null);
88
+ }
89
+ function o(s) {
90
+ if (n.value === null) return;
91
+ s.preventDefault();
92
+ const f = n.value, t = e.value;
93
+ if (n.value = null, e.value = null, !t) return;
94
+ const v = r.childrenColumnName?.() || "children", D = r.dataSource(), g = x(
95
+ D,
96
+ r.getRowKey,
97
+ f,
98
+ t.key,
99
+ t.position,
100
+ v
101
+ );
102
+ g && r.onDrop?.(g, {
103
+ draggedKey: f,
104
+ targetKey: t.key,
105
+ orderedKeys: k(g, r.getRowKey, v)
106
+ });
107
+ }
108
+ function d() {
109
+ n.value = null, e.value = null;
110
+ }
111
+ function h(s, f, t) {
112
+ const D = r.enabled() && t?.draggable !== !1, g = (c, y) => {
113
+ const p = t?.[c];
114
+ typeof p == "function" && p(y);
115
+ };
116
+ return {
117
+ draggable: D,
118
+ onDragstart: (c) => {
119
+ D && i(s, f, c), g("onDragstart", c);
120
+ },
121
+ onDragover: (c) => {
122
+ D && u(s, f, c), g("onDragover", c);
123
+ },
124
+ onDragleave: (c) => {
125
+ D && a(s, f), g("onDragleave", c);
126
+ },
127
+ onDrop: (c) => {
128
+ D && o(c), g("onDrop", c);
129
+ },
130
+ onDragend: (c) => {
131
+ D && d(), g("onDragend", c);
132
+ }
133
+ };
134
+ }
135
+ return {
136
+ draggingKey: n,
137
+ dropTarget: e,
138
+ isDragging: l,
139
+ getBindings: h
140
+ };
141
+ }
142
+ export {
143
+ x as moveTreeNode,
144
+ E as resolveRowDragClass,
145
+ S as useRowDragSort
146
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useRowDragSort.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRowDragSort.test.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useRowDragSort.test.ts"],"names":[],"mappings":""}