stk-table-vue 0.11.13 → 0.11.15
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 +3 -3
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +2 -1
- 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.15
|
|
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) => {
|
|
@@ -4137,7 +4137,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4137
4137
|
class: "table-cell-wrapper",
|
|
4138
4138
|
tabindex: "-1",
|
|
4139
4139
|
title: row[col.dataIndex] || ""
|
|
4140
|
-
}, toDisplayString((row && row[col.dataIndex])
|
|
4140
|
+
}, toDisplayString((row && row[col.dataIndex]) != null ? row && row[col.dataIndex] : getEmptyCellText.value(col, row)), 9, _hoisted_16)) : col.type === "seq" ? (openBlock(), createElementBlock("div", _hoisted_17, toDisplayString((props.seqConfig.startIndex || 0) + getAbsoluteRowIndex(rowIndex) + 1), 1)) : col.type === "tree-node" ? (openBlock(), createBlock(_sfc_main$3, {
|
|
4141
4141
|
key: 3,
|
|
4142
4142
|
class: "table-cell-wrapper",
|
|
4143
4143
|
tabindex: "-1",
|
package/lib/style.css
CHANGED
package/package.json
CHANGED
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
</template>
|
|
180
180
|
</component>
|
|
181
181
|
<div v-else-if="!col.type" class="table-cell-wrapper" tabindex="-1" :title="row[col.dataIndex] || ''">
|
|
182
|
-
{{ (row && row[col.dataIndex])
|
|
182
|
+
{{ (row && row[col.dataIndex]) != null ? row && row[col.dataIndex] : getEmptyCellText(col, row) }}
|
|
183
183
|
</div>
|
|
184
184
|
<div v-else-if="col.type === 'seq'" class="table-cell-wrapper" tabindex="-1">
|
|
185
185
|
{{ (props.seqConfig.startIndex || 0) + getAbsoluteRowIndex(rowIndex) + 1 }}
|
|
@@ -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 {
|