stk-table-vue 0.6.7 → 0.6.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stk-table-vue",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
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",
@@ -62,7 +62,7 @@
62
62
  "prettier": "^3.2.5",
63
63
  "typescript": "^5.4.5",
64
64
  "vite": "^5.4.10",
65
- "vite-plugin-dts": "^4.3.0",
65
+ "vite-plugin-dts": "3.9.1",
66
66
  "vitepress": "^1.5.0",
67
67
  "vitepress-demo-plugin": "^1.2.2",
68
68
  "vitest": "^2.1.3",
@@ -24,6 +24,7 @@
24
24
  'header-text-overflow': props.showHeaderOverflow,
25
25
  'fixed-relative-mode': isRelativeMode,
26
26
  'auto-row-height': props.autoRowHeight,
27
+ 'scroll-row-by-row': props.scrollRowByRow,
27
28
  }"
28
29
  :style="{
29
30
  '--row-height': props.autoRowHeight ? void 0 : virtualScroll.rowHeight + 'px',
@@ -34,13 +35,13 @@
34
35
  @scroll="onTableScroll"
35
36
  @wheel="onTableWheel"
36
37
  >
37
- <!-- 这个元素用于虚拟滚动时,撑开父容器的高度 (已弃用,因为滚动条拖动过快,下方tr为加载出来时,会导致表头sticky闪动)
38
+ <!-- 这个元素用于整数行虚拟滚动时,撑开父容器的高度) -->
38
39
  <div
39
- v-if="virtual"
40
- class="virtual-table-height"
41
- :style="{ height: dataSourceCopy.length * virtualScroll.rowHeight + 'px' }"
40
+ v-if="props.scrollRowByRow && virtual"
41
+ class="row-by-row-table-height"
42
+ :style="{ height: dataSourceCopy.length * virtualScroll.rowHeight + 'px' }"
42
43
  ></div>
43
- -->
44
+
44
45
  <div v-if="colResizable" ref="colResizeIndicatorRef" class="column-resize-indicator"></div>
45
46
  <!-- 表格主体 -->
46
47
  <table
@@ -118,7 +119,7 @@
118
119
  <!-- <tbody v-if="virtual_on" :style="{ height: `${virtualScroll.offsetTop}px` }"></tbody> -->
119
120
  <!-- <tbody :style="{ transform: `translateY(${virtualScroll.offsetTop}px)` }"> -->
120
121
  <tbody class="stk-tbody-main" @dragover="onTrDragOver" @dragenter="onTrDragEnter" @dragend="onTrDragEnd">
121
- <tr v-if="virtual_on" :style="`height:${virtualScroll.offsetTop}px`" class="padding-top-tr">
122
+ <tr v-if="virtual_on && !props.scrollRowByRow" :style="`height:${virtualScroll.offsetTop}px`" class="padding-top-tr">
122
123
  <!--这个td用于配合虚拟滚动的th对应,防止列错位-->
123
124
  <td v-if="virtualX_on && fixedMode && headless" class="vt-x-left"></td>
124
125
  <template v-if="fixedMode && headless">
@@ -181,6 +182,7 @@
181
182
  onCellClick(e, row, col);
182
183
  }
183
184
  "
185
+ @mousedown="e => onCellMouseDown(e, row, col)"
184
186
  @mouseenter="e => onCellMouseEnter(e, row, col)"
185
187
  @mouseleave="e => onCellMouseLeave(e, row, col)"
186
188
  @mouseover="e => onCellMouseOver(e, row, col)"
@@ -221,7 +223,7 @@
221
223
  </td>
222
224
  </template>
223
225
  </tr>
224
- <tr v-if="virtual_on" :style="`height: ${virtual_offsetBottom}px`"></tr>
226
+ <tr v-if="virtual_on && !props.scrollRowByRow" :style="`height: ${virtual_offsetBottom}px`"></tr>
225
227
  </tbody>
226
228
  </table>
227
229
  <div v-if="(!dataSourceCopy || !dataSourceCopy.length) && showNoData" class="stk-table-no-data" :class="{ 'no-data-full': noDataFull }">
@@ -406,6 +408,8 @@ const props = withDefaults(
406
408
  * - true: 不使用 onwheel 滚动。鼠标滚轮滚动时更加平滑。滚动过快时会白屏。
407
409
  */
408
410
  smoothScroll?: boolean;
411
+ /** 按整数行纵向滚动 */
412
+ scrollRowByRow?: boolean;
409
413
  }>(),
410
414
  {
411
415
  width: '',
@@ -456,6 +460,7 @@ const props = withDefaults(
456
460
  dragRowConfig: () => ({}),
457
461
  cellFixedMode: 'sticky',
458
462
  smoothScroll: DEFAULT_SMOOTH_SCROLL,
463
+ scrollRowByRow: false,
459
464
  },
460
465
  );
461
466
 
@@ -526,6 +531,12 @@ const emits = defineEmits<{
526
531
  * ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
527
532
  */
528
533
  (e: 'cell-mouseover', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
534
+ /**
535
+ * 单元格鼠标按下事件
536
+ *
537
+ * ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
538
+ */
539
+ (e: 'cell-mousedown', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
529
540
  /**
530
541
  * 表头单元格点击事件
531
542
  *
@@ -571,9 +582,9 @@ const emits = defineEmits<{
571
582
  /**
572
583
  * 列宽变动时触发
573
584
  *
574
- * ```(cols: StkTableColumn<DT>)```
585
+ * ```(col: StkTableColumn<DT>)```
575
586
  */
576
- (e: 'col-resize', cols: StkTableColumn<DT>): void;
587
+ (e: 'col-resize', col: StkTableColumn<DT>): void;
577
588
  /**
578
589
  * 展开行触发
579
590
  *
@@ -1149,6 +1160,10 @@ function onCellMouseOver(e: MouseEvent, row: DT, col: StkTableColumn<DT>) {
1149
1160
  emits('cell-mouseover', e, row, col);
1150
1161
  }
1151
1162
 
1163
+ function onCellMouseDown(e: MouseEvent, row: DT, col: StkTableColumn<DT>) {
1164
+ emits('cell-mousedown', e, row, col);
1165
+ }
1166
+
1152
1167
  /**
1153
1168
  * 鼠标滚轮事件监听。代理滚轮事件,防止滚动过快出现白屏。
1154
1169
  * @param e
@@ -54,7 +54,7 @@
54
54
  /**深色模式 */
55
55
  &.dark {
56
56
  --th-bgc: #202029;
57
- --th-color: #C0C0D1;
57
+ --th-color: #c0c0d1;
58
58
  --td-bgc: #1b1b24;
59
59
  --td-hover-color: #70a6ff;
60
60
  --td-active-color: #386ccc;
@@ -83,7 +83,6 @@
83
83
  /* ⭐这里加background-color会导致表格出滚动白屏*/
84
84
  color: #d1d1e0;
85
85
  }
86
-
87
86
 
88
87
  &.headless {
89
88
  &.border {
@@ -140,8 +139,6 @@
140
139
  --bg-border-top: linear-gradient(transparent, transparent);
141
140
  }
142
141
 
143
-
144
-
145
142
  &.border-body-v {
146
143
  tbody {
147
144
  --bg-border-bottom: linear-gradient(transparent, transparent);
@@ -167,13 +164,11 @@
167
164
  }
168
165
  }
169
166
 
170
-
171
167
  /** more weight for custom row background*/
172
168
  &.row-hover .stk-tbody-main tr:hover {
173
169
  background-color: var(--tr-hover-bgc);
174
170
  }
175
171
 
176
-
177
172
  &.row-active .stk-tbody-main tr.active {
178
173
  background-color: var(--tr-active-bgc);
179
174
  }
@@ -212,7 +207,6 @@
212
207
 
213
208
  /**虚拟滚动模式 */
214
209
  &.virtual {
215
-
216
210
  /* 为不影响布局,表头行高要定死*/
217
211
  .table-header-cell-wrapper {
218
212
  overflow: hidden;
@@ -246,7 +240,6 @@
246
240
  }
247
241
 
248
242
  &.auto-row-height {
249
-
250
243
  tbody td {
251
244
  height: unset;
252
245
 
@@ -255,7 +248,6 @@
255
248
  overflow: initial;
256
249
  }
257
250
  }
258
-
259
251
  }
260
252
 
261
253
  &.fixed-relative-mode {
@@ -268,6 +260,19 @@
268
260
  }
269
261
  }
270
262
 
263
+ &.scroll-row-by-row {
264
+ .stk-table-main {
265
+ position: sticky;
266
+ top: 0;
267
+ }
268
+ }
269
+
270
+ .row-by-row-table-height {
271
+ width: 1px;
272
+ position: absolute;
273
+ left: 0;
274
+ }
275
+
271
276
  th,
272
277
  td {
273
278
  font-size: 14px;
@@ -322,7 +327,6 @@
322
327
  fill: var(--sort-arrow-active-sub-color);
323
328
  }
324
329
  }
325
-
326
330
  }
327
331
 
328
332
  thead tr {
@@ -330,13 +334,11 @@
330
334
  height: var(--header-row-height);
331
335
  }
332
336
 
333
-
334
337
  tbody tr {
335
338
  background-color: var(--td-bgc);
336
339
  height: var(--row-height);
337
340
  }
338
341
 
339
-
340
342
  .vt-x-left,
341
343
  .vt-x-right {
342
344
  padding: 0;
@@ -344,7 +346,6 @@
344
346
  pointer-events: none;
345
347
  }
346
348
 
347
-
348
349
  /** 列宽调整指示器 */
349
350
  .column-resize-indicator {
350
351
  width: 0;
@@ -387,23 +388,23 @@
387
388
  .expand-cell {
388
389
  cursor: pointer;
389
390
 
390
- .expanded-cell-wrapper {
391
- &::before {
392
- content: '';
393
- display: inline-block;
394
- margin: 0 2px;
395
- width: 0;
396
- height: 0;
397
- border-left: 5px solid #757699;
398
- border-top: 4px solid transparent;
399
- border-bottom: 4px solid transparent;
400
- transition: transform 0.2s ease;
401
- }
402
-
403
- >span {
404
- margin-left: var(--cell-padding-x)
405
- }
391
+ .expanded-cell-wrapper {
392
+ &::before {
393
+ content: '';
394
+ display: inline-block;
395
+ margin: 0 2px;
396
+ width: 0;
397
+ height: 0;
398
+ border-left: 5px solid #757699;
399
+ border-top: 4px solid transparent;
400
+ border-bottom: 4px solid transparent;
401
+ transition: transform 0.2s ease;
402
+ }
403
+
404
+ > span {
405
+ margin-left: var(--cell-padding-x);
406
406
  }
407
+ }
407
408
 
408
409
  &.expanded {
409
410
  .table-cell-wrapper::before {
@@ -430,14 +431,14 @@
430
431
  cursor: grabbing;
431
432
  }
432
433
 
433
- >svg {
434
+ > svg {
434
435
  vertical-align: -2px;
435
436
  }
436
437
  }
437
438
  }
438
439
 
439
440
  .tr-dragging {
440
- opacity: .5;
441
+ opacity: 0.5;
441
442
  }
442
443
 
443
444
  .tr-dragging-over {
@@ -470,7 +471,7 @@
470
471
  top: 0px;
471
472
  position: absolute;
472
473
  pointer-events: none;
473
- background-image: linear-gradient(var(--shadow-rotate), var(--fixed-col-shadow-color-from), var(--fixed-col-shadow-color-to)),
474
+ background-image: linear-gradient(var(--shadow-rotate), var(--fixed-col-shadow-color-from), var(--fixed-col-shadow-color-to));
474
475
  }
475
476
 
476
477
  .fixed-cell--active {
@@ -551,7 +552,4 @@
551
552
  flex: 1;
552
553
  }
553
554
  }
554
-
555
-
556
-
557
- }
555
+ }