@vtable-guild/vtable-guild 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/css/presets/antdv.css +36 -0
  2. package/css/presets/element-plus.css +38 -0
  3. package/css/style.css +436 -0
  4. package/css/tailwind3-utilities.css +337 -0
  5. package/css/tailwind3.css +99 -0
  6. package/css/tailwind4.css +99 -0
  7. package/css/transitions.css +25 -0
  8. package/dist/core/src/components/VirtualList/VirtualList.d.ts +3 -0
  9. package/dist/core/src/components/VirtualList/VirtualList.d.ts.map +1 -1
  10. package/dist/core/src/components/VirtualList/VirtualList.mjs +28 -27
  11. package/dist/core/src/components/VirtualList/VirtualScrollBar.d.ts +1 -1
  12. package/dist/core/src/index.d.ts +1 -1
  13. package/dist/core/src/index.d.ts.map +1 -1
  14. package/dist/core/src/utils/types.d.ts +18 -0
  15. package/dist/core/src/utils/types.d.ts.map +1 -1
  16. package/dist/css/presets/antdv.css +36 -0
  17. package/dist/css/presets/element-plus.css +38 -0
  18. package/dist/css/style.css +436 -0
  19. package/dist/css/tailwind3-utilities.css +337 -0
  20. package/dist/css/tailwind3.css +99 -0
  21. package/dist/css/tailwind4.css +99 -0
  22. package/dist/css/transitions.css +25 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.full.mjs +5218 -3869
  25. package/dist/index.mjs +85 -75
  26. package/dist/table/src/components/ColGroup.d.ts.map +1 -1
  27. package/dist/table/src/components/ColGroup.mjs +10 -10
  28. package/dist/table/src/components/ColumnWidthRow.d.ts +4 -0
  29. package/dist/table/src/components/ColumnWidthRow.d.ts.map +1 -0
  30. package/dist/table/src/components/ColumnWidthRow.mjs +23 -0
  31. package/dist/table/src/components/PaginationSizeSelect.d.ts +57 -0
  32. package/dist/table/src/components/PaginationSizeSelect.d.ts.map +1 -0
  33. package/dist/table/src/components/PaginationSizeSelect.mjs +138 -0
  34. package/dist/table/src/components/SelectionDropdown.d.ts +9 -0
  35. package/dist/table/src/components/SelectionDropdown.d.ts.map +1 -1
  36. package/dist/table/src/components/SelectionDropdown.mjs +32 -26
  37. package/dist/table/src/components/Table.d.ts +13 -2
  38. package/dist/table/src/components/Table.d.ts.map +1 -1
  39. package/dist/table/src/components/Table.mjs +497 -403
  40. package/dist/table/src/components/TableCell.d.ts.map +1 -1
  41. package/dist/table/src/components/TableCell.mjs +80 -74
  42. package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
  43. package/dist/table/src/components/TableHeaderCell.mjs +85 -83
  44. package/dist/table/src/components/TablePagination.d.ts +74 -0
  45. package/dist/table/src/components/TablePagination.d.ts.map +1 -0
  46. package/dist/table/src/components/TablePagination.mjs +350 -0
  47. package/dist/table/src/components/TablePagination.test.d.ts +2 -0
  48. package/dist/table/src/components/TablePagination.test.d.ts.map +1 -0
  49. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts +2 -0
  50. package/dist/table/src/components/TablePaginationCompatClass.test.d.ts.map +1 -0
  51. package/dist/table/src/components/TablePaginationLayout.test.d.ts +2 -0
  52. package/dist/table/src/components/TablePaginationLayout.test.d.ts.map +1 -0
  53. package/dist/table/src/components/VTable.vue.d.ts.map +1 -1
  54. package/dist/table/src/components/VTable.vue.mjs +34 -26
  55. package/dist/table/src/components/VTableMinWidth.test.d.ts +2 -0
  56. package/dist/table/src/components/VTableMinWidth.test.d.ts.map +1 -0
  57. package/dist/table/src/components/VTableSummaryCell.d.ts.map +1 -1
  58. package/dist/table/src/components/VTableSummaryCell.mjs +26 -24
  59. package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
  60. package/dist/table/src/components/VirtualTableBody.mjs +143 -134
  61. package/dist/table/src/composables/useColumnLayout.d.ts +28 -0
  62. package/dist/table/src/composables/useColumnLayout.d.ts.map +1 -0
  63. package/dist/table/src/composables/useColumnLayout.mjs +259 -0
  64. package/dist/table/src/composables/useColumnLayout.test.d.ts +2 -0
  65. package/dist/table/src/composables/useColumnLayout.test.d.ts.map +1 -0
  66. package/dist/table/src/composables/useColumnMetrics.d.ts +5 -3
  67. package/dist/table/src/composables/useColumnMetrics.d.ts.map +1 -1
  68. package/dist/table/src/composables/useColumnMetrics.mjs +64 -55
  69. package/dist/table/src/composables/useExpand.d.ts +2 -0
  70. package/dist/table/src/composables/useExpand.d.ts.map +1 -1
  71. package/dist/table/src/composables/useExpand.mjs +44 -20
  72. package/dist/table/src/composables/usePagination.d.ts +15 -0
  73. package/dist/table/src/composables/usePagination.d.ts.map +1 -0
  74. package/dist/table/src/composables/usePagination.mjs +65 -0
  75. package/dist/table/src/composables/usePagination.test.d.ts +2 -0
  76. package/dist/table/src/composables/usePagination.test.d.ts.map +1 -0
  77. package/dist/table/src/composables/useResize.d.ts +1 -0
  78. package/dist/table/src/composables/useResize.d.ts.map +1 -1
  79. package/dist/table/src/composables/useResize.mjs +67 -39
  80. package/dist/table/src/composables/useScroll.d.ts +3 -0
  81. package/dist/table/src/composables/useScroll.d.ts.map +1 -1
  82. package/dist/table/src/composables/useScroll.mjs +43 -41
  83. package/dist/table/src/composables/useSelection.d.ts +2 -1
  84. package/dist/table/src/composables/useSelection.d.ts.map +1 -1
  85. package/dist/table/src/composables/useSelection.mjs +210 -171
  86. package/dist/table/src/composables/useTreeData.d.ts +4 -0
  87. package/dist/table/src/composables/useTreeData.d.ts.map +1 -1
  88. package/dist/table/src/composables/useTreeData.mjs +48 -43
  89. package/dist/table/src/context.d.ts +6 -1
  90. package/dist/table/src/context.d.ts.map +1 -1
  91. package/dist/table/src/index.d.ts +3 -1
  92. package/dist/table/src/index.d.ts.map +1 -1
  93. package/dist/table/src/types/column.d.ts +8 -2
  94. package/dist/table/src/types/column.d.ts.map +1 -1
  95. package/dist/table/src/types/index.d.ts +1 -0
  96. package/dist/table/src/types/index.d.ts.map +1 -1
  97. package/dist/table/src/types/pagination.d.ts +66 -0
  98. package/dist/table/src/types/pagination.d.ts.map +1 -0
  99. package/dist/table/src/types/pagination.typecheck.d.ts +25 -0
  100. package/dist/table/src/types/pagination.typecheck.d.ts.map +1 -0
  101. package/dist/table/src/types/table.d.ts +8 -1
  102. package/dist/table/src/types/table.d.ts.map +1 -1
  103. package/dist/table/src/utils/columnWidth.d.ts +60 -0
  104. package/dist/table/src/utils/columnWidth.d.ts.map +1 -0
  105. package/dist/table/src/utils/columnWidth.mjs +96 -0
  106. package/dist/table/src/utils/columnWidth.test.d.ts +2 -0
  107. package/dist/table/src/utils/columnWidth.test.d.ts.map +1 -0
  108. package/dist/table/src/utils/paginationLayout.d.ts +13 -0
  109. package/dist/table/src/utils/paginationLayout.d.ts.map +1 -0
  110. package/dist/table/src/utils/paginationLayout.mjs +55 -0
  111. package/dist/table/src/utils/paginationLayout.test.d.ts +2 -0
  112. package/dist/table/src/utils/paginationLayout.test.d.ts.map +1 -0
  113. package/dist/table/src/utils/popupPosition.d.ts +4 -1
  114. package/dist/table/src/utils/popupPosition.d.ts.map +1 -1
  115. package/dist/table/src/utils/popupPosition.mjs +34 -15
  116. package/dist/theme/src/augment.d.ts +2 -0
  117. package/dist/theme/src/augment.d.ts.map +1 -1
  118. package/dist/theme/src/compat/antdv-pagination.d.ts +4 -0
  119. package/dist/theme/src/compat/antdv-pagination.d.ts.map +1 -0
  120. package/dist/theme/src/compat/antdv-pagination.mjs +29 -0
  121. package/dist/theme/src/index.d.ts +5 -0
  122. package/dist/theme/src/index.d.ts.map +1 -1
  123. package/dist/theme/src/pagination.d.ts +153 -0
  124. package/dist/theme/src/pagination.d.ts.map +1 -0
  125. package/dist/theme/src/pagination.mjs +144 -0
  126. package/dist/theme/src/presets/antdv/table-locale.d.ts +2 -2
  127. package/dist/theme/src/presets/antdv/table-locale.mjs +2 -2
  128. package/dist/theme/src/presets/antdv/table.d.ts +3 -0
  129. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  130. package/dist/theme/src/presets/antdv/table.mjs +3 -0
  131. package/dist/theme/src/presets/element-plus/table-locale.d.ts +2 -2
  132. package/dist/theme/src/presets/element-plus/table-locale.mjs +2 -2
  133. package/dist/theme/src/presets/element-plus/table.d.ts +3 -0
  134. package/dist/theme/src/presets/element-plus/table.d.ts.map +1 -1
  135. package/dist/theme/src/presets/element-plus/table.mjs +3 -0
  136. package/dist/theme/src/presets/index.d.ts.map +1 -1
  137. package/dist/theme/src/presets/index.mjs +60 -57
  138. package/dist/theme/src/presets/types.d.ts +1 -0
  139. package/dist/theme/src/presets/types.d.ts.map +1 -1
  140. package/package.json +1 -1
@@ -1,21 +1,23 @@
1
- import { defineComponent as G, inject as U, ref as C, computed as c, onBeforeUnmount as Y, watch as J, createVNode as a, isVNode as Q } from "vue";
1
+ import { defineComponent as U, inject as Y, ref as C, computed as w, onBeforeUnmount as J, watch as Q, createVNode as r, isVNode as Z } from "vue";
2
2
  import "../../../core/src/utils/tv.mjs";
3
- import Z from "./TableRow.mjs";
4
- import ee from "./TableCell.mjs";
5
- import te from "./TableEmpty.mjs";
6
- import le from "./ExpandedRowTr.mjs";
3
+ import ee from "./TableRow.mjs";
4
+ import te from "./TableCell.mjs";
5
+ import le from "./TableEmpty.mjs";
6
+ import oe from "./ExpandedRowTr.mjs";
7
7
  import ne from "./ColGroup.mjs";
8
- import { TABLE_CONTEXT_KEY as oe } from "../context.mjs";
9
- import { resolveFixedColumnRanges as re, useColumnWindow as ae } from "../composables/useColumnWindow.mjs";
10
- import { resolveRowDragClass as ie } from "../composables/useRowDragSort.mjs";
11
- import { getRowCompatClass as se } from "../utils/compat.mjs";
12
- import { resolveRowKey as V } from "../utils/rowKey.mjs";
13
- import de from "../../../core/src/components/VirtualList/VirtualList.mjs";
14
- import { cn as ue } from "tailwind-variants";
15
- function ce(t) {
16
- return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !Q(t);
8
+ import ae from "./ColumnWidthRow.mjs";
9
+ import { TABLE_CONTEXT_KEY as re } from "../context.mjs";
10
+ import { resolveFixedColumnRanges as ie, useColumnWindow as se } from "../composables/useColumnWindow.mjs";
11
+ import { resolveRowDragClass as de } from "../composables/useRowDragSort.mjs";
12
+ import { getRowCompatClass as ue } from "../utils/compat.mjs";
13
+ import { resolveRowKey as N } from "../utils/rowKey.mjs";
14
+ import { sumDeclaredColumnWidths as ce, parseStylePxWidth as fe } from "../utils/columnWidth.mjs";
15
+ import me from "../../../core/src/components/VirtualList/VirtualList.mjs";
16
+ import { cn as W } from "tailwind-variants";
17
+ function we(e) {
18
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !Z(e);
17
19
  }
18
- const Fe = /* @__PURE__ */ G({
20
+ const qe = /* @__PURE__ */ U({
19
21
  name: "VirtualTableBody",
20
22
  props: {
21
23
  dataSource: {
@@ -94,177 +96,184 @@ const Fe = /* @__PURE__ */ G({
94
96
  default: "hover"
95
97
  }
96
98
  },
97
- setup(t) {
98
- const r = U(oe, {}), m = C(), x = C(0), f = C(0);
99
- function b(e) {
100
- x.value = e.x, t.onVirtualScroll?.({
101
- ...e,
102
- maxX: m.value?.getHorizontalRange() ?? 0
99
+ setup(e, {
100
+ expose: F
101
+ }) {
102
+ const n = Y(re, {}), c = C();
103
+ F({
104
+ scrollToTop: () => c.value?.scrollTo({
105
+ top: 0
106
+ })
107
+ });
108
+ const x = C(0), f = C(0);
109
+ function b(t) {
110
+ x.value = t.x, e.onVirtualScroll?.({
111
+ ...t,
112
+ maxX: c.value?.getHorizontalRange() ?? 0
103
113
  });
104
114
  }
105
- function k(e, l) {
106
- return V(e, l, t.rowKey);
115
+ function V(t, l) {
116
+ return N(t, l, e.rowKey);
107
117
  }
108
- function q(e) {
109
- const l = t.dataSource.indexOf(e);
110
- return V(e, l, t.rowKey);
118
+ function k(t) {
119
+ const l = e.dataSource.indexOf(t);
120
+ return N(t, l, e.rowKey);
111
121
  }
112
- const O = c(() => {
113
- let e = 0;
114
- for (const l of t.columns) {
115
- const u = typeof l.width == "number" ? l.width : parseInt(String(l.width || "0"), 10);
116
- e += u || 0;
117
- }
118
- return e;
119
- }), W = c(() => {
120
- const e = t.virtualColumn ? t.columnMetrics?.total : void 0;
121
- return e && e > 0 ? e : O.value;
122
- }), v = c(() => re(t.columns)), S = c(() => {
123
- if (!t.virtualColumn || f.value <= 0) return null;
124
- const e = t.columnMetrics;
125
- return !e || e.widths.length !== t.columns.length ? null : e.widths;
122
+ const q = w(() => {
123
+ const t = e.columnMetrics?.total;
124
+ if (t && t > 0) return t;
125
+ const l = ce(e.columns, n.columnWidths), u = fe(e.tableStyle?.width);
126
+ return Math.max(l, u);
127
+ }), y = w(() => ie(e.columns)), O = w(() => {
128
+ if (!e.virtualColumn || f.value <= 0) return null;
129
+ const t = e.columnMetrics;
130
+ return !t || t.widths.length !== e.columns.length ? null : t.widths;
126
131
  }), {
127
- active: R,
128
- start: H,
132
+ active: H,
133
+ start: _,
129
134
  end: I,
130
- leftSpacer: p,
131
- rightSpacer: E
132
- } = ae({
133
- widths: () => S.value,
134
- leftFixedCount: () => v.value.leftFixedCount,
135
- rightFixedStart: () => v.value.rightFixedStart,
135
+ leftSpacer: S,
136
+ rightSpacer: p
137
+ } = se({
138
+ widths: () => O.value,
139
+ leftFixedCount: () => y.value.leftFixedCount,
140
+ rightFixedStart: () => y.value.rightFixedStart,
136
141
  offsetX: () => x.value,
137
142
  viewportWidth: () => f.value
138
- }), _ = c(() => {
139
- const e = t.columns.length;
140
- if (!R.value)
143
+ }), K = w(() => {
144
+ const t = e.columns.length;
145
+ if (!H.value)
141
146
  return Array.from({
142
- length: e
143
- }, (n, i) => ({
147
+ length: t
148
+ }, (o, i) => ({
144
149
  index: i
145
150
  }));
146
151
  const {
147
152
  leftFixedCount: l,
148
153
  rightFixedStart: u
149
- } = v.value, o = [];
150
- for (let n = 0; n < l; n += 1) o.push({
151
- index: n
154
+ } = y.value, a = [];
155
+ for (let o = 0; o < l; o += 1) a.push({
156
+ index: o
152
157
  });
153
- p.value > 0 && o.push({
154
- spacer: p.value
158
+ S.value > 0 && a.push({
159
+ spacer: S.value
155
160
  });
156
- for (let n = H.value; n <= I.value; n += 1) o.push({
157
- index: n
161
+ for (let o = _.value; o <= I.value; o += 1) a.push({
162
+ index: o
158
163
  });
159
- E.value > 0 && o.push({
160
- spacer: E.value
164
+ p.value > 0 && a.push({
165
+ spacer: p.value
161
166
  });
162
- for (let n = u; n < e; n += 1) o.push({
163
- index: n
167
+ for (let o = u; o < t; o += 1) a.push({
168
+ index: o
164
169
  });
165
- return o;
170
+ return a;
166
171
  });
167
- function fe(e) {
172
+ function ye(t) {
168
173
  }
169
174
  let s = null, d = null;
170
- function B(e) {
171
- const l = e ?? null;
175
+ function R(t) {
176
+ const l = t ?? null;
172
177
  l !== d && (s && d && s.unobserve(d), d = l, l && (f.value = l.clientWidth, !s && typeof ResizeObserver < "u" && (s = new ResizeObserver(() => {
173
178
  d && (f.value = d.clientWidth);
174
179
  })), s?.observe(l)));
175
180
  }
176
- return Y(() => {
181
+ return J(() => {
177
182
  s?.disconnect(), s = null, d = null;
178
- }), J(() => m.value, (e) => {
179
- if (e) {
180
- const l = e.getScrollInfo();
181
- b(l), e.nativeElement, B(e.nativeElement);
183
+ }), Q(() => c.value, (t) => {
184
+ if (t) {
185
+ const l = t.getScrollInfo();
186
+ b(l), t.nativeElement, R(t.nativeElement);
182
187
  } else
183
- B(null);
184
- }), () => t.dataSource.length === 0 ? a("table", {
185
- class: t.tableClass,
186
- style: t.tableStyle
187
- }, [a(ne, {
188
- columns: t.columns
189
- }, null), a("tbody", {
190
- class: t.tbodyClass
191
- }, [a(te, {
192
- colSpan: t.columns.length || 1,
193
- emptyClass: t.emptyClass,
194
- tdClass: t.tdClass
195
- }, null)])]) : a(de, {
196
- ref: m,
197
- data: t.dataSource,
198
- height: t.height,
199
- itemHeight: t.itemHeight,
200
- itemKey: q,
201
- scrollWidth: W.value || void 0,
202
- disableHeightMeasure: t.fixedHeight,
188
+ R(null);
189
+ }), () => e.dataSource.length === 0 ? r("table", {
190
+ "data-vtg-table": "",
191
+ class: W(e.tableClass, n.compatClass?.("body")),
192
+ style: e.tableStyle
193
+ }, [r(ne, {
194
+ columns: e.columns
195
+ }, null), r(ae, null, null), r("tbody", {
196
+ class: e.tbodyClass
197
+ }, [r(le, {
198
+ colSpan: e.columns.length || 1,
199
+ emptyClass: e.emptyClass,
200
+ tdClass: e.tdClass
201
+ }, null)])]) : r(me, {
202
+ ref: c,
203
+ holderClass: n.compatClass?.("body"),
204
+ data: e.dataSource,
205
+ height: e.height,
206
+ itemHeight: e.itemHeight,
207
+ itemKey: k,
208
+ scrollWidth: q.value || void 0,
209
+ disableHeightMeasure: e.fixedHeight,
203
210
  fullHeight: !1,
204
211
  onVirtualScroll: b,
205
- showScrollBar: t.showScrollBar,
212
+ showScrollBar: e.showScrollBar,
206
213
  style: {
207
214
  overflow: "hidden"
208
215
  }
209
216
  }, {
210
217
  default: ({
211
- item: e,
218
+ item: t,
212
219
  index: l
213
220
  }) => {
214
221
  let u;
215
- const o = l, n = k(e, o), i = r.expandable?.(), K = r.isExpanded?.(n) ?? !1, j = i?.expandRowByClick ?? !1, D = r.isRowExpandable?.(e) ?? !1, N = r.getRowClassName?.(e, o), F = r.getRowProps?.(e, o), A = r.rowDrag?.enabled.value ? r.rowDrag.getBindings(e, o, F) : void 0, P = {
216
- ...F,
217
- ...A
218
- }, L = ie(r.rowDrag, n, r.subThemeSlots), y = (r.isTreeData?.value ? r.getFlattenRow?.(e) : void 0)?.level ?? 0, M = typeof i?.expandedRowClassName == "function" ? i.expandedRowClassName(e, o, y) : i?.expandedRowClassName, X = j ? () => {
219
- D && r.toggleExpand?.(e, o);
220
- } : void 0, T = _.value, z = R.value ? S.value : null;
221
- return a("table", {
222
- class: t.tableClass,
222
+ const a = l, o = V(t, a), i = n.expandable?.(), D = n.isExpanded?.(o) ?? !1, P = i?.expandRowByClick ?? !1, j = n.isRowExpandable?.(t) ?? !1, E = n.getRowClassName?.(t, a), B = n.getRowProps?.(t, a), M = n.rowDrag?.enabled.value ? n.rowDrag.getBindings(t, a, B) : void 0, A = {
223
+ ...B,
224
+ ...M
225
+ }, L = de(n.rowDrag, o, n.subThemeSlots), v = (n.isTreeData?.value ? n.getFlattenRow?.(t) : void 0)?.level ?? 0, X = typeof i?.expandedRowClassName == "function" ? i.expandedRowClassName(t, a, v) : i?.expandedRowClassName, z = P ? () => {
226
+ j && n.toggleExpand?.(t, a);
227
+ } : void 0, T = K.value, $ = e.columnMetrics?.widths;
228
+ return r("table", {
229
+ "data-vtg-table": "",
230
+ class: e.tableClass,
223
231
  style: {
224
- ...t.tableStyle,
232
+ ...e.tableStyle,
225
233
  tableLayout: "fixed"
226
234
  }
227
- }, [a("tbody", {
228
- class: t.tbodyClass,
229
- "data-vtg-preserve-last-border": l < t.dataSource.length - 1 ? "" : void 0
230
- }, [a(Z, {
231
- key: n,
232
- rowClass: ue(t.rowClass, N, L, se(r, e, o, y)) ?? "",
233
- rowProps: P,
234
- onClick: X
235
- }, ce(u = T.map((g, $) => {
235
+ }, [r("tbody", {
236
+ class: e.tbodyClass,
237
+ "data-vtg-preserve-last-border": l < e.dataSource.length - 1 ? "" : void 0
238
+ }, [r(ee, {
239
+ "data-vtg-virtual-row": "",
240
+ key: o,
241
+ rowClass: W(e.rowClass, E, L, ue(n, t, a, v)) ?? "",
242
+ rowProps: A,
243
+ onClick: z
244
+ }, we(u = T.map((g, G) => {
236
245
  if (g.spacer !== void 0)
237
- return a("td", {
238
- key: `__vtg_spacer_${$}`,
246
+ return r("td", {
247
+ key: `__vtg_spacer_${G}`,
239
248
  style: {
240
249
  width: `${g.spacer}px`,
241
250
  padding: "0"
242
251
  },
243
252
  "aria-hidden": "true"
244
253
  }, null);
245
- const w = g.index, h = t.columns[w];
246
- return a(ee, {
247
- key: h.key ?? String(h.dataIndex ?? w),
248
- record: e,
249
- rowIndex: o,
254
+ const m = g.index, h = e.columns[m];
255
+ return r(te, {
256
+ key: h.key ?? String(h.dataIndex ?? m),
257
+ record: t,
258
+ rowIndex: a,
250
259
  column: h,
251
- colIndex: w,
252
- widthOverride: z?.[w],
253
- tdClass: t.tdClass,
254
- bodyCellEllipsisClass: t.bodyCellEllipsisClass
260
+ colIndex: m,
261
+ widthOverride: $?.[m],
262
+ tdClass: e.tdClass,
263
+ bodyCellEllipsisClass: e.bodyCellEllipsisClass
255
264
  }, null);
256
265
  })) ? u : {
257
266
  default: () => [u]
258
- }), K && i?.expandedRowRender ? a(le, {
259
- key: `${n}-expanded`,
260
- record: e,
261
- rowIndex: o,
267
+ }), D && i?.expandedRowRender ? r(oe, {
268
+ key: `${o}-expanded`,
269
+ record: t,
270
+ rowIndex: a,
262
271
  colspan: T.length,
263
- rowIndent: y,
264
- rowClass: t.rowClass,
265
- rowClassName: N,
266
- expandedRowClassName: M,
267
- tdClass: t.tdClass,
272
+ rowIndent: v,
273
+ rowClass: e.rowClass,
274
+ rowClassName: E,
275
+ expandedRowClassName: X,
276
+ tdClass: e.tdClass,
268
277
  expandedRowRender: i.expandedRowRender
269
278
  }, null) : null])]);
270
279
  }
@@ -272,5 +281,5 @@ const Fe = /* @__PURE__ */ G({
272
281
  }
273
282
  });
274
283
  export {
275
- Fe as default
284
+ qe as default
276
285
  };
@@ -0,0 +1,28 @@
1
+ import { ColumnType, TableLayout } from '../types';
2
+ import { ColumnMetrics } from './useColumnMetrics';
3
+ type Column = ColumnType<Record<string, unknown>>;
4
+ export interface ColumnLayoutOptions {
5
+ columns: () => Column[];
6
+ columnWidths: Record<string, number>;
7
+ layout: () => TableLayout;
8
+ split: () => boolean;
9
+ root: () => HTMLElement | null;
10
+ viewport: () => HTMLElement | null;
11
+ scrollX: () => number | string | undefined;
12
+ onMeasure?: () => void;
13
+ }
14
+ /** Input constraints, allocation and committed browser metrics have separate lifetimes. */
15
+ export declare function useColumnLayout(options: ColumnLayoutOptions): {
16
+ enabled: import('vue').ComputedRef<boolean>;
17
+ minimums: import('vue').ComputedRef<number[]>;
18
+ minimumTotal: import('vue').ComputedRef<number>;
19
+ metrics: import('vue').ComputedRef<ColumnMetrics | null>;
20
+ synchronized: import('vue').ComputedRef<boolean>;
21
+ tableStyle: import('vue').ComputedRef<Record<string, string>>;
22
+ columnStyle: (index: number, span?: number) => Record<string, string>;
23
+ overflow: import('vue').ShallowRef<boolean, boolean>;
24
+ remeasure: () => void;
25
+ };
26
+ export type ColumnLayout = ReturnType<typeof useColumnLayout>;
27
+ export {};
28
+ //# sourceMappingURL=useColumnLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnLayout.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnLayout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAQ5E,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAMjD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,MAAM,EAAE,CAAA;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,MAAM,EAAE,MAAM,WAAW,CAAA;IACzB,KAAK,EAAE,MAAM,OAAO,CAAA;IACpB,IAAI,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;IAC9B,QAAQ,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;IAClC,OAAO,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB;;;;;;;yBAyD9B,MAAM,oBAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;EAsYtE;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA"}
@@ -0,0 +1,259 @@
1
+ import { computed as p, shallowRef as z, watch as et, onMounted as ct, onUpdated as dt, onBeforeUnmount as ht, nextTick as mt } from "vue";
2
+ import { measureColumnTracks as nt } from "./useColumnMetrics.mjs";
3
+ import { normalizeMinWidth as it, parseColumnWidth as x, resolveColumnWidth as ft, allocateFixedColumnWidths as vt } from "../utils/columnWidth.mjs";
4
+ const rt = 0.1, O = (e) => typeof e == "string" && /^(?:min-content|max-content|fit-content(?:\(.*\))?)$/i.test(e.trim());
5
+ function pt(e) {
6
+ const w = p(
7
+ () => e.columns().some((t) => it(t.minWidth) !== void 0)
8
+ ), T = z(0), q = z({}), A = z([]), k = (t, n) => q.value[`${n}:${t}`], L = z(null), F = z(!1), I = p(
9
+ () => Math.max(
10
+ T.value,
11
+ x(e.scrollX(), T.value, k) ?? 0
12
+ )
13
+ ), j = p(
14
+ () => e.columns().map(
15
+ (t, n) => O(t.width) && A.value[n] !== void 0 ? { ...t, width: A.value[n] } : t
16
+ )
17
+ ), $ = p(
18
+ () => j.value.map(
19
+ (t, n) => ft(t, n, {
20
+ columnWidths: e.columnWidths,
21
+ referenceWidth: I.value,
22
+ resolveCssLength: k
23
+ })
24
+ )
25
+ ), S = p(
26
+ () => $.value.map((t) => Math.max(t.effectiveMinWidth ?? 0, t.resizedWidth ?? 0))
27
+ ), B = p(() => S.value.reduce((t, n) => t + n, 0)), V = p(
28
+ () => vt(j.value, {
29
+ containerWidth: T.value,
30
+ targetWidth: I.value,
31
+ columnWidths: e.columnWidths,
32
+ resolveCssLength: k
33
+ })
34
+ ), C = p(() => w.value ? e.layout() === "fixed" ? { widths: V.value.widths, total: V.value.totalWidth } : L.value : null), H = p(
35
+ () => w.value && (e.layout() === "fixed" || e.split())
36
+ );
37
+ function lt(t, n = 1) {
38
+ if (!w.value) return {};
39
+ const r = $.value[t];
40
+ if (!r) return {};
41
+ const a = S.value.slice(t, t + n).reduce((b, h) => b + h, 0), u = H.value ? C.value?.widths.slice(t, t + n) : void 0, g = u ? u.reduce((b, h) => b + h, 0) : n === 1 ? r.targetWidth : void 0;
42
+ return {
43
+ minWidth: `${a}px`,
44
+ ...g !== void 0 ? { width: `${g}px` } : {}
45
+ };
46
+ }
47
+ const ot = p(() => w.value ? H.value && C.value ? {
48
+ tableLayout: "fixed",
49
+ width: `${C.value.total}px`,
50
+ minWidth: `${C.value.total}px`
51
+ } : { minWidth: `max(100%, ${B.value}px)` } : {});
52
+ let R = 0, N, P, J = null, Y = null, X = !1;
53
+ const _ = ["load", "error", "loadedmetadata"], G = ["src", "srcset", "sizes", "width", "height", "href"];
54
+ function D(t) {
55
+ return !!(t instanceof Element ? t : t.parentElement)?.closest("[inert]");
56
+ }
57
+ function K(t) {
58
+ return t instanceof Element && t.matches("img, video, iframe, object, embed, source, image");
59
+ }
60
+ function Q(t) {
61
+ K(t.target) && !D(t.target) && W();
62
+ }
63
+ function Z() {
64
+ for (const t of _)
65
+ J?.removeEventListener(t, Q, !0);
66
+ }
67
+ function st(t, n) {
68
+ return t?.widths.length === n.widths.length && t.widths.every((r, a) => Math.abs(r - n.widths[a]) < rt);
69
+ }
70
+ function at(t, n, r) {
71
+ const a = [...t.querySelectorAll("table[data-vtg-table]")].filter(
72
+ (l) => !l.parentElement?.closest("table[data-vtg-table]")
73
+ );
74
+ if (!a.length) return null;
75
+ const u = a[0].cloneNode(!1);
76
+ u.removeAttribute("id"), u.style.tableLayout = "auto", u.style.width = `${r}px`, u.style.minWidth = `${B.value}px`;
77
+ const g = document.createElement("colgroup");
78
+ for (let l = 0; l < $.value.length; l++) {
79
+ const o = document.createElement("col"), s = e.columns()[l], v = $.value[l], i = v.resizedWidth ?? x(s.width, r);
80
+ i !== void 0 ? o.style.width = `${Math.max(i, v.effectiveMinWidth ?? 0)}px` : typeof s.width == "string" && !/content/.test(s.width) && (o.style.width = s.width), o.style.minWidth = `${S.value[l]}px`, g.append(o);
81
+ }
82
+ u.append(g);
83
+ const b = document.createElement("tbody");
84
+ b.dataset.vtgWidthRow = "";
85
+ const h = b.insertRow();
86
+ S.value.forEach((l, o) => {
87
+ const s = h.insertCell();
88
+ s.dataset.vtgTrack = String(o), s.style.cssText = "padding:0;border:0;height:0;line-height:0;font-size:0";
89
+ const v = document.createElement("div");
90
+ v.style.cssText = `height:0;min-width:${l}px`, s.append(v);
91
+ }), u.append(b);
92
+ for (const l of a)
93
+ for (const o of [...l.children]) {
94
+ if (!["THEAD", "TBODY", "TFOOT"].includes(o.tagName) || o.hasAttribute("data-vtg-width-row"))
95
+ continue;
96
+ const s = o.cloneNode(!0), v = o.querySelectorAll("img");
97
+ s.querySelectorAll("img").forEach((i, y) => {
98
+ const m = v[y];
99
+ if (!m.naturalWidth || !m.naturalHeight || i.naturalWidth) return;
100
+ const c = getComputedStyle(m);
101
+ /\b(?:size|inline-size|strict)\b/.test(c.contain) || (i.style.contain = c.contain === "content" ? "strict" : `${c.contain && c.contain !== "none" ? `${c.contain} ` : ""}size`, i.style.containIntrinsicSize = `${m.naturalWidth}px ${m.naturalHeight}px`, (!c.aspectRatio || /\bauto\b/.test(c.aspectRatio)) && (i.style.aspectRatio = `auto ${m.naturalWidth} / ${m.naturalHeight}`));
102
+ });
103
+ for (const i of s.querySelectorAll("th,td")) {
104
+ const y = Number(i.dataset.vtgLeafCol ?? i.dataset.vtgCol);
105
+ if (i.style.removeProperty("width"), i.style.removeProperty("min-width"), i.style.removeProperty("max-width"), i.style.removeProperty("position"), i.style.removeProperty("left"), i.style.removeProperty("right"), Number.isInteger(y) && $.value[y]) {
106
+ const m = $.value[y], c = e.columns()[y], d = m.resizedWidth ?? x(c.width, r);
107
+ d !== void 0 ? i.style.width = `${Math.max(d, m.effectiveMinWidth ?? 0)}px` : typeof c.width == "string" && !/content/.test(c.width) && (i.style.width = c.width), i.style.minWidth = `${S.value[y]}px`;
108
+ }
109
+ }
110
+ for (const i of s.querySelectorAll("tr[data-vtg-virtual-row]")) {
111
+ const y = [...i.querySelectorAll("td[data-vtg-col]")];
112
+ i.replaceChildren(
113
+ ...e.columns().map(
114
+ (m, c) => y.find((d) => Number(d.dataset.vtgCol) === c) ?? document.createElement("td")
115
+ )
116
+ );
117
+ }
118
+ for (const i of s.querySelectorAll("[id]")) i.removeAttribute("id");
119
+ u.append(s);
120
+ }
121
+ return n.append(u), u;
122
+ }
123
+ function ut() {
124
+ if (R = 0, X || !w.value) return;
125
+ const t = e.root(), n = e.viewport() ?? t;
126
+ if (!t || !n) return;
127
+ const r = n.clientWidth;
128
+ if (r <= 0) return;
129
+ let a = Math.abs(T.value - r) > rt;
130
+ a && (T.value = r);
131
+ let u = !1;
132
+ const g = /* @__PURE__ */ new Set();
133
+ for (const o of [e.scrollX(), ...e.columns().map((s) => s.width)])
134
+ typeof o == "string" && o !== "auto" && x(o, r) === void 0 && g.add(o);
135
+ const b = e.layout() === "auto" && e.split() || [...g].some((o) => /content/.test(o)), h = document.createElement("div");
136
+ h.inert = !0, h.setAttribute("aria-hidden", "true"), h.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;overflow:hidden;height:0;width:${r}px;contain:layout style;`, t.append(h);
137
+ let l = null;
138
+ try {
139
+ let o = function(d, f) {
140
+ if (!CSS.supports("width", d)) return;
141
+ h.style.width = `${f}px`;
142
+ let E;
143
+ if (O(d)) {
144
+ if (!l) return;
145
+ l.style.width = d, E = l.getBoundingClientRect().width;
146
+ } else {
147
+ const M = document.createElement("div");
148
+ M.style.width = d, h.append(M), E = M.getBoundingClientRect().width, M.remove();
149
+ }
150
+ return s[`${f}:${d}`] = E, E;
151
+ };
152
+ const s = {}, v = e.scrollX(), i = Math.max(
153
+ r,
154
+ O(v) ? 0 : x(v, r, o) ?? 0
155
+ );
156
+ b && (l = at(t, h, i));
157
+ const y = x(v, r, o), m = Math.max(r, y ?? 0), c = e.columns().map((d) => {
158
+ if (!O(d.width)) {
159
+ x(d.width, m, o);
160
+ return;
161
+ }
162
+ });
163
+ if (l) {
164
+ const d = new Set(
165
+ e.columns().flatMap((f) => O(f.width) ? [f.width] : [])
166
+ );
167
+ for (const f of d) {
168
+ l.style.width = f;
169
+ const E = nt(l, e.columns().length);
170
+ e.columns().forEach((M, tt) => {
171
+ M.width === f && (c[tt] = E?.widths[tt]);
172
+ });
173
+ }
174
+ }
175
+ if (JSON.stringify(c) !== JSON.stringify(A.value) && (A.value = c, a = !0), JSON.stringify(s) !== JSON.stringify(q.value) && (q.value = s, a = !0), e.layout() === "auto")
176
+ if (!e.split() && a)
177
+ u = !0;
178
+ else {
179
+ l && (l.style.width = `${I.value}px`);
180
+ const d = e.split() ? l : t.querySelector("table[data-vtg-table]"), f = d ? nt(d, e.columns().length) : null;
181
+ f && !st(L.value, f) && (L.value = f);
182
+ }
183
+ u || (F.value = Math.max(C.value?.total ?? 0, n.scrollWidth) > r + 1);
184
+ } finally {
185
+ h.remove();
186
+ }
187
+ if (u) {
188
+ mt(W);
189
+ return;
190
+ }
191
+ e.onMeasure?.();
192
+ }
193
+ function W() {
194
+ X || R || !w.value || (R = requestAnimationFrame(ut));
195
+ }
196
+ function U() {
197
+ const t = w.value ? e.root() : null, n = w.value ? e.viewport() ?? t : null;
198
+ if (!(t === J && n === Y) && (N?.disconnect(), P?.disconnect(), Z(), J = t, Y = n, !!t)) {
199
+ N ??= typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(W), N?.observe(t), n && n !== t && N?.observe(n);
200
+ for (const r of _) t.addEventListener(r, Q, !0);
201
+ P ??= new MutationObserver((r) => {
202
+ r.some((a) => {
203
+ if (D(a.target)) return !1;
204
+ if (a.type === "attributes")
205
+ return K(a.target) && G.includes(a.attributeName ?? "");
206
+ const u = [...a.addedNodes, ...a.removedNodes];
207
+ return !u.length || u.some((g) => !D(g));
208
+ }) && W();
209
+ }), P.observe(t, {
210
+ childList: !0,
211
+ subtree: !0,
212
+ characterData: !0,
213
+ attributes: !0,
214
+ attributeFilter: G
215
+ });
216
+ }
217
+ }
218
+ return et(
219
+ () => [
220
+ e.columns().map((t) => [t.key, t.width, t.minWidth, t.maxWidth]),
221
+ { ...e.columnWidths },
222
+ e.layout(),
223
+ e.split(),
224
+ e.scrollX()
225
+ ],
226
+ () => {
227
+ L.value = null, w.value || (F.value = !1, q.value = {}, A.value = []), U(), W();
228
+ },
229
+ { deep: !0, flush: "post" }
230
+ ), et(
231
+ () => e.columns().map((t) => [t.key, t.minWidth, t.maxWidth]),
232
+ () => {
233
+ for (const t of e.columns()) {
234
+ const n = it(t.minWidth);
235
+ t.minWidth, n !== void 0 && t.maxWidth !== void 0 && t.maxWidth < n;
236
+ }
237
+ },
238
+ { immediate: !0, deep: !0 }
239
+ ), ct(() => {
240
+ U(), W();
241
+ }), dt(() => {
242
+ U(), W();
243
+ }), ht(() => {
244
+ X = !0, R && cancelAnimationFrame(R), N?.disconnect(), P?.disconnect(), Z();
245
+ }), {
246
+ enabled: w,
247
+ minimums: S,
248
+ minimumTotal: B,
249
+ metrics: C,
250
+ synchronized: H,
251
+ tableStyle: ot,
252
+ columnStyle: lt,
253
+ overflow: F,
254
+ remeasure: W
255
+ };
256
+ }
257
+ export {
258
+ pt as useColumnLayout
259
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useColumnLayout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnLayout.test.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnLayout.test.ts"],"names":[],"mappings":""}