@vtable-guild/vtable-guild 2.4.0 → 2.5.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.
- package/css/style.css +9 -0
- package/css/tailwind3-utilities.css +9 -0
- package/dist/core/src/components/VirtualList/VirtualList.d.ts +21 -0
- package/dist/core/src/components/VirtualList/VirtualList.d.ts.map +1 -1
- package/dist/core/src/components/VirtualList/VirtualList.mjs +201 -216
- package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts +7 -1
- package/dist/core/src/components/VirtualList/hooks/useHeights.d.ts.map +1 -1
- package/dist/core/src/components/VirtualList/hooks/useHeights.mjs +29 -27
- package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts +3 -1
- package/dist/core/src/components/VirtualList/hooks/useScrollTo.d.ts.map +1 -1
- package/dist/core/src/components/VirtualList/hooks/useScrollTo.mjs +57 -50
- package/dist/core/src/components/VirtualList/index.d.ts +1 -0
- package/dist/core/src/components/VirtualList/index.d.ts.map +1 -1
- package/dist/core/src/components/VirtualList/utils/PrefixSums.d.ts +50 -0
- package/dist/core/src/components/VirtualList/utils/PrefixSums.d.ts.map +1 -0
- package/dist/core/src/components/VirtualList/utils/PrefixSums.mjs +54 -0
- package/dist/core/src/components/VirtualList/utils/PrefixSums.test.d.ts +2 -0
- package/dist/core/src/components/VirtualList/utils/PrefixSums.test.d.ts.map +1 -0
- package/dist/core/src/composables/useTheme.d.ts +1 -1
- package/dist/core/src/composables/useTheme.mjs +5 -5
- package/dist/core/src/index.d.ts +5 -0
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/plugin/index.d.ts +1 -1
- package/dist/core/src/utils/props.d.ts +1 -1
- package/dist/core/src/utils/tv.d.ts +2 -2
- package/dist/core/src/utils/types.d.ts +2 -2
- package/dist/css/style.css +9 -0
- package/dist/css/tailwind3-utilities.css +9 -0
- package/dist/index.full.mjs +3614 -3292
- package/dist/index.mjs +32 -30
- package/dist/table/src/components/ColGroup.d.ts.map +1 -1
- package/dist/table/src/components/ColGroup.mjs +11 -8
- package/dist/table/src/components/Table.d.ts +62 -0
- package/dist/table/src/components/Table.d.ts.map +1 -1
- package/dist/table/src/components/Table.mjs +353 -298
- package/dist/table/src/components/TableBody.d.ts.map +1 -1
- package/dist/table/src/components/TableBody.mjs +22 -22
- package/dist/table/src/components/TableCell.d.ts +23 -0
- package/dist/table/src/components/TableCell.d.ts.map +1 -1
- package/dist/table/src/components/TableCell.mjs +50 -39
- package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
- package/dist/table/src/components/TableHeaderCell.mjs +172 -169
- package/dist/table/src/components/VTable.vue.mjs +10 -8
- package/dist/table/src/components/VirtualTableBody.d.ts +40 -0
- package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
- package/dist/table/src/components/VirtualTableBody.mjs +157 -67
- package/dist/table/src/composables/index.d.ts +4 -0
- package/dist/table/src/composables/index.d.ts.map +1 -1
- package/dist/table/src/composables/useColumnMetrics.d.ts +39 -0
- package/dist/table/src/composables/useColumnMetrics.d.ts.map +1 -0
- package/dist/table/src/composables/useColumnMetrics.mjs +88 -0
- package/dist/table/src/composables/useColumnWindow.d.ts +90 -0
- package/dist/table/src/composables/useColumnWindow.d.ts.map +1 -0
- package/dist/table/src/composables/useColumnWindow.mjs +62 -0
- package/dist/table/src/composables/useColumnWindow.test.d.ts +2 -0
- package/dist/table/src/composables/useColumnWindow.test.d.ts.map +1 -0
- package/dist/table/src/composables/useColumns.d.ts +8 -0
- package/dist/table/src/composables/useColumns.d.ts.map +1 -1
- package/dist/table/src/composables/useColumns.mjs +46 -43
- package/dist/table/src/composables/useSelection.d.ts.map +1 -1
- package/dist/table/src/composables/useSelection.mjs +93 -94
- package/dist/table/src/composables/useVirtual.d.ts +10 -0
- package/dist/table/src/composables/useVirtual.d.ts.map +1 -1
- package/dist/table/src/composables/useVirtual.mjs +15 -11
- package/dist/table/src/index.d.ts +2 -0
- package/dist/table/src/index.d.ts.map +1 -1
- package/dist/table/src/types/table.d.ts +25 -0
- package/dist/table/src/types/table.d.ts.map +1 -1
- package/dist/theme/src/presets/antdv/table.d.ts +3 -0
- package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
- package/dist/theme/src/presets/antdv/table.mjs +4 -1
- package/package.json +10 -3
- package/dist/core/src/components/VirtualList/hooks/useDiffItem.d.ts +0 -4
- package/dist/core/src/components/VirtualList/hooks/useDiffItem.d.ts.map +0 -1
- package/dist/core/src/components/VirtualList/hooks/useDiffItem.mjs +0 -16
- package/dist/core/src/components/VirtualList/utils/algorithmUtil.d.ts +0 -7
- package/dist/core/src/components/VirtualList/utils/algorithmUtil.d.ts.map +0 -1
- package/dist/core/src/components/VirtualList/utils/algorithmUtil.mjs +0 -22
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
2
|
import { VirtualScrollInfo } from '../../../core/src/index.ts';
|
|
3
|
+
import { ColumnMetrics } from '../composables/useColumnMetrics';
|
|
3
4
|
import { ColumnType, Key } from '../types';
|
|
4
5
|
type VirtualTableScrollInfo = VirtualScrollInfo & {
|
|
5
6
|
maxX: number;
|
|
@@ -53,6 +54,24 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
53
54
|
type: NumberConstructor;
|
|
54
55
|
required: true;
|
|
55
56
|
};
|
|
57
|
+
/** 定高快路径开关,见 VTable 的 rowHeight prop */
|
|
58
|
+
fixedHeight: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* 横向虚拟化开关。由 VTable 判定完全部前提后才会为 true,
|
|
64
|
+
* 这里只管渲染,不再重复校验。
|
|
65
|
+
*/
|
|
66
|
+
virtualColumn: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** 从表头实测到的列宽。null 表示还没测到,此时渲染全部列。 */
|
|
71
|
+
columnMetrics: {
|
|
72
|
+
type: PropType<ColumnMetrics | null>;
|
|
73
|
+
default: null;
|
|
74
|
+
};
|
|
56
75
|
/** Sync header scroll when virtual body scrolls horizontally */
|
|
57
76
|
onVirtualScroll: {
|
|
58
77
|
type: PropType<(info: VirtualTableScrollInfo) => void>;
|
|
@@ -111,6 +130,24 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
111
130
|
type: NumberConstructor;
|
|
112
131
|
required: true;
|
|
113
132
|
};
|
|
133
|
+
/** 定高快路径开关,见 VTable 的 rowHeight prop */
|
|
134
|
+
fixedHeight: {
|
|
135
|
+
type: BooleanConstructor;
|
|
136
|
+
default: boolean;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* 横向虚拟化开关。由 VTable 判定完全部前提后才会为 true,
|
|
140
|
+
* 这里只管渲染,不再重复校验。
|
|
141
|
+
*/
|
|
142
|
+
virtualColumn: {
|
|
143
|
+
type: BooleanConstructor;
|
|
144
|
+
default: boolean;
|
|
145
|
+
};
|
|
146
|
+
/** 从表头实测到的列宽。null 表示还没测到,此时渲染全部列。 */
|
|
147
|
+
columnMetrics: {
|
|
148
|
+
type: PropType<ColumnMetrics | null>;
|
|
149
|
+
default: null;
|
|
150
|
+
};
|
|
114
151
|
/** Sync header scroll when virtual body scrolls horizontally */
|
|
115
152
|
onVirtualScroll: {
|
|
116
153
|
type: PropType<(info: VirtualTableScrollInfo) => void>;
|
|
@@ -125,6 +162,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
125
162
|
onVirtualScroll: (info: VirtualTableScrollInfo) => void;
|
|
126
163
|
rowKey: string | ((record: Record<string, unknown>) => Key);
|
|
127
164
|
tableStyle: Record<string, string>;
|
|
165
|
+
fixedHeight: boolean;
|
|
166
|
+
virtualColumn: boolean;
|
|
167
|
+
columnMetrics: ColumnMetrics | null;
|
|
128
168
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
129
169
|
export default _default;
|
|
130
170
|
//# sourceMappingURL=VirtualTableBody.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualTableBody.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/VirtualTableBody.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,KAAK,CAAA;AAElD,OAAO,KAAK,EAAW,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAMpE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,sBAAsB,GAAG,iBAAiB,GAAG;IAChD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;;;
|
|
1
|
+
{"version":3,"file":"VirtualTableBody.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/VirtualTableBody.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,KAAK,CAAA;AAElD,OAAO,KAAK,EAAW,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAMpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAEpE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,sBAAsB,GAAG,iBAAiB,GAAG;IAChD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;;;cAQgC,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,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cAEhC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;;;;;;;;IAK3F,wCAAwC;;;;;IAExC;;;OAGG;;;;;IAEH,qCAAqC;;cACJ,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC;;;IAC/D,gEAAgE;;cAE5C,QAAQ,CAAC,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;;;;cAIvC,QAAQ,CAAC,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;;;;;cA9BxC,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,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cAEhC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;;;;;;;;;;;IAK3F,wCAAwC;;;;;IAExC;;;OAGG;;;;;IAEH,qCAAqC;;cACJ,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC;;;IAC/D,gEAAgE;;cAE5C,QAAQ,CAAC,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;;;;cAIvC,QAAQ,CAAC,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;;;;;4BAJjC,sBAAsB,KAAK,IAAI;+BAhBT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG;;;;;;AAb7F,wBAiYE"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as z, inject as $, ref as g, computed as c, onBeforeUnmount as D, watch as G, createVNode as r, isVNode as U } from "vue";
|
|
2
2
|
import "../../../core/src/utils/tv.mjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { TABLE_CONTEXT_KEY as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
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 ne from "../../../core/src/components/VirtualList/VirtualList.mjs";
|
|
10
|
+
import { cn as C } from "tailwind-variants";
|
|
11
|
+
function oe(e) {
|
|
12
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !U(e);
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
+
const he = /* @__PURE__ */ z({
|
|
14
15
|
name: "VirtualTableBody",
|
|
15
16
|
props: {
|
|
16
17
|
dataSource: {
|
|
@@ -61,6 +62,24 @@ const D = /* @__PURE__ */ q({
|
|
|
61
62
|
type: Number,
|
|
62
63
|
required: !0
|
|
63
64
|
},
|
|
65
|
+
/** 定高快路径开关,见 VTable 的 rowHeight prop */
|
|
66
|
+
fixedHeight: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: !1
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* 横向虚拟化开关。由 VTable 判定完全部前提后才会为 true,
|
|
72
|
+
* 这里只管渲染,不再重复校验。
|
|
73
|
+
*/
|
|
74
|
+
virtualColumn: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: !1
|
|
77
|
+
},
|
|
78
|
+
/** 从表头实测到的列宽。null 表示还没测到,此时渲染全部列。 */
|
|
79
|
+
columnMetrics: {
|
|
80
|
+
type: Object,
|
|
81
|
+
default: null
|
|
82
|
+
},
|
|
64
83
|
/** Sync header scroll when virtual body scrolls horizontally */
|
|
65
84
|
onVirtualScroll: {
|
|
66
85
|
type: Function,
|
|
@@ -72,52 +91,112 @@ const D = /* @__PURE__ */ q({
|
|
|
72
91
|
}
|
|
73
92
|
},
|
|
74
93
|
setup(e) {
|
|
75
|
-
const
|
|
76
|
-
function
|
|
77
|
-
e.onVirtualScroll?.({
|
|
94
|
+
const a = $(ee, {}), w = g(), x = g(0), f = g(0);
|
|
95
|
+
function b(t) {
|
|
96
|
+
x.value = t.x, e.onVirtualScroll?.({
|
|
78
97
|
...t,
|
|
79
|
-
maxX:
|
|
98
|
+
maxX: w.value?.getHorizontalRange() ?? 0
|
|
80
99
|
});
|
|
81
100
|
}
|
|
82
|
-
function
|
|
83
|
-
return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] :
|
|
101
|
+
function N(t, l) {
|
|
102
|
+
return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : l;
|
|
84
103
|
}
|
|
85
|
-
function
|
|
104
|
+
function T(t) {
|
|
86
105
|
return typeof e.rowKey == "function" ? e.rowKey(t) : typeof e.rowKey == "string" && e.rowKey in t ? t[e.rowKey] : e.dataSource.indexOf(t);
|
|
87
106
|
}
|
|
88
|
-
const
|
|
107
|
+
const V = c(() => {
|
|
89
108
|
let t = 0;
|
|
90
|
-
for (const
|
|
91
|
-
const
|
|
92
|
-
t +=
|
|
109
|
+
for (const l of e.columns) {
|
|
110
|
+
const d = typeof l.width == "number" ? l.width : parseInt(String(l.width || "0"), 10);
|
|
111
|
+
t += d || 0;
|
|
93
112
|
}
|
|
94
113
|
return t;
|
|
114
|
+
}), k = c(() => {
|
|
115
|
+
const t = e.virtualColumn ? e.columnMetrics?.total : void 0;
|
|
116
|
+
return t && t > 0 ? t : V.value;
|
|
117
|
+
}), m = c(() => te(e.columns)), S = c(() => {
|
|
118
|
+
if (!e.virtualColumn || f.value <= 0) return null;
|
|
119
|
+
const t = e.columnMetrics;
|
|
120
|
+
return !t || t.widths.length !== e.columns.length ? null : t.widths;
|
|
121
|
+
}), {
|
|
122
|
+
active: R,
|
|
123
|
+
start: q,
|
|
124
|
+
end: O,
|
|
125
|
+
leftSpacer: p,
|
|
126
|
+
rightSpacer: E
|
|
127
|
+
} = le({
|
|
128
|
+
widths: () => S.value,
|
|
129
|
+
leftFixedCount: () => m.value.leftFixedCount,
|
|
130
|
+
rightFixedStart: () => m.value.rightFixedStart,
|
|
131
|
+
offsetX: () => x.value,
|
|
132
|
+
viewportWidth: () => f.value
|
|
133
|
+
}), W = c(() => {
|
|
134
|
+
const t = e.columns.length;
|
|
135
|
+
if (!R.value)
|
|
136
|
+
return Array.from({
|
|
137
|
+
length: t
|
|
138
|
+
}, (n, i) => ({
|
|
139
|
+
index: i
|
|
140
|
+
}));
|
|
141
|
+
const {
|
|
142
|
+
leftFixedCount: l,
|
|
143
|
+
rightFixedStart: d
|
|
144
|
+
} = m.value, o = [];
|
|
145
|
+
for (let n = 0; n < l; n += 1) o.push({
|
|
146
|
+
index: n
|
|
147
|
+
});
|
|
148
|
+
p.value > 0 && o.push({
|
|
149
|
+
spacer: p.value
|
|
150
|
+
});
|
|
151
|
+
for (let n = q.value; n <= O.value; n += 1) o.push({
|
|
152
|
+
index: n
|
|
153
|
+
});
|
|
154
|
+
E.value > 0 && o.push({
|
|
155
|
+
spacer: E.value
|
|
156
|
+
});
|
|
157
|
+
for (let n = d; n < t; n += 1) o.push({
|
|
158
|
+
index: n
|
|
159
|
+
});
|
|
160
|
+
return o;
|
|
95
161
|
});
|
|
96
|
-
|
|
162
|
+
function re(t) {
|
|
163
|
+
}
|
|
164
|
+
let u = null, s = null;
|
|
165
|
+
function K(t) {
|
|
166
|
+
const l = t ?? null;
|
|
167
|
+
l !== s && (u && s && u.unobserve(s), s = l, l && (f.value = l.clientWidth, !u && typeof ResizeObserver < "u" && (u = new ResizeObserver(() => {
|
|
168
|
+
s && (f.value = s.clientWidth);
|
|
169
|
+
})), u?.observe(l)));
|
|
170
|
+
}
|
|
171
|
+
return D(() => {
|
|
172
|
+
u?.disconnect(), u = null, s = null;
|
|
173
|
+
}), G(() => w.value, (t) => {
|
|
97
174
|
if (t) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
175
|
+
const l = t.getScrollInfo();
|
|
176
|
+
b(l), t.nativeElement, K(t.nativeElement);
|
|
177
|
+
} else
|
|
178
|
+
K(null);
|
|
179
|
+
}), () => e.dataSource.length === 0 ? r("table", {
|
|
102
180
|
class: e.tableClass,
|
|
103
181
|
style: e.tableStyle
|
|
104
|
-
}, [
|
|
182
|
+
}, [r(Z, {
|
|
105
183
|
columns: e.columns
|
|
106
|
-
}, null),
|
|
184
|
+
}, null), r("tbody", {
|
|
107
185
|
class: e.tbodyClass
|
|
108
|
-
}, [
|
|
186
|
+
}, [r(Q, {
|
|
109
187
|
colSpan: e.columns.length || 1,
|
|
110
188
|
emptyClass: e.emptyClass,
|
|
111
189
|
tdClass: e.tdClass
|
|
112
|
-
}, null)])]) :
|
|
113
|
-
ref:
|
|
190
|
+
}, null)])]) : r(ne, {
|
|
191
|
+
ref: w,
|
|
114
192
|
data: e.dataSource,
|
|
115
193
|
height: e.height,
|
|
116
194
|
itemHeight: e.itemHeight,
|
|
117
|
-
itemKey:
|
|
118
|
-
scrollWidth:
|
|
195
|
+
itemKey: T,
|
|
196
|
+
scrollWidth: k.value || void 0,
|
|
197
|
+
disableHeightMeasure: e.fixedHeight,
|
|
119
198
|
fullHeight: !1,
|
|
120
|
-
onVirtualScroll:
|
|
199
|
+
onVirtualScroll: b,
|
|
121
200
|
showScrollBar: e.showScrollBar,
|
|
122
201
|
style: {
|
|
123
202
|
overflow: "hidden"
|
|
@@ -125,48 +204,59 @@ const D = /* @__PURE__ */ q({
|
|
|
125
204
|
}, {
|
|
126
205
|
default: ({
|
|
127
206
|
item: t,
|
|
128
|
-
index:
|
|
207
|
+
index: l
|
|
129
208
|
}) => {
|
|
130
|
-
let
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
} : void 0;
|
|
134
|
-
return
|
|
209
|
+
let d;
|
|
210
|
+
const o = l, n = N(t, o), i = a.expandable?.(), H = a.isExpanded?.(n) ?? !1, _ = i?.expandRowByClick ?? !1, I = a.isRowExpandable?.(t) ?? !1, B = a.getRowClassName?.(t, o), j = a.getRowProps?.(t, o), A = (a.isTreeData?.value ? a.getFlattenRow?.(t) : void 0)?.level ?? 0, L = typeof i?.expandedRowClassName == "function" ? i.expandedRowClassName(t, o, A) : i?.expandedRowClassName, M = _ ? () => {
|
|
211
|
+
I && a.toggleExpand?.(t, o);
|
|
212
|
+
} : void 0, F = W.value, P = R.value ? S.value : null;
|
|
213
|
+
return r("table", {
|
|
135
214
|
class: e.tableClass,
|
|
136
215
|
style: {
|
|
137
216
|
...e.tableStyle,
|
|
138
217
|
tableLayout: "fixed"
|
|
139
218
|
}
|
|
140
|
-
}, [
|
|
141
|
-
columns: e.columns
|
|
142
|
-
}, null), l("tbody", {
|
|
219
|
+
}, [r("tbody", {
|
|
143
220
|
class: e.tbodyClass
|
|
144
|
-
}, [
|
|
145
|
-
key:
|
|
146
|
-
rowClass:
|
|
147
|
-
rowProps:
|
|
148
|
-
onClick:
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
221
|
+
}, [r(Y, {
|
|
222
|
+
key: n,
|
|
223
|
+
rowClass: C(e.rowClass, B) ?? "",
|
|
224
|
+
rowProps: j,
|
|
225
|
+
onClick: M
|
|
226
|
+
}, oe(d = F.map((v, X) => {
|
|
227
|
+
if (v.spacer !== void 0)
|
|
228
|
+
return r("td", {
|
|
229
|
+
key: `__vtg_spacer_${X}`,
|
|
230
|
+
style: {
|
|
231
|
+
width: `${v.spacer}px`,
|
|
232
|
+
padding: "0"
|
|
233
|
+
},
|
|
234
|
+
"aria-hidden": "true"
|
|
235
|
+
}, null);
|
|
236
|
+
const y = v.index, h = e.columns[y];
|
|
237
|
+
return r(J, {
|
|
238
|
+
key: h.key ?? String(h.dataIndex ?? y),
|
|
239
|
+
record: t,
|
|
240
|
+
rowIndex: o,
|
|
241
|
+
column: h,
|
|
242
|
+
colIndex: y,
|
|
243
|
+
widthOverride: P?.[y],
|
|
244
|
+
tdClass: e.tdClass,
|
|
245
|
+
bodyCellEllipsisClass: e.bodyCellEllipsisClass
|
|
246
|
+
}, null);
|
|
247
|
+
})) ? d : {
|
|
248
|
+
default: () => [d]
|
|
249
|
+
}), H && i?.expandedRowRender && r("tr", {
|
|
250
|
+
key: `${n}-expanded`,
|
|
251
|
+
class: C(e.rowClass, B, a.subThemeSlots?.expandedRow(), L)
|
|
252
|
+
}, [r("td", {
|
|
253
|
+
colspan: F.length,
|
|
254
|
+
class: C(e.tdClass, a.subThemeSlots?.expandedRowCell())
|
|
255
|
+
}, [i.expandedRowRender(t, o, 0, !0)])])])]);
|
|
166
256
|
}
|
|
167
257
|
});
|
|
168
258
|
}
|
|
169
259
|
});
|
|
170
260
|
export {
|
|
171
|
-
|
|
261
|
+
he as default
|
|
172
262
|
};
|
|
@@ -12,4 +12,8 @@ export { useExpand } from './useExpand';
|
|
|
12
12
|
export { useResize } from './useResize';
|
|
13
13
|
export { useHoverState, isInHoverRange } from './useHoverState';
|
|
14
14
|
export type { HoverState } from './useHoverState';
|
|
15
|
+
export { useColumnMetrics } from './useColumnMetrics';
|
|
16
|
+
export type { ColumnMetrics } from './useColumnMetrics';
|
|
17
|
+
export { useColumnWindow, computeColumnWindow, resolveFixedColumnRanges, DEFAULT_COLUMN_OVERSCAN, } from './useColumnWindow';
|
|
18
|
+
export type { ColumnWindow, FixedColumnRanges } from './useColumnWindow';
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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"}
|
|
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,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,39 @@
|
|
|
1
|
+
import { ShallowRef } from 'vue';
|
|
2
|
+
import { ColumnType } from '../types';
|
|
3
|
+
export interface ColumnMetrics {
|
|
4
|
+
/** 各叶子列的实测宽度(px),下标即 displayColumns 下标。 */
|
|
5
|
+
widths: number[];
|
|
6
|
+
/** 列总宽。 */
|
|
7
|
+
total: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UseColumnMetricsOptions {
|
|
10
|
+
/** 关闭时不测量、不注册 observer,`metrics` 恒为 null。 */
|
|
11
|
+
enabled: () => boolean;
|
|
12
|
+
/** 表头外层容器(useScroll 的 headerWrapRef)。 */
|
|
13
|
+
headerEl: () => HTMLElement | null;
|
|
14
|
+
columns: () => ColumnType<Record<string, unknown>>[];
|
|
15
|
+
/** 拖拽列宽覆写。变了就得重测。 */
|
|
16
|
+
columnWidths: Record<string, number>;
|
|
17
|
+
/** 是否渲染了表头。false 时没有参照可量,只能退回读声明宽度。 */
|
|
18
|
+
hasHeader: () => boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface UseColumnMetricsReturn {
|
|
21
|
+
/** null 表示还没测到;调用方据此回落到渲染全部列。 */
|
|
22
|
+
metrics: ShallowRef<ColumnMetrics | null>;
|
|
23
|
+
/** 手动触发一次重测(下一帧执行)。 */
|
|
24
|
+
remeasure: () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 实测每个叶子列的宽度,作为横向虚拟化的定位参照。
|
|
28
|
+
*
|
|
29
|
+
* **为什么量表头而不是要求用户声明数字列宽**:表头始终渲染全部 N 列,
|
|
30
|
+
* 它本身就是浏览器算好的精确列宽结果,直接读即可,不必复刻一套
|
|
31
|
+
* `width / minWidth / auto / 百分比 → renderWidth` 的解析(vxe-table 必须自己算,
|
|
32
|
+
* 是因为它表头表体都窗口化,没有一份完整布局可参照)。因此我们天然支持
|
|
33
|
+
* `auto`、百分比,以及 `table-layout: fixed` 下浏览器对余量的分配。
|
|
34
|
+
*
|
|
35
|
+
* **不会震荡**:表头布局不依赖表体,所以「量表头 → 改表体」不构成反馈环。
|
|
36
|
+
* 这是整个方案能成立的关键。
|
|
37
|
+
*/
|
|
38
|
+
export declare function useColumnMetrics(options: UseColumnMetricsOptions): UseColumnMetricsReturn;
|
|
39
|
+
//# sourceMappingURL=useColumnMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useColumnMetrics.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AACpF,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,UAAU,CAAA;AAG/C,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,OAAO,CAAA;IACtB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;IAClC,OAAO,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAA;IACpD,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,uCAAuC;IACvC,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,iCAAiC;IACjC,OAAO,EAAE,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACzC,uBAAuB;IACvB,SAAS,EAAE,MAAM,IAAI,CAAA;CACtB;AA0CD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAgHzF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { shallowRef as b, watch as v, onMounted as y, onBeforeUnmount as N } from "vue";
|
|
2
|
+
import { getColumnKey as A } from "./useColumns.mjs";
|
|
3
|
+
const F = 0.5;
|
|
4
|
+
function O(e, n) {
|
|
5
|
+
if (e === null || n === null) return e === n;
|
|
6
|
+
if (e.widths.length !== n.widths.length) return !1;
|
|
7
|
+
for (let t = 0; t < e.widths.length; t += 1)
|
|
8
|
+
if (Math.abs(e.widths[t] - n.widths[t]) > F) return !1;
|
|
9
|
+
return !0;
|
|
10
|
+
}
|
|
11
|
+
function C(e, n) {
|
|
12
|
+
return A(e) ?? n;
|
|
13
|
+
}
|
|
14
|
+
function E(e, n) {
|
|
15
|
+
const t = [];
|
|
16
|
+
let r = 0;
|
|
17
|
+
for (let l = 0; l < e.length; l += 1) {
|
|
18
|
+
const f = n[String(C(e[l], l))] ?? e[l].width, i = typeof f == "number" ? f : Number.NaN;
|
|
19
|
+
if (!Number.isFinite(i) || i <= 0) return null;
|
|
20
|
+
t.push(i), r += i;
|
|
21
|
+
}
|
|
22
|
+
return r > 0 ? { widths: t, total: r } : null;
|
|
23
|
+
}
|
|
24
|
+
function M(e) {
|
|
25
|
+
const n = b(null);
|
|
26
|
+
let t = 0, r = null, l = null;
|
|
27
|
+
function f() {
|
|
28
|
+
const u = e.columns(), a = u.length;
|
|
29
|
+
if (a === 0) return null;
|
|
30
|
+
if (!e.hasHeader())
|
|
31
|
+
return E(u, e.columnWidths);
|
|
32
|
+
const w = e.headerEl();
|
|
33
|
+
if (!w) return null;
|
|
34
|
+
const g = w.querySelectorAll("th[data-vtg-leaf-col]");
|
|
35
|
+
if (g.length !== a) return null;
|
|
36
|
+
const d = new Array(a).fill(-1);
|
|
37
|
+
for (const s of g) {
|
|
38
|
+
const o = Number(s.dataset.vtgLeafCol);
|
|
39
|
+
if (!Number.isInteger(o) || o < 0 || o >= a) return null;
|
|
40
|
+
d[o] = s.getBoundingClientRect().width;
|
|
41
|
+
}
|
|
42
|
+
let h = 0;
|
|
43
|
+
for (const s of d) {
|
|
44
|
+
if (s < 0) return null;
|
|
45
|
+
h += s;
|
|
46
|
+
}
|
|
47
|
+
return h > 0 ? { widths: d, total: h } : null;
|
|
48
|
+
}
|
|
49
|
+
function i() {
|
|
50
|
+
if (t = 0, !e.enabled()) {
|
|
51
|
+
n.value = null;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const u = f();
|
|
55
|
+
O(n.value, u) || (n.value = u);
|
|
56
|
+
}
|
|
57
|
+
function c() {
|
|
58
|
+
if (typeof requestAnimationFrame > "u") {
|
|
59
|
+
i();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
t || (t = requestAnimationFrame(i));
|
|
63
|
+
}
|
|
64
|
+
function m() {
|
|
65
|
+
const u = e.enabled() && e.hasHeader() ? e.headerEl() : null;
|
|
66
|
+
u !== l && (r && l && r.unobserve(l), l = u, u && (!r && typeof ResizeObserver < "u" && (r = new ResizeObserver(c)), r?.observe(u)));
|
|
67
|
+
}
|
|
68
|
+
return v(
|
|
69
|
+
[
|
|
70
|
+
() => e.enabled(),
|
|
71
|
+
() => e.hasHeader(),
|
|
72
|
+
() => e.headerEl(),
|
|
73
|
+
() => e.columns(),
|
|
74
|
+
() => ({ ...e.columnWidths })
|
|
75
|
+
],
|
|
76
|
+
() => {
|
|
77
|
+
m(), c();
|
|
78
|
+
},
|
|
79
|
+
{ deep: !1 }
|
|
80
|
+
), y(() => {
|
|
81
|
+
m(), c();
|
|
82
|
+
}), N(() => {
|
|
83
|
+
t && cancelAnimationFrame(t), r?.disconnect(), r = null, l = null;
|
|
84
|
+
}), { metrics: n, remeasure: c };
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
M as useColumnMetrics
|
|
88
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { PrefixSums } from '../../../core/src/index.ts';
|
|
3
|
+
import { ColumnType } from '../types';
|
|
4
|
+
/** 窗口两侧各多渲染的列数。缓冲一帧内的滚动位移,避免边缘列闪空。 */
|
|
5
|
+
export declare const DEFAULT_COLUMN_OVERSCAN = 2;
|
|
6
|
+
export interface FixedColumnRanges {
|
|
7
|
+
/** 左固定列数量。它们恒渲染、不参与窗口。 */
|
|
8
|
+
leftFixedCount: number;
|
|
9
|
+
/** 首个右固定列的下标;无右固定列时等于列总数。 */
|
|
10
|
+
rightFixedStart: number;
|
|
11
|
+
/**
|
|
12
|
+
* 左固定列是否构成前缀、右固定列是否构成后缀。
|
|
13
|
+
*
|
|
14
|
+
* 不成立时窗口算法失效:窗口是一段**连续**下标区间,
|
|
15
|
+
* 中间夹着的固定列会被整段跳过或重复渲染。
|
|
16
|
+
*/
|
|
17
|
+
contiguous: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 解析固定列的边界。
|
|
21
|
+
*
|
|
22
|
+
* `useScroll.fixedOffsets` 只关心每列各自的偏移,这里关心的是**结构**:
|
|
23
|
+
* 横向窗口化要求「左固定 | 可滚动 | 右固定」三段式,因此额外校验连续性。
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveFixedColumnRanges(columns: readonly ColumnType<Record<string, unknown>>[]): FixedColumnRanges;
|
|
26
|
+
export interface ColumnWindow {
|
|
27
|
+
/** 窗口首列下标(闭区间)。 */
|
|
28
|
+
start: number;
|
|
29
|
+
/** 窗口末列下标(闭区间)。`end < start` 表示空窗口。 */
|
|
30
|
+
end: number;
|
|
31
|
+
/** 左固定列与窗口首列之间的占位宽度。 */
|
|
32
|
+
leftSpacer: number;
|
|
33
|
+
/** 窗口末列与右固定列之间的占位宽度。 */
|
|
34
|
+
rightSpacer: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ComputeColumnWindowOptions {
|
|
37
|
+
/** 已按列宽同步好的位置表。 */
|
|
38
|
+
prefix: PrefixSums;
|
|
39
|
+
columnCount: number;
|
|
40
|
+
leftFixedCount: number;
|
|
41
|
+
rightFixedStart: number;
|
|
42
|
+
/** 当前横向滚动偏移。 */
|
|
43
|
+
offsetX: number;
|
|
44
|
+
/** 可视区宽度(含被固定列盖住的部分)。 */
|
|
45
|
+
viewportWidth: number;
|
|
46
|
+
overscan: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 求当前应该渲染的列区间与两侧占位宽度。
|
|
50
|
+
*
|
|
51
|
+
* 列 `i` 占 `[offsetOf(i), offsetOf(i + 1))`。视口显示 `[offsetX, offsetX + viewportWidth)`,
|
|
52
|
+
* 但左右固定列是 `position: sticky`,**盖住**视口两端,所以可滚动内容真正露出来的区间是
|
|
53
|
+
* `[offsetX + leftFixedWidth, offsetX + viewportWidth - rightFixedWidth)`。
|
|
54
|
+
*
|
|
55
|
+
* 与 vxe-table 的 `handleVirtualXVisible` 同式,可互为佐证。
|
|
56
|
+
*
|
|
57
|
+
* 不变量(见单测):
|
|
58
|
+
* `leftFixedWidth + leftSpacer + windowWidth + rightSpacer + rightFixedWidth === total`
|
|
59
|
+
*/
|
|
60
|
+
export declare function computeColumnWindow(options: ComputeColumnWindowOptions): ColumnWindow;
|
|
61
|
+
export interface UseColumnWindowOptions {
|
|
62
|
+
/**
|
|
63
|
+
* 各叶子列的实测宽度,下标即 displayColumns 下标。
|
|
64
|
+
* 返回 null 表示尚未测到(首帧),调用方据此回落到渲染全部列。
|
|
65
|
+
*/
|
|
66
|
+
widths: () => readonly number[] | null;
|
|
67
|
+
leftFixedCount: () => number;
|
|
68
|
+
rightFixedStart: () => number;
|
|
69
|
+
offsetX: () => number;
|
|
70
|
+
viewportWidth: () => number;
|
|
71
|
+
overscan?: () => number;
|
|
72
|
+
}
|
|
73
|
+
export interface UseColumnWindowReturn {
|
|
74
|
+
/** 是否真的在做列窗口化。false 时调用方必须渲染全部列。 */
|
|
75
|
+
active: ComputedRef<boolean>;
|
|
76
|
+
start: ComputedRef<number>;
|
|
77
|
+
end: ComputedRef<number>;
|
|
78
|
+
leftSpacer: ComputedRef<number>;
|
|
79
|
+
rightSpacer: ComputedRef<number>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 横向窗口的响应式包装。
|
|
83
|
+
*
|
|
84
|
+
* **输出刻意是四个独立的 primitive computed,而不是一个对象**:
|
|
85
|
+
* 横向滚动每一帧都改 `offsetX`,但只有跨越列边界时这四个数才会变。
|
|
86
|
+
* primitive 的脏检查会把中间帧全部吃掉,下游单元格因此不会每帧失效。
|
|
87
|
+
* 理由同 `useScroll` 里把 `scrollState` 拆成两个布尔 computed。
|
|
88
|
+
*/
|
|
89
|
+
export declare function useColumnWindow(options: UseColumnWindowOptions): UseColumnWindowReturn;
|
|
90
|
+
//# sourceMappingURL=useColumnWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useColumnWindow.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useColumnWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,KAAK,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,sCAAsC;AACtC,eAAO,MAAM,uBAAuB,IAAI,CAAA;AAExC,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,cAAc,EAAE,MAAM,CAAA;IACtB,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,GACtD,iBAAiB,CAsBnB;AAED,MAAM,WAAW,YAAY;IAC3B,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,mBAAmB;IACnB,MAAM,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,yBAAyB;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,YAAY,CAkCrF;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,MAAM,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;IACtC,cAAc,EAAE,MAAM,MAAM,CAAA;IAC5B,eAAe,EAAE,MAAM,MAAM,CAAA;IAC7B,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,oCAAoC;IACpC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC1B,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACxB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CAkCtF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { computed as l } from "vue";
|
|
2
|
+
import { PrefixSums as m } from "../../../core/src/components/VirtualList/utils/PrefixSums.mjs";
|
|
3
|
+
const S = 2;
|
|
4
|
+
function w(r) {
|
|
5
|
+
const t = r.length;
|
|
6
|
+
let n = 0;
|
|
7
|
+
for (; n < t && r[n].fixed === "left"; )
|
|
8
|
+
n += 1;
|
|
9
|
+
let i = t;
|
|
10
|
+
for (; i > n && r[i - 1].fixed === "right"; )
|
|
11
|
+
i -= 1;
|
|
12
|
+
let e = !0;
|
|
13
|
+
for (let f = n; f < i; f += 1)
|
|
14
|
+
if (r[f].fixed === "left" || r[f].fixed === "right") {
|
|
15
|
+
e = !1;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
return { leftFixedCount: n, rightFixedStart: i, contiguous: e };
|
|
19
|
+
}
|
|
20
|
+
function p(r) {
|
|
21
|
+
const { prefix: t, columnCount: n, leftFixedCount: i, rightFixedStart: e, offsetX: f, viewportWidth: s, overscan: d } = r, u = i, c = e - 1;
|
|
22
|
+
if (u > c)
|
|
23
|
+
return { start: u, end: u - 1, leftSpacer: 0, rightSpacer: 0 };
|
|
24
|
+
const h = t.offsetOf(i), x = t.total - t.offsetOf(e), g = f + h, v = f + s - x;
|
|
25
|
+
let a = t.findIndex(g) - d, o = t.findIndex(v);
|
|
26
|
+
return o >= n && (o = n - 1), o += d, a = Math.min(Math.max(a, u), c), o = Math.min(Math.max(o, u), c), o < a && (o = a), {
|
|
27
|
+
start: a,
|
|
28
|
+
end: o,
|
|
29
|
+
leftSpacer: t.offsetOf(a) - t.offsetOf(u),
|
|
30
|
+
rightSpacer: t.offsetOf(e) - t.offsetOf(o + 1)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function O(r) {
|
|
34
|
+
const t = new m(), n = l(() => {
|
|
35
|
+
const e = r.widths();
|
|
36
|
+
return !e || e.length === 0 ? null : (t.markAllDirty(), t.sync(e.length, (f) => e[f], 0), e.length);
|
|
37
|
+
}), i = l(() => {
|
|
38
|
+
const e = n.value;
|
|
39
|
+
return e === null ? null : p({
|
|
40
|
+
prefix: t,
|
|
41
|
+
columnCount: e,
|
|
42
|
+
leftFixedCount: r.leftFixedCount(),
|
|
43
|
+
rightFixedStart: r.rightFixedStart(),
|
|
44
|
+
offsetX: r.offsetX(),
|
|
45
|
+
viewportWidth: r.viewportWidth(),
|
|
46
|
+
overscan: r.overscan?.() ?? S
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
active: l(() => i.value !== null),
|
|
51
|
+
start: l(() => i.value?.start ?? 0),
|
|
52
|
+
end: l(() => i.value?.end ?? -1),
|
|
53
|
+
leftSpacer: l(() => i.value?.leftSpacer ?? 0),
|
|
54
|
+
rightSpacer: l(() => i.value?.rightSpacer ?? 0)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
S as DEFAULT_COLUMN_OVERSCAN,
|
|
59
|
+
p as computeColumnWindow,
|
|
60
|
+
w as resolveFixedColumnRanges,
|
|
61
|
+
O as useColumnWindow
|
|
62
|
+
};
|