stk-table-vue 0.11.13 → 0.11.14
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/lib/index-BzpbBYPO.js +1 -1
- package/lib/src/StkTable/useIndexResolver.d.ts +4 -0
- package/lib/stk-table-vue.js +2 -2
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +1 -0
- package/src/StkTable/useIndexResolver.ts +29 -0
- package/src/StkTable/utils/index.ts +1 -1
package/lib/index-BzpbBYPO.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { StkTableColumn, UniqKey } from './types';
|
|
3
|
+
|
|
4
|
+
export declare function useIndexResolver<DT extends Record<string, any>>(dataSourceRef: Ref<DT[]>, columnsRef: Ref<StkTableColumn<DT>[]>, rowKeyGen: (row: DT | null | undefined) => UniqKey): readonly [(row: DT) => number, (column: StkTableColumn<DT>) => number];
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: stk-table-vue
|
|
3
|
-
* version: v0.11.
|
|
3
|
+
* version: v0.11.14
|
|
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/
|
|
@@ -54,7 +54,7 @@ function insertToOrderedArray(sortState, newItem, targetArray, sortConfig = {})
|
|
|
54
54
|
}
|
|
55
55
|
const { emptyToBottom, customCompare, stringLocaleCompare } = { emptyToBottom: false, ...sortConfig };
|
|
56
56
|
const targetVal = newItem[field];
|
|
57
|
-
if (emptyToBottom && isEmptyValue(targetVal)) {
|
|
57
|
+
if (emptyToBottom && isEmptyValue(targetVal, sortType === "number")) {
|
|
58
58
|
data.push(newItem);
|
|
59
59
|
} else {
|
|
60
60
|
const customCompareFn = customCompare || ((a, b) => {
|
package/lib/style.css
CHANGED
package/package.json
CHANGED
|
@@ -296,6 +296,7 @@ import { useTableColumns } from './useTableColumns';
|
|
|
296
296
|
import { useThDrag } from './useThDrag';
|
|
297
297
|
import { useTrDrag } from './useTrDrag';
|
|
298
298
|
import { useTree } from './useTree';
|
|
299
|
+
import { useIndexResolver } from './useIndexResolver';
|
|
299
300
|
import { useVirtualScroll } from './useVirtualScroll';
|
|
300
301
|
import { useWheeling } from './useWheeling';
|
|
301
302
|
import { createStkTableId, getCalculatedColWidth } from './utils/constRefUtils';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { StkTableColumn, UniqKey } from './types';
|
|
3
|
+
|
|
4
|
+
export function useIndexResolver<DT extends Record<string, any>>(
|
|
5
|
+
dataSourceRef: Ref<DT[]>,
|
|
6
|
+
columnsRef: Ref<StkTableColumn<DT>[]>,
|
|
7
|
+
rowKeyGen: (row: DT | null | undefined) => UniqKey,
|
|
8
|
+
) {
|
|
9
|
+
function getRowIndex(row: DT): number {
|
|
10
|
+
const targetKey = rowKeyGen(row);
|
|
11
|
+
const data = dataSourceRef.value;
|
|
12
|
+
for (let i = 0; i < data.length; i++) {
|
|
13
|
+
if (rowKeyGen(data[i]) === targetKey) return i;
|
|
14
|
+
}
|
|
15
|
+
return -1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getColumnIndex(column: StkTableColumn<DT>): number {
|
|
19
|
+
const targetDataIndex = column?.dataIndex;
|
|
20
|
+
if (targetDataIndex === void 0 || targetDataIndex === null) return -1;
|
|
21
|
+
const columns = columnsRef.value;
|
|
22
|
+
for (let i = 0; i < columns.length; i++) {
|
|
23
|
+
if (columns[i]?.dataIndex === targetDataIndex) return i;
|
|
24
|
+
}
|
|
25
|
+
return -1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return [getRowIndex, getColumnIndex] as const;
|
|
29
|
+
}
|
|
@@ -43,7 +43,7 @@ export function insertToOrderedArray<T extends object>(
|
|
|
43
43
|
const { emptyToBottom, customCompare, stringLocaleCompare } = { emptyToBottom: false, ...sortConfig };
|
|
44
44
|
|
|
45
45
|
const targetVal: any = newItem[field];
|
|
46
|
-
if (emptyToBottom && isEmptyValue(targetVal)) {
|
|
46
|
+
if (emptyToBottom && isEmptyValue(targetVal, sortType === 'number')) {
|
|
47
47
|
// 空值排在最下方
|
|
48
48
|
data.push(newItem);
|
|
49
49
|
} else {
|