stk-table-vue 1.0.3 → 1.0.4
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/README.md +22 -9
- package/lib/{Dropdown-gzfyZN4Y.js → Dropdown-D7PIq_F7.js} +2 -2
- package/lib/{StkTable-CoLDxW4i.js → StkTable-DuT_ezDm.js} +28 -5
- package/lib/src/StkTable/StkTable.vue.d.ts +2 -0
- package/lib/src/StkTable/useTree.d.ts +21 -2
- package/lib/stk-table-vue.js +3 -3
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/StkTable/useRowExpand.ts +2 -2
- package/src/StkTable/useTree.ts +55 -6
package/README.md
CHANGED
|
@@ -12,13 +12,26 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
|
-
Stk Table Vue(Sticky Table) is a high-performance virtual
|
|
16
|
-
|
|
17
|
-
Smooth performance with tens of thousands of rows
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
Stk Table Vue(Sticky Table) is a high-performance virtual scrolling table component based on Vue 3 / Vue 2.7.
|
|
16
|
+
|
|
17
|
+
Smooth performance with tens of thousands of rows. Designed for real-time data display with built-in highlighting and animation effects.
|
|
18
|
+
|
|
19
|
+
- Vue 3 & Vue 2.7 support
|
|
20
|
+
- Virtual scrolling (X & Y axis)
|
|
21
|
+
- CSS `sticky` based fixed columns & fixed header
|
|
22
|
+
- Multi-level header with horizontal virtual scroll
|
|
23
|
+
- Tree table & expandable rows
|
|
24
|
+
- Area selection with keyboard navigation
|
|
25
|
+
- Cell highlighting with Animation API
|
|
26
|
+
- Built-in custom cells: Filter, Editable, Checkbox, Number, Change
|
|
27
|
+
- Column resize, header drag, row drag
|
|
28
|
+
- Merge cells (virtual mode supported)
|
|
29
|
+
- Custom scrollbar
|
|
30
|
+
- Sortable & filterable
|
|
31
|
+
- Theme support (dark / light)
|
|
32
|
+
- CSS variables for easy customization
|
|
33
|
+
- Based on native `<table>` element
|
|
34
|
+
- Zero third-party runtime dependencies
|
|
22
35
|
|
|
23
36
|
|
|
24
37
|
## Documentation
|
|
@@ -172,5 +185,5 @@ const dataSource = [
|
|
|
172
185
|
Compare performance with other vue table [vue-table-compare](https://github.com/ja-plus/vue-table-compare)
|
|
173
186
|
|
|
174
187
|
|
|
175
|
-
##
|
|
176
|
-
|
|
188
|
+
## License
|
|
189
|
+
[MIT](LICENSE)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: stk-table-vue
|
|
3
|
-
* version: v1.0.
|
|
3
|
+
* version: v1.0.4
|
|
4
4
|
* description: High performance realtime virtual table for vue3 and vue2.7
|
|
5
5
|
* author: japlus
|
|
6
6
|
* homepage: https://ja-plus.github.io/stk-table-vue/
|
|
7
7
|
* license: MIT
|
|
8
8
|
*/
|
|
9
|
-
import { t as StkTable_default } from "./StkTable-
|
|
9
|
+
import { t as StkTable_default } from "./StkTable-DuT_ezDm.js";
|
|
10
10
|
import { createElementBlock, createElementVNode, createVNode, defineComponent, h, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, reactive, ref, withModifiers } from "vue";
|
|
11
11
|
//#region src/StkTable/custom-cells/FilterCell/Dropdown/index.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var DROPDOWN_DEFAULT_WIDTH = 300;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: stk-table-vue
|
|
3
|
-
* version: v1.0.
|
|
3
|
+
* version: v1.0.4
|
|
4
4
|
* description: High performance realtime virtual table for vue3 and vue2.7
|
|
5
5
|
* author: japlus
|
|
6
6
|
* homepage: https://ja-plus.github.io/stk-table-vue/
|
|
@@ -2170,7 +2170,7 @@ function useRowExpand(emits, dataSourceCopy, rowKeyGen, onDataSourceChange) {
|
|
|
2170
2170
|
*/
|
|
2171
2171
|
function setRowExpand(rowKeyOrRow, expand, data) {
|
|
2172
2172
|
let rowKey;
|
|
2173
|
-
if (typeof rowKeyOrRow === "string") rowKey = rowKeyOrRow;
|
|
2173
|
+
if (typeof rowKeyOrRow === "string" || typeof rowKeyOrRow === "number") rowKey = rowKeyOrRow;
|
|
2174
2174
|
else rowKey = rowKeyGen(rowKeyOrRow);
|
|
2175
2175
|
const tempData = dataSourceCopy.value.slice();
|
|
2176
2176
|
const index = tempData.findIndex((it) => rowKeyGen(it) === rowKey);
|
|
@@ -2929,6 +2929,8 @@ function useTree(props, dataSourceCopy, rowKeyGen, emits, onDataSourceChange) {
|
|
|
2929
2929
|
* @param row rowKey or row
|
|
2930
2930
|
* @param option
|
|
2931
2931
|
* @param option.expand expand or collapse
|
|
2932
|
+
* @param option.all expand all descendants
|
|
2933
|
+
* @param option.level expand to the nth level
|
|
2932
2934
|
* @param option.silent if set true, not emit `toggle-tree-expand`, default:false
|
|
2933
2935
|
*/
|
|
2934
2936
|
function privateSetTreeExpand(row, option) {
|
|
@@ -2937,7 +2939,7 @@ function useTree(props, dataSourceCopy, rowKeyGen, emits, onDataSourceChange) {
|
|
|
2937
2939
|
for (let i = 0; i < rowKeyOrRowArr.length; i++) {
|
|
2938
2940
|
const rowKeyOrRow = rowKeyOrRowArr[i];
|
|
2939
2941
|
let rowKey;
|
|
2940
|
-
if (typeof rowKeyOrRow === "string") rowKey = rowKeyOrRow;
|
|
2942
|
+
if (typeof rowKeyOrRow === "string" || typeof rowKeyOrRow === "number") rowKey = rowKeyOrRow;
|
|
2941
2943
|
else rowKey = rowKeyGen(rowKeyOrRow);
|
|
2942
2944
|
const index = tempData.findIndex((it) => rowKeyGen(it) === rowKey);
|
|
2943
2945
|
if (index === -1) {
|
|
@@ -2946,12 +2948,22 @@ function useTree(props, dataSourceCopy, rowKeyGen, emits, onDataSourceChange) {
|
|
|
2946
2948
|
}
|
|
2947
2949
|
const row = tempData[index];
|
|
2948
2950
|
const level = row.__T_LV__ || 0;
|
|
2951
|
+
const wasExpanded = Boolean(row.__T_EXP__);
|
|
2949
2952
|
let expanded = option === null || option === void 0 ? void 0 : option.expand;
|
|
2950
2953
|
if (expanded === void 0) expanded = !row.__T_EXP__;
|
|
2951
|
-
if (
|
|
2954
|
+
if (option.all || option.level !== void 0) {
|
|
2955
|
+
const targetLevel = option.all ? Infinity : option.level || 0;
|
|
2956
|
+
setDescendantsToLevel(row, level + 1, targetLevel, expanded);
|
|
2957
|
+
}
|
|
2958
|
+
if (expanded) if (wasExpanded) {
|
|
2959
|
+
const deleteCount = foldNode(index, tempData, level);
|
|
2952
2960
|
const children = expandNode(row, level);
|
|
2953
|
-
tempData.splice(index + 1,
|
|
2961
|
+
tempData.splice(index + 1, deleteCount, ...children);
|
|
2954
2962
|
} else {
|
|
2963
|
+
const children = expandNode(row, level);
|
|
2964
|
+
tempData.splice(index + 1, 0, ...children);
|
|
2965
|
+
}
|
|
2966
|
+
else {
|
|
2955
2967
|
const deleteCount = foldNode(index, tempData, level);
|
|
2956
2968
|
tempData.splice(index + 1, deleteCount);
|
|
2957
2969
|
}
|
|
@@ -3006,6 +3018,17 @@ function useTree(props, dataSourceCopy, rowKeyGen, emits, onDataSourceChange) {
|
|
|
3006
3018
|
isFirstLoad = false;
|
|
3007
3019
|
return result;
|
|
3008
3020
|
}
|
|
3021
|
+
/**
|
|
3022
|
+
* 递归设置目标节点后代到指定层级的展开/折叠状态
|
|
3023
|
+
* en: Recursively set expand/collapse state for descendants up to the target level
|
|
3024
|
+
*/
|
|
3025
|
+
function setDescendantsToLevel(row, currentLevel, targetLevel, expanded) {
|
|
3026
|
+
if (!row.children || currentLevel > targetLevel) return;
|
|
3027
|
+
for (const child of row.children) {
|
|
3028
|
+
setNodeExpanded(child, expanded, currentLevel, row);
|
|
3029
|
+
setDescendantsToLevel(child, currentLevel + 1, targetLevel, expanded);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3009
3032
|
function expandNode(row, level) {
|
|
3010
3033
|
let result = [];
|
|
3011
3034
|
row.children && row.children.forEach((child) => {
|
|
@@ -381,6 +381,8 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
|
|
|
381
381
|
children?: (PrivateRowDT & /*elided*/ any)[];
|
|
382
382
|
}))[], option?: {
|
|
383
383
|
expand?: boolean;
|
|
384
|
+
all?: boolean;
|
|
385
|
+
level?: number;
|
|
384
386
|
}) => void;
|
|
385
387
|
/**
|
|
386
388
|
* 获取拖选选中的单元格信息
|
|
@@ -4,7 +4,26 @@ import { PrivateRowDT, RowKeyGen, UniqKey } from './types';
|
|
|
4
4
|
type DT = PrivateRowDT & {
|
|
5
5
|
children?: DT[];
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type SetTreeExpandOption = {
|
|
8
|
+
/**
|
|
9
|
+
* 是否展开
|
|
10
|
+
* en: Whether to expand
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
8
13
|
expand?: boolean;
|
|
9
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 是否展开所有子节点
|
|
16
|
+
* en: Whether to expand all child nodes
|
|
17
|
+
* @default false
|
|
18
|
+
* @version 1.0.4
|
|
19
|
+
*/
|
|
20
|
+
all?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 展开到第几层
|
|
23
|
+
* en: Expand to the nth level
|
|
24
|
+
* @version 1.0.4
|
|
25
|
+
*/
|
|
26
|
+
level?: number;
|
|
27
|
+
};
|
|
28
|
+
export declare function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen: RowKeyGen, emits: any, onDataSourceChange: () => void): readonly [(row: DT, col: any) => void, (row: (UniqKey | DT) | (UniqKey | DT)[], option?: SetTreeExpandOption) => void, (data: DT[]) => DT[]];
|
|
10
29
|
export {};
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: stk-table-vue
|
|
3
|
-
* version: v1.0.
|
|
3
|
+
* version: v1.0.4
|
|
4
4
|
* description: High performance realtime virtual table for vue3 and vue2.7
|
|
5
5
|
* author: japlus
|
|
6
6
|
* homepage: https://ja-plus.github.io/stk-table-vue/
|
|
7
7
|
* license: MIT
|
|
8
8
|
*/
|
|
9
|
-
import { a as insertToOrderedArray, i as binarySearch, n as registerFeature, o as strCompare, r as useAreaSelection, s as tableSort, t as StkTable_default } from "./StkTable-
|
|
9
|
+
import { a as insertToOrderedArray, i as binarySearch, n as registerFeature, o as strCompare, r as useAreaSelection, s as tableSort, t as StkTable_default } from "./StkTable-DuT_ezDm.js";
|
|
10
10
|
import { Fragment, computed, createApp, createBlock, createElementBlock, createElementVNode, createTextVNode, defineComponent, getCurrentInstance, h, markRaw, nextTick, normalizeClass, openBlock, ref, renderSlot, resolveDynamicComponent, toDisplayString, watch, withModifiers } from "vue";
|
|
11
11
|
//#region src/StkTable/custom-cells/FilterCell/Dropdown/index.ts
|
|
12
12
|
var DropdownIns = null;
|
|
@@ -15,7 +15,7 @@ async function getDropdownIns() {
|
|
|
15
15
|
const div = document.createElement("div");
|
|
16
16
|
div.classList.add("stk-filter-dropdown-wrapper");
|
|
17
17
|
document.body.appendChild(div);
|
|
18
|
-
DropdownIns = createApp(await import("./Dropdown-
|
|
18
|
+
DropdownIns = createApp(await import("./Dropdown-D7PIq_F7.js").then((module) => module.default)).mount(div);
|
|
19
19
|
}
|
|
20
20
|
return DropdownIns;
|
|
21
21
|
}
|
package/lib/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShallowRef
|
|
1
|
+
import { ShallowRef } from 'vue';
|
|
2
2
|
import { EXPANDED_ROW_KEY_PREFIX } from './const';
|
|
3
3
|
import { PrivateRowDT, RowKeyGen, StkTableColumn, UniqKey } from './types';
|
|
4
4
|
type DT = PrivateRowDT;
|
|
@@ -24,7 +24,7 @@ export function useRowExpand(emits: any, dataSourceCopy: ShallowRef<DT[]>, rowKe
|
|
|
24
24
|
*/
|
|
25
25
|
function setRowExpand(rowKeyOrRow: string | undefined | DT, expand?: boolean | null, data?: { col?: StkTableColumn<DT>; silent?: boolean }) {
|
|
26
26
|
let rowKey: UniqKey;
|
|
27
|
-
if (typeof rowKeyOrRow === 'string') {
|
|
27
|
+
if (typeof rowKeyOrRow === 'string' || typeof rowKeyOrRow === 'number') {
|
|
28
28
|
rowKey = rowKeyOrRow;
|
|
29
29
|
} else {
|
|
30
30
|
rowKey = rowKeyGen(rowKeyOrRow);
|
package/src/StkTable/useTree.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
import { ShallowRef
|
|
1
|
+
import { ShallowRef } from 'vue';
|
|
2
2
|
import { PrivateRowDT, RowKeyGen, TreeConfig, UniqKey } from './types';
|
|
3
3
|
|
|
4
4
|
type DT = PrivateRowDT & { children?: DT[] };
|
|
5
5
|
|
|
6
|
+
type SetTreeExpandOption = {
|
|
7
|
+
/**
|
|
8
|
+
* 是否展开
|
|
9
|
+
* en: Whether to expand
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
expand?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 是否展开所有子节点
|
|
15
|
+
* en: Whether to expand all child nodes
|
|
16
|
+
* @default false
|
|
17
|
+
* @version 1.0.4
|
|
18
|
+
*/
|
|
19
|
+
all?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 展开到第几层
|
|
22
|
+
* en: Expand to the nth level
|
|
23
|
+
* @version 1.0.4
|
|
24
|
+
*/
|
|
25
|
+
level?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
6
28
|
export function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen: RowKeyGen, emits: any, onDataSourceChange: () => void) {
|
|
7
29
|
const { defaultExpandAll, defaultExpandKeys, defaultExpandLevel }: TreeConfig = props.treeConfig;
|
|
8
30
|
/** It used to check if it is first load. To execute defaultExpandXXX */
|
|
@@ -18,16 +40,18 @@ export function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen:
|
|
|
18
40
|
* @param row rowKey or row
|
|
19
41
|
* @param option
|
|
20
42
|
* @param option.expand expand or collapse
|
|
43
|
+
* @param option.all expand all descendants
|
|
44
|
+
* @param option.level expand to the nth level
|
|
21
45
|
* @param option.silent if set true, not emit `toggle-tree-expand`, default:false
|
|
22
46
|
*/
|
|
23
|
-
function privateSetTreeExpand(row: (UniqKey | DT) | (UniqKey | DT)[], option:
|
|
47
|
+
function privateSetTreeExpand(row: (UniqKey | DT) | (UniqKey | DT)[], option: SetTreeExpandOption & { col?: any; isClick: boolean }) {
|
|
24
48
|
const rowKeyOrRowArr: (UniqKey | DT)[] = Array.isArray(row) ? row : [row];
|
|
25
49
|
|
|
26
50
|
const tempData = dataSourceCopy.value.slice();
|
|
27
51
|
for (let i = 0; i < rowKeyOrRowArr.length; i++) {
|
|
28
52
|
const rowKeyOrRow = rowKeyOrRowArr[i];
|
|
29
53
|
let rowKey: UniqKey;
|
|
30
|
-
if (typeof rowKeyOrRow === 'string') {
|
|
54
|
+
if (typeof rowKeyOrRow === 'string' || typeof rowKeyOrRow === 'number') {
|
|
31
55
|
rowKey = rowKeyOrRow;
|
|
32
56
|
} else {
|
|
33
57
|
rowKey = rowKeyGen(rowKeyOrRow);
|
|
@@ -40,13 +64,26 @@ export function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen:
|
|
|
40
64
|
|
|
41
65
|
const row = tempData[index];
|
|
42
66
|
const level = row.__T_LV__ || 0;
|
|
67
|
+
const wasExpanded = Boolean(row.__T_EXP__);
|
|
43
68
|
let expanded = option?.expand;
|
|
44
69
|
if (expanded === void 0) {
|
|
45
70
|
expanded = !row.__T_EXP__;
|
|
46
71
|
}
|
|
72
|
+
if (option.all || option.level !== void 0) {
|
|
73
|
+
const targetLevel = option.all ? Infinity : option.level || 0;
|
|
74
|
+
setDescendantsToLevel(row, level + 1, targetLevel, expanded);
|
|
75
|
+
}
|
|
47
76
|
if (expanded) {
|
|
48
|
-
|
|
49
|
-
|
|
77
|
+
if (wasExpanded) {
|
|
78
|
+
// already expanded, rebuild the flattened subtree so newly expanded
|
|
79
|
+
// descendants are inserted into the visible data source
|
|
80
|
+
const deleteCount = foldNode(index, tempData, level);
|
|
81
|
+
const children = expandNode(row, level);
|
|
82
|
+
tempData.splice(index + 1, deleteCount, ...children);
|
|
83
|
+
} else {
|
|
84
|
+
const children = expandNode(row, level);
|
|
85
|
+
tempData.splice(index + 1, 0, ...children);
|
|
86
|
+
}
|
|
50
87
|
} else {
|
|
51
88
|
// delete all child nodes from i
|
|
52
89
|
const deleteCount = foldNode(index, tempData, level);
|
|
@@ -64,7 +101,7 @@ export function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen:
|
|
|
64
101
|
onDataSourceChange();
|
|
65
102
|
}
|
|
66
103
|
|
|
67
|
-
function setTreeExpand(row: (UniqKey | DT) | (UniqKey | DT)[], option?:
|
|
104
|
+
function setTreeExpand(row: (UniqKey | DT) | (UniqKey | DT)[], option?: SetTreeExpandOption) {
|
|
68
105
|
privateSetTreeExpand(row, { ...option, isClick: false });
|
|
69
106
|
}
|
|
70
107
|
|
|
@@ -119,6 +156,18 @@ export function useTree(props: any, dataSourceCopy: ShallowRef<DT[]>, rowKeyGen:
|
|
|
119
156
|
return result;
|
|
120
157
|
}
|
|
121
158
|
|
|
159
|
+
/**
|
|
160
|
+
* 递归设置目标节点后代到指定层级的展开/折叠状态
|
|
161
|
+
* en: Recursively set expand/collapse state for descendants up to the target level
|
|
162
|
+
*/
|
|
163
|
+
function setDescendantsToLevel(row: DT, currentLevel: number, targetLevel: number, expanded: boolean) {
|
|
164
|
+
if (!row.children || currentLevel > targetLevel) return;
|
|
165
|
+
for (const child of row.children) {
|
|
166
|
+
setNodeExpanded(child, expanded, currentLevel, row);
|
|
167
|
+
setDescendantsToLevel(child, currentLevel + 1, targetLevel, expanded);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
122
171
|
function expandNode(row: DT, level: number) {
|
|
123
172
|
let result: DT[] = [];
|
|
124
173
|
row.children &&
|