stk-table-vue 0.6.16 → 0.6.17

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.
@@ -64,17 +64,18 @@ function insertToOrderedArray(sortState, newItem, targetArray, sortConfig = {})
64
64
  data.unshift(newItem);
65
65
  return data;
66
66
  }
67
- if (sortConfig.emptyToBottom && isEmptyValue(newItem)) {
67
+ const targetVal = newItem[dataIndex];
68
+ if (sortConfig.emptyToBottom && isEmptyValue(targetVal)) {
68
69
  data.push(newItem);
70
+ } else {
71
+ const isNumber = sortType === "number";
72
+ const sIndex = binarySearch(data, (midIndex) => {
73
+ const midVal = data[midIndex][dataIndex];
74
+ const compareRes = strCompare(midVal, targetVal, isNumber, sortConfig.stringLocaleCompare);
75
+ return order === "asc" ? compareRes : -compareRes;
76
+ });
77
+ data.splice(sIndex, 0, newItem);
69
78
  }
70
- const isNumber = sortType === "number";
71
- const targetVal = newItem[dataIndex];
72
- const sIndex = binarySearch(data, (midIndex) => {
73
- const midVal = data[midIndex][dataIndex];
74
- const compareRes = strCompare(midVal, targetVal, isNumber, sortConfig.stringLocaleCompare);
75
- return order === "asc" ? compareRes : -compareRes;
76
- });
77
- data.splice(sIndex, 0, newItem);
78
79
  return data;
79
80
  }
80
81
  function binarySearch(searchArray, compareCallback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stk-table-vue",
3
- "version": "0.6.16",
3
+ "version": "0.6.17",
4
4
  "description": "Simple realtime virtual table for vue3 and vue2.7",
5
5
  "main": "./lib/stk-table-vue.js",
6
6
  "types": "./lib/src/StkTable/index.d.ts",
@@ -34,21 +34,21 @@ export function insertToOrderedArray<T extends object>(sortState: SortState<T>,
34
34
  return data;
35
35
  }
36
36
 
37
- if (sortConfig.emptyToBottom && isEmptyValue(newItem)) {
37
+ const targetVal: any = newItem[dataIndex];
38
+ if (sortConfig.emptyToBottom && isEmptyValue(targetVal)) {
38
39
  // 空值排在最下方
39
40
  data.push(newItem);
41
+ } else {
42
+ const isNumber = sortType === 'number';
43
+ // 二分插入
44
+ const sIndex = binarySearch(data, midIndex => {
45
+ const midVal: any = data[midIndex][dataIndex];
46
+ const compareRes = strCompare(midVal, targetVal, isNumber, sortConfig.stringLocaleCompare);
47
+ return order === 'asc' ? compareRes : -compareRes;
48
+ });
49
+ data.splice(sIndex, 0, newItem);
40
50
  }
41
51
 
42
- const isNumber = sortType === 'number';
43
-
44
- // 二分插入
45
- const targetVal: any = newItem[dataIndex];
46
- const sIndex = binarySearch(data, midIndex => {
47
- const midVal: any = data[midIndex][dataIndex];
48
- const compareRes = strCompare(midVal, targetVal, isNumber, sortConfig.stringLocaleCompare);
49
- return order === 'asc' ? compareRes : -compareRes;
50
- });
51
- data.splice(sIndex, 0, newItem);
52
52
  return data;
53
53
  }
54
54