stk-table-vue 0.4.2 → 0.4.3
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 +11 -4
- package/lib/src/StkTable/StkTable.vue.d.ts +24 -6
- package/lib/stk-table-vue.js +10 -1
- package/lib/style.css +7 -7
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +19 -3
- package/src/StkTable/style.less +15 -17
package/README.md
CHANGED
|
@@ -86,11 +86,11 @@ vue2.7 支持引入源码使用。依赖`less`。
|
|
|
86
86
|
Use `css`
|
|
87
87
|
```html
|
|
88
88
|
<script>
|
|
89
|
-
import
|
|
89
|
+
import StkTable from 'stk-table-vue/src/StkTable/StkTable.vue';
|
|
90
90
|
import 'stk-table-vue/lib/style.css';
|
|
91
91
|
</script>
|
|
92
92
|
```
|
|
93
|
-
#### webpack TS
|
|
93
|
+
#### webpack TS
|
|
94
94
|
##### webpack.config.js
|
|
95
95
|
```js
|
|
96
96
|
rules:[{
|
|
@@ -134,6 +134,12 @@ export type StkProps = {
|
|
|
134
134
|
theme?: 'light' | 'dark';
|
|
135
135
|
/** 行高 */
|
|
136
136
|
rowHeight?: number;
|
|
137
|
+
/** 是否高亮鼠标悬浮的行 */
|
|
138
|
+
rowHover?: boolean;
|
|
139
|
+
/** 是否高亮选中的行 */
|
|
140
|
+
rowActive?: boolean;
|
|
141
|
+
/** 当前行再次点击否可以取消 */
|
|
142
|
+
rowCurrentRevokable?: boolean;
|
|
137
143
|
/** 表头行高。default = rowHeight */
|
|
138
144
|
headerRowHeight?: number | null;
|
|
139
145
|
/** 虚拟滚动 */
|
|
@@ -162,6 +168,7 @@ export type StkProps = {
|
|
|
162
168
|
showOverflow?: boolean;
|
|
163
169
|
/** 是否增加行hover class */
|
|
164
170
|
showTrHoverClass?: boolean;
|
|
171
|
+
|
|
165
172
|
/** 是否高亮鼠标悬浮的单元格 */
|
|
166
173
|
cellHover?: boolean;
|
|
167
174
|
/** 表头是否可拖动。支持回调函数。 */
|
|
@@ -436,7 +443,7 @@ export type SortConfig<T extends Record<string, any>> = {
|
|
|
436
443
|
rowKeyValues: UniqKey[],
|
|
437
444
|
option: {
|
|
438
445
|
method?: 'css' | 'animation' | 'js';
|
|
439
|
-
/** @deprecated
|
|
446
|
+
/** @deprecated use method */
|
|
440
447
|
useCss?: boolean;
|
|
441
448
|
className?: string;
|
|
442
449
|
keyframe?: Parameters<Animatable['animate']>['0'];
|
|
@@ -450,7 +457,7 @@ export type SortConfig<T extends Record<string, any>> = {
|
|
|
450
457
|
rowKeyValues: UniqKey[],
|
|
451
458
|
option: {
|
|
452
459
|
method?: 'css' | 'animation' | 'js';
|
|
453
|
-
/** @deprecated
|
|
460
|
+
/** @deprecated use method */
|
|
454
461
|
useCss?: boolean;
|
|
455
462
|
className?: string;
|
|
456
463
|
keyframe?: Parameters<Animatable['animate']>['0'];
|
|
@@ -53,6 +53,12 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
53
53
|
theme?: "light" | "dark" | undefined;
|
|
54
54
|
/** 行高 */
|
|
55
55
|
rowHeight?: number | undefined;
|
|
56
|
+
/** 是否高亮鼠标悬浮的行 */
|
|
57
|
+
rowHover?: boolean | undefined;
|
|
58
|
+
/** 是否高亮选中的行 */
|
|
59
|
+
rowActive?: boolean | undefined;
|
|
60
|
+
/** 当前行再次点击否可以取消 */
|
|
61
|
+
rowCurrentRevokable?: boolean | undefined;
|
|
56
62
|
/** 表头行高。default = rowHeight */
|
|
57
63
|
headerRowHeight?: number | null | undefined;
|
|
58
64
|
/** 虚拟滚动 */
|
|
@@ -82,7 +88,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
82
88
|
showHeaderOverflow?: boolean | undefined;
|
|
83
89
|
/** 表体溢出是否展示... */
|
|
84
90
|
showOverflow?: boolean | undefined;
|
|
85
|
-
/** 是否增加行hover class */
|
|
91
|
+
/** 是否增加行hover class $*$ rename*/
|
|
86
92
|
showTrHoverClass?: boolean | undefined;
|
|
87
93
|
/** 是否高亮鼠标悬浮的单元格 */
|
|
88
94
|
cellHover?: boolean | undefined;
|
|
@@ -146,6 +152,9 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
146
152
|
headless: boolean;
|
|
147
153
|
theme: string;
|
|
148
154
|
rowHeight: number;
|
|
155
|
+
rowHover: boolean;
|
|
156
|
+
rowActive: boolean;
|
|
157
|
+
rowCurrentRevokable: boolean;
|
|
149
158
|
headerRowHeight: null;
|
|
150
159
|
virtual: boolean;
|
|
151
160
|
virtualX: boolean;
|
|
@@ -190,10 +199,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
190
199
|
setHighlightDimCell: (rowKeyValue: string, dataIndex: string, option?: {
|
|
191
200
|
className?: string | undefined;
|
|
192
201
|
method?: "animation" | "css" | undefined;
|
|
193
|
-
keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined;
|
|
194
|
-
* 选中一行触发。ev返回null表示不是点击事件触发的
|
|
195
|
-
* ```(ev: MouseEvent | null, row: DT | undefined, data: { select: boolean })```
|
|
196
|
-
*/
|
|
202
|
+
keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined;
|
|
197
203
|
duration?: number | undefined;
|
|
198
204
|
}) => void;
|
|
199
205
|
/** 设置高亮渐暗行 */
|
|
@@ -255,6 +261,12 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
255
261
|
theme?: "light" | "dark" | undefined;
|
|
256
262
|
/** 行高 */
|
|
257
263
|
rowHeight?: number | undefined;
|
|
264
|
+
/** 是否高亮鼠标悬浮的行 */
|
|
265
|
+
rowHover?: boolean | undefined;
|
|
266
|
+
/** 是否高亮选中的行 */
|
|
267
|
+
rowActive?: boolean | undefined;
|
|
268
|
+
/** 当前行再次点击否可以取消 */
|
|
269
|
+
rowCurrentRevokable?: boolean | undefined;
|
|
258
270
|
/** 表头行高。default = rowHeight */
|
|
259
271
|
headerRowHeight?: number | null | undefined;
|
|
260
272
|
/** 虚拟滚动 */
|
|
@@ -284,7 +296,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
284
296
|
showHeaderOverflow?: boolean | undefined;
|
|
285
297
|
/** 表体溢出是否展示... */
|
|
286
298
|
showOverflow?: boolean | undefined;
|
|
287
|
-
/** 是否增加行hover class */
|
|
299
|
+
/** 是否增加行hover class $*$ rename*/
|
|
288
300
|
showTrHoverClass?: boolean | undefined;
|
|
289
301
|
/** 是否高亮鼠标悬浮的单元格 */
|
|
290
302
|
cellHover?: boolean | undefined;
|
|
@@ -348,6 +360,9 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
348
360
|
headless: boolean;
|
|
349
361
|
theme: string;
|
|
350
362
|
rowHeight: number;
|
|
363
|
+
rowHover: boolean;
|
|
364
|
+
rowActive: boolean;
|
|
365
|
+
rowCurrentRevokable: boolean;
|
|
351
366
|
headerRowHeight: null;
|
|
352
367
|
virtual: boolean;
|
|
353
368
|
virtualX: boolean;
|
|
@@ -412,6 +427,9 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
412
427
|
stripe: boolean;
|
|
413
428
|
fixedMode: boolean;
|
|
414
429
|
theme: "light" | "dark";
|
|
430
|
+
rowHover: boolean;
|
|
431
|
+
rowActive: boolean;
|
|
432
|
+
rowCurrentRevokable: boolean;
|
|
415
433
|
virtual: boolean;
|
|
416
434
|
virtualX: boolean;
|
|
417
435
|
columns: StkTableColumn<DT>[];
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -1153,6 +1153,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1153
1153
|
headless: { type: Boolean, default: false },
|
|
1154
1154
|
theme: { default: "light" },
|
|
1155
1155
|
rowHeight: { default: DEFAULT_ROW_HEIGHT },
|
|
1156
|
+
rowHover: { type: Boolean, default: true },
|
|
1157
|
+
rowActive: { type: Boolean, default: true },
|
|
1158
|
+
rowCurrentRevokable: { type: Boolean, default: true },
|
|
1156
1159
|
headerRowHeight: { default: null },
|
|
1157
1160
|
virtual: { type: Boolean, default: false },
|
|
1158
1161
|
virtualX: { type: Boolean, default: false },
|
|
@@ -1479,7 +1482,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1479
1482
|
}
|
|
1480
1483
|
function onRowClick(e, row) {
|
|
1481
1484
|
emits("row-click", e, row);
|
|
1482
|
-
|
|
1485
|
+
const isCurrentRow = props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row;
|
|
1486
|
+
if (isCurrentRow) {
|
|
1487
|
+
if (!props.rowCurrentRevokable) {
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1483
1490
|
currentRow.value = void 0;
|
|
1484
1491
|
currentRowKey.value = void 0;
|
|
1485
1492
|
emits("current-change", e, row, { select: false });
|
|
@@ -1667,6 +1674,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1667
1674
|
"border-body-v": props.bordered === "body-v",
|
|
1668
1675
|
stripe: props.stripe,
|
|
1669
1676
|
"cell-hover": props.cellHover,
|
|
1677
|
+
"row-hover": props.rowHover,
|
|
1678
|
+
"row-active": props.rowActive,
|
|
1670
1679
|
"text-overflow": props.showOverflow,
|
|
1671
1680
|
"header-text-overflow": props.showHeaderOverflow,
|
|
1672
1681
|
"fixed-relative-mode": isRelativeMode.value
|
package/lib/style.css
CHANGED
|
@@ -94,6 +94,12 @@
|
|
|
94
94
|
.stk-table.stripe tbody tr:nth-child(even){
|
|
95
95
|
background-color:var(--stripe-bgc);
|
|
96
96
|
}
|
|
97
|
+
.stk-table.row-hover tbody tr:hover{
|
|
98
|
+
background-color:var(--tr-hover-bgc);
|
|
99
|
+
}
|
|
100
|
+
.stk-table.row-active tbody tr.active{
|
|
101
|
+
background-color:var(--tr-active-bgc);
|
|
102
|
+
}
|
|
97
103
|
.stk-table.cell-hover tbody td:hover{
|
|
98
104
|
box-shadow:inset 0 0 0 2px var(--td-hover-color);
|
|
99
105
|
}
|
|
@@ -177,16 +183,10 @@
|
|
|
177
183
|
background-color:var(--th-bgc);
|
|
178
184
|
height:var(--header-row-height);
|
|
179
185
|
}
|
|
180
|
-
.stk-table
|
|
186
|
+
.stk-table tbody tr{
|
|
181
187
|
background-color:var(--td-bgc);
|
|
182
188
|
height:var(--row-height);
|
|
183
189
|
}
|
|
184
|
-
.stk-table .stk-table-main tbody tr:hover{
|
|
185
|
-
background-color:var(--tr-hover-bgc);
|
|
186
|
-
}
|
|
187
|
-
.stk-table .stk-table-main tbody tr.active{
|
|
188
|
-
background-color:var(--tr-active-bgc);
|
|
189
|
-
}
|
|
190
190
|
.stk-table .virtual-x-left,
|
|
191
191
|
.stk-table .virtual-x-right{
|
|
192
192
|
padding:0;
|
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
'border-body-v': props.bordered === 'body-v',
|
|
16
16
|
stripe: props.stripe,
|
|
17
17
|
'cell-hover': props.cellHover,
|
|
18
|
+
'row-hover': props.rowHover,
|
|
19
|
+
'row-active': props.rowActive,
|
|
18
20
|
'text-overflow': props.showOverflow,
|
|
19
21
|
'header-text-overflow': props.showHeaderOverflow,
|
|
20
22
|
'fixed-relative-mode': isRelativeMode,
|
|
@@ -249,6 +251,12 @@ const props = withDefaults(
|
|
|
249
251
|
theme?: 'light' | 'dark';
|
|
250
252
|
/** 行高 */
|
|
251
253
|
rowHeight?: number;
|
|
254
|
+
/** 是否高亮鼠标悬浮的行 */
|
|
255
|
+
rowHover?: boolean;
|
|
256
|
+
/** 是否高亮选中的行 */
|
|
257
|
+
rowActive?: boolean;
|
|
258
|
+
/** 当前行再次点击否可以取消 */
|
|
259
|
+
rowCurrentRevokable?: boolean;
|
|
252
260
|
/** 表头行高。default = rowHeight */
|
|
253
261
|
headerRowHeight?: number | null;
|
|
254
262
|
/** 虚拟滚动 */
|
|
@@ -275,7 +283,7 @@ const props = withDefaults(
|
|
|
275
283
|
showHeaderOverflow?: boolean;
|
|
276
284
|
/** 表体溢出是否展示... */
|
|
277
285
|
showOverflow?: boolean;
|
|
278
|
-
/** 是否增加行hover class */
|
|
286
|
+
/** 是否增加行hover class $*$ rename*/
|
|
279
287
|
showTrHoverClass?: boolean;
|
|
280
288
|
/** 是否高亮鼠标悬浮的单元格 */
|
|
281
289
|
cellHover?: boolean;
|
|
@@ -340,6 +348,9 @@ const props = withDefaults(
|
|
|
340
348
|
headless: false,
|
|
341
349
|
theme: 'light',
|
|
342
350
|
rowHeight: DEFAULT_ROW_HEIGHT,
|
|
351
|
+
rowHover: true,
|
|
352
|
+
rowActive: true,
|
|
353
|
+
rowCurrentRevokable: true,
|
|
343
354
|
headerRowHeight: null,
|
|
344
355
|
virtual: false,
|
|
345
356
|
virtualX: false,
|
|
@@ -874,8 +885,13 @@ function onColumnSort(col?: StkTableColumn<DT>, click = true, options: { force?:
|
|
|
874
885
|
|
|
875
886
|
function onRowClick(e: MouseEvent, row: DT) {
|
|
876
887
|
emits('row-click', e, row);
|
|
877
|
-
|
|
878
|
-
if (
|
|
888
|
+
const isCurrentRow = props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row;
|
|
889
|
+
if (isCurrentRow) {
|
|
890
|
+
if (!props.rowCurrentRevokable) {
|
|
891
|
+
// 不可取消
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
// 点击同一行,取消当前选中行。
|
|
879
895
|
currentRow.value = void 0;
|
|
880
896
|
currentRowKey.value = void 0;
|
|
881
897
|
emits('current-change', e, row, { select: false });
|
package/src/StkTable/style.less
CHANGED
|
@@ -141,6 +141,15 @@
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
&.row-hover tbody tr:hover {
|
|
145
|
+
background-color: var(--tr-hover-bgc);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
&.row-active tbody tr.active {
|
|
150
|
+
background-color: var(--tr-active-bgc);
|
|
151
|
+
}
|
|
152
|
+
|
|
144
153
|
/* 单元格悬浮 */
|
|
145
154
|
&.cell-hover tbody td:hover {
|
|
146
155
|
box-shadow: inset 0 0 0 2px var(--td-hover-color);
|
|
@@ -258,29 +267,18 @@
|
|
|
258
267
|
|
|
259
268
|
}
|
|
260
269
|
|
|
261
|
-
thead {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
height: var(--header-row-height);
|
|
265
|
-
}
|
|
270
|
+
thead tr {
|
|
271
|
+
background-color: var(--th-bgc);
|
|
272
|
+
height: var(--header-row-height);
|
|
266
273
|
}
|
|
267
274
|
|
|
268
|
-
|
|
269
|
-
|
|
275
|
+
|
|
276
|
+
tbody tr {
|
|
270
277
|
background-color: var(--td-bgc);
|
|
271
278
|
height: var(--row-height);
|
|
272
|
-
/** 一行分层,有利于高亮行重绘
|
|
273
|
-
transform: translateZ(0);*/
|
|
274
|
-
|
|
275
|
-
&:hover {
|
|
276
|
-
background-color: var(--tr-hover-bgc);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
&.active {
|
|
280
|
-
background-color: var(--tr-active-bgc);
|
|
281
|
-
}
|
|
282
279
|
}
|
|
283
280
|
|
|
281
|
+
|
|
284
282
|
.virtual-x-left,
|
|
285
283
|
.virtual-x-right {
|
|
286
284
|
padding: 0;
|