stk-table-vue 0.3.0 → 0.3.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 +26 -12
- package/lib/src/StkTable/StkTable.vue.d.ts +21 -4
- package/lib/stk-table-vue.js +63 -42
- package/lib/style.css +118 -117
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +74 -30
- package/src/StkTable/style.less +202 -203
- package/src/StkTable/useFixedStyle.ts +1 -1
- package/src/StkTable/useHighlight.ts +5 -4
- package/src/StkTable/useVirtualScroll.ts +11 -10
- package/src/StkTable/utils.ts +1 -1
package/lib/style.css
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
--border-color:#e8e8f4;
|
|
12
12
|
--border-width:1px;
|
|
13
13
|
--td-bgc:#fff;
|
|
14
|
+
--td-hover-color:#71a2fd;
|
|
14
15
|
--th-bgc:#fafafc;
|
|
15
16
|
--th-color:#272841;
|
|
16
17
|
--tr-active-bgc:#e6f7ff;
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
--bg-border-left:linear-gradient(90deg, var(--border-color) var(--border-width), transparent var(--border-width));
|
|
22
23
|
--highlight-color:#71a2fd;
|
|
23
24
|
--highlight-duration:2s;
|
|
24
|
-
--highlight-
|
|
25
|
+
--highlight-timing-function:linear;
|
|
25
26
|
--stripe-bgc:#fafafc;
|
|
26
27
|
--sort-arrow-color:#757699;
|
|
27
28
|
--sort-arrow-hover-color:#8f90b5;
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
--th-bgc:#202029;
|
|
45
46
|
--th-color:#C0C0D1;
|
|
46
47
|
--td-bgc:#1b1b24;
|
|
48
|
+
--td-hover-color:#70a6ff;
|
|
47
49
|
--border-color:#292933;
|
|
48
50
|
--tr-active-bgc:#283f63;
|
|
49
51
|
--tr-hover-bgc:#1a2b46;
|
|
@@ -98,11 +100,103 @@
|
|
|
98
100
|
.stk-table.border-body-v tbody{
|
|
99
101
|
--bg-border-bottom:linear-gradient(transparent, transparent);
|
|
100
102
|
}
|
|
101
|
-
.stk-table.stripe{
|
|
102
|
-
}
|
|
103
103
|
.stk-table.stripe tbody tr:nth-child(odd){
|
|
104
104
|
background-color:var(--stripe-bgc);
|
|
105
105
|
}
|
|
106
|
+
.stk-table.cell-hover tbody td:hover{
|
|
107
|
+
box-shadow:inset 0 0 0 2px var(--td-hover-color);
|
|
108
|
+
}
|
|
109
|
+
.stk-table.text-overflow .table-cell-wrapper{
|
|
110
|
+
white-space:nowrap;
|
|
111
|
+
overflow:hidden;
|
|
112
|
+
text-overflow:ellipsis;
|
|
113
|
+
}
|
|
114
|
+
.stk-table.header-text-overflow .table-header-cell-wrapper{
|
|
115
|
+
white-space:nowrap;
|
|
116
|
+
overflow:hidden;
|
|
117
|
+
}
|
|
118
|
+
.stk-table.header-text-overflow .table-header-title{
|
|
119
|
+
text-overflow:ellipsis;
|
|
120
|
+
overflow:hidden;
|
|
121
|
+
}
|
|
122
|
+
.stk-table.virtual{
|
|
123
|
+
}
|
|
124
|
+
.stk-table.virtual .table-header-cell-wrapper{
|
|
125
|
+
overflow:hidden;
|
|
126
|
+
max-height:var(--header-row-height);
|
|
127
|
+
}
|
|
128
|
+
.stk-table.virtual tbody td{
|
|
129
|
+
height:var(--row-height);
|
|
130
|
+
line-height:1;
|
|
131
|
+
}
|
|
132
|
+
.stk-table.virtual tbody td .table-cell-wrapper{
|
|
133
|
+
max-height:var(--row-height);
|
|
134
|
+
overflow:hidden;
|
|
135
|
+
}
|
|
136
|
+
.stk-table.virtual .padding-top-tr td{
|
|
137
|
+
height:0;
|
|
138
|
+
}
|
|
139
|
+
.stk-table.virtual-x .virtual-x-left{
|
|
140
|
+
padding:0;
|
|
141
|
+
}
|
|
142
|
+
.stk-table th,
|
|
143
|
+
.stk-table td{
|
|
144
|
+
z-index:1;
|
|
145
|
+
font-size:14px;
|
|
146
|
+
box-sizing:border-box;
|
|
147
|
+
padding:0 var(--cell-padding-x);
|
|
148
|
+
}
|
|
149
|
+
.stk-table th{
|
|
150
|
+
color:var(--th-color);
|
|
151
|
+
background-color:inherit;
|
|
152
|
+
}
|
|
153
|
+
.stk-table th.sortable{
|
|
154
|
+
cursor:pointer;
|
|
155
|
+
}
|
|
156
|
+
.stk-table th:not(.sorter-desc):not(.sorter-asc):hover .table-header-sorter .arrow-up{
|
|
157
|
+
fill:var(--sort-arrow-hover-color);
|
|
158
|
+
}
|
|
159
|
+
.stk-table th:not(.sorter-desc):not(.sorter-asc):hover .table-header-sorter .arrow-down{
|
|
160
|
+
fill:var(--sort-arrow-hover-color);
|
|
161
|
+
}
|
|
162
|
+
.stk-table th.sorter-desc .table-header-sorter{
|
|
163
|
+
display:inline;
|
|
164
|
+
display:initial;
|
|
165
|
+
}
|
|
166
|
+
.stk-table th.sorter-desc .table-header-sorter .arrow-up{
|
|
167
|
+
fill:var(--sort-arrow-active-sub-color);
|
|
168
|
+
}
|
|
169
|
+
.stk-table th.sorter-desc .table-header-sorter .arrow-down{
|
|
170
|
+
fill:var(--sort-arrow-active-color);
|
|
171
|
+
}
|
|
172
|
+
.stk-table th.sorter-asc .table-header-sorter{
|
|
173
|
+
display:inline;
|
|
174
|
+
display:initial;
|
|
175
|
+
}
|
|
176
|
+
.stk-table th.sorter-asc .table-header-sorter .arrow-up{
|
|
177
|
+
fill:var(--sort-arrow-active-color);
|
|
178
|
+
}
|
|
179
|
+
.stk-table th.sorter-asc .table-header-sorter .arrow-down{
|
|
180
|
+
fill:var(--sort-arrow-active-sub-color);
|
|
181
|
+
}
|
|
182
|
+
.stk-table thead tr{
|
|
183
|
+
background-color:var(--th-bgc);
|
|
184
|
+
height:var(--header-row-height);
|
|
185
|
+
}
|
|
186
|
+
.stk-table thead tr:first-child th{
|
|
187
|
+
position:sticky;
|
|
188
|
+
top:0;
|
|
189
|
+
}
|
|
190
|
+
.stk-table .stk-table-main tbody tr{
|
|
191
|
+
background-color:var(--td-bgc);
|
|
192
|
+
height:var(--row-height);
|
|
193
|
+
}
|
|
194
|
+
.stk-table .stk-table-main tbody tr:hover{
|
|
195
|
+
background-color:var(--tr-hover-bgc);
|
|
196
|
+
}
|
|
197
|
+
.stk-table .stk-table-main tbody tr.active{
|
|
198
|
+
background-color:var(--tr-active-bgc);
|
|
199
|
+
}
|
|
106
200
|
.stk-table .column-resize-indicator{
|
|
107
201
|
width:0;
|
|
108
202
|
height:100%;
|
|
@@ -124,55 +218,29 @@
|
|
|
124
218
|
min-width:-moz-min-content;
|
|
125
219
|
min-width:min-content;
|
|
126
220
|
}
|
|
127
|
-
.stk-table .
|
|
128
|
-
.stk-table .stk-table-main td{
|
|
129
|
-
z-index:1;
|
|
130
|
-
font-size:14px;
|
|
131
|
-
box-sizing:border-box;
|
|
132
|
-
padding:0 var(--cell-padding-x);
|
|
133
|
-
}
|
|
134
|
-
.stk-table .stk-table-main th{
|
|
135
|
-
color:var(--th-color);
|
|
136
|
-
background-color:var(--th-bgc);
|
|
137
|
-
}
|
|
138
|
-
.stk-table .stk-table-main th.sortable{
|
|
139
|
-
cursor:pointer;
|
|
140
|
-
}
|
|
141
|
-
.stk-table .stk-table-main th.text-overflow .table-header-cell-wrapper{
|
|
142
|
-
white-space:nowrap;
|
|
143
|
-
overflow:hidden;
|
|
144
|
-
}
|
|
145
|
-
.stk-table .stk-table-main th.text-overflow .table-header-title{
|
|
146
|
-
text-overflow:ellipsis;
|
|
147
|
-
overflow:hidden;
|
|
148
|
-
}
|
|
149
|
-
.stk-table .stk-table-main td.fixed-cell{
|
|
221
|
+
.stk-table .fixed-cell{
|
|
150
222
|
background-color:inherit;
|
|
151
223
|
}
|
|
152
|
-
.stk-table .
|
|
153
|
-
animation:stk-table-dim var(--highlight-duration)
|
|
224
|
+
.stk-table .highlight-cell{
|
|
225
|
+
animation:stk-table-dim var(--highlight-duration);
|
|
226
|
+
animation-timing-function:var(--highlight-timing-function);
|
|
154
227
|
}
|
|
155
|
-
.stk-table .
|
|
156
|
-
white-space:nowrap;
|
|
157
|
-
overflow:hidden;
|
|
158
|
-
text-overflow:ellipsis;
|
|
159
|
-
}
|
|
160
|
-
.stk-table .stk-table-main td.seq-column{
|
|
228
|
+
.stk-table .seq-column{
|
|
161
229
|
text-align:center;
|
|
162
230
|
}
|
|
163
|
-
.stk-table .
|
|
231
|
+
.stk-table .fixed-cell--left{
|
|
164
232
|
--shadow-rotate:90deg;
|
|
165
233
|
}
|
|
166
|
-
.stk-table .
|
|
234
|
+
.stk-table .fixed-cell--left.fixed-cell--shadow::after{
|
|
167
235
|
right:-10px;
|
|
168
236
|
}
|
|
169
|
-
.stk-table .
|
|
237
|
+
.stk-table .fixed-cell--right{
|
|
170
238
|
--shadow-rotate:-90deg;
|
|
171
239
|
}
|
|
172
|
-
.stk-table .
|
|
240
|
+
.stk-table .fixed-cell--right.fixed-cell--shadow::after{
|
|
173
241
|
left:-10px;
|
|
174
242
|
}
|
|
175
|
-
.stk-table .
|
|
243
|
+
.stk-table .fixed-cell--shadow::after{
|
|
176
244
|
content:'';
|
|
177
245
|
width:10px;
|
|
178
246
|
height:100%;
|
|
@@ -181,86 +249,42 @@
|
|
|
181
249
|
pointer-events:none;
|
|
182
250
|
background-image:linear-gradient(var(--shadow-rotate), var(--fixed-col-shadow-color-from), var(--fixed-col-shadow-color-to));
|
|
183
251
|
}
|
|
184
|
-
.stk-table .
|
|
185
|
-
height:var(--header-row-height);
|
|
186
|
-
}
|
|
187
|
-
.stk-table .stk-table-main thead tr:first-child th{
|
|
188
|
-
position:sticky;
|
|
189
|
-
top:0;
|
|
190
|
-
}
|
|
191
|
-
.stk-table .stk-table-main th:not(.sorter-desc):not(.sorter-asc):hover .table-header-sorter .arrow-up{
|
|
192
|
-
fill:var(--sort-arrow-hover-color);
|
|
193
|
-
}
|
|
194
|
-
.stk-table .stk-table-main th:not(.sorter-desc):not(.sorter-asc):hover .table-header-sorter .arrow-down{
|
|
195
|
-
fill:var(--sort-arrow-hover-color);
|
|
196
|
-
}
|
|
197
|
-
.stk-table .stk-table-main th.sorter-desc .table-header-sorter{
|
|
198
|
-
display:inline;
|
|
199
|
-
display:initial;
|
|
200
|
-
}
|
|
201
|
-
.stk-table .stk-table-main th.sorter-desc .table-header-sorter .arrow-up{
|
|
202
|
-
fill:var(--sort-arrow-active-sub-color);
|
|
203
|
-
}
|
|
204
|
-
.stk-table .stk-table-main th.sorter-desc .table-header-sorter .arrow-down{
|
|
205
|
-
fill:var(--sort-arrow-active-color);
|
|
206
|
-
}
|
|
207
|
-
.stk-table .stk-table-main th.sorter-asc .table-header-sorter{
|
|
208
|
-
display:inline;
|
|
209
|
-
display:initial;
|
|
210
|
-
}
|
|
211
|
-
.stk-table .stk-table-main th.sorter-asc .table-header-sorter .arrow-up{
|
|
212
|
-
fill:var(--sort-arrow-active-color);
|
|
213
|
-
}
|
|
214
|
-
.stk-table .stk-table-main th.sorter-asc .table-header-sorter .arrow-down{
|
|
215
|
-
fill:var(--sort-arrow-active-sub-color);
|
|
216
|
-
}
|
|
217
|
-
.stk-table .stk-table-main .table-header-cell-wrapper{
|
|
252
|
+
.stk-table .table-header-cell-wrapper{
|
|
218
253
|
max-width:100%;
|
|
219
254
|
display:inline-flex;
|
|
220
255
|
align-items:center;
|
|
221
256
|
}
|
|
222
|
-
.stk-table .
|
|
257
|
+
.stk-table .table-header-title{
|
|
223
258
|
overflow:hidden;
|
|
224
259
|
align-self:flex-start;
|
|
225
260
|
}
|
|
226
|
-
.stk-table .
|
|
261
|
+
.stk-table .table-header-sorter{
|
|
227
262
|
flex-shrink:0;
|
|
228
263
|
margin-left:4px;
|
|
229
264
|
width:16px;
|
|
230
265
|
height:16px;
|
|
231
266
|
display:none;
|
|
232
267
|
}
|
|
233
|
-
.stk-table .
|
|
234
|
-
.stk-table .
|
|
268
|
+
.stk-table .table-header-sorter .arrow-up,
|
|
269
|
+
.stk-table .table-header-sorter .arrow-down{
|
|
235
270
|
fill:var(--sort-arrow-color);
|
|
236
271
|
}
|
|
237
|
-
.stk-table .
|
|
272
|
+
.stk-table .table-header-resizer{
|
|
238
273
|
position:absolute;
|
|
239
274
|
top:0;
|
|
240
275
|
bottom:0;
|
|
241
276
|
cursor:col-resize;
|
|
242
277
|
width:var(--resize-handle-width);
|
|
243
278
|
}
|
|
244
|
-
.stk-table .
|
|
279
|
+
.stk-table .table-header-resizer.left{
|
|
245
280
|
left:0;
|
|
246
281
|
}
|
|
247
|
-
.stk-table .
|
|
282
|
+
.stk-table .table-header-resizer.right{
|
|
248
283
|
right:0;
|
|
249
284
|
}
|
|
250
|
-
.stk-table .
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
transform:translateZ(0);
|
|
254
|
-
}
|
|
255
|
-
.stk-table .stk-table-main tbody tr.highlight-row{
|
|
256
|
-
animation:stk-table-dim var(--highlight-duration) var(--highlight-easing);
|
|
257
|
-
}
|
|
258
|
-
.stk-table .stk-table-main tbody tr.hover,
|
|
259
|
-
.stk-table .stk-table-main tbody tr:hover{
|
|
260
|
-
background-color:var(--tr-hover-bgc);
|
|
261
|
-
}
|
|
262
|
-
.stk-table .stk-table-main tbody tr.active{
|
|
263
|
-
background-color:var(--tr-active-bgc);
|
|
285
|
+
.stk-table .highlight-row{
|
|
286
|
+
animation:stk-table-dim var(--highlight-duration);
|
|
287
|
+
animation-timing-function:var(--highlight-timing-function);
|
|
264
288
|
}
|
|
265
289
|
.stk-table .stk-table-no-data{
|
|
266
290
|
background-color:var(--table-bgc);
|
|
@@ -279,26 +303,3 @@
|
|
|
279
303
|
.stk-table .stk-table-no-data.no-data-full{
|
|
280
304
|
flex:1;
|
|
281
305
|
}
|
|
282
|
-
.stk-table.virtual{
|
|
283
|
-
}
|
|
284
|
-
.stk-table.virtual .table-header-cell-wrapper{
|
|
285
|
-
overflow:hidden;
|
|
286
|
-
max-height:var(--header-row-height);
|
|
287
|
-
}
|
|
288
|
-
.stk-table.virtual tbody{
|
|
289
|
-
position:relative;
|
|
290
|
-
}
|
|
291
|
-
.stk-table.virtual tbody tr td{
|
|
292
|
-
height:var(--row-height);
|
|
293
|
-
line-height:1;
|
|
294
|
-
}
|
|
295
|
-
.stk-table.virtual tbody tr td .table-cell-wrapper{
|
|
296
|
-
max-height:var(--row-height);
|
|
297
|
-
overflow:hidden;
|
|
298
|
-
}
|
|
299
|
-
.stk-table.virtual .padding-top-tr td{
|
|
300
|
-
height:0;
|
|
301
|
-
}
|
|
302
|
-
.stk-table.virtual-x .virtual-x-left{
|
|
303
|
-
padding:0;
|
|
304
|
-
}
|
package/package.json
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
'border-v': props.bordered === 'v',
|
|
15
15
|
'border-body-v': props.bordered === 'body-v',
|
|
16
16
|
stripe: props.stripe,
|
|
17
|
+
'cell-hover': props.cellHover,
|
|
18
|
+
'text-overflow': props.showOverflow,
|
|
19
|
+
'header-text-overflow': props.showHeaderOverflow,
|
|
17
20
|
}"
|
|
18
21
|
:style="[
|
|
19
22
|
virtual && {
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
},
|
|
23
26
|
{
|
|
24
27
|
'--highlight-duration': props.highlightConfig.duration && props.highlightConfig.duration + 's',
|
|
25
|
-
'--highlight-
|
|
28
|
+
'--highlight-timing-function': highlightSteps ? `steps(${highlightSteps})` : '',
|
|
26
29
|
},
|
|
27
30
|
]"
|
|
28
31
|
@scroll="onTableScroll"
|
|
@@ -69,7 +72,6 @@
|
|
|
69
72
|
:class="[
|
|
70
73
|
col.sorter ? 'sortable' : '',
|
|
71
74
|
col.dataIndex === sortCol && sortOrderIndex !== 0 && 'sorter-' + sortSwitchOrder[sortOrderIndex],
|
|
72
|
-
showHeaderOverflow ? 'text-overflow' : '',
|
|
73
75
|
col.headerClassName,
|
|
74
76
|
fixedColClassMap.get(colKeyGen(col)),
|
|
75
77
|
]"
|
|
@@ -151,8 +153,8 @@
|
|
|
151
153
|
:key="rowKey ? rowKeyGen(row) : rowIndex"
|
|
152
154
|
:data-row-key="rowKey ? rowKeyGen(row) : rowIndex"
|
|
153
155
|
:class="{
|
|
154
|
-
active: rowKey ? rowKeyGen(row) === rowKeyGen(
|
|
155
|
-
hover: rowKey ? rowKeyGen(row) ===
|
|
156
|
+
active: rowKey ? rowKeyGen(row) === rowKeyGen(currentRow) : row === currentRow,
|
|
157
|
+
hover: props.showTrHoverClass && (rowKey ? rowKeyGen(row) === currentHoverRowKey : row === currentHoverRowKey),
|
|
156
158
|
[rowClassName(row, rowIndex)]: true,
|
|
157
159
|
}"
|
|
158
160
|
@click="e => onRowClick(e, row)"
|
|
@@ -166,14 +168,12 @@
|
|
|
166
168
|
v-for="(col, colIndex) in virtualX_columnPart"
|
|
167
169
|
:key="col.dataIndex"
|
|
168
170
|
:data-index="col.dataIndex"
|
|
169
|
-
:class="[
|
|
170
|
-
col.className,
|
|
171
|
-
fixedColClassMap.get(colKeyGen(col)),
|
|
172
|
-
showOverflow ? 'text-overflow' : '',
|
|
173
|
-
col.type === 'seq' ? 'seq-column' : '',
|
|
174
|
-
]"
|
|
175
171
|
:style="cellStyleMap[TagType.TD].get(colKeyGen(col))"
|
|
172
|
+
:class="[col.className, fixedColClassMap.get(colKeyGen(col)), col.type === 'seq' ? 'seq-column' : '']"
|
|
176
173
|
@click="e => onCellClick(e, row, col)"
|
|
174
|
+
@mouseenter="e => onCellMouseEnter(e, row, col)"
|
|
175
|
+
@mouseleave="e => onCellMouseLeave(e, row, col)"
|
|
176
|
+
@mouseover="e => onCellMouseOver(e, row, col)"
|
|
177
177
|
>
|
|
178
178
|
<component
|
|
179
179
|
:is="col.customCell"
|
|
@@ -223,7 +223,7 @@ import { useHighlight } from './useHighlight';
|
|
|
223
223
|
import { useKeyboardArrowScroll } from './useKeyboardArrowScroll';
|
|
224
224
|
import { useThDrag } from './useThDrag';
|
|
225
225
|
import { useVirtualScroll } from './useVirtualScroll';
|
|
226
|
-
import { createStkTableId, getCalculatedColWidth, getColWidth,
|
|
226
|
+
import { createStkTableId, getCalculatedColWidth, getColWidth, howDeepTheHeader, tableSort, transformWidthToStr } from './utils';
|
|
227
227
|
|
|
228
228
|
/** Generic stands for DataType */
|
|
229
229
|
type DT = any;
|
|
@@ -277,6 +277,8 @@ const props = withDefaults(
|
|
|
277
277
|
showOverflow?: boolean;
|
|
278
278
|
/** 是否增加行hover class */
|
|
279
279
|
showTrHoverClass?: boolean;
|
|
280
|
+
/** 是否高亮鼠标悬浮的单元格 */
|
|
281
|
+
cellHover?: boolean;
|
|
280
282
|
/** 表头是否可拖动。支持回调函数。 */
|
|
281
283
|
headerDrag?: boolean | ((col: StkTableColumn<DT>) => boolean);
|
|
282
284
|
/**
|
|
@@ -342,6 +344,7 @@ const props = withDefaults(
|
|
|
342
344
|
showHeaderOverflow: false,
|
|
343
345
|
showOverflow: false,
|
|
344
346
|
showTrHoverClass: false,
|
|
347
|
+
cellHover: false,
|
|
345
348
|
headerDrag: false,
|
|
346
349
|
rowClassName: () => '',
|
|
347
350
|
colResizable: false,
|
|
@@ -373,9 +376,9 @@ const emits = defineEmits<{
|
|
|
373
376
|
(e: 'row-click', ev: MouseEvent, row: DT): void;
|
|
374
377
|
/**
|
|
375
378
|
* 选中一行触发。ev返回null表示不是点击事件触发的
|
|
376
|
-
* ```(ev: MouseEvent | null, row: DT)```
|
|
379
|
+
* ```(ev: MouseEvent | null, row: DT, data: { select: boolean })```
|
|
377
380
|
*/
|
|
378
|
-
(e: 'current-change', ev: MouseEvent | null, row: DT): void;
|
|
381
|
+
(e: 'current-change', ev: MouseEvent | null, row: DT, data: { select: boolean }): void;
|
|
379
382
|
/**
|
|
380
383
|
* 行双击事件
|
|
381
384
|
* ```(ev: MouseEvent, row: DT)```
|
|
@@ -396,6 +399,21 @@ const emits = defineEmits<{
|
|
|
396
399
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
397
400
|
*/
|
|
398
401
|
(e: 'cell-click', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
402
|
+
/**
|
|
403
|
+
* 单元格鼠标进入事件
|
|
404
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
405
|
+
*/
|
|
406
|
+
(e: 'cell-mouseenter', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
407
|
+
/**
|
|
408
|
+
* 单元格鼠标移出事件
|
|
409
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
410
|
+
*/
|
|
411
|
+
(e: 'cell-mouseleave', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
412
|
+
/**
|
|
413
|
+
* 单元格悬浮事件
|
|
414
|
+
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
415
|
+
*/
|
|
416
|
+
(e: 'cell-mouseover', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
399
417
|
/**
|
|
400
418
|
* 表头单元格点击事件
|
|
401
419
|
* ```(ev: MouseEvent, col: StkTableColumn<DT>)```
|
|
@@ -441,14 +459,18 @@ const emits = defineEmits<{
|
|
|
441
459
|
const tableContainerRef = ref<HTMLDivElement>();
|
|
442
460
|
const colResizeIndicatorRef = ref<HTMLDivElement>();
|
|
443
461
|
/** 当前选中的一行*/
|
|
444
|
-
const
|
|
462
|
+
const currentRow = ref<DT | null>(null);
|
|
445
463
|
/**
|
|
446
464
|
* 保存当前选中行的key<br>
|
|
447
465
|
* 原因:vue3 不用ref包dataSource时,row为原始对象,与currentItem(Ref)相比会不相等。
|
|
448
466
|
*/
|
|
449
|
-
const
|
|
450
|
-
/** 当前hover
|
|
451
|
-
|
|
467
|
+
const currentRowKey = ref<any>(null);
|
|
468
|
+
/** 当前hover行 */
|
|
469
|
+
let currentHoverRow: DT = null;
|
|
470
|
+
/** 当前hover的行的key */
|
|
471
|
+
const currentHoverRowKey = ref(null);
|
|
472
|
+
/** 当前hover的列的key */
|
|
473
|
+
// const currentColHoverKey = ref(null);
|
|
452
474
|
|
|
453
475
|
/** 排序的列dataIndex*/
|
|
454
476
|
let sortCol = ref<string | null>();
|
|
@@ -791,11 +813,16 @@ function onColumnSort(col?: StkTableColumn<DT>, click = true, options: { force?:
|
|
|
791
813
|
|
|
792
814
|
function onRowClick(e: MouseEvent, row: DT) {
|
|
793
815
|
emits('row-click', e, row);
|
|
794
|
-
//
|
|
795
|
-
if (props.rowKey ?
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
816
|
+
// 选中同一行,取消当前选中行。
|
|
817
|
+
if (props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row) {
|
|
818
|
+
currentRow.value = null;
|
|
819
|
+
currentRowKey.value = null;
|
|
820
|
+
emits('current-change', e, row, { select: false });
|
|
821
|
+
} else {
|
|
822
|
+
currentRow.value = row;
|
|
823
|
+
currentRowKey.value = rowKeyGen(row);
|
|
824
|
+
emits('current-change', e, row, { select: true });
|
|
825
|
+
}
|
|
799
826
|
}
|
|
800
827
|
|
|
801
828
|
function onRowDblclick(e: MouseEvent, row: DT) {
|
|
@@ -822,6 +849,23 @@ function onHeaderCellClick(e: MouseEvent, col: StkTableColumn<DT>) {
|
|
|
822
849
|
emits('header-cell-click', e, col);
|
|
823
850
|
}
|
|
824
851
|
|
|
852
|
+
/** td mouseenter */
|
|
853
|
+
function onCellMouseEnter(e: MouseEvent, row: DT, col: StkTableColumn<DT>) {
|
|
854
|
+
// currentColHoverKey.value = colKeyGen(col);
|
|
855
|
+
emits('cell-mouseenter', e, row, col);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** td mouseleave */
|
|
859
|
+
function onCellMouseLeave(e: MouseEvent, row: DT, col: StkTableColumn<DT>) {
|
|
860
|
+
// currentColHoverKey.value = null;
|
|
861
|
+
emits('cell-mouseleave', e, row, col);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** td mouseover event */
|
|
865
|
+
function onCellMouseOver(e: MouseEvent, row: DT, col: StkTableColumn<DT>) {
|
|
866
|
+
emits('cell-mouseover', e, row, col);
|
|
867
|
+
}
|
|
868
|
+
|
|
825
869
|
/**
|
|
826
870
|
* 鼠标滚轮事件监听
|
|
827
871
|
* @param {MouseEvent} e
|
|
@@ -849,7 +893,7 @@ function onTableScroll(e: Event) {
|
|
|
849
893
|
const isXScroll = scrollLeft !== vScrollLeft;
|
|
850
894
|
|
|
851
895
|
// 纵向滚动有变化
|
|
852
|
-
if (isYScroll
|
|
896
|
+
if (isYScroll) {
|
|
853
897
|
updateVirtualScrollY(scrollTop);
|
|
854
898
|
}
|
|
855
899
|
|
|
@@ -876,22 +920,22 @@ function onTableScroll(e: Event) {
|
|
|
876
920
|
|
|
877
921
|
/** tr hover事件 */
|
|
878
922
|
function onTrMouseOver(_e: MouseEvent, row: DT) {
|
|
879
|
-
if (
|
|
880
|
-
|
|
881
|
-
|
|
923
|
+
if (currentHoverRow === row) return;
|
|
924
|
+
currentHoverRow = row;
|
|
925
|
+
currentHoverRowKey.value = rowKeyGen(row);
|
|
882
926
|
}
|
|
883
927
|
|
|
884
928
|
/**
|
|
885
929
|
* 选中一行,
|
|
886
|
-
* @param {string} rowKey
|
|
930
|
+
* @param {string} rowKey selected rowKey, null to unselect
|
|
887
931
|
* @param {boolean} option.silent 是否触发回调
|
|
888
932
|
*/
|
|
889
933
|
function setCurrentRow(rowKey: string, option = { silent: false }) {
|
|
890
934
|
if (!dataSourceCopy.value.length) return;
|
|
891
|
-
|
|
892
|
-
|
|
935
|
+
currentRow.value = dataSourceCopy.value.find(it => rowKeyGen(it) === rowKey);
|
|
936
|
+
currentRowKey.value = rowKeyGen(currentRow.value);
|
|
893
937
|
if (!option.silent) {
|
|
894
|
-
emits('current-change', null,
|
|
938
|
+
emits('current-change', /** no Event */ null, currentRow.value, { select: Boolean(currentRowKey.value) });
|
|
895
939
|
}
|
|
896
940
|
}
|
|
897
941
|
|