stk-table-vue 0.0.1-beta.2 → 0.0.1-beta.4
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 +103 -21
- package/lib/{StkTable → src/StkTable}/StkTable.vue.d.ts +11 -4
- package/lib/{StkTable → src/StkTable}/types/index.d.ts +33 -3
- package/lib/src/StkTable/utils.d.ts +23 -0
- package/lib/stk-table-vue.js +11 -6
- package/lib/style.css +80 -65
- package/lib/test/StkTable.browser.test.d.ts +1 -0
- package/lib/test/insertToOrderedArray.test.d.ts +1 -0
- package/package.json +59 -57
- package/src/StkTable/StkTable.vue +66 -31
- package/src/StkTable/types/index.ts +30 -2
- package/src/StkTable/utils.ts +5 -5
- package/lib/StkTable/utils.d.ts +0 -23
- /package/lib/{StkTable → src/StkTable}/const.d.ts +0 -0
- /package/lib/{StkTable → src/StkTable}/index.d.ts +0 -0
- /package/lib/{StkTable → src/StkTable}/useColResize.d.ts +0 -0
- /package/lib/{StkTable → src/StkTable}/useHighlight.d.ts +0 -0
- /package/lib/{StkTable → src/StkTable}/useThDrag.d.ts +0 -0
- /package/lib/{StkTable → src/StkTable}/useVirtualScroll.d.ts +0 -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
|
@@ -112,30 +112,112 @@ export type StkProps = Partial<{
|
|
|
112
112
|
}>;
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
### StkTableColumn
|
|
116
116
|
``` ts
|
|
117
117
|
type Sorter = boolean | Function;
|
|
118
|
-
|
|
118
|
+
/** 表格列配置 */
|
|
119
119
|
export type StkTableColumn<T extends Record<string, any>> = {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
/** 取值id */
|
|
121
|
+
dataIndex: keyof T & string;
|
|
122
|
+
/** 表头文字 */
|
|
123
|
+
title?: string;
|
|
124
|
+
/** 列内容对齐方式 */
|
|
125
|
+
align?: 'right' | 'left' | 'center';
|
|
126
|
+
/** 表头内容对齐方式 */
|
|
127
|
+
headerAlign?: 'right' | 'left' | 'center';
|
|
128
|
+
/** 筛选 */
|
|
129
|
+
sorter?: Sorter;
|
|
130
|
+
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
131
|
+
width?: string;
|
|
132
|
+
/** 最小列宽。非x虚拟滚动生效。 */
|
|
133
|
+
minWidth?: string;
|
|
134
|
+
/** 最大列宽。非x虚拟滚动生效。 */
|
|
135
|
+
maxWidth?: string;
|
|
136
|
+
/**th class */
|
|
137
|
+
headerClassName?: string;
|
|
138
|
+
/** td class */
|
|
139
|
+
className?: string;
|
|
140
|
+
/** 排序字段。default: dataIndex */
|
|
141
|
+
sortField?: keyof T;
|
|
142
|
+
/** 排序方式。按数字/字符串 */
|
|
143
|
+
sortType?: 'number' | 'string';
|
|
144
|
+
/** 固定列 */
|
|
145
|
+
fixed?: 'left' | 'right' | null;
|
|
146
|
+
/** private */ rowSpan?: number;
|
|
147
|
+
/** private */ colSpan?: number;
|
|
148
|
+
/**自定义 td 渲染内容 */
|
|
149
|
+
customCell?: Component | VNode | CustomCellFunc<T>;
|
|
150
|
+
/** 自定义 th 渲染内容 */
|
|
151
|
+
customHeaderCell?: Component | VNode | CustomHeaderCellFunc<T>;
|
|
152
|
+
/** 二级表头 */
|
|
153
|
+
children?: StkTableColumn<T>[];
|
|
154
|
+
/**
|
|
155
|
+
* 单元格分割线。
|
|
156
|
+
* 默认横竖都有
|
|
157
|
+
* horizontal - 仅展示横线
|
|
158
|
+
*/
|
|
159
|
+
border: boolean | 'horizontal';
|
|
139
160
|
};
|
|
140
161
|
```
|
|
141
162
|
|
|
163
|
+
|
|
164
|
+
### Example
|
|
165
|
+
```vue
|
|
166
|
+
<template>
|
|
167
|
+
<StkTable
|
|
168
|
+
ref="stkTable"
|
|
169
|
+
row-key="name"
|
|
170
|
+
v-model:columns="columns"
|
|
171
|
+
:style="{height:props.height}"
|
|
172
|
+
theme='dark'
|
|
173
|
+
height='200px'
|
|
174
|
+
:show-overflow="false"
|
|
175
|
+
:show-header-overflow="false"
|
|
176
|
+
:sort-remote="false"
|
|
177
|
+
col-resizable
|
|
178
|
+
header-drag
|
|
179
|
+
virtual
|
|
180
|
+
virtual-x
|
|
181
|
+
no-data-full
|
|
182
|
+
:headless="false"
|
|
183
|
+
:data-source="dataSource"
|
|
184
|
+
@current-change="onCurrentChange"
|
|
185
|
+
@row-menu="onRowMenu"
|
|
186
|
+
@header-row-menu="onHeaderRowMenu"
|
|
187
|
+
@row-click="onRowClick"
|
|
188
|
+
@row-dblclick="onRowDblclick"
|
|
189
|
+
@sort-change="handleSortChange"
|
|
190
|
+
@cell-click="onCellClick"
|
|
191
|
+
@header-cell-click="onHeaderCellClick"
|
|
192
|
+
@scroll="onTableScroll"
|
|
193
|
+
@col-order-change="onColOrderChange"
|
|
194
|
+
/>
|
|
195
|
+
</template>
|
|
196
|
+
<script setup>
|
|
197
|
+
import { h, defineComponent } from 'vue';
|
|
198
|
+
const columns = [
|
|
199
|
+
{
|
|
200
|
+
title: 'Name',
|
|
201
|
+
dataIndex: 'name',
|
|
202
|
+
fixed: 'left',
|
|
203
|
+
width: '200px',
|
|
204
|
+
headerClassName: 'my-th',
|
|
205
|
+
className: 'my-td',
|
|
206
|
+
sorter: true,
|
|
207
|
+
customHeaderCell: function FunctionalComponent(props){
|
|
208
|
+
return h(
|
|
209
|
+
'span',
|
|
210
|
+
{ style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
|
|
211
|
+
props.col.title + '(render) text-overflow,',
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
customCell: defineComponent({
|
|
215
|
+
setup(){
|
|
216
|
+
//...
|
|
217
|
+
return () => <div></div>
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
]
|
|
222
|
+
</script>
|
|
223
|
+
```
|
|
@@ -30,8 +30,12 @@ declare function setSorter(dataIndex: string, order: null | 'asc' | 'desc', opti
|
|
|
30
30
|
}): any[];
|
|
31
31
|
/** 重置排序 */
|
|
32
32
|
declare function resetSorter(): void;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* 设置滚动条位置
|
|
35
|
+
* @param top 传null 则不变动位置
|
|
36
|
+
* @param left 传null 则不变动位置
|
|
37
|
+
*/
|
|
38
|
+
declare function scrollTo(top?: number | null, left?: number | null): void;
|
|
35
39
|
/** 获取当前状态的表格数据 */
|
|
36
40
|
declare function getTableData(): any[];
|
|
37
41
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Partial<{
|
|
@@ -56,9 +60,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
56
60
|
showTrHoverClass: boolean;
|
|
57
61
|
headerDrag: boolean;
|
|
58
62
|
rowClassName: (row: any, i: number) => string;
|
|
59
|
-
/** rowKey缓存 */
|
|
60
63
|
colResizable: boolean;
|
|
61
64
|
colMinWidth: number;
|
|
65
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
62
66
|
}>>, {
|
|
63
67
|
width: string;
|
|
64
68
|
fixedMode: boolean;
|
|
@@ -83,6 +87,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
83
87
|
rowClassName: () => "";
|
|
84
88
|
colResizable: boolean;
|
|
85
89
|
colMinWidth: number;
|
|
90
|
+
bordered: boolean;
|
|
86
91
|
}>, {
|
|
87
92
|
setCurrentRow: typeof setCurrentRow;
|
|
88
93
|
setHighlightDimCell: (rowKeyValue: string, dataIndex: string) => void;
|
|
@@ -127,9 +132,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
127
132
|
showTrHoverClass: boolean;
|
|
128
133
|
headerDrag: boolean;
|
|
129
134
|
rowClassName: (row: any, i: number) => string;
|
|
130
|
-
/** rowKey缓存 */
|
|
131
135
|
colResizable: boolean;
|
|
132
136
|
colMinWidth: number;
|
|
137
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
133
138
|
}>>, {
|
|
134
139
|
width: string;
|
|
135
140
|
fixedMode: boolean;
|
|
@@ -154,6 +159,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
154
159
|
rowClassName: () => "";
|
|
155
160
|
colResizable: boolean;
|
|
156
161
|
colMinWidth: number;
|
|
162
|
+
bordered: boolean;
|
|
157
163
|
}>>> & {
|
|
158
164
|
onScroll?: ((...args: any[]) => any) | undefined;
|
|
159
165
|
"onTh-drag-start"?: ((...args: any[]) => any) | undefined;
|
|
@@ -192,6 +198,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
192
198
|
rowClassName: (row: any, i: number) => string;
|
|
193
199
|
colResizable: boolean;
|
|
194
200
|
colMinWidth: number;
|
|
201
|
+
bordered: boolean | "h" | "v" | "body-v";
|
|
195
202
|
}, {}>, {
|
|
196
203
|
tableHeader?(_: {
|
|
197
204
|
column: StkTableColumn<any>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Component, VNode } from 'vue';
|
|
2
|
-
|
|
2
|
+
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
3
|
+
export type Order = null | 'asc' | 'desc';
|
|
4
|
+
type Sorter = boolean | ((data: any[], option: {
|
|
5
|
+
order: Order;
|
|
6
|
+
column: any;
|
|
7
|
+
}) => any[]);
|
|
3
8
|
export type CustomCellFunc<T extends Record<string, any>> = (props: {
|
|
4
9
|
row: T;
|
|
5
10
|
col: StkTableColumn<T>;
|
|
@@ -8,29 +13,46 @@ export type CustomCellFunc<T extends Record<string, any>> = (props: {
|
|
|
8
13
|
export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: {
|
|
9
14
|
col: StkTableColumn<T>;
|
|
10
15
|
}) => VNode;
|
|
16
|
+
/** 表格列配置 */
|
|
11
17
|
export type StkTableColumn<T extends Record<string, any>> = {
|
|
18
|
+
/** 取值id */
|
|
12
19
|
dataIndex: keyof T & string;
|
|
20
|
+
/** 表头文字 */
|
|
13
21
|
title?: string;
|
|
22
|
+
/** 列内容对齐方式 */
|
|
14
23
|
align?: 'right' | 'left' | 'center';
|
|
24
|
+
/** 表头内容对齐方式 */
|
|
15
25
|
headerAlign?: 'right' | 'left' | 'center';
|
|
26
|
+
/** 筛选 */
|
|
16
27
|
sorter?: Sorter;
|
|
28
|
+
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
17
29
|
width?: string;
|
|
30
|
+
/** 最小列宽。非x虚拟滚动生效。 */
|
|
18
31
|
minWidth?: string;
|
|
32
|
+
/** 最大列宽。非x虚拟滚动生效。 */
|
|
19
33
|
maxWidth?: string;
|
|
34
|
+
/**th class */
|
|
20
35
|
headerClassName?: string;
|
|
36
|
+
/** td class */
|
|
21
37
|
className?: string;
|
|
38
|
+
/** 排序字段。default: dataIndex */
|
|
22
39
|
sortField?: keyof T;
|
|
40
|
+
/** 排序方式。按数字/字符串 */
|
|
23
41
|
sortType?: 'number' | 'string';
|
|
42
|
+
/** 固定列 */
|
|
24
43
|
fixed?: 'left' | 'right' | null;
|
|
25
44
|
/** private */ rowSpan?: number;
|
|
26
45
|
/** private */ colSpan?: number;
|
|
46
|
+
/**自定义 td 渲染内容 */
|
|
27
47
|
customCell?: Component | VNode | CustomCellFunc<T>;
|
|
48
|
+
/** 自定义 th 渲染内容 */
|
|
28
49
|
customHeaderCell?: Component | VNode | CustomHeaderCellFunc<T>;
|
|
50
|
+
/** 二级表头 */
|
|
29
51
|
children?: StkTableColumn<T>[];
|
|
30
52
|
};
|
|
31
53
|
export type SortOption = Pick<StkTableColumn<any>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
|
|
32
|
-
export type SortState = {
|
|
33
|
-
dataIndex:
|
|
54
|
+
export type SortState<T> = {
|
|
55
|
+
dataIndex: T;
|
|
34
56
|
order: null | 'asc' | 'desc';
|
|
35
57
|
sortType?: 'number' | 'string';
|
|
36
58
|
};
|
|
@@ -88,5 +110,13 @@ export type StkProps = Partial<{
|
|
|
88
110
|
colResizable: boolean;
|
|
89
111
|
/** 可拖动至最小的列宽 */
|
|
90
112
|
colMinWidth: number;
|
|
113
|
+
/**
|
|
114
|
+
* 单元格分割线。
|
|
115
|
+
* 默认横竖都有
|
|
116
|
+
* "h" - 仅展示横线
|
|
117
|
+
* "v" - 仅展示竖线
|
|
118
|
+
* "body-v" - 仅表体展示竖线
|
|
119
|
+
*/
|
|
120
|
+
bordered: boolean | 'h' | 'v' | 'body-v';
|
|
91
121
|
}>;
|
|
92
122
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Order, SortOption, SortState, StkTableColumn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 对有序数组插入新数据
|
|
4
|
+
* @param sortState
|
|
5
|
+
* @param sortState.dataIndex 排序的列
|
|
6
|
+
* @param sortState.order 排序顺序
|
|
7
|
+
* @param sortState.sortType 排序方式
|
|
8
|
+
* @param newItem 要插入的数据
|
|
9
|
+
* @param targetArray 表格数据
|
|
10
|
+
*/
|
|
11
|
+
export declare function insertToOrderedArray<T extends object>(sortState: SortState<keyof T>, newItem: any, targetArray: T[]): T[];
|
|
12
|
+
/**
|
|
13
|
+
* 表格排序抽离
|
|
14
|
+
* 可以在组件外部自己实现表格排序,组件配置remote,使表格不排序。
|
|
15
|
+
* 使用者在@sort-change事件中自行更改table props 'dataSource'完成排序。
|
|
16
|
+
* TODO: key 唯一值,排序字段相同时,根据唯一值排序。
|
|
17
|
+
* @param sortOption 列配置
|
|
18
|
+
* @param order 排序方式
|
|
19
|
+
* @param dataSource 排序的数组
|
|
20
|
+
*/
|
|
21
|
+
export declare function tableSort(sortOption: SortOption, order: Order, dataSource: any[]): any[];
|
|
22
|
+
/** column 的层级 */
|
|
23
|
+
export declare function howDeepTheColumn(arr: StkTableColumn<any>[], level?: number): number;
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -435,9 +435,9 @@ function strCompare(a, b, type) {
|
|
|
435
435
|
if (type === "number") {
|
|
436
436
|
if (+a > +b)
|
|
437
437
|
return 1;
|
|
438
|
-
if (+a === +b)
|
|
438
|
+
else if (+a === +b)
|
|
439
439
|
return 0;
|
|
440
|
-
|
|
440
|
+
else
|
|
441
441
|
return -1;
|
|
442
442
|
} else {
|
|
443
443
|
return String(a).localeCompare(b);
|
|
@@ -492,7 +492,7 @@ function howDeepTheColumn(arr, level = 1) {
|
|
|
492
492
|
});
|
|
493
493
|
return Math.max(...levels);
|
|
494
494
|
}
|
|
495
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
495
|
+
const _withScopeId = (n) => (pushScopeId("data-v-0aa41491"), n = n(), popScopeId(), n);
|
|
496
496
|
const _hoisted_1 = { key: 0 };
|
|
497
497
|
const _hoisted_2 = ["data-col-key", "draggable", "rowspan", "colspan", "title", "onClick"];
|
|
498
498
|
const _hoisted_3 = { class: "table-header-cell-wrapper" };
|
|
@@ -563,7 +563,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
563
563
|
headerDrag: { type: Boolean, default: false },
|
|
564
564
|
rowClassName: { type: Function, default: () => "" },
|
|
565
565
|
colResizable: { type: Boolean, default: false },
|
|
566
|
-
colMinWidth: { default: 10 }
|
|
566
|
+
colMinWidth: { default: 10 },
|
|
567
|
+
bordered: { type: [Boolean, String], default: true }
|
|
567
568
|
},
|
|
568
569
|
emits: [
|
|
569
570
|
"sort-change",
|
|
@@ -920,7 +921,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
920
921
|
"virtual-x": _ctx.virtualX,
|
|
921
922
|
dark: _ctx.theme === "dark",
|
|
922
923
|
headless: _ctx.headless,
|
|
923
|
-
"is-col-resizing": unref(isColResizing)
|
|
924
|
+
"is-col-resizing": unref(isColResizing),
|
|
925
|
+
border: props.bordered,
|
|
926
|
+
"border-h": props.bordered === "h",
|
|
927
|
+
"border-v": props.bordered === "v",
|
|
928
|
+
"border-body-v": props.bordered === "body-v"
|
|
924
929
|
}]),
|
|
925
930
|
style: normalizeStyle(_ctx.virtual && { "--row-height": unref(virtualScroll).rowHeight + "px" }),
|
|
926
931
|
onScroll: onTableScroll,
|
|
@@ -1093,7 +1098,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
1093
1098
|
}
|
|
1094
1099
|
return target;
|
|
1095
1100
|
};
|
|
1096
|
-
const StkTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
1101
|
+
const StkTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0aa41491"]]);
|
|
1097
1102
|
export {
|
|
1098
1103
|
StkTable,
|
|
1099
1104
|
insertToOrderedArray,
|
package/lib/style.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.stk-table[data-v-
|
|
1
|
+
.stk-table[data-v-0aa41491] {
|
|
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[data-v-
|
|
31
|
+
.stk-table.dark[data-v-0aa41491] {
|
|
32
32
|
--th-bgc: #181c21;
|
|
33
33
|
--td-bgc: #181c21;
|
|
34
34
|
--border-color: #26292e;
|
|
@@ -43,13 +43,45 @@
|
|
|
43
43
|
--col-resize-indicator-color: #5d6064;
|
|
44
44
|
color: #d0d1d2;
|
|
45
45
|
}
|
|
46
|
-
.stk-table.headless[data-v-
|
|
46
|
+
.stk-table.headless[data-v-0aa41491] {
|
|
47
47
|
border-top: 1px solid var(--border-color);
|
|
48
48
|
}
|
|
49
|
-
.stk-table.is-col-resizing th[data-v-
|
|
49
|
+
.stk-table.is-col-resizing th[data-v-0aa41491] {
|
|
50
50
|
pointer-events: none;
|
|
51
51
|
}
|
|
52
|
-
.stk-table
|
|
52
|
+
.stk-table.border-h[data-v-0aa41491] {
|
|
53
|
+
--bg-border-right: linear-gradient(transparent, transparent);
|
|
54
|
+
--bg-border-left: linear-gradient(transparent, transparent);
|
|
55
|
+
}
|
|
56
|
+
.stk-table.border-v[data-v-0aa41491] {
|
|
57
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
58
|
+
}
|
|
59
|
+
.stk-table.border .stk-table-main th[data-v-0aa41491],
|
|
60
|
+
.stk-table.border .stk-table-main td[data-v-0aa41491] {
|
|
61
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
62
|
+
}
|
|
63
|
+
.stk-table.border .stk-table-main thead tr:first-child th[data-v-0aa41491] {
|
|
64
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
65
|
+
}
|
|
66
|
+
.stk-table.border .stk-table-main thead tr:first-child th[data-v-0aa41491]:first-child {
|
|
67
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
68
|
+
}
|
|
69
|
+
.stk-table.border .stk-table-main thead tr th[data-v-0aa41491]:first-child {
|
|
70
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
71
|
+
}
|
|
72
|
+
.stk-table.border .stk-table-main tbody td[data-v-0aa41491]:first-child {
|
|
73
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
74
|
+
}
|
|
75
|
+
.stk-table.border.virtual-x .stk-table-main thead tr:first-child .virtual-x-left + th[data-v-0aa41491] {
|
|
76
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
77
|
+
}
|
|
78
|
+
.stk-table.border.virtual-x .stk-table-main tr .virtual-x-left + th[data-v-0aa41491] {
|
|
79
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
80
|
+
}
|
|
81
|
+
.stk-table.border-body-v .stk-table-main tbody[data-v-0aa41491] {
|
|
82
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
83
|
+
}
|
|
84
|
+
.stk-table .column-resize-indicator[data-v-0aa41491] {
|
|
53
85
|
width: 0;
|
|
54
86
|
height: 100%;
|
|
55
87
|
border-left: 1px dashed var(--col-resize-indicator-color);
|
|
@@ -58,133 +90,122 @@
|
|
|
58
90
|
display: none;
|
|
59
91
|
pointer-events: none;
|
|
60
92
|
}
|
|
61
|
-
.stk-table .stk-table-main[data-v-
|
|
93
|
+
.stk-table .stk-table-main[data-v-0aa41491] {
|
|
62
94
|
border-spacing: 0;
|
|
63
95
|
border-collapse: separate;
|
|
64
96
|
}
|
|
65
|
-
.stk-table .stk-table-main.fixed-mode[data-v-
|
|
97
|
+
.stk-table .stk-table-main.fixed-mode[data-v-0aa41491] {
|
|
66
98
|
table-layout: fixed;
|
|
67
99
|
}
|
|
68
|
-
.stk-table .stk-table-main th[data-v-
|
|
69
|
-
.stk-table .stk-table-main td[data-v-
|
|
100
|
+
.stk-table .stk-table-main th[data-v-0aa41491],
|
|
101
|
+
.stk-table .stk-table-main td[data-v-0aa41491] {
|
|
70
102
|
z-index: 1;
|
|
71
103
|
height: var(--row-height);
|
|
72
104
|
font-size: 14px;
|
|
73
105
|
box-sizing: border-box;
|
|
74
106
|
padding: 0 var(--cell-padding-x);
|
|
75
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
76
107
|
}
|
|
77
|
-
.stk-table .stk-table-main thead tr:first-child th[data-v-
|
|
108
|
+
.stk-table .stk-table-main thead tr:first-child th[data-v-0aa41491] {
|
|
78
109
|
position: sticky;
|
|
79
110
|
top: 0;
|
|
80
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
81
111
|
}
|
|
82
|
-
.stk-table .stk-table-main thead tr
|
|
83
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
84
|
-
}
|
|
85
|
-
.stk-table .stk-table-main thead tr th[data-v-646b1c00] {
|
|
112
|
+
.stk-table .stk-table-main thead tr th[data-v-0aa41491] {
|
|
86
113
|
background-color: var(--th-bgc);
|
|
87
114
|
}
|
|
88
|
-
.stk-table .stk-table-main thead tr th.sortable[data-v-
|
|
115
|
+
.stk-table .stk-table-main thead tr th.sortable[data-v-0aa41491] {
|
|
89
116
|
cursor: pointer;
|
|
90
117
|
}
|
|
91
|
-
.stk-table .stk-table-main thead tr th[data-v-
|
|
92
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
93
|
-
}
|
|
94
|
-
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper[data-v-646b1c00] {
|
|
118
|
+
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper[data-v-0aa41491] {
|
|
95
119
|
white-space: nowrap;
|
|
96
120
|
overflow: hidden;
|
|
97
121
|
}
|
|
98
|
-
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper .table-header-title[data-v-
|
|
122
|
+
.stk-table .stk-table-main thead tr th.text-overflow .table-header-cell-wrapper .table-header-title[data-v-0aa41491] {
|
|
99
123
|
text-overflow: ellipsis;
|
|
100
124
|
overflow: hidden;
|
|
101
125
|
}
|
|
102
|
-
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-
|
|
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[data-v-0aa41491] {
|
|
103
127
|
fill: var(--sort-arrow-hover-color);
|
|
104
128
|
}
|
|
105
|
-
.stk-table .stk-table-main thead tr th:not(.sorter-desc):not(.sorter-asc):hover .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-
|
|
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[data-v-0aa41491] {
|
|
106
130
|
fill: var(--sort-arrow-hover-color);
|
|
107
131
|
}
|
|
108
|
-
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-
|
|
132
|
+
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-0aa41491] {
|
|
109
133
|
fill: var(--sort-arrow-active-sub-color);
|
|
110
134
|
}
|
|
111
|
-
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-
|
|
135
|
+
.stk-table .stk-table-main thead tr th.sorter-desc .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-0aa41491] {
|
|
112
136
|
fill: var(--sort-arrow-active-color);
|
|
113
137
|
}
|
|
114
|
-
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-
|
|
138
|
+
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-0aa41491] {
|
|
115
139
|
fill: var(--sort-arrow-active-color);
|
|
116
140
|
}
|
|
117
|
-
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-
|
|
141
|
+
.stk-table .stk-table-main thead tr th.sorter-asc .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-0aa41491] {
|
|
118
142
|
fill: var(--sort-arrow-active-sub-color);
|
|
119
143
|
}
|
|
120
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper[data-v-
|
|
144
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper[data-v-0aa41491] {
|
|
121
145
|
max-width: 100%;
|
|
122
146
|
display: inline-flex;
|
|
123
147
|
align-items: center;
|
|
124
148
|
}
|
|
125
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-title[data-v-
|
|
149
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-title[data-v-0aa41491] {
|
|
126
150
|
overflow: hidden;
|
|
127
151
|
align-self: flex-start;
|
|
128
152
|
}
|
|
129
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter[data-v-
|
|
153
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter[data-v-0aa41491] {
|
|
130
154
|
flex-shrink: 0;
|
|
131
155
|
margin-left: 4px;
|
|
132
156
|
width: 16px;
|
|
133
157
|
height: 16px;
|
|
134
158
|
}
|
|
135
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-
|
|
136
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-
|
|
159
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-up[data-v-0aa41491],
|
|
160
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-sorter #arrow-down[data-v-0aa41491] {
|
|
137
161
|
fill: var(--sort-arrow-color);
|
|
138
162
|
}
|
|
139
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer[data-v-
|
|
163
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer[data-v-0aa41491] {
|
|
140
164
|
position: absolute;
|
|
141
165
|
top: 0;
|
|
142
166
|
bottom: 0;
|
|
143
167
|
cursor: col-resize;
|
|
144
168
|
width: var(--resize-handle-width);
|
|
145
169
|
}
|
|
146
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.left[data-v-
|
|
170
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.left[data-v-0aa41491] {
|
|
147
171
|
left: 0;
|
|
148
172
|
}
|
|
149
|
-
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.right[data-v-
|
|
173
|
+
.stk-table .stk-table-main thead tr th .table-header-cell-wrapper .table-header-resizer.right[data-v-0aa41491] {
|
|
150
174
|
right: 0;
|
|
151
175
|
}
|
|
152
|
-
.stk-table .stk-table-main tbody[data-v-
|
|
176
|
+
.stk-table .stk-table-main tbody[data-v-0aa41491] {
|
|
153
177
|
/**高亮渐暗 */
|
|
154
178
|
}
|
|
155
|
-
@keyframes dim-
|
|
179
|
+
@keyframes dim-0aa41491 {
|
|
156
180
|
from {
|
|
157
181
|
background-color: var(--highlight-color);
|
|
158
182
|
}
|
|
159
183
|
}
|
|
160
|
-
.stk-table .stk-table-main tbody tr[data-v-
|
|
184
|
+
.stk-table .stk-table-main tbody tr[data-v-0aa41491] {
|
|
161
185
|
background-color: var(--td-bgc);
|
|
162
186
|
}
|
|
163
|
-
.stk-table .stk-table-main tbody tr.highlight-row[data-v-
|
|
164
|
-
animation: dim-
|
|
187
|
+
.stk-table .stk-table-main tbody tr.highlight-row[data-v-0aa41491] {
|
|
188
|
+
animation: dim-0aa41491 2s linear;
|
|
165
189
|
}
|
|
166
|
-
.stk-table .stk-table-main tbody tr.hover[data-v-
|
|
167
|
-
.stk-table .stk-table-main tbody tr[data-v-
|
|
190
|
+
.stk-table .stk-table-main tbody tr.hover[data-v-0aa41491],
|
|
191
|
+
.stk-table .stk-table-main tbody tr[data-v-0aa41491]:hover {
|
|
168
192
|
background-color: var(--tr-hover-bgc);
|
|
169
193
|
}
|
|
170
|
-
.stk-table .stk-table-main tbody tr.active[data-v-
|
|
194
|
+
.stk-table .stk-table-main tbody tr.active[data-v-0aa41491] {
|
|
171
195
|
background-color: var(--tr-active-bgc);
|
|
172
196
|
}
|
|
173
|
-
.stk-table .stk-table-main tbody tr td.fixed-cell[data-v-
|
|
197
|
+
.stk-table .stk-table-main tbody tr td.fixed-cell[data-v-0aa41491] {
|
|
174
198
|
background-color: inherit;
|
|
175
199
|
}
|
|
176
|
-
.stk-table .stk-table-main tbody tr td[data-v-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
.stk-table .stk-table-main tbody tr td.highlight-cell[data-v-646b1c00] {
|
|
180
|
-
animation: dim-646b1c00 2s linear;
|
|
200
|
+
.stk-table .stk-table-main tbody tr td.highlight-cell[data-v-0aa41491] {
|
|
201
|
+
animation: dim-0aa41491 2s linear;
|
|
181
202
|
}
|
|
182
|
-
.stk-table .stk-table-main tbody tr td.text-overflow .table-cell-wrapper[data-v-
|
|
203
|
+
.stk-table .stk-table-main tbody tr td.text-overflow .table-cell-wrapper[data-v-0aa41491] {
|
|
183
204
|
white-space: nowrap;
|
|
184
205
|
overflow: hidden;
|
|
185
206
|
text-overflow: ellipsis;
|
|
186
207
|
}
|
|
187
|
-
.stk-table .stk-table-no-data[data-v-
|
|
208
|
+
.stk-table .stk-table-no-data[data-v-0aa41491] {
|
|
188
209
|
background-color: var(--table-bgc);
|
|
189
210
|
line-height: var(--row-height);
|
|
190
211
|
text-align: center;
|
|
@@ -199,33 +220,27 @@ from {
|
|
|
199
220
|
align-items: center;
|
|
200
221
|
justify-content: center;
|
|
201
222
|
}
|
|
202
|
-
.stk-table .stk-table-no-data.no-data-full[data-v-
|
|
223
|
+
.stk-table .stk-table-no-data.no-data-full[data-v-0aa41491] {
|
|
203
224
|
flex: 1;
|
|
204
225
|
}
|
|
205
|
-
.stk-table.virtual .stk-table-main thead tr th .table-header-cell-wrapper[data-v-
|
|
226
|
+
.stk-table.virtual .stk-table-main thead tr th .table-header-cell-wrapper[data-v-0aa41491] {
|
|
206
227
|
overflow: hidden;
|
|
207
228
|
max-height: var(--row-height);
|
|
208
229
|
}
|
|
209
|
-
.stk-table.virtual .stk-table-main tbody[data-v-
|
|
230
|
+
.stk-table.virtual .stk-table-main tbody[data-v-0aa41491] {
|
|
210
231
|
position: relative;
|
|
211
232
|
}
|
|
212
|
-
.stk-table.virtual .stk-table-main tbody tr.padding-top-tr td[data-v-
|
|
233
|
+
.stk-table.virtual .stk-table-main tbody tr.padding-top-tr td[data-v-0aa41491] {
|
|
213
234
|
height: 0;
|
|
214
235
|
}
|
|
215
|
-
.stk-table.virtual .stk-table-main tbody tr td[data-v-
|
|
236
|
+
.stk-table.virtual .stk-table-main tbody tr td[data-v-0aa41491] {
|
|
216
237
|
height: var(--row-height);
|
|
217
238
|
line-height: 1;
|
|
218
239
|
}
|
|
219
|
-
.stk-table.virtual .stk-table-main tbody tr td .table-cell-wrapper[data-v-
|
|
240
|
+
.stk-table.virtual .stk-table-main tbody tr td .table-cell-wrapper[data-v-0aa41491] {
|
|
220
241
|
max-height: var(--row-height);
|
|
221
242
|
overflow: hidden;
|
|
222
243
|
}
|
|
223
|
-
.stk-table.virtual-x .stk-table-main .virtual-x-left[data-v-
|
|
244
|
+
.stk-table.virtual-x .stk-table-main .virtual-x-left[data-v-0aa41491] {
|
|
224
245
|
padding: 0;
|
|
225
246
|
}
|
|
226
|
-
.stk-table.virtual-x .stk-table-main thead tr:first-child .virtual-x-left + th[data-v-646b1c00] {
|
|
227
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
228
|
-
}
|
|
229
|
-
.stk-table.virtual-x .stk-table-main tr .virtual-x-left + th[data-v-646b1c00] {
|
|
230
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
231
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "stk-table-vue",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
4
|
-
"description": "simple realtime virtual table for vue3",
|
|
5
|
-
"main": "./lib/stk-table-vue.js",
|
|
6
|
-
"types": "./lib/StkTable/index.d.ts",
|
|
7
|
-
"packageManager": "pnpm@8.11.0",
|
|
8
|
-
"directories": {
|
|
9
|
-
"test": "test"
|
|
10
|
-
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "vite",
|
|
14
|
-
"build": "vite build",
|
|
15
|
-
"test": "vitest"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"virtual table",
|
|
19
|
-
"vue",
|
|
20
|
-
"highlight",
|
|
21
|
-
"sticky"
|
|
22
|
-
],
|
|
23
|
-
"files": [
|
|
24
|
-
"lib",
|
|
25
|
-
"src"
|
|
26
|
-
],
|
|
27
|
-
"author": "japlus",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "https://gitee.com/japlus/stk-table-vue"
|
|
31
|
-
},
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/d3-interpolate": "^3.0.4",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
36
|
-
"@typescript-eslint/parser": "^6.14.0",
|
|
37
|
-
"@vitejs/plugin-vue": "^4.5.0",
|
|
38
|
-
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
39
|
-
"
|
|
40
|
-
"eslint
|
|
41
|
-
"eslint-
|
|
42
|
-
"eslint-plugin-
|
|
43
|
-
"eslint-plugin-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "stk-table-vue",
|
|
3
|
+
"version": "0.0.1-beta.4",
|
|
4
|
+
"description": "simple realtime virtual table for vue3",
|
|
5
|
+
"main": "./lib/stk-table-vue.js",
|
|
6
|
+
"types": "./lib/StkTable/index.d.ts",
|
|
7
|
+
"packageManager": "pnpm@8.11.0",
|
|
8
|
+
"directories": {
|
|
9
|
+
"test": "test"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"build": "vite build",
|
|
15
|
+
"test": "vitest"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"virtual table",
|
|
19
|
+
"vue",
|
|
20
|
+
"highlight",
|
|
21
|
+
"sticky"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"lib",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"author": "japlus",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://gitee.com/japlus/stk-table-vue"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/d3-interpolate": "^3.0.4",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
36
|
+
"@typescript-eslint/parser": "^6.14.0",
|
|
37
|
+
"@vitejs/plugin-vue": "^4.5.0",
|
|
38
|
+
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
39
|
+
"@vue/test-utils": "2.4.0-alpha.2",
|
|
40
|
+
"eslint": "^8.55.0",
|
|
41
|
+
"eslint-config-prettier": "^9.1.0",
|
|
42
|
+
"eslint-plugin-html": "^7.1.0",
|
|
43
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
44
|
+
"eslint-plugin-vue": "^9.19.2",
|
|
45
|
+
"happy-dom": "^12.10.3",
|
|
46
|
+
"less": "^4.2.0",
|
|
47
|
+
"prettier": "^3.1.1",
|
|
48
|
+
"pug": "^3.0.2",
|
|
49
|
+
"typescript": "^5.3.3",
|
|
50
|
+
"vite": "^5.0.6",
|
|
51
|
+
"vite-plugin-dts": "^3.6.4",
|
|
52
|
+
"vitest": "^1.1.0",
|
|
53
|
+
"vue": "^3.3.9",
|
|
54
|
+
"vue-eslint-parser": "^9.3.2",
|
|
55
|
+
"vue-loader": "^17.2.2"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"d3-interpolate": "^3.0.1"
|
|
59
|
+
}
|
|
58
60
|
}
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
dark: theme === 'dark',
|
|
9
9
|
headless,
|
|
10
10
|
'is-col-resizing': isColResizing,
|
|
11
|
+
border: props.bordered,
|
|
12
|
+
'border-h': props.bordered === 'h',
|
|
13
|
+
'border-v': props.bordered === 'v',
|
|
14
|
+
'border-body-v': props.bordered === 'body-v',
|
|
11
15
|
}"
|
|
12
16
|
:style="virtual && { '--row-height': virtualScroll.rowHeight + 'px' }"
|
|
13
17
|
@scroll="onTableScroll"
|
|
@@ -185,7 +189,7 @@
|
|
|
185
189
|
* [] 计算的高亮颜色,挂在数据源上对象上,若多个表格使用同一个数据源对象会有问题。需要深拷贝。(解决方案:获取组件uid)
|
|
186
190
|
* [] highlight-row 颜色不能恢复到active的颜色
|
|
187
191
|
*/
|
|
188
|
-
import { SortOption, StkProps, StkTableColumn } from '@/StkTable/types/index';
|
|
192
|
+
import { Order, SortOption, StkProps, StkTableColumn } from '@/StkTable/types/index';
|
|
189
193
|
import { CSSProperties, computed, onMounted, ref, shallowRef, toRaw, watch } from 'vue';
|
|
190
194
|
import { Default_Col_Width, Is_Legacy_Mode } from './const';
|
|
191
195
|
import { useColResize } from './useColResize';
|
|
@@ -218,6 +222,7 @@ const props = withDefaults(defineProps<StkProps>(), {
|
|
|
218
222
|
rowClassName: () => '',
|
|
219
223
|
colResizable: false,
|
|
220
224
|
colMinWidth: 10,
|
|
225
|
+
bordered: true,
|
|
221
226
|
});
|
|
222
227
|
|
|
223
228
|
const emit = defineEmits([
|
|
@@ -248,7 +253,7 @@ let sortCol = ref<string | null>();
|
|
|
248
253
|
let sortOrderIndex = ref(0);
|
|
249
254
|
|
|
250
255
|
/** 排序切换顺序 */
|
|
251
|
-
const sortSwitchOrder = [null, 'desc', 'asc'];
|
|
256
|
+
const sortSwitchOrder: Order[] = [null, 'desc', 'asc'];
|
|
252
257
|
|
|
253
258
|
/** 表头.内容是 props.columns 的引用集合 */
|
|
254
259
|
const tableHeaders = ref<StkTableColumn<any>[][]>([]);
|
|
@@ -767,6 +772,65 @@ defineExpose({
|
|
|
767
772
|
&.is-col-resizing th {
|
|
768
773
|
pointer-events: none;
|
|
769
774
|
}
|
|
775
|
+
&.border-h {
|
|
776
|
+
--bg-border-right: linear-gradient(transparent, transparent);
|
|
777
|
+
--bg-border-left: linear-gradient(transparent, transparent);
|
|
778
|
+
}
|
|
779
|
+
&.border-v {
|
|
780
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
&.border {
|
|
784
|
+
.stk-table-main {
|
|
785
|
+
th,
|
|
786
|
+
td {
|
|
787
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
788
|
+
}
|
|
789
|
+
thead {
|
|
790
|
+
tr {
|
|
791
|
+
&:first-child th {
|
|
792
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
793
|
+
|
|
794
|
+
&:first-child {
|
|
795
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
th {
|
|
799
|
+
&:first-child {
|
|
800
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
tbody {
|
|
806
|
+
td {
|
|
807
|
+
&:first-child {
|
|
808
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
&.virtual-x {
|
|
815
|
+
.stk-table-main {
|
|
816
|
+
thead tr:first-child .virtual-x-left + th {
|
|
817
|
+
// 横向虚拟滚动时,左侧第一个单元格加上border-left
|
|
818
|
+
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
tr .virtual-x-left + th {
|
|
822
|
+
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
&.border-body-v {
|
|
828
|
+
.stk-table-main {
|
|
829
|
+
tbody {
|
|
830
|
+
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
770
834
|
|
|
771
835
|
/** 列宽调整指示器 */
|
|
772
836
|
.column-resize-indicator {
|
|
@@ -793,7 +857,6 @@ defineExpose({
|
|
|
793
857
|
font-size: 14px;
|
|
794
858
|
box-sizing: border-box;
|
|
795
859
|
padding: 0 var(--cell-padding-x);
|
|
796
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
797
860
|
}
|
|
798
861
|
|
|
799
862
|
thead {
|
|
@@ -801,12 +864,6 @@ defineExpose({
|
|
|
801
864
|
&:first-child th {
|
|
802
865
|
position: sticky;
|
|
803
866
|
top: 0;
|
|
804
|
-
// border-top: 1px solid var(--border-color);
|
|
805
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
806
|
-
|
|
807
|
-
&:first-child {
|
|
808
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
809
|
-
}
|
|
810
867
|
}
|
|
811
868
|
|
|
812
869
|
th {
|
|
@@ -816,15 +873,6 @@ defineExpose({
|
|
|
816
873
|
cursor: pointer;
|
|
817
874
|
}
|
|
818
875
|
|
|
819
|
-
&:first-child {
|
|
820
|
-
// border-left: 1px solid var(--border-color);
|
|
821
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
822
|
-
// padding-left: 12px;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
// &:last-child {
|
|
826
|
-
// padding-right: 12px;
|
|
827
|
-
// }
|
|
828
876
|
&.text-overflow {
|
|
829
877
|
.table-header-cell-wrapper {
|
|
830
878
|
white-space: nowrap;
|
|
@@ -945,10 +993,6 @@ defineExpose({
|
|
|
945
993
|
background-color: inherit; // 防止横向滚动后透明
|
|
946
994
|
}
|
|
947
995
|
|
|
948
|
-
&:first-child {
|
|
949
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
996
|
&.highlight-cell {
|
|
953
997
|
animation: dim 2s linear;
|
|
954
998
|
}
|
|
@@ -1059,15 +1103,6 @@ defineExpose({
|
|
|
1059
1103
|
.virtual-x-left {
|
|
1060
1104
|
padding: 0;
|
|
1061
1105
|
}
|
|
1062
|
-
|
|
1063
|
-
thead tr:first-child .virtual-x-left + th {
|
|
1064
|
-
// 横向虚拟滚动时,左侧第一个单元格加上border-left
|
|
1065
|
-
background-image: var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
tr .virtual-x-left + th {
|
|
1069
|
-
background-image: var(--bg-border-right), var(--bg-border-bottom), var(--bg-border-left);
|
|
1070
|
-
}
|
|
1071
1106
|
}
|
|
1072
1107
|
}
|
|
1073
1108
|
}
|
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
import { Component, VNode } from 'vue';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
4
|
+
export type Order = null | 'asc' | 'desc';
|
|
5
|
+
|
|
6
|
+
type Sorter = boolean | ((data: any[], option: { order: Order; column: any }) => any[]);
|
|
4
7
|
|
|
5
8
|
export type CustomCellFunc<T extends Record<string, any>> = (props: { row: T; col: StkTableColumn<T>; cellValue: any }) => VNode;
|
|
6
9
|
export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: { col: StkTableColumn<T> }) => VNode;
|
|
7
10
|
|
|
11
|
+
/** 表格列配置 */
|
|
8
12
|
export type StkTableColumn<T extends Record<string, any>> = {
|
|
13
|
+
/** 取值id */
|
|
9
14
|
dataIndex: keyof T & string;
|
|
15
|
+
/** 表头文字 */
|
|
10
16
|
title?: string;
|
|
17
|
+
/** 列内容对齐方式 */
|
|
11
18
|
align?: 'right' | 'left' | 'center';
|
|
19
|
+
/** 表头内容对齐方式 */
|
|
12
20
|
headerAlign?: 'right' | 'left' | 'center';
|
|
21
|
+
/** 筛选 */
|
|
13
22
|
sorter?: Sorter;
|
|
23
|
+
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
14
24
|
width?: string;
|
|
25
|
+
/** 最小列宽。非x虚拟滚动生效。 */
|
|
15
26
|
minWidth?: string;
|
|
27
|
+
/** 最大列宽。非x虚拟滚动生效。 */
|
|
16
28
|
maxWidth?: string;
|
|
29
|
+
/**th class */
|
|
17
30
|
headerClassName?: string;
|
|
31
|
+
/** td class */
|
|
18
32
|
className?: string;
|
|
33
|
+
/** 排序字段。default: dataIndex */
|
|
19
34
|
sortField?: keyof T;
|
|
35
|
+
/** 排序方式。按数字/字符串 */
|
|
20
36
|
sortType?: 'number' | 'string';
|
|
37
|
+
/** 固定列 */
|
|
21
38
|
fixed?: 'left' | 'right' | null;
|
|
22
|
-
|
|
23
39
|
/** private */ rowSpan?: number;
|
|
24
40
|
/** private */ colSpan?: number;
|
|
41
|
+
/**自定义 td 渲染内容 */
|
|
25
42
|
customCell?: Component | VNode | CustomCellFunc<T>;
|
|
43
|
+
/** 自定义 th 渲染内容 */
|
|
26
44
|
customHeaderCell?: Component | VNode | CustomHeaderCellFunc<T>;
|
|
45
|
+
/** 二级表头 */
|
|
27
46
|
children?: StkTableColumn<T>[];
|
|
28
47
|
};
|
|
29
48
|
|
|
@@ -112,4 +131,13 @@ export type StkProps = Partial<{
|
|
|
112
131
|
|
|
113
132
|
/** 可拖动至最小的列宽 */
|
|
114
133
|
colMinWidth: number;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 单元格分割线。
|
|
137
|
+
* 默认横竖都有
|
|
138
|
+
* "h" - 仅展示横线
|
|
139
|
+
* "v" - 仅展示竖线
|
|
140
|
+
* "body-v" - 仅表体展示竖线
|
|
141
|
+
*/
|
|
142
|
+
bordered: boolean | 'h' | 'v' | 'body-v';
|
|
115
143
|
}>;
|
package/src/StkTable/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SortOption, SortState, StkTableColumn } from './types';
|
|
1
|
+
import { Order, SortOption, SortState, StkTableColumn } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 对有序数组插入新数据
|
|
@@ -67,11 +67,11 @@ function strCompare(a: string, b: string, type: 'number' | 'string'): number {
|
|
|
67
67
|
* 可以在组件外部自己实现表格排序,组件配置remote,使表格不排序。
|
|
68
68
|
* 使用者在@sort-change事件中自行更改table props 'dataSource'完成排序。
|
|
69
69
|
* TODO: key 唯一值,排序字段相同时,根据唯一值排序。
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
70
|
+
* @param sortOption 列配置
|
|
71
|
+
* @param order 排序方式
|
|
72
|
+
* @param dataSource 排序的数组
|
|
73
73
|
*/
|
|
74
|
-
export function tableSort(sortOption: SortOption, order:
|
|
74
|
+
export function tableSort(sortOption: SortOption, order: Order, dataSource: any[]): any[] {
|
|
75
75
|
let targetDataSource = [...dataSource];
|
|
76
76
|
if (typeof sortOption.sorter === 'function') {
|
|
77
77
|
const customSorterData = sortOption.sorter(targetDataSource, { order, column: sortOption });
|
package/lib/StkTable/utils.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SortOption, SortState, StkTableColumn } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* 对有序数组插入新数据
|
|
4
|
-
* @param {object} sortState
|
|
5
|
-
* @param {string} sortState.dataIndex 排序的列
|
|
6
|
-
* @param {null|'asc'|'desc'} sortState.order 排序顺序
|
|
7
|
-
* @param {'number'|'string'} [sortState.sortType] 排序方式
|
|
8
|
-
* @param {object} newItem 要插入的数据
|
|
9
|
-
* @param {Array} targetArray 表格数据
|
|
10
|
-
*/
|
|
11
|
-
export declare function insertToOrderedArray(sortState: SortState, newItem: any, targetArray: any[]): any[];
|
|
12
|
-
/**
|
|
13
|
-
* 表格排序抽离
|
|
14
|
-
* 可以在组件外部自己实现表格排序,组件配置remote,使表格不排序。
|
|
15
|
-
* 使用者在@sort-change事件中自行更改table props 'dataSource'完成排序。
|
|
16
|
-
* TODO: key 唯一值,排序字段相同时,根据唯一值排序。
|
|
17
|
-
* @param {SortOption} sortOption 列配置
|
|
18
|
-
* @param {string|null} order 排序方式
|
|
19
|
-
* @param {any} dataSource 排序的数组
|
|
20
|
-
*/
|
|
21
|
-
export declare function tableSort(sortOption: SortOption, order: string | null, dataSource: any[]): any[];
|
|
22
|
-
/** column 的层级 */
|
|
23
|
-
export declare function howDeepTheColumn(arr: StkTableColumn<any>[], level?: number): number;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|