@vtable-guild/vtable-guild 2.4.1 → 2.6.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 (95) hide show
  1. package/css/style.css +12 -0
  2. package/css/tailwind3-utilities.css +12 -0
  3. package/dist/core/src/components/VTableGuildConfigProvider.d.ts.map +1 -1
  4. package/dist/core/src/components/VTableGuildConfigProvider.mjs +17 -12
  5. package/dist/core/src/components/VirtualList/VirtualList.d.ts +21 -0
  6. package/dist/core/src/components/VirtualList/VirtualList.d.ts.map +1 -1
  7. package/dist/core/src/components/VirtualList/VirtualList.mjs +201 -216
  8. package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts +7 -1
  9. package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts.map +1 -1
  10. package/dist/core/src/components/VirtualList/hooks/useHeights.mjs +29 -27
  11. package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts +3 -1
  12. package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts.map +1 -1
  13. package/dist/core/src/components/VirtualList/hooks/useScrollTo.mjs +57 -50
  14. package/dist/core/src/components/VirtualList/index.d.ts +1 -0
  15. package/dist/core/src/components/VirtualList/index.d.ts.map +1 -1
  16. package/dist/core/src/components/VirtualList/utils/PrefixSums.d.ts +50 -0
  17. package/dist/core/src/components/VirtualList/utils/PrefixSums.d.ts.map +1 -0
  18. package/dist/core/src/components/VirtualList/utils/PrefixSums.mjs +54 -0
  19. package/dist/core/src/components/VirtualList/utils/PrefixSums.test.d.ts +2 -0
  20. package/dist/core/src/components/VirtualList/utils/PrefixSums.test.d.ts.map +1 -0
  21. package/dist/core/src/composables/useTheme.d.ts +9 -1
  22. package/dist/core/src/composables/useTheme.d.ts.map +1 -1
  23. package/dist/core/src/composables/useTheme.mjs +83 -60
  24. package/dist/core/src/index.d.ts +9 -0
  25. package/dist/core/src/index.d.ts.map +1 -1
  26. package/dist/core/src/plugin/index.d.ts.map +1 -1
  27. package/dist/core/src/plugin/index.mjs +4 -3
  28. package/dist/core/src/utils/types.d.ts +3 -0
  29. package/dist/core/src/utils/types.d.ts.map +1 -1
  30. package/dist/css/style.css +12 -0
  31. package/dist/css/tailwind3-utilities.css +12 -0
  32. package/dist/index.full.mjs +3450 -3006
  33. package/dist/index.mjs +41 -37
  34. package/dist/table/src/components/ColGroup.d.ts.map +1 -1
  35. package/dist/table/src/components/ColGroup.mjs +11 -8
  36. package/dist/table/src/components/Table.d.ts +68 -6
  37. package/dist/table/src/components/Table.d.ts.map +1 -1
  38. package/dist/table/src/components/Table.mjs +361 -297
  39. package/dist/table/src/components/TableBody.d.ts.map +1 -1
  40. package/dist/table/src/components/TableBody.mjs +38 -37
  41. package/dist/table/src/components/TableCell.d.ts +23 -0
  42. package/dist/table/src/components/TableCell.d.ts.map +1 -1
  43. package/dist/table/src/components/TableCell.mjs +85 -60
  44. package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
  45. package/dist/table/src/components/TableHeaderCell.mjs +177 -174
  46. package/dist/table/src/components/VTable.vue.mjs +10 -8
  47. package/dist/table/src/components/VTableCompatClass.test.d.ts +2 -0
  48. package/dist/table/src/components/VTableCompatClass.test.d.ts.map +1 -0
  49. package/dist/table/src/components/VirtualTableBody.d.ts +40 -0
  50. package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
  51. package/dist/table/src/components/VirtualTableBody.mjs +158 -67
  52. package/dist/table/src/composables/index.d.ts +4 -0
  53. package/dist/table/src/composables/index.d.ts.map +1 -1
  54. package/dist/table/src/composables/useColumnMetrics.d.ts +39 -0
  55. package/dist/table/src/composables/useColumnMetrics.d.ts.map +1 -0
  56. package/dist/table/src/composables/useColumnMetrics.mjs +88 -0
  57. package/dist/table/src/composables/useColumnWindow.d.ts +90 -0
  58. package/dist/table/src/composables/useColumnWindow.d.ts.map +1 -0
  59. package/dist/table/src/composables/useColumnWindow.mjs +62 -0
  60. package/dist/table/src/composables/useColumnWindow.test.d.ts +2 -0
  61. package/dist/table/src/composables/useColumnWindow.test.d.ts.map +1 -0
  62. package/dist/table/src/composables/useColumns.d.ts +8 -0
  63. package/dist/table/src/composables/useColumns.d.ts.map +1 -1
  64. package/dist/table/src/composables/useColumns.mjs +46 -43
  65. package/dist/table/src/composables/useFixedColumnStyle.d.ts.map +1 -1
  66. package/dist/table/src/composables/useFixedColumnStyle.mjs +12 -11
  67. package/dist/table/src/composables/useSelection.d.ts.map +1 -1
  68. package/dist/table/src/composables/useSelection.mjs +93 -94
  69. package/dist/table/src/composables/useVirtual.d.ts +10 -0
  70. package/dist/table/src/composables/useVirtual.d.ts.map +1 -1
  71. package/dist/table/src/composables/useVirtual.mjs +15 -11
  72. package/dist/table/src/context.d.ts +7 -0
  73. package/dist/table/src/context.d.ts.map +1 -1
  74. package/dist/table/src/index.d.ts +2 -0
  75. package/dist/table/src/index.d.ts.map +1 -1
  76. package/dist/table/src/types/table.d.ts +25 -0
  77. package/dist/table/src/types/table.d.ts.map +1 -1
  78. package/dist/table/src/utils/compat.d.ts +9 -0
  79. package/dist/table/src/utils/compat.d.ts.map +1 -0
  80. package/dist/table/src/utils/compat.mjs +28 -0
  81. package/dist/theme/src/compat/antdv-table.d.ts +4 -0
  82. package/dist/theme/src/compat/antdv-table.d.ts.map +1 -0
  83. package/dist/theme/src/compat/antdv-table.mjs +51 -0
  84. package/dist/theme/src/index.d.ts +2 -0
  85. package/dist/theme/src/index.d.ts.map +1 -1
  86. package/dist/theme/src/presets/antdv/table.d.ts +3 -0
  87. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  88. package/dist/theme/src/presets/antdv/table.mjs +4 -1
  89. package/package.json +1 -1
  90. package/dist/core/src/components/VirtualList/hooks/useDiffItem.d.ts +0 -4
  91. package/dist/core/src/components/VirtualList/hooks/useDiffItem.d.ts.map +0 -1
  92. package/dist/core/src/components/VirtualList/hooks/useDiffItem.mjs +0 -16
  93. package/dist/core/src/components/VirtualList/utils/algorithmUtil.d.ts +0 -7
  94. package/dist/core/src/components/VirtualList/utils/algorithmUtil.d.ts.map +0 -1
  95. package/dist/core/src/components/VirtualList/utils/algorithmUtil.mjs +0 -22
@@ -1 +1 @@
1
- {"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableBody.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AAOtE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;;;cAkBd,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;;;;cACtC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;cAO3C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;;cAR9D,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;;;;cACtC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;cAO3C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;+BAAjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG;;AAX7F,wBAwJE"}
1
+ {"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableBody.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AAOtE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;;;cAmBd,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;;;;cACtC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;cAO3C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;;cAR9D,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;;;;cACtC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;cAO3C,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;+BAAjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG;;AAX7F,wBAiKE"}
@@ -1,16 +1,17 @@
1
- import { defineComponent as g, inject as x, computed as h, createVNode as u } from "vue";
1
+ import { defineComponent as b, inject as x, computed as h, createVNode as m } from "vue";
2
2
  import "../../../core/src/utils/tv.mjs";
3
3
  import E from "./TableRow.mjs";
4
4
  import T from "./TableCell.mjs";
5
5
  import v from "./TableEmpty.mjs";
6
6
  import { TABLE_CONTEXT_KEY as k } from "../context.mjs";
7
7
  import { resolveBodyCell as K } from "../utils/cell.mjs";
8
- import { getByDataIndex as N } from "../composables/useColumns.mjs";
8
+ import { getRowCompatClass as N } from "../utils/compat.mjs";
9
+ import { getByDataIndex as q } from "../composables/useColumns.mjs";
9
10
  import { cn as p } from "tailwind-variants";
10
11
  function R(e) {
11
12
  return Number.isFinite(e) ? e <= 0 ? 0 : Math.floor(e) : 1;
12
13
  }
13
- const j = /* @__PURE__ */ g({
14
+ const L = /* @__PURE__ */ b({
14
15
  name: "TableBody",
15
16
  props: {
16
17
  dataSource: {
@@ -48,71 +49,71 @@ const j = /* @__PURE__ */ g({
48
49
  },
49
50
  setup(e) {
50
51
  const l = x(k, {});
51
- function S(t, n) {
52
- return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : n;
52
+ function g(t, a) {
53
+ return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : a;
53
54
  }
54
- const b = h(() => {
55
+ const S = h(() => {
55
56
  const t = /* @__PURE__ */ new Set();
56
- return e.dataSource.map((n, o) => {
57
+ return e.dataSource.map((a, o) => {
57
58
  const s = [];
58
- return e.columns.forEach((m, r) => {
59
+ return e.columns.forEach((C, r) => {
59
60
  const c = `${o}:${r}`;
60
61
  if (t.has(c)) return;
61
62
  const y = K({
62
- text: N(n, m.dataIndex),
63
- record: n,
63
+ text: q(a, C.dataIndex),
64
+ record: a,
64
65
  rowIndex: o,
65
- column: m,
66
+ column: C,
66
67
  bodyCell: l.bodyCell,
67
68
  transformCellText: l.transformCellText
68
- }), C = R(y.colSpan), d = R(y.rowSpan);
69
- if (C === 0 || d === 0) return;
70
- const f = Math.min(e.dataSource.length, o + d), w = Math.min(e.columns.length, r + C);
71
- for (let i = o; i < f; i += 1)
72
- for (let a = r; a < w; a += 1)
73
- i === o && a === r || t.add(`${i}:${a}`);
69
+ }), i = R(y.colSpan), d = R(y.rowSpan);
70
+ if (i === 0 || d === 0) return;
71
+ const f = Math.min(e.dataSource.length, o + d), w = Math.min(e.columns.length, r + i);
72
+ for (let u = o; u < f; u += 1)
73
+ for (let n = r; n < w; n += 1)
74
+ u === o && n === r || t.add(`${u}:${n}`);
74
75
  s.push({
75
- column: m,
76
+ column: C,
76
77
  colIndex: r,
77
78
  resolvedCell: {
78
79
  ...y,
79
- colSpan: C,
80
+ colSpan: i,
80
81
  rowSpan: d
81
82
  }
82
83
  });
83
84
  }), s;
84
85
  });
85
86
  });
86
- return () => u("tbody", {
87
+ return () => m("tbody", {
87
88
  class: e.tbodyClass
88
- }, [e.dataSource.length > 0 ? e.dataSource.map((t, n) => {
89
- const o = S(t, n), s = l.expandable?.(), m = l.isExpanded?.(o) ?? !1, r = s?.expandRowByClick ?? !1, c = l.isRowExpandable?.(t) ?? !1, C = l.treeFlattenData?.value?.find((a) => a.record === t)?.level ?? 0, d = l.getRowClassName?.(t, n), f = l.getRowProps?.(t, n), w = typeof s?.expandedRowClassName == "function" ? s.expandedRowClassName(t, n, C) : s?.expandedRowClassName, i = r ? () => {
90
- c && l.toggleExpand?.(t, n);
89
+ }, [e.dataSource.length > 0 ? e.dataSource.map((t, a) => {
90
+ const o = g(t, a), s = l.expandable?.(), C = l.isExpanded?.(o) ?? !1, r = s?.expandRowByClick ?? !1, c = l.isRowExpandable?.(t) ?? !1, i = (l.isTreeData?.value ? l.getFlattenRow?.(t) : void 0)?.level ?? 0, d = l.getRowClassName?.(t, a), f = l.getRowProps?.(t, a), w = typeof s?.expandedRowClassName == "function" ? s.expandedRowClassName(t, a, i) : s?.expandedRowClassName, u = r ? () => {
91
+ c && l.toggleExpand?.(t, a);
91
92
  } : void 0;
92
- return [u(E, {
93
+ return [m(E, {
93
94
  key: o,
94
- rowClass: p(e.rowClass, d) ?? "",
95
+ rowClass: p(e.rowClass, d, N(l, t, a, i)) ?? "",
95
96
  rowProps: f,
96
- onClick: i
97
+ onClick: u
97
98
  }, {
98
- default: () => [b.value[n]?.map((a) => u(T, {
99
- key: a.column.key ?? String(a.column.dataIndex ?? a.colIndex),
99
+ default: () => [S.value[a]?.map((n) => m(T, {
100
+ key: n.column.key ?? String(n.column.dataIndex ?? n.colIndex),
100
101
  record: t,
101
- rowIndex: n,
102
- column: a.column,
103
- colIndex: a.colIndex,
104
- resolvedCell: a.resolvedCell,
102
+ rowIndex: a,
103
+ column: n.column,
104
+ colIndex: n.colIndex,
105
+ resolvedCell: n.resolvedCell,
105
106
  tdClass: e.tdClass,
106
107
  bodyCellEllipsisClass: e.bodyCellEllipsisClass
107
108
  }, null))]
108
- }), m && s?.expandedRowRender && u("tr", {
109
+ }), C && s?.expandedRowRender && m("tr", {
109
110
  key: `${o}-expanded`,
110
111
  class: p(e.rowClass, d, l.subThemeSlots?.expandedRow(), w)
111
- }, [u("td", {
112
+ }, [m("td", {
112
113
  colspan: e.columns.length,
113
114
  class: p(e.tdClass, l.subThemeSlots?.expandedRowCell())
114
- }, [s.expandedRowRender(t, n, 0, !0)])])];
115
- }) : u(v, {
115
+ }, [s.expandedRowRender(t, a, 0, !0)])])];
116
+ }) : m(v, {
116
117
  colSpan: e.columns.length || 1,
117
118
  emptyClass: e.emptyClass,
118
119
  tdClass: e.tdClass
@@ -120,5 +121,5 @@ const j = /* @__PURE__ */ g({
120
121
  }
121
122
  });
122
123
  export {
123
- j as default
124
+ L as default
124
125
  };
@@ -30,6 +30,17 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
30
30
  type: StringConstructor;
31
31
  required: true;
32
32
  };
33
+ /**
34
+ * 实测列宽(px),仅横向虚拟化时传入。
35
+ *
36
+ * 必要而非优化:窗口化之后表体的这一行不再包含全部列,若某列没有声明宽度,
37
+ * 浏览器会按窗口后的结构重新分配余量,与始终渲染全部列的表头对不上。
38
+ * 把从表头量到的宽度显式写回来,表体布局才被钉死。
39
+ */
40
+ widthOverride: {
41
+ type: NumberConstructor;
42
+ default: undefined;
43
+ };
33
44
  }>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
34
45
  record: {
35
46
  type: PropType<Record<string, unknown>>;
@@ -59,8 +70,20 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
59
70
  type: StringConstructor;
60
71
  required: true;
61
72
  };
73
+ /**
74
+ * 实测列宽(px),仅横向虚拟化时传入。
75
+ *
76
+ * 必要而非优化:窗口化之后表体的这一行不再包含全部列,若某列没有声明宽度,
77
+ * 浏览器会按窗口后的结构重新分配余量,与始终渲染全部列的表头对不上。
78
+ * 把从表头量到的宽度显式写回来,表体布局才被钉死。
79
+ */
80
+ widthOverride: {
81
+ type: NumberConstructor;
82
+ default: undefined;
83
+ };
62
84
  }>> & Readonly<{}>, {
63
85
  resolvedCell: ResolvedBodyCell;
86
+ widthOverride: number;
64
87
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
65
88
  export default _default;
66
89
  //# sourceMappingURL=TableCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,QAAQ,EAAmB,MAAM,KAAK,CAAA;AAG5F,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,UAAU,CAAA;AAK/D,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAA;;;cAQQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;cAEjC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;cAGrD,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;cALlB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;cAEjC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;cAGrD,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;;AARhD,wBAsZE"}
1
+ {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,QAAQ,EAAmB,MAAM,KAAK,CAAA;AAG5F,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,UAAU,CAAA;AAK/D,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAA;;;cAQQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;cAEjC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;cAGrD,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;IAK5C;;;;;;OAMG;;;;;;;cAhBuB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;cAEjC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;cAGrD,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;IAK5C;;;;;;OAMG;;;;;;;;;AAnBP,wBA0aE"}
@@ -1,17 +1,17 @@
1
- import { defineComponent as J, inject as Q, ref as B, computed as c, createVNode as r, mergeProps as L } from "vue";
1
+ import { defineComponent as U, inject as Z, ref as q, computed as c, createVNode as r, mergeProps as B } from "vue";
2
2
  import "../../../core/src/utils/tv.mjs";
3
- import U from "../../../core/src/components/Tooltip.mjs";
4
- import { TABLE_CONTEXT_KEY as Z } from "../context.mjs";
5
- import { getByDataIndex as ee, getColumnKey as O } from "../composables/useColumns.mjs";
6
- import { useFixedColumnStyle as le } from "../composables/useFixedColumnStyle.mjs";
7
- import { resolveBodyCell as ne, omitCellProps as P, isRenderedCell as te, getEllipsisConfig as oe } from "../utils/cell.mjs";
8
- import ae from "./SelectionCheckbox.mjs";
9
- import se from "./SelectionRadio.mjs";
10
- import N from "./ExpandIcon.mjs";
11
- import { isInHoverRange as re } from "../composables/useHoverState.mjs";
12
- import { TABLE_ALIGN_CLASSES as ce } from "../../../theme/src/presets/antdv/table.mjs";
3
+ import ee from "../../../core/src/components/Tooltip.mjs";
4
+ import { TABLE_CONTEXT_KEY as le } from "../context.mjs";
5
+ import { getByDataIndex as ne, getColumnKey as L } from "../composables/useColumns.mjs";
6
+ import { useFixedColumnStyle as te } from "../composables/useFixedColumnStyle.mjs";
7
+ import { resolveBodyCell as oe, getEllipsisConfig as D, omitCellProps as N, isRenderedCell as ae } from "../utils/cell.mjs";
8
+ import se from "./SelectionCheckbox.mjs";
9
+ import re from "./SelectionRadio.mjs";
10
+ import P from "./ExpandIcon.mjs";
11
+ import { isInHoverRange as ce } from "../composables/useHoverState.mjs";
12
+ import { TABLE_ALIGN_CLASSES as de } from "../../../theme/src/presets/antdv/table.mjs";
13
13
  import { cn as m } from "tailwind-variants";
14
- const Ie = /* @__PURE__ */ J({
14
+ const Te = /* @__PURE__ */ U({
15
15
  name: "TableCell",
16
16
  props: {
17
17
  record: {
@@ -41,30 +41,41 @@ const Ie = /* @__PURE__ */ J({
41
41
  bodyCellEllipsisClass: {
42
42
  type: String,
43
43
  required: !0
44
+ },
45
+ /**
46
+ * 实测列宽(px),仅横向虚拟化时传入。
47
+ *
48
+ * 必要而非优化:窗口化之后表体的这一行不再包含全部列,若某列没有声明宽度,
49
+ * 浏览器会按窗口后的结构重新分配余量,与始终渲染全部列的表头对不上。
50
+ * 把从表头量到的宽度显式写回来,表体布局才被钉死。
51
+ */
52
+ widthOverride: {
53
+ type: Number,
54
+ default: void 0
44
55
  }
45
56
  },
46
57
  setup(e) {
47
- const l = Q(Z, {}), H = B(null), I = B(!1), o = c(() => e.resolvedCell ?? ne({
48
- text: ee(e.record, e.column.dataIndex),
58
+ const l = Z(le, {}), H = q(null), I = q(!1), o = c(() => e.resolvedCell ?? oe({
59
+ text: ne(e.record, e.column.dataIndex),
49
60
  record: e.record,
50
61
  rowIndex: e.rowIndex,
51
62
  column: e.column,
52
63
  bodyCell: l.bodyCell,
53
64
  transformCellText: l.transformCellText
54
- })), D = c(() => {
65
+ })), j = c(() => {
55
66
  if (!e.column.fixed) return null;
56
- const n = O(e.column) ?? e.colIndex;
67
+ const n = L(e.column) ?? e.colIndex;
57
68
  return l.fixedOffsets?.value?.get(n) ?? null;
58
69
  }), {
59
- fixedStyle: W,
70
+ fixedStyle: A,
60
71
  fixedClass: T
61
- } = le({
62
- fixedInfo: () => D.value
63
- }), i = c(() => l.getSelectionState?.(e.record, e.rowIndex) ?? {
72
+ } = te({
73
+ fixedInfo: () => j.value
74
+ }), W = c(() => D(e.column).enabled ? l.compatClass?.("cell-ellipsis") ?? "" : ""), i = c(() => l.getSelectionState?.(e.record, e.rowIndex) ?? {
64
75
  checked: !1,
65
76
  indeterminate: !1,
66
77
  disabled: !1
67
- }), f = c(() => i.value.checked), _ = c(() => re(e.rowIndex, o.value.rowSpan ?? 1, l.hoverRange?.value ?? null));
78
+ }), f = c(() => i.value.checked), _ = c(() => ce(e.rowIndex, o.value.rowSpan ?? 1, l.hoverRange?.value ?? null));
68
79
  function S() {
69
80
  if (!l.hoverable?.value) return;
70
81
  const n = Math.max(1, o.value.rowSpan ?? 1);
@@ -73,46 +84,60 @@ const Ie = /* @__PURE__ */ J({
73
84
  function h() {
74
85
  l.hoverable?.value && l.clearHoverRange?.();
75
86
  }
76
- function j(n) {
87
+ function K(n) {
77
88
  return (t) => {
78
89
  S(), typeof n == "function" && n(t);
79
90
  };
80
91
  }
81
- function A(n) {
92
+ function z(n) {
82
93
  return (t) => {
83
94
  h(), typeof n == "function" && n(t);
84
95
  };
85
96
  }
86
97
  const E = c(() => ({
87
- ...P(o.value.renderCellProps),
88
- ...P(o.value.customCellProps)
89
- })), z = c(() => {
90
- const n = e.column.align ? ce[e.column.align] : "", t = l.subThemeSlots, a = _.value && l.hoverable?.value, x = l.isColumnSorted?.(e.column) && t ? t.tdSorted() : "", R = f.value && t ? m(t.tdSelected(), a ? t.tdRowSelectedHover() : "") : "", k = a && t && !f.value ? t.tdRowHover() : "";
91
- return m(e.tdClass, n, e.column.className, o.value.customCellProps?.class, o.value.customCellProps?.className, o.value.renderCellProps?.class, o.value.renderCellProps?.className, x, R, k, T.value);
98
+ ...N(o.value.renderCellProps),
99
+ ...N(o.value.customCellProps)
100
+ })), F = c(() => {
101
+ const n = e.column.align ? de[e.column.align] : "", t = l.subThemeSlots, a = _.value && l.hoverable?.value, C = l.isColumnSorted?.(e.column) && t ? t.tdSorted() : "", R = f.value && t ? m(t.tdSelected(), a ? t.tdRowSelectedHover() : "") : "", p = a && t && !f.value ? t.tdRowHover() : "";
102
+ return m(
103
+ e.tdClass,
104
+ n,
105
+ e.column.className,
106
+ o.value.customCellProps?.class,
107
+ o.value.customCellProps?.className,
108
+ o.value.renderCellProps?.class,
109
+ o.value.renderCellProps?.className,
110
+ C,
111
+ R,
112
+ p,
113
+ T.value,
114
+ // antdv 把 ellipsis 类放在 td 上,我们的 slot 落在内层 span,故在此补
115
+ W.value
116
+ );
92
117
  }), w = c(() => {
93
- const n = {}, a = l.columnWidths?.[String(O(e.column) ?? e.colIndex)] ?? e.column.width;
118
+ const n = {}, t = l.columnWidths?.[String(L(e.column) ?? e.colIndex)], a = e.widthOverride ?? t ?? e.column.width;
94
119
  return a && (n.width = typeof a == "number" ? `${a}px` : a), {
95
120
  ...n,
96
- ...W.value ?? {},
121
+ ...A.value ?? {},
97
122
  ...o.value.customCellProps?.style ?? {},
98
123
  ...o.value.renderCellProps?.style ?? {}
99
124
  };
100
- }), K = c(() => l.isTreeData?.value ? l.getFlattenRow?.(e.record) ?? null : null), F = c(() => l.isTreeData?.value && e.column.key !== "__vtg_selection__" && e.column.key !== "__vtg_expand__" && e.colIndex <= 2 ? (() => {
125
+ }), $ = c(() => l.isTreeData?.value ? l.getFlattenRow?.(e.record) ?? null : null), G = c(() => l.isTreeData?.value && e.column.key !== "__vtg_selection__" && e.column.key !== "__vtg_expand__" && e.colIndex <= 2 ? (() => {
101
126
  const n = l.rowSelection?.(), t = l.expandable?.();
102
127
  let a = 0;
103
128
  return n && (a += 1), t && t.showExpandColumn !== !1 && (a += 1), e.colIndex === a;
104
129
  })() : !1);
105
- function $(n) {
130
+ function V(n) {
106
131
  return {
107
132
  ...w.value,
108
133
  ...n ?? {}
109
134
  };
110
135
  }
111
- function G() {
136
+ function X() {
112
137
  const n = H.value, t = o.value.tooltipText;
113
138
  I.value = !!(n && t && (n.scrollWidth > n.clientWidth || n.scrollHeight > n.clientHeight));
114
139
  }
115
- function V() {
140
+ function Y() {
116
141
  I.value = !1;
117
142
  }
118
143
  return () => {
@@ -120,25 +145,25 @@ const Ie = /* @__PURE__ */ J({
120
145
  return null;
121
146
  const n = o.value.colSpan !== 1 ? o.value.colSpan : void 0, t = o.value.rowSpan !== 1 ? o.value.rowSpan : void 0;
122
147
  if (e.column.key === "__vtg_selection__") {
123
- const v = l.rowSelection?.(), C = v?.type === "radio" ? r(se, {
148
+ const v = l.rowSelection?.(), x = v?.type === "radio" ? r(re, {
124
149
  checked: i.value.checked,
125
150
  disabled: i.value.disabled,
126
151
  onChange: (d) => l.toggleRow?.(e.record, e.rowIndex, d)
127
- }, null) : r(ae, {
152
+ }, null) : r(se, {
128
153
  checked: i.value.checked,
129
154
  indeterminate: i.value.indeterminate,
130
155
  disabled: i.value.disabled,
131
156
  onChange: (d, y) => l.toggleRow?.(e.record, e.rowIndex, y)
132
157
  }, null);
133
- let u = C, s;
158
+ let u = x, s;
134
159
  if (v?.renderCell) {
135
- const d = v.renderCell(i.value.checked, e.record, e.rowIndex, C);
136
- te(d) ? (u = d.children, s = d.props) : u = d;
160
+ const d = v.renderCell(i.value.checked, e.record, e.rowIndex, x);
161
+ ae(d) ? (u = d.children, s = d.props) : u = d;
137
162
  }
138
- const g = !!v?.renderCell, b = _.value && l.hoverable?.value, M = m(e.tdClass, l.vtgClass?.(g ? "text-center" : "text-center leading-[0]"), e.column.className, s?.class, s?.className, f.value && l.subThemeSlots ? m(l.subThemeSlots.tdSelected(), b ? l.subThemeSlots.tdRowSelectedHover() : "") : b && l.subThemeSlots ? l.subThemeSlots.tdRowHover() : "", T.value);
139
- return r("td", L(P(s), {
163
+ const b = !!v?.renderCell, g = _.value && l.hoverable?.value, M = m(e.tdClass, l.vtgClass?.(b ? "text-center" : "text-center leading-[0]"), e.column.className, s?.class, s?.className, f.value && l.subThemeSlots ? m(l.subThemeSlots.tdSelected(), g ? l.subThemeSlots.tdRowSelectedHover() : "") : g && l.subThemeSlots ? l.subThemeSlots.tdRowHover() : "", T.value, l.compatClass?.("selection-column"));
164
+ return r("td", B(N(s), {
140
165
  class: M,
141
- style: $(s?.style),
166
+ style: V(s?.style),
142
167
  colspan: n,
143
168
  rowspan: t,
144
169
  onMouseenter: S,
@@ -146,7 +171,7 @@ const Ie = /* @__PURE__ */ J({
146
171
  }), [u]);
147
172
  }
148
173
  if (e.column.key === "__vtg_expand__") {
149
- const v = l.expandable?.(), p = l.getRowKey?.(e.record, e.rowIndex), C = p !== void 0 && (l.isExpanded?.(p) ?? !1), u = l.isRowExpandable?.(e.record) ?? !1, s = l.subThemeSlots, g = _.value && l.hoverable?.value, b = l.isColumnSorted?.(e.column) && s ? s.tdSorted() : "", M = f.value && s ? m(s.tdSelected(), g ? s.tdRowSelectedHover() : "") : "", d = g && s && !f.value ? s.tdRowHover() : "", y = m(e.tdClass, l.vtgClass?.("text-center"), e.column.className, b, M, d, T.value);
174
+ const v = l.expandable?.(), k = l.getRowKey?.(e.record, e.rowIndex), x = k !== void 0 && (l.isExpanded?.(k) ?? !1), u = l.isRowExpandable?.(e.record) ?? !1, s = l.subThemeSlots, b = _.value && l.hoverable?.value, g = l.isColumnSorted?.(e.column) && s ? s.tdSorted() : "", M = f.value && s ? m(s.tdSelected(), b ? s.tdRowSelectedHover() : "") : "", d = b && s && !f.value ? s.tdRowHover() : "", y = m(e.tdClass, l.vtgClass?.("text-center"), e.column.className, g, M, d, T.value, l.compatClass?.("row-expand-icon-cell"));
150
175
  return v?.expandIcon ? r("td", {
151
176
  class: y,
152
177
  style: w.value,
@@ -155,11 +180,11 @@ const Ie = /* @__PURE__ */ J({
155
180
  onMouseenter: S,
156
181
  onMouseleave: h
157
182
  }, [v.expandIcon({
158
- expanded: C,
183
+ expanded: x,
159
184
  record: e.record,
160
185
  expandable: u,
161
- onExpand: (de, Y) => {
162
- Y.stopPropagation(), u && l.toggleExpand?.(e.record, e.rowIndex);
186
+ onExpand: (ue, Q) => {
187
+ Q.stopPropagation(), u && l.toggleExpand?.(e.record, e.rowIndex);
163
188
  }
164
189
  })]) : r("td", {
165
190
  class: y,
@@ -168,8 +193,8 @@ const Ie = /* @__PURE__ */ J({
168
193
  rowspan: t,
169
194
  onMouseenter: S,
170
195
  onMouseleave: h
171
- }, [r(N, {
172
- expanded: C,
196
+ }, [r(P, {
197
+ expanded: x,
173
198
  expandable: u,
174
199
  variant: "row",
175
200
  onClick: () => {
@@ -177,21 +202,21 @@ const Ie = /* @__PURE__ */ J({
177
202
  }
178
203
  }, null)]);
179
204
  }
180
- const a = K.value, x = F.value && a, R = x ? r("span", {
205
+ const a = $.value, C = G.value && a, R = C ? r("span", {
181
206
  style: {
182
207
  display: "inline-block",
183
208
  width: `${a.level * (l.treeIndentSize?.value ?? 15)}px`
184
209
  }
185
- }, null) : null, k = x && a.hasChildren ? r(N, {
210
+ }, null) : null, p = C && a.hasChildren ? r(P, {
186
211
  expanded: a.expanded,
187
212
  expandable: !0,
188
213
  variant: "tree",
189
214
  onClick: () => l.toggleTreeExpand?.(e.record, e.rowIndex)
190
- }, null) : x ? r(N, {
215
+ }, null) : C ? r(P, {
191
216
  expanded: !1,
192
217
  expandable: !1,
193
218
  variant: "tree"
194
- }, null) : null, q = oe(e.column), X = q.enabled ? q.showTitle ? r(U, {
219
+ }, null) : null, O = D(e.column), J = O.enabled ? O.showTitle ? r(ee, {
195
220
  block: !0,
196
221
  title: o.value.tooltipText,
197
222
  placement: "top",
@@ -200,23 +225,23 @@ const Ie = /* @__PURE__ */ J({
200
225
  default: () => [r("div", {
201
226
  ref: H,
202
227
  class: e.bodyCellEllipsisClass,
203
- onMouseenter: G,
204
- onMouseleave: V
228
+ onMouseenter: X,
229
+ onMouseleave: Y
205
230
  }, [o.value.content])]
206
231
  }) : r("div", {
207
232
  class: e.bodyCellEllipsisClass
208
233
  }, [o.value.content]) : o.value.content;
209
- return r("td", L(E.value, {
210
- class: z.value,
234
+ return r("td", B(E.value, {
235
+ class: F.value,
211
236
  style: w.value,
212
237
  colspan: n,
213
238
  rowspan: t,
214
- onMouseenter: j(E.value.onMouseenter),
215
- onMouseleave: A(E.value.onMouseleave)
216
- }), [R, k, X]);
239
+ onMouseenter: K(E.value.onMouseenter),
240
+ onMouseleave: z(E.value.onMouseleave)
241
+ }), [R, p, J]);
217
242
  };
218
243
  }
219
244
  });
220
245
  export {
221
- Ie as default
246
+ Te as default
222
247
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TableHeaderCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableHeaderCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACd,MAAM,KAAK,CAAA;AAOZ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;;;cAuBzC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;cAAjD,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;AAJvE,wBA2tBE"}
1
+ {"version":3,"file":"TableHeaderCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableHeaderCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACd,MAAM,KAAK,CAAA;AAOZ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;;;cAuBzC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;cAAjD,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;AAJvE,wBA4uBE"}