stk-table-vue 0.8.12 → 0.8.13
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.
|
@@ -157,7 +157,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
157
157
|
* "v" - 仅展示竖线
|
|
158
158
|
* "body-v" - 仅表体展示竖线
|
|
159
159
|
*/
|
|
160
|
-
bordered?: boolean | "h" | "v" | "body-v";
|
|
160
|
+
bordered?: boolean | "h" | "v" | "body-v" | "body-h";
|
|
161
161
|
/**
|
|
162
162
|
* 自动重新计算虚拟滚动高度宽度。默认true
|
|
163
163
|
* [非响应式]
|
|
@@ -526,7 +526,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
526
526
|
* "v" - 仅展示竖线
|
|
527
527
|
* "body-v" - 仅表体展示竖线
|
|
528
528
|
*/
|
|
529
|
-
bordered?: boolean | "h" | "v" | "body-v";
|
|
529
|
+
bordered?: boolean | "h" | "v" | "body-v" | "body-h";
|
|
530
530
|
/**
|
|
531
531
|
* 自动重新计算虚拟滚动高度宽度。默认true
|
|
532
532
|
* [非响应式]
|
|
@@ -714,7 +714,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
714
714
|
rowClassName: (row: DT, i: number) => string | undefined;
|
|
715
715
|
colResizable: boolean | ColResizableConfig<DT>;
|
|
716
716
|
colMinWidth: number;
|
|
717
|
-
bordered: boolean | "h" | "v" | "body-v";
|
|
717
|
+
bordered: boolean | "h" | "v" | "body-v" | "body-h";
|
|
718
718
|
autoResize: boolean | (() => void);
|
|
719
719
|
fixedColShadow: boolean;
|
|
720
720
|
hideHeaderTitle: boolean | string[];
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -227,9 +227,9 @@ const DEFAULT_SORT_CONFIG = {
|
|
|
227
227
|
sortChildren: false
|
|
228
228
|
};
|
|
229
229
|
const DEFAULT_ROW_ACTIVE_CONFIG = {
|
|
230
|
-
enabled:
|
|
230
|
+
enabled: true,
|
|
231
231
|
disabled: () => false,
|
|
232
|
-
revokable:
|
|
232
|
+
revokable: true
|
|
233
233
|
};
|
|
234
234
|
var TagType = /* @__PURE__ */ ((TagType2) => {
|
|
235
235
|
TagType2[TagType2["TH"] = 0] = "TH";
|
|
@@ -917,17 +917,21 @@ function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKeyGen, v
|
|
|
917
917
|
hiddenCellMap.value = {};
|
|
918
918
|
hoverRowMap.value = {};
|
|
919
919
|
});
|
|
920
|
-
function hideCells(rowKey,
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (!
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
920
|
+
function hideCells(rowKey, colKey, colspan, isSelfRow = false, mergeCellKey) {
|
|
921
|
+
const startIndex = tableHeaderLast.value.findIndex((item) => colKeyGen.value(item) === colKey);
|
|
922
|
+
for (let i = startIndex; i < startIndex + colspan; i++) {
|
|
923
|
+
if (!isSelfRow) {
|
|
924
|
+
if (!hoverRowMap.value[rowKey]) hoverRowMap.value[rowKey] = /* @__PURE__ */ new Set();
|
|
925
|
+
hoverRowMap.value[rowKey].add(mergeCellKey);
|
|
926
|
+
}
|
|
927
|
+
if (isSelfRow && i === startIndex) {
|
|
928
|
+
continue;
|
|
928
929
|
}
|
|
929
|
-
|
|
930
|
-
|
|
930
|
+
const nextCol = tableHeaderLast.value[i];
|
|
931
|
+
if (!nextCol) break;
|
|
932
|
+
const nextColKey = colKeyGen.value(nextCol);
|
|
933
|
+
if (!hiddenCellMap.value[rowKey]) hiddenCellMap.value[rowKey] = /* @__PURE__ */ new Set();
|
|
934
|
+
hiddenCellMap.value[rowKey].add(nextColKey);
|
|
931
935
|
}
|
|
932
936
|
}
|
|
933
937
|
function mergeCellsWrapper(row, col, rowIndex, colIndex) {
|
|
@@ -937,21 +941,20 @@ function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKeyGen, v
|
|
|
937
941
|
rowspan = rowspan || 1;
|
|
938
942
|
if (colspan === 1 && rowspan === 1) return;
|
|
939
943
|
const rowKey = rowKeyGen(row);
|
|
940
|
-
const colKey = colKeyGen.value(col);
|
|
941
|
-
const curColIndex = tableHeaderLast.value.findIndex((item) => colKeyGen.value(item) === colKey);
|
|
942
944
|
const curRowIndex = virtual_dataSourcePart.value.findIndex((item) => rowKeyGen(item) === rowKey);
|
|
943
|
-
const mergedCellKey = pureCellKeyGen(rowKey, colKey);
|
|
944
945
|
if (curRowIndex === -1) return;
|
|
946
|
+
const colKey = colKeyGen.value(col);
|
|
947
|
+
const mergedCellKey = pureCellKeyGen(rowKey, colKey);
|
|
945
948
|
for (let i = curRowIndex; i < curRowIndex + rowspan; i++) {
|
|
946
949
|
const row2 = virtual_dataSourcePart.value[i];
|
|
947
950
|
if (!row2) break;
|
|
948
|
-
hideCells(rowKeyGen(row2),
|
|
951
|
+
hideCells(rowKeyGen(row2), colKey, colspan, i === curRowIndex, mergedCellKey);
|
|
949
952
|
}
|
|
950
953
|
return { colspan, rowspan };
|
|
951
954
|
}
|
|
955
|
+
const emptySet = /* @__PURE__ */ new Set();
|
|
952
956
|
function updateHoverMergedCells(rowKey) {
|
|
953
|
-
|
|
954
|
-
hoverMergedCells.value = set || /* @__PURE__ */ new Set();
|
|
957
|
+
hoverMergedCells.value = rowKey === void 0 ? emptySet : hoverRowMap.value[rowKey] || emptySet;
|
|
955
958
|
}
|
|
956
959
|
function updateActiveMergedCells(clear, rowKey) {
|
|
957
960
|
if (!rowActiveProp.value.enabled) return;
|
|
@@ -1721,7 +1724,7 @@ const _hoisted_8 = {
|
|
|
1721
1724
|
};
|
|
1722
1725
|
const _hoisted_9 = ["colspan"];
|
|
1723
1726
|
const _hoisted_10 = { class: "table-cell-wrapper" };
|
|
1724
|
-
const _hoisted_11 = ["
|
|
1727
|
+
const _hoisted_11 = ["onClick", "onMousedown", "onMouseenter", "onMouseleave", "onMouseover"];
|
|
1725
1728
|
const _hoisted_12 = ["title"];
|
|
1726
1729
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1727
1730
|
__name: "StkTable",
|
|
@@ -2123,6 +2126,41 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2123
2126
|
}
|
|
2124
2127
|
return col.title || "";
|
|
2125
2128
|
}
|
|
2129
|
+
function getTDProps(row, col) {
|
|
2130
|
+
const colKey = colKeyGen.value(col);
|
|
2131
|
+
if (!row) {
|
|
2132
|
+
return {
|
|
2133
|
+
style: cellStyleMap.value[TagType.TD].get(colKey)
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
const cellKey = cellKeyGen(row, col);
|
|
2137
|
+
const classList = [col.className, fixedColClassMap.value.get(colKeyGen.value(col))];
|
|
2138
|
+
if (col.mergeCells) {
|
|
2139
|
+
if (hoverMergedCells.value.has(cellKey)) {
|
|
2140
|
+
classList.push("cell-hover");
|
|
2141
|
+
}
|
|
2142
|
+
if (activeMergedCells.value.has(cellKey)) {
|
|
2143
|
+
classList.push("cell-active");
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (props.cellActive && currentSelectedCellKey.value === cellKey) {
|
|
2147
|
+
classList.push("active");
|
|
2148
|
+
}
|
|
2149
|
+
if (col.type === "seq") {
|
|
2150
|
+
classList.push("seq-column");
|
|
2151
|
+
} else if (col.type === "expand" && (row.__EXP__ ? colKeyGen.value(row.__EXP__) === colKeyGen.value(col) : false)) {
|
|
2152
|
+
classList.push("expanded");
|
|
2153
|
+
} else if (col.type === "tree-node" && row.__T_EXP__) {
|
|
2154
|
+
classList.push("tree-expanded");
|
|
2155
|
+
} else if (col.type === "dragRow") {
|
|
2156
|
+
classList.push("drag-row-cell");
|
|
2157
|
+
}
|
|
2158
|
+
return {
|
|
2159
|
+
"data-cell-key": cellKey,
|
|
2160
|
+
style: cellStyleMap.value[TagType.TD].get(colKey),
|
|
2161
|
+
class: classList
|
|
2162
|
+
};
|
|
2163
|
+
}
|
|
2126
2164
|
function onColumnSort(col, click = true, options = {}) {
|
|
2127
2165
|
if (!col) {
|
|
2128
2166
|
console.warn("onColumnSort: not found col:", col);
|
|
@@ -2726,23 +2764,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2726
2764
|
var _a2;
|
|
2727
2765
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
2728
2766
|
!((_a2 = unref(hiddenCellMap)[rowKeyGen(row)]) == null ? void 0 : _a2.has(colKeyGen.value(col))) ? (openBlock(), createElementBlock("td", mergeProps({
|
|
2729
|
-
key: colKeyGen.value(col)
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
unref(fixedColClassMap).get(colKeyGen.value(col)),
|
|
2735
|
-
{
|
|
2736
|
-
"cell-hover": col.mergeCells && unref(hoverMergedCells).has(cellKeyGen(row, col)),
|
|
2737
|
-
"cell-active": col.mergeCells && unref(activeMergedCells).has(cellKeyGen(row, col)),
|
|
2738
|
-
"seq-column": col.type === "seq",
|
|
2739
|
-
active: props.cellActive && currentSelectedCellKey.value === cellKeyGen(row, col),
|
|
2740
|
-
expanded: col.type === "expand" && (row.__EXP__ ? colKeyGen.value(row.__EXP__) === colKeyGen.value(col) : false),
|
|
2741
|
-
"tree-expanded": col.type === "tree-node" && row.__T_EXP__,
|
|
2742
|
-
"drag-row-cell": col.type === "dragRow"
|
|
2743
|
-
}
|
|
2744
|
-
]
|
|
2745
|
-
}, { ref_for: true }, unref(mergeCellsWrapper)(row, col, rowIndex, colIndex), {
|
|
2767
|
+
key: colKeyGen.value(col)
|
|
2768
|
+
}, { ref_for: true }, {
|
|
2769
|
+
...getTDProps(row, col),
|
|
2770
|
+
...unref(mergeCellsWrapper)(row, col, rowIndex, colIndex)
|
|
2771
|
+
}, {
|
|
2746
2772
|
onClick: ($event) => onCellClick($event, row, col, getRowIndex(rowIndex)),
|
|
2747
2773
|
onMousedown: ($event) => onCellMouseDown($event, row, col, getRowIndex(rowIndex)),
|
|
2748
2774
|
onMouseenter: ($event) => onCellMouseEnter($event, row, col),
|
package/package.json
CHANGED
|
@@ -139,22 +139,10 @@
|
|
|
139
139
|
<td
|
|
140
140
|
v-if="!hiddenCellMap[rowKeyGen(row)]?.has(colKeyGen(col))"
|
|
141
141
|
:key="colKeyGen(col)"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
fixedColClassMap.get(colKeyGen(col)),
|
|
147
|
-
{
|
|
148
|
-
'cell-hover': col.mergeCells && hoverMergedCells.has(cellKeyGen(row, col)),
|
|
149
|
-
'cell-active': col.mergeCells && activeMergedCells.has(cellKeyGen(row, col)),
|
|
150
|
-
'seq-column': col.type === 'seq',
|
|
151
|
-
active: props.cellActive && currentSelectedCellKey === cellKeyGen(row, col),
|
|
152
|
-
expanded: col.type === 'expand' && (row.__EXP__ ? colKeyGen(row.__EXP__) === colKeyGen(col) : false),
|
|
153
|
-
'tree-expanded': col.type === 'tree-node' && row.__T_EXP__,
|
|
154
|
-
'drag-row-cell': col.type === 'dragRow',
|
|
155
|
-
},
|
|
156
|
-
]"
|
|
157
|
-
v-bind="mergeCellsWrapper(row, col, rowIndex, colIndex)"
|
|
142
|
+
v-bind="{
|
|
143
|
+
...getTDProps(row, col),
|
|
144
|
+
...mergeCellsWrapper(row, col, rowIndex, colIndex),
|
|
145
|
+
}"
|
|
158
146
|
@click="onCellClick($event, row, col, getRowIndex(rowIndex))"
|
|
159
147
|
@mousedown="onCellMouseDown($event, row, col, getRowIndex(rowIndex))"
|
|
160
148
|
@mouseenter="onCellMouseEnter($event, row, col)"
|
|
@@ -376,7 +364,7 @@ const props = withDefaults(
|
|
|
376
364
|
* "v" - 仅展示竖线
|
|
377
365
|
* "body-v" - 仅表体展示竖线
|
|
378
366
|
*/
|
|
379
|
-
bordered?: boolean | 'h' | 'v' | 'body-v';
|
|
367
|
+
bordered?: boolean | 'h' | 'v' | 'body-v' | 'body-h';
|
|
380
368
|
/**
|
|
381
369
|
* 自动重新计算虚拟滚动高度宽度。默认true
|
|
382
370
|
* [非响应式]
|
|
@@ -1105,6 +1093,47 @@ function getHeaderTitle(col: StkTableColumn<DT>): string {
|
|
|
1105
1093
|
return col.title || '';
|
|
1106
1094
|
}
|
|
1107
1095
|
|
|
1096
|
+
function getTDProps(row: PrivateRowDT | null | undefined, col: StkTableColumn<PrivateRowDT>) {
|
|
1097
|
+
const colKey = colKeyGen.value(col);
|
|
1098
|
+
if (!row) {
|
|
1099
|
+
return {
|
|
1100
|
+
style: cellStyleMap.value[TagType.TD].get(colKey),
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
const cellKey = cellKeyGen(row, col);
|
|
1105
|
+
|
|
1106
|
+
const classList = [col.className, fixedColClassMap.value.get(colKeyGen.value(col))];
|
|
1107
|
+
if (col.mergeCells) {
|
|
1108
|
+
if (hoverMergedCells.value.has(cellKey)) {
|
|
1109
|
+
classList.push('cell-hover');
|
|
1110
|
+
}
|
|
1111
|
+
if (activeMergedCells.value.has(cellKey)) {
|
|
1112
|
+
classList.push('cell-active');
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
if (props.cellActive && currentSelectedCellKey.value === cellKey) {
|
|
1117
|
+
classList.push('active');
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (col.type === 'seq') {
|
|
1121
|
+
classList.push('seq-column');
|
|
1122
|
+
} else if (col.type === 'expand' && (row.__EXP__ ? colKeyGen.value(row.__EXP__) === colKeyGen.value(col) : false)) {
|
|
1123
|
+
classList.push('expanded');
|
|
1124
|
+
} else if (col.type === 'tree-node' && row.__T_EXP__) {
|
|
1125
|
+
classList.push('tree-expanded');
|
|
1126
|
+
} else if (col.type === 'dragRow') {
|
|
1127
|
+
classList.push('drag-row-cell');
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return {
|
|
1131
|
+
'data-cell-key': cellKey,
|
|
1132
|
+
style: cellStyleMap.value[TagType.TD].get(colKey),
|
|
1133
|
+
class: classList,
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1108
1137
|
/**
|
|
1109
1138
|
* 表头点击排序
|
|
1110
1139
|
* @param click 是否为点击表头触发
|
package/src/StkTable/const.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const DEFAULT_SORT_CONFIG = {
|
|
|
44
44
|
} satisfies SortConfig<any>;
|
|
45
45
|
|
|
46
46
|
export const DEFAULT_ROW_ACTIVE_CONFIG: Required<RowActiveOption<any>> = {
|
|
47
|
-
enabled:
|
|
47
|
+
enabled: true,
|
|
48
48
|
disabled: () => false,
|
|
49
|
-
revokable:
|
|
49
|
+
revokable: true,
|
|
50
50
|
};
|
|
@@ -35,20 +35,25 @@ export function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKe
|
|
|
35
35
|
/**
|
|
36
36
|
* abstract the logic of hiding cells
|
|
37
37
|
*/
|
|
38
|
-
function hideCells(rowKey: UniqKey,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
hiddenCellMap.value[rowKey].add(nextColKey);
|
|
38
|
+
function hideCells(rowKey: UniqKey, colKey: UniqKey, colspan: number, isSelfRow = false, mergeCellKey: string) {
|
|
39
|
+
const startIndex = tableHeaderLast.value.findIndex(item => colKeyGen.value(item) === colKey);
|
|
40
|
+
|
|
41
|
+
for (let i = startIndex; i < startIndex + colspan; i++) {
|
|
42
|
+
if(!isSelfRow) {
|
|
43
|
+
// if other row hovered, the rowspan cell need to be highlight
|
|
44
|
+
if (!hoverRowMap.value[rowKey]) hoverRowMap.value[rowKey] = new Set();
|
|
45
|
+
hoverRowMap.value[rowKey].add(mergeCellKey);
|
|
47
46
|
}
|
|
47
|
+
if (isSelfRow && i === startIndex) {
|
|
48
|
+
// self row start cell does not need to be hidden
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const nextCol = tableHeaderLast.value[i];
|
|
52
|
+
if (!nextCol) break;
|
|
53
|
+
const nextColKey = colKeyGen.value(nextCol);
|
|
54
|
+
if (!hiddenCellMap.value[rowKey]) hiddenCellMap.value[rowKey] = new Set();
|
|
55
|
+
hiddenCellMap.value[rowKey].add(nextColKey);
|
|
48
56
|
|
|
49
|
-
// if other row hovered, the rowspan cell need to be highlight
|
|
50
|
-
if (!hoverRowMap.value[rowKey]) hoverRowMap.value[rowKey] = new Set();
|
|
51
|
-
hoverRowMap.value[rowKey].add(mergeCellKey);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -78,25 +83,24 @@ export function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKe
|
|
|
78
83
|
|
|
79
84
|
const rowKey = rowKeyGen(row);
|
|
80
85
|
|
|
81
|
-
const colKey = colKeyGen.value(col);
|
|
82
|
-
const curColIndex = tableHeaderLast.value.findIndex(item => colKeyGen.value(item) === colKey);
|
|
83
86
|
const curRowIndex = virtual_dataSourcePart.value.findIndex(item => rowKeyGen(item) === rowKey);
|
|
84
|
-
const mergedCellKey = pureCellKeyGen(rowKey, colKey);
|
|
85
|
-
|
|
86
87
|
if (curRowIndex === -1) return;
|
|
87
88
|
|
|
89
|
+
const colKey = colKeyGen.value(col);
|
|
90
|
+
const mergedCellKey = pureCellKeyGen(rowKey, colKey);
|
|
91
|
+
|
|
88
92
|
for (let i = curRowIndex; i < curRowIndex + rowspan; i++) {
|
|
89
93
|
const row = virtual_dataSourcePart.value[i];
|
|
90
94
|
if (!row) break;
|
|
91
|
-
hideCells(rowKeyGen(row),
|
|
95
|
+
hideCells(rowKeyGen(row), colKey, colspan, i === curRowIndex, mergedCellKey);
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
return { colspan, rowspan };
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
const emptySet = new Set<string>();
|
|
97
102
|
function updateHoverMergedCells(rowKey: UniqKey | undefined) {
|
|
98
|
-
|
|
99
|
-
hoverMergedCells.value = set || new Set();
|
|
103
|
+
hoverMergedCells.value = rowKey === void 0 ? emptySet : hoverRowMap.value[rowKey] || emptySet;
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
function updateActiveMergedCells(clear?: boolean, rowKey?: UniqKey) {
|