stk-table-vue 0.0.1-beta.3 → 0.0.1-beta.5
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/LICENSE +21 -0
- package/README.md +12 -0
- package/lib/src/StkTable/StkTable.vue.d.ts +20 -20
- package/lib/src/StkTable/index.d.ts +1 -0
- package/lib/src/StkTable/types/index.d.ts +4 -2
- package/lib/stk-table-vue.js +14 -18
- package/lib/style.css +63 -57
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +28 -10
- package/src/StkTable/index.ts +1 -0
- package/src/StkTable/types/index.ts +7 -2
- package/src/StkTable/useAutoResize.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 JA+
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -109,6 +109,18 @@ export type StkProps = Partial<{
|
|
|
109
109
|
|
|
110
110
|
/** 可拖动至最小的列宽 */
|
|
111
111
|
colMinWidth: number;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 单元格分割线。
|
|
115
|
+
* 默认横竖都有
|
|
116
|
+
* "h" - 仅展示横线
|
|
117
|
+
* "v" - 仅展示竖线
|
|
118
|
+
* "body-v" - 仅表体展示竖线
|
|
119
|
+
*/
|
|
120
|
+
bordered: boolean | 'h' | 'v' | 'body-v';
|
|
121
|
+
|
|
122
|
+
/** 自动重新计算虚拟滚动高度宽度。默认true */
|
|
123
|
+
autoResize: boolean;
|
|
112
124
|
}>;
|
|
113
125
|
```
|
|
114
126
|
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
import { SortOption, StkTableColumn } from './types/index';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* TODO:存在的问题:
|
|
5
|
-
* [] column.dataIndex 作为唯一键,不能重复
|
|
6
|
-
* [] 计算的高亮颜色,挂在数据源上对象上,若多个表格使用同一个数据源对象会有问题。需要深拷贝。(解决方案:获取组件uid)
|
|
7
|
-
* [] highlight-row 颜色不能恢复到active的颜色
|
|
3
|
+
* 初始化虚拟滚动参数
|
|
4
|
+
* @param {number} [height] 虚拟滚动的高度
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
declare function initVirtualScroll(height?: number): void;
|
|
10
7
|
/**
|
|
11
8
|
* 选中一行,
|
|
12
9
|
* @param {string} rowKey
|
|
@@ -43,14 +40,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
43
40
|
minWidth: string;
|
|
44
41
|
maxWidth: string;
|
|
45
42
|
fixedMode: boolean;
|
|
46
|
-
headless: boolean;
|
|
43
|
+
headless: boolean; /** 排序切换顺序 */
|
|
47
44
|
theme: "light" | "dark";
|
|
48
45
|
virtual: boolean;
|
|
49
46
|
virtualX: boolean;
|
|
50
47
|
columns: StkTableColumn<any>[];
|
|
51
48
|
dataSource: any[];
|
|
52
|
-
rowKey: import(
|
|
53
|
-
colKey: import(
|
|
49
|
+
rowKey: import("./types/index").UniqKey;
|
|
50
|
+
colKey: import("./types/index").UniqKey;
|
|
54
51
|
emptyCellText: string;
|
|
55
52
|
noDataFull: boolean;
|
|
56
53
|
showNoData: boolean;
|
|
@@ -62,7 +59,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
62
59
|
rowClassName: (row: any, i: number) => string;
|
|
63
60
|
colResizable: boolean;
|
|
64
61
|
colMinWidth: number;
|
|
65
|
-
|
|
62
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
66
63
|
}>>, {
|
|
67
64
|
width: string;
|
|
68
65
|
fixedMode: boolean;
|
|
@@ -87,8 +84,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
87
84
|
rowClassName: () => "";
|
|
88
85
|
colResizable: boolean;
|
|
89
86
|
colMinWidth: number;
|
|
90
|
-
|
|
87
|
+
bordered: boolean;
|
|
91
88
|
}>, {
|
|
89
|
+
initVirtualScroll: typeof initVirtualScroll;
|
|
90
|
+
initVirtualScrollX: () => void;
|
|
91
|
+
initVirtualScrollY: (height?: number | undefined) => void;
|
|
92
92
|
setCurrentRow: typeof setCurrentRow;
|
|
93
93
|
setHighlightDimCell: (rowKeyValue: string, dataIndex: string) => void;
|
|
94
94
|
setHighlightDimRow: (rowKeyValues: (string | number)[]) => void;
|
|
@@ -115,14 +115,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
115
115
|
minWidth: string;
|
|
116
116
|
maxWidth: string;
|
|
117
117
|
fixedMode: boolean;
|
|
118
|
-
headless: boolean;
|
|
118
|
+
headless: boolean; /** 排序切换顺序 */
|
|
119
119
|
theme: "light" | "dark";
|
|
120
120
|
virtual: boolean;
|
|
121
121
|
virtualX: boolean;
|
|
122
122
|
columns: StkTableColumn<any>[];
|
|
123
123
|
dataSource: any[];
|
|
124
|
-
rowKey: import(
|
|
125
|
-
colKey: import(
|
|
124
|
+
rowKey: import("./types/index").UniqKey;
|
|
125
|
+
colKey: import("./types/index").UniqKey;
|
|
126
126
|
emptyCellText: string;
|
|
127
127
|
noDataFull: boolean;
|
|
128
128
|
showNoData: boolean;
|
|
@@ -134,7 +134,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
134
134
|
rowClassName: (row: any, i: number) => string;
|
|
135
135
|
colResizable: boolean;
|
|
136
136
|
colMinWidth: number;
|
|
137
|
-
|
|
137
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
138
138
|
}>>, {
|
|
139
139
|
width: string;
|
|
140
140
|
fixedMode: boolean;
|
|
@@ -159,7 +159,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
159
159
|
rowClassName: () => "";
|
|
160
160
|
colResizable: boolean;
|
|
161
161
|
colMinWidth: number;
|
|
162
|
-
|
|
162
|
+
bordered: boolean;
|
|
163
163
|
}>>> & {
|
|
164
164
|
onScroll?: ((...args: any[]) => any) | undefined;
|
|
165
165
|
"onTh-drag-start"?: ((...args: any[]) => any) | undefined;
|
|
@@ -178,7 +178,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
178
178
|
width: string;
|
|
179
179
|
minWidth: string;
|
|
180
180
|
maxWidth: string;
|
|
181
|
-
colKey: import(
|
|
181
|
+
colKey: import("./types/index").UniqKey;
|
|
182
182
|
fixedMode: boolean;
|
|
183
183
|
headless: boolean;
|
|
184
184
|
theme: "light" | "dark";
|
|
@@ -186,7 +186,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
186
186
|
virtualX: boolean;
|
|
187
187
|
columns: StkTableColumn<any>[];
|
|
188
188
|
dataSource: any[];
|
|
189
|
-
rowKey: import(
|
|
189
|
+
rowKey: import("./types/index").UniqKey;
|
|
190
190
|
emptyCellText: string;
|
|
191
191
|
noDataFull: boolean;
|
|
192
192
|
showNoData: boolean;
|
|
@@ -198,7 +198,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
198
198
|
rowClassName: (row: any, i: number) => string;
|
|
199
199
|
colResizable: boolean;
|
|
200
200
|
colMinWidth: number;
|
|
201
|
-
|
|
201
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
202
202
|
}, {}>, {
|
|
203
203
|
tableHeader?(_: {
|
|
204
204
|
column: StkTableColumn<any>;
|
|
@@ -113,8 +113,10 @@ export type StkProps = Partial<{
|
|
|
113
113
|
/**
|
|
114
114
|
* 单元格分割线。
|
|
115
115
|
* 默认横竖都有
|
|
116
|
-
*
|
|
116
|
+
* "h" - 仅展示横线
|
|
117
|
+
* "v" - 仅展示竖线
|
|
118
|
+
* "body-v" - 仅表体展示竖线
|
|
117
119
|
*/
|
|
118
|
-
|
|
120
|
+
bordered: boolean | 'h' | 'v' | 'body-v';
|
|
119
121
|
}>;
|
|
120
122
|
export {};
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, onMounted, onBeforeUnmount, computed, defineComponent, shallowRef, watch, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, withDirectives, createElementVNode, vShow, Fragment, renderList, createCommentVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, createTextVNode
|
|
1
|
+
import { ref, onMounted, onBeforeUnmount, computed, defineComponent, shallowRef, watch, toRaw, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, withDirectives, createElementVNode, vShow, Fragment, renderList, createCommentVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, createTextVNode } from "vue";
|
|
2
2
|
import { interpolateRgb } from "d3-interpolate";
|
|
3
3
|
const Default_Col_Width = "100";
|
|
4
4
|
const Default_Table_Height = 100;
|
|
@@ -492,7 +492,6 @@ function howDeepTheColumn(arr, level = 1) {
|
|
|
492
492
|
});
|
|
493
493
|
return Math.max(...levels);
|
|
494
494
|
}
|
|
495
|
-
const _withScopeId = (n) => (pushScopeId("data-v-a99d823a"), n = n(), popScopeId(), n);
|
|
496
495
|
const _hoisted_1 = { key: 0 };
|
|
497
496
|
const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
498
497
|
const _hoisted_3 = { class: "table-header-cell-wrapper" };
|
|
@@ -501,7 +500,7 @@ const _hoisted_5 = {
|
|
|
501
500
|
key: 2,
|
|
502
501
|
class: "table-header-sorter"
|
|
503
502
|
};
|
|
504
|
-
const _hoisted_6 = /* @__PURE__ */
|
|
503
|
+
const _hoisted_6 = /* @__PURE__ */ createElementVNode("svg", {
|
|
505
504
|
xmlns: "http://www.w3.org/2000/svg",
|
|
506
505
|
width: "16px",
|
|
507
506
|
height: "16px",
|
|
@@ -519,7 +518,7 @@ const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
519
518
|
points: "8 10 4.8 14 11.2 14"
|
|
520
519
|
})
|
|
521
520
|
])
|
|
522
|
-
], -1)
|
|
521
|
+
], -1);
|
|
523
522
|
const _hoisted_7 = [
|
|
524
523
|
_hoisted_6
|
|
525
524
|
];
|
|
@@ -564,7 +563,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
564
563
|
rowClassName: { type: Function, default: () => "" },
|
|
565
564
|
colResizable: { type: Boolean, default: false },
|
|
566
565
|
colMinWidth: { default: 10 },
|
|
567
|
-
|
|
566
|
+
bordered: { type: [Boolean, String], default: true }
|
|
568
567
|
},
|
|
569
568
|
emits: [
|
|
570
569
|
"sort-change",
|
|
@@ -904,6 +903,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
904
903
|
return toRaw(dataSourceCopy.value);
|
|
905
904
|
}
|
|
906
905
|
__expose({
|
|
906
|
+
initVirtualScroll,
|
|
907
|
+
initVirtualScrollX,
|
|
908
|
+
initVirtualScrollY,
|
|
907
909
|
setCurrentRow,
|
|
908
910
|
setHighlightDimCell,
|
|
909
911
|
setHighlightDimRow,
|
|
@@ -922,8 +924,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
922
924
|
dark: _ctx.theme === "dark",
|
|
923
925
|
headless: _ctx.headless,
|
|
924
926
|
"is-col-resizing": unref(isColResizing),
|
|
925
|
-
border: props.
|
|
926
|
-
"border-
|
|
927
|
+
border: props.bordered,
|
|
928
|
+
"border-h": props.bordered === "h",
|
|
929
|
+
"border-v": props.bordered === "v",
|
|
930
|
+
"border-body-v": props.bordered === "body-v"
|
|
927
931
|
}]),
|
|
928
932
|
style: normalizeStyle(_ctx.virtual && { "--row-height": unref(virtualScroll).rowHeight + "px" }),
|
|
929
933
|
onScroll: onTableScroll,
|
|
@@ -992,7 +996,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
992
996
|
column: col
|
|
993
997
|
}, () => [
|
|
994
998
|
createElementVNode("span", _hoisted_4, toDisplayString(col.title), 1)
|
|
995
|
-
]
|
|
999
|
+
]),
|
|
996
1000
|
col.sorter ? (openBlock(), createElementBlock("span", _hoisted_5, _hoisted_7)) : createCommentVNode("", true),
|
|
997
1001
|
_ctx.colResizable && colIndex > 0 ? (openBlock(), createElementBlock("div", {
|
|
998
1002
|
key: 3,
|
|
@@ -1083,22 +1087,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1083
1087
|
}, [
|
|
1084
1088
|
renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
1085
1089
|
createTextVNode("暂无数据")
|
|
1086
|
-
]
|
|
1090
|
+
])
|
|
1087
1091
|
], 2)) : createCommentVNode("", true)
|
|
1088
1092
|
], 38);
|
|
1089
1093
|
};
|
|
1090
1094
|
}
|
|
1091
1095
|
});
|
|
1092
|
-
const _export_sfc = (sfc, props) => {
|
|
1093
|
-
const target = sfc.__vccOpts || sfc;
|
|
1094
|
-
for (const [key, val] of props) {
|
|
1095
|
-
target[key] = val;
|
|
1096
|
-
}
|
|
1097
|
-
return target;
|
|
1098
|
-
};
|
|
1099
|
-
const StkTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a99d823a"]]);
|
|
1100
1096
|
export {
|
|
1101
|
-
StkTable,
|
|
1097
|
+
_sfc_main as StkTable,
|
|
1102
1098
|
insertToOrderedArray,
|
|
1103
1099
|
tableSort
|
|
1104
1100
|
};
|
package/lib/style.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.stk-table
|
|
1
|
+
.stk-table {
|
|
2
2
|
--row-height: 28px;
|
|
3
3
|
--cell-padding-x: 8px;
|
|
4
4
|
--resize-handle-width: 4px;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
/** 列宽调整指示器 */
|
|
29
29
|
/**虚拟滚动模式 */
|
|
30
30
|
}
|
|
31
|
-
.stk-table.dark
|
|
31
|
+
.stk-table.dark {
|
|
32
32
|
--th-bgc: #181c21;
|
|
33
33
|
--td-bgc: #181c21;
|
|
34
34
|
--border-color: #26292e;
|
|
@@ -43,39 +43,45 @@
|
|
|
43
43
|
--col-resize-indicator-color: #5d6064;
|
|
44
44
|
color: #d0d1d2;
|
|
45
45
|
}
|
|
46
|
-
.stk-table.headless
|
|
46
|
+
.stk-table.headless {
|
|
47
47
|
border-top: 1px solid var(--border-color);
|
|
48
48
|
}
|
|
49
|
-
.stk-table.is-col-resizing th
|
|
49
|
+
.stk-table.is-col-resizing th {
|
|
50
50
|
pointer-events: none;
|
|
51
51
|
}
|
|
52
|
-
.stk-table.border-
|
|
52
|
+
.stk-table.border-h {
|
|
53
53
|
--bg-border-right: linear-gradient(transparent, transparent);
|
|
54
54
|
--bg-border-left: linear-gradient(transparent, transparent);
|
|
55
55
|
}
|
|
56
|
-
.stk-table.border
|
|
57
|
-
|
|
56
|
+
.stk-table.border-v {
|
|
57
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
58
|
+
}
|
|
59
|
+
.stk-table.border .stk-table-main th,
|
|
60
|
+
.stk-table.border .stk-table-main td {
|
|
58
61
|
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
59
62
|
}
|
|
60
|
-
.stk-table.border .stk-table-main thead tr:first-child th
|
|
63
|
+
.stk-table.border .stk-table-main thead tr:first-child th {
|
|
61
64
|
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
62
65
|
}
|
|
63
|
-
.stk-table.border .stk-table-main thead tr:first-child th
|
|
66
|
+
.stk-table.border .stk-table-main thead tr:first-child th:first-child {
|
|
64
67
|
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
65
68
|
}
|
|
66
|
-
.stk-table.border .stk-table-main thead tr th
|
|
69
|
+
.stk-table.border .stk-table-main thead tr th:first-child {
|
|
67
70
|
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
68
71
|
}
|
|
69
|
-
.stk-table.border .stk-table-main tbody td
|
|
72
|
+
.stk-table.border .stk-table-main tbody td:first-child {
|
|
70
73
|
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
71
74
|
}
|
|
72
|
-
.stk-table.border.virtual-x .stk-table-main thead tr:first-child .virtual-x-left + th
|
|
75
|
+
.stk-table.border.virtual-x .stk-table-main thead tr:first-child .virtual-x-left + th {
|
|
73
76
|
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
74
77
|
}
|
|
75
|
-
.stk-table.border.virtual-x .stk-table-main tr .virtual-x-left + th
|
|
78
|
+
.stk-table.border.virtual-x .stk-table-main tr .virtual-x-left + th {
|
|
76
79
|
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
77
80
|
}
|
|
78
|
-
.stk-table
|
|
81
|
+
.stk-table.border-body-v .stk-table-main tbody {
|
|
82
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
83
|
+
}
|
|
84
|
+
.stk-table .column-resize-indicator {
|
|
79
85
|
width: 0;
|
|
80
86
|
height: 100%;
|
|
81
87
|
border-left: 1px dashed var(--col-resize-indicator-color);
|
|
@@ -84,122 +90,122 @@
|
|
|
84
90
|
display: none;
|
|
85
91
|
pointer-events: none;
|
|
86
92
|
}
|
|
87
|
-
.stk-table .stk-table-main
|
|
93
|
+
.stk-table .stk-table-main {
|
|
88
94
|
border-spacing: 0;
|
|
89
95
|
border-collapse: separate;
|
|
90
96
|
}
|
|
91
|
-
.stk-table .stk-table-main.fixed-mode
|
|
97
|
+
.stk-table .stk-table-main.fixed-mode {
|
|
92
98
|
table-layout: fixed;
|
|
93
99
|
}
|
|
94
|
-
.stk-table .stk-table-main th
|
|
95
|
-
.stk-table .stk-table-main td
|
|
100
|
+
.stk-table .stk-table-main th,
|
|
101
|
+
.stk-table .stk-table-main td {
|
|
96
102
|
z-index: 1;
|
|
97
103
|
height: var(--row-height);
|
|
98
104
|
font-size: 14px;
|
|
99
105
|
box-sizing: border-box;
|
|
100
106
|
padding: 0 var(--cell-padding-x);
|
|
101
107
|
}
|
|
102
|
-
.stk-table .stk-table-main thead tr:first-child th
|
|
108
|
+
.stk-table .stk-table-main thead tr:first-child th {
|
|
103
109
|
position: sticky;
|
|
104
110
|
top: 0;
|
|
105
111
|
}
|
|
106
|
-
.stk-table .stk-table-main thead tr th
|
|
112
|
+
.stk-table .stk-table-main thead tr th {
|
|
107
113
|
background-color: var(--th-bgc);
|
|
108
114
|
}
|
|
109
|
-
.stk-table .stk-table-main thead tr th.sortable
|
|
115
|
+
.stk-table .stk-table-main thead tr th.sortable {
|
|
110
116
|
cursor: pointer;
|
|
111
117
|
}
|
|
112
|
-
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper
|
|
118
|
+
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper {
|
|
113
119
|
white-space: nowrap;
|
|
114
120
|
overflow: hidden;
|
|
115
121
|
}
|
|
116
|
-
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper .table-header-title
|
|
122
|
+
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper .table-header-title {
|
|
117
123
|
text-overflow: ellipsis;
|
|
118
124
|
overflow: hidden;
|
|
119
125
|
}
|
|
120
|
-
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-up
|
|
126
|
+
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-up {
|
|
121
127
|
fill: var(--sort-arrow-hover-color);
|
|
122
128
|
}
|
|
123
|
-
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-down
|
|
129
|
+
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-down {
|
|
124
130
|
fill: var(--sort-arrow-hover-color);
|
|
125
131
|
}
|
|
126
|
-
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-up
|
|
132
|
+
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-up {
|
|
127
133
|
fill: var(--sort-arrow-active-sub-color);
|
|
128
134
|
}
|
|
129
|
-
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-down
|
|
135
|
+
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-down {
|
|
130
136
|
fill: var(--sort-arrow-active-color);
|
|
131
137
|
}
|
|
132
|
-
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-up
|
|
138
|
+
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-up {
|
|
133
139
|
fill: var(--sort-arrow-active-color);
|
|
134
140
|
}
|
|
135
|
-
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-down
|
|
141
|
+
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-down {
|
|
136
142
|
fill: var(--sort-arrow-active-sub-color);
|
|
137
143
|
}
|
|
138
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper
|
|
144
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper {
|
|
139
145
|
max-width: 100%;
|
|
140
146
|
display: inline-flex;
|
|
141
147
|
align-items: center;
|
|
142
148
|
}
|
|
143
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-title
|
|
149
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-title {
|
|
144
150
|
overflow: hidden;
|
|
145
151
|
align-self: flex-start;
|
|
146
152
|
}
|
|
147
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter
|
|
153
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter {
|
|
148
154
|
flex-shrink: 0;
|
|
149
155
|
margin-left: 4px;
|
|
150
156
|
width: 16px;
|
|
151
157
|
height: 16px;
|
|
152
158
|
}
|
|
153
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-up
|
|
154
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-down
|
|
159
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-up,
|
|
160
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-down {
|
|
155
161
|
fill: var(--sort-arrow-color);
|
|
156
162
|
}
|
|
157
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer
|
|
163
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer {
|
|
158
164
|
position: absolute;
|
|
159
165
|
top: 0;
|
|
160
166
|
bottom: 0;
|
|
161
167
|
cursor: col-resize;
|
|
162
168
|
width: var(--resize-handle-width);
|
|
163
169
|
}
|
|
164
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.left
|
|
170
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.left {
|
|
165
171
|
left: 0;
|
|
166
172
|
}
|
|
167
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.right
|
|
173
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.right {
|
|
168
174
|
right: 0;
|
|
169
175
|
}
|
|
170
|
-
.stk-table .stk-table-main tbody
|
|
176
|
+
.stk-table .stk-table-main tbody {
|
|
171
177
|
/**高亮渐暗 */
|
|
172
178
|
}
|
|
173
|
-
@keyframes dim
|
|
179
|
+
@keyframes dim {
|
|
174
180
|
from {
|
|
175
181
|
background-color: var(--highlight-color);
|
|
176
182
|
}
|
|
177
183
|
}
|
|
178
|
-
.stk-table .stk-table-main tbody tr
|
|
184
|
+
.stk-table .stk-table-main tbody tr {
|
|
179
185
|
background-color: var(--td-bgc);
|
|
180
186
|
}
|
|
181
|
-
.stk-table .stk-table-main tbody tr.highlight-row
|
|
182
|
-
animation: dim
|
|
187
|
+
.stk-table .stk-table-main tbody tr.highlight-row {
|
|
188
|
+
animation: dim 2s linear;
|
|
183
189
|
}
|
|
184
|
-
.stk-table .stk-table-main tbody tr.hover
|
|
185
|
-
.stk-table .stk-table-main tbody tr
|
|
190
|
+
.stk-table .stk-table-main tbody tr.hover,
|
|
191
|
+
.stk-table .stk-table-main tbody tr:hover {
|
|
186
192
|
background-color: var(--tr-hover-bgc);
|
|
187
193
|
}
|
|
188
|
-
.stk-table .stk-table-main tbody tr.active
|
|
194
|
+
.stk-table .stk-table-main tbody tr.active {
|
|
189
195
|
background-color: var(--tr-active-bgc);
|
|
190
196
|
}
|
|
191
|
-
.stk-table .stk-table-main tbody tr td.fixed-cell
|
|
197
|
+
.stk-table .stk-table-main tbody tr td.fixed-cell {
|
|
192
198
|
background-color: inherit;
|
|
193
199
|
}
|
|
194
|
-
.stk-table .stk-table-main tbody tr td.highlight-cell
|
|
195
|
-
animation: dim
|
|
200
|
+
.stk-table .stk-table-main tbody tr td.highlight-cell {
|
|
201
|
+
animation: dim 2s linear;
|
|
196
202
|
}
|
|
197
|
-
.stk-table .stk-table-main tbody tr td.text-overflow .table-cell-wrapper
|
|
203
|
+
.stk-table .stk-table-main tbody tr td.text-overflow .table-cell-wrapper {
|
|
198
204
|
white-space: nowrap;
|
|
199
205
|
overflow: hidden;
|
|
200
206
|
text-overflow: ellipsis;
|
|
201
207
|
}
|
|
202
|
-
.stk-table .stk-table-no-data
|
|
208
|
+
.stk-table .stk-table-no-data {
|
|
203
209
|
background-color: var(--table-bgc);
|
|
204
210
|
line-height: var(--row-height);
|
|
205
211
|
text-align: center;
|
|
@@ -214,27 +220,27 @@ from {
|
|
|
214
220
|
align-items: center;
|
|
215
221
|
justify-content: center;
|
|
216
222
|
}
|
|
217
|
-
.stk-table .stk-table-no-data.no-data-full
|
|
223
|
+
.stk-table .stk-table-no-data.no-data-full {
|
|
218
224
|
flex: 1;
|
|
219
225
|
}
|
|
220
|
-
.stk-table.virtual .stk-table-main thead tr th .table-header-cell-wrapper
|
|
226
|
+
.stk-table.virtual .stk-table-main thead tr th .table-header-cell-wrapper {
|
|
221
227
|
overflow: hidden;
|
|
222
228
|
max-height: var(--row-height);
|
|
223
229
|
}
|
|
224
|
-
.stk-table.virtual .stk-table-main tbody
|
|
230
|
+
.stk-table.virtual .stk-table-main tbody {
|
|
225
231
|
position: relative;
|
|
226
232
|
}
|
|
227
|
-
.stk-table.virtual .stk-table-main tbody tr.padding-top-tr td
|
|
233
|
+
.stk-table.virtual .stk-table-main tbody tr.padding-top-tr td {
|
|
228
234
|
height: 0;
|
|
229
235
|
}
|
|
230
|
-
.stk-table.virtual .stk-table-main tbody tr td
|
|
236
|
+
.stk-table.virtual .stk-table-main tbody tr td {
|
|
231
237
|
height: var(--row-height);
|
|
232
238
|
line-height: 1;
|
|
233
239
|
}
|
|
234
|
-
.stk-table.virtual .stk-table-main tbody tr td .table-cell-wrapper
|
|
240
|
+
.stk-table.virtual .stk-table-main tbody tr td .table-cell-wrapper {
|
|
235
241
|
max-height: var(--row-height);
|
|
236
242
|
overflow: hidden;
|
|
237
243
|
}
|
|
238
|
-
.stk-table.virtual-x .stk-table-main .virtual-x-left
|
|
244
|
+
.stk-table.virtual-x .stk-table-main .virtual-x-left {
|
|
239
245
|
padding: 0;
|
|
240
246
|
}
|
package/package.json
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
dark: theme === 'dark',
|
|
9
9
|
headless,
|
|
10
10
|
'is-col-resizing': isColResizing,
|
|
11
|
-
border: props.
|
|
12
|
-
'border-
|
|
11
|
+
border: props.bordered,
|
|
12
|
+
'border-h': props.bordered === 'h',
|
|
13
|
+
'border-v': props.bordered === 'v',
|
|
14
|
+
'border-body-v': props.bordered === 'body-v',
|
|
13
15
|
}"
|
|
14
16
|
:style="virtual && { '--row-height': virtualScroll.rowHeight + 'px' }"
|
|
15
17
|
@scroll="onTableScroll"
|
|
@@ -187,9 +189,10 @@
|
|
|
187
189
|
* [] 计算的高亮颜色,挂在数据源上对象上,若多个表格使用同一个数据源对象会有问题。需要深拷贝。(解决方案:获取组件uid)
|
|
188
190
|
* [] highlight-row 颜色不能恢复到active的颜色
|
|
189
191
|
*/
|
|
190
|
-
import { Order, SortOption, StkProps, StkTableColumn } from '@/StkTable/types/index';
|
|
191
192
|
import { CSSProperties, computed, onMounted, ref, shallowRef, toRaw, watch } from 'vue';
|
|
192
193
|
import { Default_Col_Width, Is_Legacy_Mode } from './const';
|
|
194
|
+
import { Order, SortOption, StkProps, StkTableColumn } from './types/index';
|
|
195
|
+
import { useAutoResize } from './useAutoResize';
|
|
193
196
|
import { useColResize } from './useColResize';
|
|
194
197
|
import { useHighlight } from './useHighlight';
|
|
195
198
|
import { useThDrag } from './useThDrag';
|
|
@@ -220,7 +223,8 @@ const props = withDefaults(defineProps<StkProps>(), {
|
|
|
220
223
|
rowClassName: () => '',
|
|
221
224
|
colResizable: false,
|
|
222
225
|
colMinWidth: 10,
|
|
223
|
-
|
|
226
|
+
bordered: true,
|
|
227
|
+
autoResize: true,
|
|
224
228
|
});
|
|
225
229
|
|
|
226
230
|
const emit = defineEmits([
|
|
@@ -331,6 +335,8 @@ const {
|
|
|
331
335
|
*/
|
|
332
336
|
const { setHighlightDimCell, setHighlightDimRow } = useHighlight({ props, tableContainer, rowKeyGen });
|
|
333
337
|
|
|
338
|
+
useAutoResize({ initVirtualScroll, props, debounceMs: 500 });
|
|
339
|
+
|
|
334
340
|
watch(
|
|
335
341
|
() => props.columns,
|
|
336
342
|
() => {
|
|
@@ -692,6 +698,9 @@ function getTableData() {
|
|
|
692
698
|
}
|
|
693
699
|
|
|
694
700
|
defineExpose({
|
|
701
|
+
initVirtualScroll,
|
|
702
|
+
initVirtualScrollX,
|
|
703
|
+
initVirtualScrollY,
|
|
695
704
|
setCurrentRow,
|
|
696
705
|
setHighlightDimCell,
|
|
697
706
|
setHighlightDimRow,
|
|
@@ -702,7 +711,7 @@ defineExpose({
|
|
|
702
711
|
});
|
|
703
712
|
</script>
|
|
704
713
|
|
|
705
|
-
<style lang="less"
|
|
714
|
+
<style lang="less">
|
|
706
715
|
.stk-table {
|
|
707
716
|
// contain: strict;
|
|
708
717
|
--row-height: 28px;
|
|
@@ -770,10 +779,13 @@ defineExpose({
|
|
|
770
779
|
&.is-col-resizing th {
|
|
771
780
|
pointer-events: none;
|
|
772
781
|
}
|
|
773
|
-
&.border-
|
|
782
|
+
&.border-h {
|
|
774
783
|
--bg-border-right: linear-gradient(transparent, transparent);
|
|
775
784
|
--bg-border-left: linear-gradient(transparent, transparent);
|
|
776
785
|
}
|
|
786
|
+
&.border-v {
|
|
787
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
788
|
+
}
|
|
777
789
|
|
|
778
790
|
&.border {
|
|
779
791
|
.stk-table-main {
|
|
@@ -819,6 +831,13 @@ defineExpose({
|
|
|
819
831
|
}
|
|
820
832
|
}
|
|
821
833
|
}
|
|
834
|
+
&.border-body-v {
|
|
835
|
+
.stk-table-main {
|
|
836
|
+
tbody {
|
|
837
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
822
841
|
|
|
823
842
|
/** 列宽调整指示器 */
|
|
824
843
|
.column-resize-indicator {
|
|
@@ -884,7 +903,7 @@ defineExpose({
|
|
|
884
903
|
}
|
|
885
904
|
|
|
886
905
|
&.sorter-desc .table-header-cell-wrapper .table-header-sorter {
|
|
887
|
-
|
|
906
|
+
display: initial;
|
|
888
907
|
#arrow-up {
|
|
889
908
|
fill: var(--sort-arrow-active-sub-color);
|
|
890
909
|
}
|
|
@@ -895,7 +914,7 @@ defineExpose({
|
|
|
895
914
|
}
|
|
896
915
|
|
|
897
916
|
&.sorter-asc .table-header-cell-wrapper .table-header-sorter {
|
|
898
|
-
|
|
917
|
+
display: initial;
|
|
899
918
|
#arrow-up {
|
|
900
919
|
fill: var(--sort-arrow-active-color);
|
|
901
920
|
}
|
|
@@ -920,8 +939,7 @@ defineExpose({
|
|
|
920
939
|
margin-left: 4px;
|
|
921
940
|
width: 16px;
|
|
922
941
|
height: 16px;
|
|
923
|
-
|
|
924
|
-
// display:none;
|
|
942
|
+
display: none;
|
|
925
943
|
#arrow-up,
|
|
926
944
|
#arrow-down {
|
|
927
945
|
fill: var(--sort-arrow-color);
|
package/src/StkTable/index.ts
CHANGED
|
@@ -135,7 +135,12 @@ export type StkProps = Partial<{
|
|
|
135
135
|
/**
|
|
136
136
|
* 单元格分割线。
|
|
137
137
|
* 默认横竖都有
|
|
138
|
-
*
|
|
138
|
+
* "h" - 仅展示横线
|
|
139
|
+
* "v" - 仅展示竖线
|
|
140
|
+
* "body-v" - 仅表体展示竖线
|
|
139
141
|
*/
|
|
140
|
-
|
|
142
|
+
bordered: boolean | 'h' | 'v' | 'body-v';
|
|
143
|
+
|
|
144
|
+
/** 自动重新计算虚拟滚动高度宽度。默认true */
|
|
145
|
+
autoResize: boolean;
|
|
141
146
|
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted } from 'vue';
|
|
2
|
+
|
|
3
|
+
type Options = {
|
|
4
|
+
initVirtualScroll: () => void;
|
|
5
|
+
props: any;
|
|
6
|
+
/** 防抖延时 */
|
|
7
|
+
debounceMs: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 窗口变化自动重置虚拟滚动
|
|
11
|
+
* @param param0
|
|
12
|
+
*/
|
|
13
|
+
export function useAutoResize({ initVirtualScroll, props, debounceMs }: Options) {
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
window.addEventListener('resize', resizeCallback);
|
|
16
|
+
});
|
|
17
|
+
onBeforeUnmount(() => {
|
|
18
|
+
window.removeEventListener('resize', resizeCallback);
|
|
19
|
+
});
|
|
20
|
+
let debounceTime = 0;
|
|
21
|
+
function resizeCallback() {
|
|
22
|
+
if (debounceTime) {
|
|
23
|
+
window.clearTimeout(debounceTime);
|
|
24
|
+
}
|
|
25
|
+
debounceTime = window.setTimeout(() => {
|
|
26
|
+
// TODO: 使用ResizeObserver 监听。
|
|
27
|
+
if (props.autoResize) {
|
|
28
|
+
scrollTo();
|
|
29
|
+
initVirtualScroll();
|
|
30
|
+
}
|
|
31
|
+
debounceTime = 0;
|
|
32
|
+
}, debounceMs);
|
|
33
|
+
}
|
|
34
|
+
}
|