stk-table-vue 1.2.4 → 1.2.5

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.
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.4
3
+ * version: v1.2.5
4
4
  * description: High performance realtime virtual table for vue3 and vue2.7
5
5
  * author: japlus
6
6
  * homepage: https://ja-plus.github.io/stk-table-vue/
7
7
  * license: MIT
8
8
  */
9
- import { t as StkTable_default } from "./StkTable-CVcmlZi9.js";
9
+ import { t as StkTable_default } from "./StkTable-CzktjLlV.js";
10
10
  import { createElementBlock, createElementVNode, createVNode, defineComponent, h, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, reactive, ref, withModifiers } from "vue";
11
11
  //#region src/StkTable/custom-cells/FilterCell/Dropdown/index.vue?vue&type=script&setup=true&lang.ts
12
12
  var DROPDOWN_DEFAULT_WIDTH = 300;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.4
3
+ * version: v1.2.5
4
4
  * description: High performance realtime virtual table for vue3 and vue2.7
5
5
  * author: japlus
6
6
  * homepage: https://ja-plus.github.io/stk-table-vue/
@@ -4093,6 +4093,7 @@ function useVirtualScroll(props, tableContainerRef, trRef, dataSourceCopy, table
4093
4093
  /** fix: 滚动条不在顶部时,表格数据变少,导致滚动条位置有误 */
4094
4094
  scrollTop = maxScrollTop;
4095
4095
  assignVs(virtualScroll, {
4096
+ rowHeight,
4096
4097
  containerHeight,
4097
4098
  pageSize,
4098
4099
  scrollHeight
@@ -4953,7 +4954,21 @@ var StkTable_default = /* @__PURE__ */ defineComponent({
4953
4954
  watch(() => props.virtual, () => {
4954
4955
  nextTick(initVirtualScrollY);
4955
4956
  });
4956
- watch(() => props.rowHeight, initVirtualScrollY);
4957
+ /**
4958
+ * 行高类配置变化后重算虚拟滚动几何。
4959
+ * 合并为一个 watcher:同一 tick 内多项同时变化只重算一次。
4960
+ * 必须无参调用 initVirtualScrollY(其首参是虚拟滚动容器高度,不能把行高值传入),
4961
+ * 且需 nextTick 等新的 --row-height / 表头行高等样式应用到 DOM 后再测量。
4962
+ *
4963
+ * 监听值拼接为单个原始值(字符串)而非返回数组:getter 返回数组时每次求值都是新数组,
4964
+ * 身份比较必然变化,父组件传入内联对象字面量(如 :expand-config="{ height: 40 }",官方示例即如此写法)
4965
+ * 会让本 watcher 在父组件每次重渲染时误触发;展开行/变高大表下误触发一次会连带行高树 O(n) 重建
4966
+ * (实测 50K 行每次父重渲染多付 ~10ms)。拼接为原始值后仅在值真正变化时触发,且兼容 Vue 2.7。
4967
+ */
4968
+ watch(() => {
4969
+ var _props$expandConfig;
4970
+ return `${props.rowHeight}|${props.headerRowHeight}|${props.footerRowHeight}|${(_props$expandConfig = props.expandConfig) === null || _props$expandConfig === void 0 ? void 0 : _props$expandConfig.height}`;
4971
+ }, () => nextTick(initVirtualScrollY));
4957
4972
  watch(() => props.virtualX, () => {
4958
4973
  handleDealColumns();
4959
4974
  nextTick(() => {
@@ -5168,7 +5183,7 @@ var StkTable_default = /* @__PURE__ */ defineComponent({
5168
5183
  return col.title || "";
5169
5184
  }
5170
5185
  function getTRProps(row, index) {
5171
- var _props$expandConfig;
5186
+ var _props$expandConfig2;
5172
5187
  const rowIndex = getAbsoluteRowIndex(index);
5173
5188
  const rowKey = rowKeyGen(row);
5174
5189
  const classList = [
@@ -5185,9 +5200,9 @@ var StkTable_default = /* @__PURE__ */ defineComponent({
5185
5200
  class: classList.filter(Boolean).join(" "),
5186
5201
  style: null
5187
5202
  };
5188
- if ((row === null || row === void 0 ? void 0 : row.__EXP_R__) && props.virtual && ((_props$expandConfig = props.expandConfig) === null || _props$expandConfig === void 0 ? void 0 : _props$expandConfig.height)) {
5189
- var _props$expandConfig2;
5190
- result.style = `--row-height: ${(_props$expandConfig2 = props.expandConfig) === null || _props$expandConfig2 === void 0 ? void 0 : _props$expandConfig2.height}px`;
5203
+ if ((row === null || row === void 0 ? void 0 : row.__EXP_R__) && props.virtual && ((_props$expandConfig2 = props.expandConfig) === null || _props$expandConfig2 === void 0 ? void 0 : _props$expandConfig2.height)) {
5204
+ var _props$expandConfig3;
5205
+ result.style = `--row-height: ${(_props$expandConfig3 = props.expandConfig) === null || _props$expandConfig3 === void 0 ? void 0 : _props$expandConfig3.height}px`;
5191
5206
  }
5192
5207
  return result;
5193
5208
  }
@@ -20,6 +20,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
20
20
  /**
21
21
  * 行高
22
22
  * - `props.autoRowHeight` 为 `true` 时,将表示为期望行高,用于计算。不再影响实际行高。
23
+ * - 支持动态修改,修改后自动重算可视区行数与滚动高度,并与 `--row-height` 保持同步。
23
24
  */
24
25
  rowHeight?: number;
25
26
  /**
@@ -35,9 +36,15 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
35
36
  * @deprecated
36
37
  */
37
38
  rowCurrentRevokable?: boolean;
38
- /** 表头行高。default = rowHeight */
39
+ /**
40
+ * 表头行高。default = rowHeight
41
+ * - 支持动态修改,表头占用的表体行数(pageSize)随之重算。
42
+ */
39
43
  headerRowHeight?: number | string;
40
- /** 表尾行高。default = rowHeight */
44
+ /**
45
+ * 表尾行高。default = rowHeight
46
+ * - 支持动态修改。表尾行悬浮于滚动区底部,不计入虚拟滚动的总高度。
47
+ */
41
48
  footerRowHeight?: number | string;
42
49
  /** 虚拟滚动 */
43
50
  virtual?: boolean;
@@ -510,6 +517,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
510
517
  /**
511
518
  * 行高
512
519
  * - `props.autoRowHeight` 为 `true` 时,将表示为期望行高,用于计算。不再影响实际行高。
520
+ * - 支持动态修改,修改后自动重算可视区行数与滚动高度,并与 `--row-height` 保持同步。
513
521
  */
514
522
  rowHeight?: number;
515
523
  /**
@@ -525,9 +533,15 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
525
533
  * @deprecated
526
534
  */
527
535
  rowCurrentRevokable?: boolean;
528
- /** 表头行高。default = rowHeight */
536
+ /**
537
+ * 表头行高。default = rowHeight
538
+ * - 支持动态修改,表头占用的表体行数(pageSize)随之重算。
539
+ */
529
540
  headerRowHeight?: number | string;
530
- /** 表尾行高。default = rowHeight */
541
+ /**
542
+ * 表尾行高。default = rowHeight
543
+ * - 支持动态修改。表尾行悬浮于滚动区底部,不计入虚拟滚动的总高度。
544
+ */
531
545
  footerRowHeight?: number | string;
532
546
  /** 虚拟滚动 */
533
547
  virtual?: boolean;
@@ -297,7 +297,10 @@ export type SeqConfig = {
297
297
  };
298
298
  /** Configuration options for the expand column */
299
299
  export type ExpandConfig = {
300
- /** worked in virtual mode */
300
+ /**
301
+ * worked in virtual mode
302
+ * 展开行的行高,支持动态修改(修改后行高累计与虚拟滚动会一同重算)
303
+ */
301
304
  height?: number;
302
305
  };
303
306
  /** drag row config */
@@ -13,7 +13,12 @@ export type VirtualScrollStore = {
13
13
  startIndex: number;
14
14
  /** 数组结束位置 */
15
15
  endIndex: number;
16
- /** 行高 */
16
+ /**
17
+ * 基准行高(px)。
18
+ * 由 initVirtualScrollY 随 props.rowHeight 同步(模板中的 --row-height 亦取此值,二者同源),
19
+ * 因此行高配置动态变化后此处不会是旧快照。
20
+ * 仅记录统一基准行高:变高模式(autoRowHeight)与展开行的行级高度不写入此字段。
21
+ */
17
22
  rowHeight: number;
18
23
  /** 表格定位上边距 */
19
24
  offsetTop: number;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.4
3
+ * version: v1.2.5
4
4
  * description: High performance realtime virtual table for vue3 and vue2.7
5
5
  * author: japlus
6
6
  * homepage: https://ja-plus.github.io/stk-table-vue/
7
7
  * license: MIT
8
8
  */
9
- import { a as insertToOrderedArray, i as binarySearch, n as registerFeature, o as strCompare, r as useAreaSelection, s as tableSort, t as StkTable_default } from "./StkTable-CVcmlZi9.js";
9
+ import { a as insertToOrderedArray, i as binarySearch, n as registerFeature, o as strCompare, r as useAreaSelection, s as tableSort, t as StkTable_default } from "./StkTable-CzktjLlV.js";
10
10
  import { Fragment, computed, createApp, createBlock, createElementBlock, createElementVNode, createTextVNode, defineComponent, getCurrentInstance, h, markRaw, nextTick, normalizeClass, openBlock, ref, renderSlot, resolveDynamicComponent, toDisplayString, watch, withModifiers } from "vue";
11
11
  //#region src/StkTable/custom-cells/FilterCell/Dropdown/index.ts
12
12
  var DropdownIns = null;
@@ -15,7 +15,7 @@ async function getDropdownIns() {
15
15
  const div = document.createElement("div");
16
16
  div.classList.add("stk-filter-dropdown-wrapper");
17
17
  document.body.appendChild(div);
18
- DropdownIns = createApp(await import("./Dropdown-D_9cB0rD.js").then((module) => module.default)).mount(div);
18
+ DropdownIns = createApp(await import("./Dropdown-C4c7Nmgf.js").then((module) => module.default)).mount(div);
19
19
  }
20
20
  return DropdownIns;
21
21
  }
package/lib/style.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.4
3
+ * version: v1.2.5
4
4
  * description: High performance realtime virtual table for vue3 and vue2.7
5
5
  * author: japlus
6
6
  * homepage: https://ja-plus.github.io/stk-table-vue/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stk-table-vue",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "High performance 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",
@@ -430,6 +430,7 @@ const props = withDefaults(
430
430
  /**
431
431
  * 行高
432
432
  * - `props.autoRowHeight` 为 `true` 时,将表示为期望行高,用于计算。不再影响实际行高。
433
+ * - 支持动态修改,修改后自动重算可视区行数与滚动高度,并与 `--row-height` 保持同步。
433
434
  */
434
435
  rowHeight?: number;
435
436
  /**
@@ -445,9 +446,15 @@ const props = withDefaults(
445
446
  * @deprecated
446
447
  */
447
448
  rowCurrentRevokable?: boolean;
448
- /** 表头行高。default = rowHeight */
449
+ /**
450
+ * 表头行高。default = rowHeight
451
+ * - 支持动态修改,表头占用的表体行数(pageSize)随之重算。
452
+ */
449
453
  headerRowHeight?: number | string;
450
- /** 表尾行高。default = rowHeight */
454
+ /**
455
+ * 表尾行高。default = rowHeight
456
+ * - 支持动态修改。表尾行悬浮于滚动区底部,不计入虚拟滚动的总高度。
457
+ */
451
458
  footerRowHeight?: number | string;
452
459
  /** 虚拟滚动 */
453
460
  virtual?: boolean;
@@ -1214,7 +1221,21 @@ watch(
1214
1221
  },
1215
1222
  );
1216
1223
 
1217
- watch(() => props.rowHeight, initVirtualScrollY);
1224
+ /**
1225
+ * 行高类配置变化后重算虚拟滚动几何。
1226
+ * 合并为一个 watcher:同一 tick 内多项同时变化只重算一次。
1227
+ * 必须无参调用 initVirtualScrollY(其首参是虚拟滚动容器高度,不能把行高值传入),
1228
+ * 且需 nextTick 等新的 --row-height / 表头行高等样式应用到 DOM 后再测量。
1229
+ *
1230
+ * 监听值拼接为单个原始值(字符串)而非返回数组:getter 返回数组时每次求值都是新数组,
1231
+ * 身份比较必然变化,父组件传入内联对象字面量(如 :expand-config="{ height: 40 }",官方示例即如此写法)
1232
+ * 会让本 watcher 在父组件每次重渲染时误触发;展开行/变高大表下误触发一次会连带行高树 O(n) 重建
1233
+ * (实测 50K 行每次父重渲染多付 ~10ms)。拼接为原始值后仅在值真正变化时触发,且兼容 Vue 2.7。
1234
+ */
1235
+ watch(
1236
+ () => `${props.rowHeight}|${props.headerRowHeight}|${props.footerRowHeight}|${props.expandConfig?.height}`,
1237
+ () => nextTick(initVirtualScrollY),
1238
+ );
1218
1239
 
1219
1240
  watch(
1220
1241
  () => props.virtualX,
@@ -1027,6 +1027,7 @@ function useAreaSelectionImpl<DT extends Record<string, any>>(
1027
1027
  const isScrollRowByRow = props.scrollRowByRow;
1028
1028
 
1029
1029
  // 计算目标行的位置(基于虚拟滚动数据)
1030
+ // vs.rowHeight 由 initVirtualScrollY 随 props.rowHeight 同步,动态改行高后此处即新值
1030
1031
  const rowHeight = vs.rowHeight;
1031
1032
  const targetRowTop = rowIndex * rowHeight;
1032
1033
  const targetRowBottom = targetRowTop + rowHeight;
@@ -314,7 +314,10 @@ export type SeqConfig = {
314
314
 
315
315
  /** Configuration options for the expand column */
316
316
  export type ExpandConfig = {
317
- /** worked in virtual mode */
317
+ /**
318
+ * worked in virtual mode
319
+ * 展开行的行高,支持动态修改(修改后行高累计与虚拟滚动会一同重算)
320
+ */
318
321
  height?: number;
319
322
  };
320
323
 
@@ -17,7 +17,12 @@ export type VirtualScrollStore = {
17
17
  startIndex: number;
18
18
  /** 数组结束位置 */
19
19
  endIndex: number;
20
- /** 行高 */
20
+ /**
21
+ * 基准行高(px)。
22
+ * 由 initVirtualScrollY 随 props.rowHeight 同步(模板中的 --row-height 亦取此值,二者同源),
23
+ * 因此行高配置动态变化后此处不会是旧快照。
24
+ * 仅记录统一基准行高:变高模式(autoRowHeight)与展开行的行级高度不写入此字段。
25
+ */
21
26
  rowHeight: number;
22
27
  /** 表格定位上边距 */
23
28
  offsetTop: number;
@@ -602,7 +607,9 @@ export function useVirtualScroll(
602
607
  /** fix: 滚动条不在顶部时,表格数据变少,导致滚动条位置有误 */
603
608
  scrollTop = maxScrollTop;
604
609
  }
605
- assignVs(virtualScroll, { containerHeight, pageSize, scrollHeight });
610
+ // rowHeight 必须随 props.rowHeight 变化同步:模板的 --row-height 与 SRBR/区域选取均读此字段,
611
+ // 若只在 shallowRef 初始化时求值一次,改行高后会出现「计算已用新行高、渲染仍是旧行高」的不一致。
612
+ assignVs(virtualScroll, { rowHeight, containerHeight, pageSize, scrollHeight });
606
613
  updateVirtualScrollY(scrollTop);
607
614
  }
608
615