1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../utils/index.js');
require('../../../hooks/index.js');
require('./composables/index.js');
var useColumns = require('./composables/use-columns.js');
var useScrollbar = require('./composables/use-scrollbar.js');
var index = require('../../../hooks/use-namespace/index.js');
var useRow = require('./composables/use-row.js');
var useData = require('./composables/use-data.js');
var useStyles = require('./composables/use-styles.js');
var shared = require('@vue/shared');
function useTable(props) {
const mainTableRef = vue.ref();
const leftTableRef = vue.ref();
const rightTableRef = vue.ref();
const {
columns,
columnsStyles,
columnsTotalWidth,
fixedColumnsOnLeft,
fixedColumnsOnRight,
hasFixedColumns,
mainColumns,
onColumnSorted
} = useColumns.useColumns(props, vue.toRef(props, "columns"), vue.toRef(props, "fixed"));
const {
scrollTo,
scrollToLeft,
scrollToTop,
scrollToRow,
onScroll,
onVerticalScroll,
scrollPos
} = useScrollbar.useScrollbar(props, {
mainTableRef,
leftTableRef,
rightTableRef,
onMaybeEndReached
});
const ns = index.useNamespace("table-v2");
const instance = vue.getCurrentInstance();
const isScrolling = vue.shallowRef(false);
const {
expandedRowKeys,
lastRenderedRowIndex,
isDynamic,
isResetting,
rowHeights,
resetAfterIndex,
onRowExpanded,
onRowHeightChange,
onRowHovered,
onRowsRendered
} = useRow.useRow(props, {
mainTableRef,
leftTableRef,
rightTableRef,
tableInstance: instance,
ns,
isScrolling
});
const { data, depthMap } = useData.useData(props, {
expandedRowKeys,
lastRenderedRowIndex,
resetAfterIndex
});
const {
bodyWidth,
fixedTableHeight,
mainTableHeight,
leftTableWidth,
rightTableWidth,
headerWidth,
rowsHeight,
windowHeight,
footerHeight,
emptyStyle,
rootStyle,
headerHeight
} = useStyles.useStyles(props, {
columnsTotalWidth,
data,
fixedColumnsOnLeft,
fixedColumnsOnRight
});
const containerRef = vue.ref();
const showEmpty = vue.computed(() => {
const noData = vue.unref(data).length === 0;
return shared.isArray(props.fixedData) ? props.fixedData.length === 0 && noData : noData;
});
function getRowHeight(rowIndex) {
const { estimatedRowHeight, rowHeight, rowKey } = props;
if (!estimatedRowHeight)
return rowHeight;
return vue.unref(rowHeights)[vue.unref(data)[rowIndex][rowKey]] || estimatedRowHeight;
}
function onMaybeEndReached() {
const { onEndReached } = props;
if (!onEndReached)
return;
const { scrollTop } = vue.unref(scrollPos);
const _totalHeight = vue.unref(rowsHeight);
const clientHeight = vue.unref(windowHeight);
const heightUntilEnd = _totalHeight - (scrollTop + clientHeight) + props.hScrollbarSize;
if (vue.unref(lastRenderedRowIndex) >= 0 && _totalHeight === scrollTop + vue.unref(mainTableHeight) - vue.unref(headerHeight)) {
onEndReached(heightUntilEnd);
}
}
vue.watch(() => props.expandedRowKeys, (val) => expandedRowKeys.value = val, {
deep: true
});
return {
columns,
containerRef,
mainTableRef,
leftTableRef,
rightTableRef,
isDynamic,
isResetting,
isScrolling,
hasFixedColumns,
columnsStyles,
columnsTotalWidth,
data,
expandedRowKeys,
depthMap,
fixedColumnsOnLeft,
fixedColumnsOnRight,
mainColumns,
bodyWidth,
emptyStyle,
rootStyle,
headerWidth,
footerHeight,
mainTableHeight,
fixedTableHeight,
leftTableWidth,
rightTableWidth,
showEmpty,
getRowHeight,
onColumnSorted,
onRowHovered,
onRowExpanded,
onRowsRendered,
onRowHeightChange,
scrollTo,
scrollToLeft,
scrollToTop,
scrollToRow,
onScroll,
onVerticalScroll
};
}
exports.useTable = useTable;
//# sourceMappingURL=use-table.js.map