stk-table-vue 0.8.1 → 0.8.2
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/README.md +2 -1
- package/lib/src/StkTable/StkTable.vue.d.ts +3 -3
- package/lib/stk-table-vue.js +20 -11
- package/lib/style.css +8 -8
- package/package.json +10 -12
- package/src/StkTable/StkTable.vue +15 -8
- package/src/StkTable/style.less +6 -7
- package/src/StkTable/useTree.ts +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
* [x] 行展开。(`v0.5.0`)
|
|
45
45
|
* [x] 行拖动。(`v0.5.0`)
|
|
46
46
|
* [x] 树形。(`v0.7.0`)
|
|
47
|
+
* [x] 单元格合并。(`v0.8.0`)
|
|
47
48
|
* [] 列筛选。
|
|
48
49
|
* [x] 斑马纹。
|
|
49
50
|
* [x] 拖动更改列顺序。
|
|
@@ -77,7 +78,7 @@ const stkTableRef = useTemplateRef('stkTableRef');
|
|
|
77
78
|
|
|
78
79
|
// highlight row
|
|
79
80
|
stkTableRef.value.setHighlightDimRow([rowKey],{
|
|
80
|
-
method: 'css'|'
|
|
81
|
+
method: 'css'|'animation',// 默认 animation。
|
|
81
82
|
className: 'custom-class-name', // method css 时生效。
|
|
82
83
|
keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
|
|
83
84
|
duration: 2000,// 动画时长。
|
|
@@ -136,7 +136,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
136
136
|
* 给行附加className<br>
|
|
137
137
|
* FIXME: 是否需要优化,因为不传此prop会使表格行一直执行空函数,是否有影响
|
|
138
138
|
*/
|
|
139
|
-
rowClassName?: (row: DT, i: number) => string;
|
|
139
|
+
rowClassName?: (row: DT, i: number) => string | undefined;
|
|
140
140
|
/**
|
|
141
141
|
* 列宽是否可拖动(需要设置v-model:columns)<br>
|
|
142
142
|
* **不要设置**列minWidth,**必须**设置width<br>
|
|
@@ -502,7 +502,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
502
502
|
* 给行附加className<br>
|
|
503
503
|
* FIXME: 是否需要优化,因为不传此prop会使表格行一直执行空函数,是否有影响
|
|
504
504
|
*/
|
|
505
|
-
rowClassName?: (row: DT, i: number) => string;
|
|
505
|
+
rowClassName?: (row: DT, i: number) => string | undefined;
|
|
506
506
|
/**
|
|
507
507
|
* 列宽是否可拖动(需要设置v-model:columns)<br>
|
|
508
508
|
* **不要设置**列minWidth,**必须**设置width<br>
|
|
@@ -703,7 +703,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
703
703
|
cellActive: boolean;
|
|
704
704
|
selectedCellRevokable: boolean;
|
|
705
705
|
headerDrag: boolean | HeaderDragConfig;
|
|
706
|
-
rowClassName: (row: DT, i: number) => string;
|
|
706
|
+
rowClassName: (row: DT, i: number) => string | undefined;
|
|
707
707
|
colResizable: boolean | ColResizableConfig<DT>;
|
|
708
708
|
colMinWidth: number;
|
|
709
709
|
bordered: boolean | "h" | "v" | "body-v";
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -296,7 +296,7 @@ function getColWidth(col) {
|
|
|
296
296
|
return parseInt(val);
|
|
297
297
|
}
|
|
298
298
|
function getCalculatedColWidth(col) {
|
|
299
|
-
return (col && col.__WIDTH__) ??
|
|
299
|
+
return (col && col.__WIDTH__) ?? +DEFAULT_COL_WIDTH;
|
|
300
300
|
}
|
|
301
301
|
function createStkTableId() {
|
|
302
302
|
let id = window.__STK_TB_ID_COUNT__;
|
|
@@ -2419,10 +2419,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2419
2419
|
headless: _ctx.headless,
|
|
2420
2420
|
"is-col-resizing": unref(isColResizing),
|
|
2421
2421
|
"col-resizable": props.colResizable,
|
|
2422
|
-
|
|
2423
|
-
"
|
|
2424
|
-
"
|
|
2425
|
-
"
|
|
2422
|
+
bordered: props.bordered,
|
|
2423
|
+
"bordered-h": props.bordered === "h",
|
|
2424
|
+
"bordered-v": props.bordered === "v",
|
|
2425
|
+
"bordered-body-v": props.bordered === "body-v",
|
|
2426
2426
|
stripe: props.stripe,
|
|
2427
2427
|
"cell-hover": props.cellHover,
|
|
2428
2428
|
"cell-active": props.cellActive,
|
|
@@ -2575,7 +2575,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2575
2575
|
class: normalizeClass({
|
|
2576
2576
|
active: _ctx.rowKey ? rowKeyGen(row) === currentRowKey.value : row === currentRow.value,
|
|
2577
2577
|
hover: props.showTrHoverClass && (_ctx.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
|
|
2578
|
-
[_ctx.rowClassName(row, getRowIndex(rowIndex))]: true,
|
|
2578
|
+
[_ctx.rowClassName(row, getRowIndex(rowIndex)) || ""]: true,
|
|
2579
2579
|
expanded: row == null ? void 0 : row.__EXPANDED__,
|
|
2580
2580
|
"expanded-row": row && row.__EXPANDED_ROW__
|
|
2581
2581
|
}),
|
|
@@ -2624,9 +2624,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2624
2624
|
"tree-expanded": col.type === "tree-node" && row.__T_EXPANDED__,
|
|
2625
2625
|
"drag-row-cell": col.type === "dragRow"
|
|
2626
2626
|
}
|
|
2627
|
-
]
|
|
2628
|
-
|
|
2629
|
-
}, unref(mergeCellsWrapper)(row, col, rowIndex, colIndex), {
|
|
2627
|
+
]
|
|
2628
|
+
}, { ref_for: true }, unref(mergeCellsWrapper)(row, col, rowIndex, colIndex), {
|
|
2630
2629
|
onClick: ($event) => onCellClick($event, row, col, getRowIndex(rowIndex)),
|
|
2631
2630
|
onMousedown: ($event) => onCellMouseDown($event, row, col, getRowIndex(rowIndex)),
|
|
2632
2631
|
onMouseenter: ($event) => onCellMouseEnter($event, row, col),
|
|
@@ -2649,7 +2648,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2649
2648
|
expanded: row && row.__EXPANDED__ || null,
|
|
2650
2649
|
"tree-expanded": row && row.__T_EXPANDED__ || null
|
|
2651
2650
|
}, {
|
|
2652
|
-
|
|
2651
|
+
stkFoldIcon: withCtx(() => [
|
|
2653
2652
|
createVNode(TriangleIcon)
|
|
2654
2653
|
]),
|
|
2655
2654
|
_: 2
|
|
@@ -2671,7 +2670,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2671
2670
|
rowIndex: getRowIndex(rowIndex),
|
|
2672
2671
|
colIndex,
|
|
2673
2672
|
cellValue: row && row[col.dataIndex]
|
|
2674
|
-
},
|
|
2673
|
+
}, {
|
|
2674
|
+
stkFoldIcon: withCtx(() => [
|
|
2675
|
+
createVNode(TriangleIcon)
|
|
2676
|
+
]),
|
|
2677
|
+
stkDragIcon: withCtx(() => [
|
|
2678
|
+
createVNode(DragHandle, {
|
|
2679
|
+
onDragstart: ($event) => unref(onTrDragStart)($event, getRowIndex(rowIndex))
|
|
2680
|
+
}, null, 8, ["onDragstart"])
|
|
2681
|
+
]),
|
|
2682
|
+
_: 2
|
|
2683
|
+
}, 1032, ["col", "row", "rowIndex", "colIndex", "cellValue"])) : (openBlock(), createElementBlock("div", {
|
|
2675
2684
|
key: 1,
|
|
2676
2685
|
class: "table-cell-wrapper",
|
|
2677
2686
|
title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : ""
|
package/lib/style.css
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
--drag-handle-hover-color:#5d6064;
|
|
67
67
|
color:#d1d1e0;
|
|
68
68
|
}
|
|
69
|
-
.stk-table.headless.
|
|
69
|
+
.stk-table.headless.bordered{
|
|
70
70
|
border-top:1px solid var(--border-color);
|
|
71
71
|
background-image:var(--bg-border-right), var(--bg-border-bottom);
|
|
72
72
|
}
|
|
@@ -79,27 +79,27 @@
|
|
|
79
79
|
.stk-table.is-col-resizing th{
|
|
80
80
|
pointer-events:none;
|
|
81
81
|
}
|
|
82
|
-
.stk-table.
|
|
82
|
+
.stk-table.bordered{
|
|
83
83
|
border-left:1px solid var(--border-color);
|
|
84
84
|
background-image:var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
85
85
|
}
|
|
86
|
-
.stk-table.
|
|
87
|
-
.stk-table.
|
|
86
|
+
.stk-table.bordered th,
|
|
87
|
+
.stk-table.bordered td{
|
|
88
88
|
background-image:var(--bg-border-right), var(--bg-border-bottom);
|
|
89
89
|
}
|
|
90
|
-
.stk-table.
|
|
90
|
+
.stk-table.bordered thead tr:first-child th{
|
|
91
91
|
background-image:var(--bg-border-top), var(--bg-border-right), var(--bg-border-bottom);
|
|
92
92
|
}
|
|
93
|
-
.stk-table.
|
|
93
|
+
.stk-table.bordered-h{
|
|
94
94
|
border-left:none;
|
|
95
95
|
--bg-border-right:linear-gradient(transparent, transparent);
|
|
96
96
|
--bg-border-left:linear-gradient(transparent, transparent);
|
|
97
97
|
}
|
|
98
|
-
.stk-table.
|
|
98
|
+
.stk-table.bordered-v{
|
|
99
99
|
--bg-border-bottom:linear-gradient(transparent, transparent);
|
|
100
100
|
--bg-border-top:linear-gradient(transparent, transparent);
|
|
101
101
|
}
|
|
102
|
-
.stk-table.
|
|
102
|
+
.stk-table.bordered-body-v tbody{
|
|
103
103
|
--bg-border-bottom:linear-gradient(transparent, transparent);
|
|
104
104
|
}
|
|
105
105
|
.stk-table.stripe:not(.vt-on) .stk-tbody-main tr:nth-child(even){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stk-table-vue",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Simple realtime virtual table for vue3 and vue2.7",
|
|
5
5
|
"main": "./lib/stk-table-vue.js",
|
|
6
6
|
"types": "./lib/src/StkTable/index.d.ts",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"@types/node": "^20.12.10",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
46
46
|
"@typescript-eslint/parser": "^7.7.0",
|
|
47
|
-
"@vitejs/plugin-vue": "^
|
|
48
|
-
"@vue/test-utils": "2.4.
|
|
47
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
48
|
+
"@vue/test-utils": "^2.4.6",
|
|
49
49
|
"eslint": "^8.57.0",
|
|
50
50
|
"eslint-config-prettier": "^9.1.0",
|
|
51
51
|
"eslint-plugin-html": "^8.1.0",
|
|
52
52
|
"eslint-plugin-prettier": "^5.1.3",
|
|
53
53
|
"eslint-plugin-vue": "^9.25.0",
|
|
54
|
-
"happy-dom": "^
|
|
54
|
+
"happy-dom": "^18.0.1",
|
|
55
55
|
"less": "^4.2.0",
|
|
56
56
|
"mitt": "^3.0.1",
|
|
57
57
|
"mockjs": "^1.1.0",
|
|
@@ -59,17 +59,15 @@
|
|
|
59
59
|
"postcss-discard-comments": "^6.0.2",
|
|
60
60
|
"postcss-preset-env": "^9.5.11",
|
|
61
61
|
"prettier": "^3.2.5",
|
|
62
|
-
"stk-table-vue": "^0.
|
|
63
|
-
"typescript": "^5.
|
|
64
|
-
"vite": "^
|
|
62
|
+
"stk-table-vue": "^0.8.1",
|
|
63
|
+
"typescript": "^5.8.3",
|
|
64
|
+
"vite": "^7.0.2",
|
|
65
65
|
"vite-plugin-dts": "3.9.1",
|
|
66
66
|
"vitepress": "^1.6.3",
|
|
67
67
|
"vitepress-demo-plugin": "^1.4.5",
|
|
68
|
-
"vitepress-plugin-llms": "^1.
|
|
69
|
-
"vitest": "^2.
|
|
70
|
-
"vue": "^3.5.
|
|
68
|
+
"vitepress-plugin-llms": "^1.7.0",
|
|
69
|
+
"vitest": "^3.2.4",
|
|
70
|
+
"vue": "^3.5.17",
|
|
71
71
|
"vue-eslint-parser": "^9.4.2"
|
|
72
|
-
},
|
|
73
|
-
"dependencies": {
|
|
74
72
|
}
|
|
75
73
|
}
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
headless,
|
|
13
13
|
'is-col-resizing': isColResizing,
|
|
14
14
|
'col-resizable': props.colResizable,
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
15
|
+
bordered: props.bordered,
|
|
16
|
+
'bordered-h': props.bordered === 'h',
|
|
17
|
+
'bordered-v': props.bordered === 'v',
|
|
18
|
+
'bordered-body-v': props.bordered === 'body-v',
|
|
19
19
|
stripe: props.stripe,
|
|
20
20
|
'cell-hover': props.cellHover,
|
|
21
21
|
'cell-active': props.cellActive,
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
:class="{
|
|
127
127
|
active: rowKey ? rowKeyGen(row) === currentRowKey : row === currentRow,
|
|
128
128
|
hover: props.showTrHoverClass && (rowKey ? rowKeyGen(row) === currentHoverRowKey : row === currentHoverRowKey),
|
|
129
|
-
[rowClassName(row, getRowIndex(rowIndex))]: true,
|
|
129
|
+
[rowClassName(row, getRowIndex(rowIndex)) || '']: true,
|
|
130
130
|
expanded: row?.__EXPANDED__,
|
|
131
131
|
'expanded-row': row && row.__EXPANDED_ROW__,
|
|
132
132
|
}"
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
:expanded="(row && row.__EXPANDED__) || null"
|
|
197
197
|
:tree-expanded="(row && row.__T_EXPANDED__) || null"
|
|
198
198
|
>
|
|
199
|
-
<template #
|
|
199
|
+
<template #stkFoldIcon>
|
|
200
200
|
<TriangleIcon></TriangleIcon>
|
|
201
201
|
</template>
|
|
202
202
|
</component>
|
|
@@ -221,7 +221,14 @@
|
|
|
221
221
|
:rowIndex="getRowIndex(rowIndex)"
|
|
222
222
|
:colIndex="colIndex"
|
|
223
223
|
:cellValue="row && row[col.dataIndex]"
|
|
224
|
-
|
|
224
|
+
>
|
|
225
|
+
<template #stkFoldIcon>
|
|
226
|
+
<TriangleIcon></TriangleIcon>
|
|
227
|
+
</template>
|
|
228
|
+
<template #stkDragIcon>
|
|
229
|
+
<DragHandle @dragstart="onTrDragStart($event, getRowIndex(rowIndex))" />
|
|
230
|
+
</template>
|
|
231
|
+
</component>
|
|
225
232
|
<div v-else class="table-cell-wrapper" :title="col.type !== 'seq' ? row?.[col.dataIndex] : ''">
|
|
226
233
|
<template v-if="col.type === 'seq'">
|
|
227
234
|
{{ (props.seqConfig.startIndex || 0) + getRowIndex(rowIndex) + 1 }}
|
|
@@ -376,7 +383,7 @@ const props = withDefaults(
|
|
|
376
383
|
* 给行附加className<br>
|
|
377
384
|
* FIXME: 是否需要优化,因为不传此prop会使表格行一直执行空函数,是否有影响
|
|
378
385
|
*/
|
|
379
|
-
rowClassName?: (row: DT, i: number) => string;
|
|
386
|
+
rowClassName?: (row: DT, i: number) => string | undefined;
|
|
380
387
|
/**
|
|
381
388
|
* 列宽是否可拖动(需要设置v-model:columns)<br>
|
|
382
389
|
* **不要设置**列minWidth,**必须**设置width<br>
|
package/src/StkTable/style.less
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
&.headless {
|
|
94
|
-
&.
|
|
94
|
+
&.bordered {
|
|
95
95
|
border-top: 1px solid var(--border-color);
|
|
96
96
|
background-image: var(--bg-border-right), var(--bg-border-bottom);
|
|
97
97
|
}
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
&.
|
|
115
|
+
&.bordered {
|
|
116
116
|
/**
|
|
117
117
|
* border-left: 此方案用于减少cell 中border-left 的css选择。同时利于多级表头border-left问题。利于横向滚动border-left
|
|
118
118
|
* - box-shadow inset 方案不生效,且占用属性。
|
|
@@ -134,18 +134,18 @@
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
&.
|
|
137
|
+
&.bordered-h {
|
|
138
138
|
border-left: none;
|
|
139
139
|
--bg-border-right: linear-gradient(transparent, transparent);
|
|
140
140
|
--bg-border-left: linear-gradient(transparent, transparent);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
&.
|
|
143
|
+
&.bordered-v {
|
|
144
144
|
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
145
145
|
--bg-border-top: linear-gradient(transparent, transparent);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
&.
|
|
148
|
+
&.bordered-body-v {
|
|
149
149
|
tbody {
|
|
150
150
|
--bg-border-bottom: linear-gradient(transparent, transparent);
|
|
151
151
|
}
|
|
@@ -378,13 +378,12 @@
|
|
|
378
378
|
|
|
379
379
|
.fixed-cell {
|
|
380
380
|
background-color: inherit;
|
|
381
|
-
/* 防止横向滚动后透明*/
|
|
382
381
|
}
|
|
383
382
|
|
|
384
383
|
.highlight-cell {
|
|
385
384
|
animation: stk-table-dim var(--highlight-duration);
|
|
386
385
|
animation-timing-function: var(--highlight-timing-function);
|
|
387
|
-
/*
|
|
386
|
+
/* 必须分开写,否则var(step(x))不兼容旧浏览器*/
|
|
388
387
|
}
|
|
389
388
|
|
|
390
389
|
.seq-column {
|
package/src/StkTable/useTree.ts
CHANGED
|
@@ -124,7 +124,7 @@ export function useTree({ props, dataSourceCopy, rowKeyGen, emits }: Option<DT>)
|
|
|
124
124
|
function expandNode(row: DT, level: number) {
|
|
125
125
|
let result: DT[] = [];
|
|
126
126
|
row.children &&
|
|
127
|
-
row.children.forEach(child => {
|
|
127
|
+
row.children.forEach((child: DT) => {
|
|
128
128
|
result.push(child);
|
|
129
129
|
const childLv = level + 1;
|
|
130
130
|
if (child.__T_EXPANDED__ && child.children) {
|