stk-table-vue 1.2.2 → 1.2.4

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.2
3
+ * version: v1.2.4
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-g_qwf6BE.js";
9
+ import { t as StkTable_default } from "./StkTable-CVcmlZi9.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;
@@ -115,7 +115,9 @@ var Dropdown_default = /* @__PURE__ */ defineComponent({
115
115
  }
116
116
  function handleClear() {
117
117
  checkedTempValueSet.clear();
118
- confirm();
118
+ options.value.forEach((opt) => opt.selected = false);
119
+ onConfirmFn([]);
120
+ hide();
119
121
  }
120
122
  __expose({
121
123
  visible,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.2
3
+ * version: v1.2.4
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/
@@ -323,9 +323,19 @@ var MY_FN_NAME = "stkName";
323
323
  //#endregion
324
324
  //#region src/StkTable/features/useAreaSelection.ts
325
325
  /**
326
- * 单元格区域选择功能
327
- * 支持鼠标拖拽选择、键盘导航、复制粘贴等功能
326
+ * 单元格区域选择功能(Excel 式交互)。
327
+ * 支持鼠标拖拽选择、键盘导航(方向键/Tab/Shift+Tab,Ctrl 多选、Shift 扩选)、复制到剪贴板。
328
328
  * en: Cell area selection feature with mouse drag, keyboard navigation, copy-paste, etc.
329
+ *
330
+ * 分区说明:
331
+ * - 选区状态:锚点 begin / 终点 end、选区集合、是否正在拖拽选中(isAreaSelecting)。
332
+ * - 鼠标交互:mousedown 起锚、mousemove 扩展选区、拖拽靠近容器边缘时自动滚动(EDGE_ZONE/SCROLL_SPEED_MAX)。
333
+ * - 键盘交互:方向键/Tab 移动选区(见 useKeyboardArrowScroll 联动)、Ctrl 切换多选、Shift 扩选。
334
+ * - 复制:通过 formatCellForClipboard 回调(若配置了 customCell 应自定义)生成剪贴板文本。
335
+ * - 选区转换:单元格的可见/数据坐标通过 getRowIndex/getColumnIndex、cellKeyGen/colKeyGen 与
336
+ * 虚拟滚动(虚拟窗口裁剪)和列宽缓存(getCalculatedColWidth)相互换算。
337
+ *
338
+ * 对外返回:选区配置/状态、选区范围读写(setAreaSelection/getAreaSelection)、复制处理、选择/取消等。
329
339
  */
330
340
  function useAreaSelectionImpl(props, emits, tableContainerRef, dataSourceCopy, tableHeaderLast, colKeyGen, cellKeyGen, scrollTo, virtualScroll, virtualScrollX, getRowIndex, getColumnIndex) {
331
341
  /**
@@ -1547,7 +1557,7 @@ function useFixedCol(props, colKeyGen, getFixedColPosition, tableHeaders, tableH
1547
1557
  }
1548
1558
  if (showShadow) classList.push("fixed-cell--shadow");
1549
1559
  if (fixed === "right" && fixedBorderLeftColsValue.includes(col)) classList.push("fixed-cell--border-left");
1550
- colMap.set(colKeyFn(col), classList);
1560
+ colMap.set(colKeyFn(col), classList.join(" "));
1551
1561
  }
1552
1562
  }
1553
1563
  return colMap;
@@ -3039,6 +3049,17 @@ function useSorter(props, emits, colKeyGen, tableHeaderLast, dataSourceCopy, ini
3039
3049
  /**
3040
3050
  * Table Columns Processing Hook
3041
3051
  * Handles multi-level header processing and column flattening
3052
+ *
3053
+ * 核心职责:
3054
+ * - 将用户传入的 `columns`(可能含 children 多级表头)摊平为「按层级划分」的二维数组 `tableHeaders`,
3055
+ * 每层是同一行的 th 集合;同时生成 `tableHeadersForCalc`(复制 rowSpan 位置)用于固定列计算。
3056
+ * - 为每个列补充私有元数据(@private 字段):
3057
+ * - __P__ 父列引用(双向链表)
3058
+ * - __LF_S__ / __LF_E__ 该列在叶子列中的起止索引,用于多级表头横向虚拟滚动
3059
+ * - __W__ 计算宽度(子列累加 / 叶子列取配置宽度)
3060
+ * - __R_SP__ / __C_SP__ th 的 rowSpan / colSpan
3061
+ * - 在 relative 模式(isRelativeMode)下,固定列不再用 sticky,而是重排到左右两侧。
3062
+ * - 叶子列宽度是 X 轴虚拟滚动的依据(getColWidth)。
3042
3063
  */
3043
3064
  function useTableColumns(virtualX, isRelativeMode) {
3044
3065
  /**
@@ -3717,7 +3738,7 @@ function useVirtualScroll(props, tableContainerRef, trRef, dataSourceCopy, table
3717
3738
  return (dataSourceCopyValue.length - startIndex - virtual_dataSourcePart.value.length) * rowHeight;
3718
3739
  });
3719
3740
  const virtualX_on = computed(() => {
3720
- return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getCalculatedColWidth(col), 0) > virtualScrollX.value.containerWidth + 100;
3741
+ return props.virtualX && tableHeaderLast.value.reduce((sum, col) => sum += getCalculatedColWidth(col), 0) > virtualScrollX.value.containerWidth;
3721
3742
  });
3722
3743
  /** 是否多级表头 */
3723
3744
  const isMultiLevelHeader = computed(() => tableHeaders.value.length > 1);
@@ -4654,6 +4675,36 @@ var StkTable_default = /* @__PURE__ */ defineComponent({
4654
4675
  ],
4655
4676
  setup(__props, { expose: __expose, emit: __emit }) {
4656
4677
  /**
4678
+ * StkTable 主组件(Vue 3 / Vue 2.7)
4679
+ *
4680
+ * 这是一个超大的核心组件文件,约 1800+ 行。理解它时请按以下「分区地图」定位:
4681
+ *
4682
+ * 1. 顶部(template 261 行前)
4683
+ * 渲染结构:滚动容器 + 原生 <table>。包括 colgroup(固定模式列宽)、thead(多级表头、
4684
+ * sticky 固定)、tbody(虚拟滚动 tr / 空 td 定位)、tfoot(汇总行)、自定义滚动条容器。
4685
+ * 通过 CSS 类(如 virtual / virtual-x / area-selection / theme 等)联动对应 hook 状态。
4686
+ *
4687
+ * 2. script setup(270 行起)
4688
+ * - props 定义:全部配置项,即公共 API(对应 types/index.ts 与文档 table-props.md)。
4689
+ * - 大量 useXxx hooks 的组装:本文件只做「装配」,具体逻辑在对应 hook 中。
4690
+ *
4691
+ * 3. 核心 hook 与职责(均在 src/StkTable/use*.ts):
4692
+ * - useVirtualScroll XY 轴虚拟滚动(可视区裁剪、占位 tr/th 定位、scroll 计算)
4693
+ * - useTableColumns 列配置归一化 / 多级表头展开为叶子列
4694
+ * - useFixedCol/useFixedStyle/getFixedColPosition 固定列 sticky/relative 定位
4695
+ * - useSorter/useTableColumns.sort 排序(本地/远端、多列)
4696
+ * - useColResize/useThDrag/useTrDrag 列宽调整 / 表头拖拽 / 行拖拽
4697
+ * - useMergeCells/useMaxRowSpan 单元格合并与最大行跨
4698
+ * - useRowExpand/useTree 展开行 / 树形
4699
+ * - useHighlight 单元格/行高亮(Web Animations API 或 css)
4700
+ * - useAreaSelection (features/) 区域选取(Excel 式键盘操作)
4701
+ * - useScrollbar/useScrollRowByRow/useWheeling 自定义滚动条 / 按行滚动 / 滚轮
4702
+ * - useAutoResize 容器尺寸自动适配
4703
+ *
4704
+ * 4. expose:对外暴露的实例方法(对应文档 expose.md),供 ref 调用。
4705
+ *
4706
+ * 注意:此文件与 vue2.7 兼容,props 不可抽离到独立文件(见下方注释),修改时注意不要破坏兼容性。
4707
+ *
4657
4708
  * @author japlus
4658
4709
  */
4659
4710
  const stkTableId = createStkTableId();
@@ -3,9 +3,19 @@ import { AreaSelectionConfig, AreaSelectionRange, CellKeyGen, ColKeyGen, StkTabl
3
3
  import { VirtualScrollStore, VirtualScrollXStore } from '../useVirtualScroll';
4
4
 
5
5
  /**
6
- * 单元格区域选择功能
7
- * 支持鼠标拖拽选择、键盘导航、复制粘贴等功能
6
+ * 单元格区域选择功能(Excel 式交互)。
7
+ * 支持鼠标拖拽选择、键盘导航(方向键/Tab/Shift+Tab,Ctrl 多选、Shift 扩选)、复制到剪贴板。
8
8
  * en: Cell area selection feature with mouse drag, keyboard navigation, copy-paste, etc.
9
+ *
10
+ * 分区说明:
11
+ * - 选区状态:锚点 begin / 终点 end、选区集合、是否正在拖拽选中(isAreaSelecting)。
12
+ * - 鼠标交互:mousedown 起锚、mousemove 扩展选区、拖拽靠近容器边缘时自动滚动(EDGE_ZONE/SCROLL_SPEED_MAX)。
13
+ * - 键盘交互:方向键/Tab 移动选区(见 useKeyboardArrowScroll 联动)、Ctrl 切换多选、Shift 扩选。
14
+ * - 复制:通过 formatCellForClipboard 回调(若配置了 customCell 应自定义)生成剪贴板文本。
15
+ * - 选区转换:单元格的可见/数据坐标通过 getRowIndex/getColumnIndex、cellKeyGen/colKeyGen 与
16
+ * 虚拟滚动(虚拟窗口裁剪)和列宽缓存(getCalculatedColWidth)相互换算。
17
+ *
18
+ * 对外返回:选区配置/状态、选区范围读写(setAreaSelection/getAreaSelection)、复制处理、选择/取消等。
9
19
  */
10
20
  declare function useAreaSelectionImpl<DT extends Record<string, any>>(props: any, emits: any, tableContainerRef: Ref<HTMLDivElement | undefined>, dataSourceCopy: ShallowRef<DT[]>, tableHeaderLast: ShallowRef<StkTableColumn<DT>[]>, colKeyGen: ColKeyGen, cellKeyGen: CellKeyGen, scrollTo: (top: number | null, left: number | null) => void, virtualScroll: Ref<VirtualScrollStore>, virtualScrollX: Ref<VirtualScrollXStore>, getRowIndex: (row: DT) => number, getColumnIndex: (col: StkTableColumn<DT>) => number): {
11
21
  config: import('vue').ComputedRef<AreaSelectionConfig>;
@@ -4,5 +4,16 @@ import { PrivateRowDT, PrivateStkTableColumn, StkTableColumn } from './types';
4
4
  /**
5
5
  * Table Columns Processing Hook
6
6
  * Handles multi-level header processing and column flattening
7
+ *
8
+ * 核心职责:
9
+ * - 将用户传入的 `columns`(可能含 children 多级表头)摊平为「按层级划分」的二维数组 `tableHeaders`,
10
+ * 每层是同一行的 th 集合;同时生成 `tableHeadersForCalc`(复制 rowSpan 位置)用于固定列计算。
11
+ * - 为每个列补充私有元数据(@private 字段):
12
+ * - __P__ 父列引用(双向链表)
13
+ * - __LF_S__ / __LF_E__ 该列在叶子列中的起止索引,用于多级表头横向虚拟滚动
14
+ * - __W__ 计算宽度(子列累加 / 叶子列取配置宽度)
15
+ * - __R_SP__ / __C_SP__ th 的 rowSpan / colSpan
16
+ * - 在 relative 模式(isRelativeMode)下,固定列不再用 sticky,而是重排到左右两侧。
17
+ * - 叶子列宽度是 X 轴虚拟滚动的依据(getColWidth)。
7
18
  */
8
19
  export declare function useTableColumns<DT extends Record<string, any>>(virtualX: boolean, isRelativeMode: Ref<boolean>): readonly [import('vue').ShallowRef<PrivateStkTableColumn<PrivateRowDT>[][], PrivateStkTableColumn<PrivateRowDT>[][]>, import('vue').ShallowRef<PrivateStkTableColumn<PrivateRowDT>[][], PrivateStkTableColumn<PrivateRowDT>[][]>, (columns: StkTableColumn<DT>[]) => void];
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * name: stk-table-vue
3
- * version: v1.2.2
3
+ * version: v1.2.4
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-g_qwf6BE.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-CVcmlZi9.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-D40QlY91.js").then((module) => module.default)).mount(div);
18
+ DropdownIns = createApp(await import("./Dropdown-D_9cB0rD.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.2
3
+ * version: v1.2.4
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.2",
3
+ "version": "1.2.4",
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",
@@ -302,6 +302,36 @@ export default {
302
302
 
303
303
  <script setup lang="ts">
304
304
  /**
305
+ * StkTable 主组件(Vue 3 / Vue 2.7)
306
+ *
307
+ * 这是一个超大的核心组件文件,约 1800+ 行。理解它时请按以下「分区地图」定位:
308
+ *
309
+ * 1. 顶部(template 261 行前)
310
+ * 渲染结构:滚动容器 + 原生 <table>。包括 colgroup(固定模式列宽)、thead(多级表头、
311
+ * sticky 固定)、tbody(虚拟滚动 tr / 空 td 定位)、tfoot(汇总行)、自定义滚动条容器。
312
+ * 通过 CSS 类(如 virtual / virtual-x / area-selection / theme 等)联动对应 hook 状态。
313
+ *
314
+ * 2. script setup(270 行起)
315
+ * - props 定义:全部配置项,即公共 API(对应 types/index.ts 与文档 table-props.md)。
316
+ * - 大量 useXxx hooks 的组装:本文件只做「装配」,具体逻辑在对应 hook 中。
317
+ *
318
+ * 3. 核心 hook 与职责(均在 src/StkTable/use*.ts):
319
+ * - useVirtualScroll XY 轴虚拟滚动(可视区裁剪、占位 tr/th 定位、scroll 计算)
320
+ * - useTableColumns 列配置归一化 / 多级表头展开为叶子列
321
+ * - useFixedCol/useFixedStyle/getFixedColPosition 固定列 sticky/relative 定位
322
+ * - useSorter/useTableColumns.sort 排序(本地/远端、多列)
323
+ * - useColResize/useThDrag/useTrDrag 列宽调整 / 表头拖拽 / 行拖拽
324
+ * - useMergeCells/useMaxRowSpan 单元格合并与最大行跨
325
+ * - useRowExpand/useTree 展开行 / 树形
326
+ * - useHighlight 单元格/行高亮(Web Animations API 或 css)
327
+ * - useAreaSelection (features/) 区域选取(Excel 式键盘操作)
328
+ * - useScrollbar/useScrollRowByRow/useWheeling 自定义滚动条 / 按行滚动 / 滚轮
329
+ * - useAutoResize 容器尺寸自动适配
330
+ *
331
+ * 4. expose:对外暴露的实例方法(对应文档 expose.md),供 ref 调用。
332
+ *
333
+ * 注意:此文件与 vue2.7 兼容,props 不可抽离到独立文件(见下方注释),修改时注意不要破坏兼容性。
334
+ *
305
335
  * @author japlus
306
336
  */
307
337
  import { computed, nextTick, onMounted, provide, ref, shallowRef, toRaw, toRef, watch } from 'vue';
@@ -146,7 +146,9 @@ function setTheme(t: 'light' | 'dark') {
146
146
 
147
147
  function handleClear() {
148
148
  checkedTempValueSet.clear();
149
- confirm();
149
+ options.value.forEach(opt => (opt.selected = false));
150
+ onConfirmFn([]);
151
+ hide();
150
152
  }
151
153
 
152
154
  defineExpose({ visible, show, hide, setTheme });
@@ -15,9 +15,19 @@ import { getCalculatedColWidth } from '../utils/constRefUtils';
15
15
  import { MY_FN_NAME } from './const';
16
16
 
17
17
  /**
18
- * 单元格区域选择功能
19
- * 支持鼠标拖拽选择、键盘导航、复制粘贴等功能
18
+ * 单元格区域选择功能(Excel 式交互)。
19
+ * 支持鼠标拖拽选择、键盘导航(方向键/Tab/Shift+Tab,Ctrl 多选、Shift 扩选)、复制到剪贴板。
20
20
  * en: Cell area selection feature with mouse drag, keyboard navigation, copy-paste, etc.
21
+ *
22
+ * 分区说明:
23
+ * - 选区状态:锚点 begin / 终点 end、选区集合、是否正在拖拽选中(isAreaSelecting)。
24
+ * - 鼠标交互:mousedown 起锚、mousemove 扩展选区、拖拽靠近容器边缘时自动滚动(EDGE_ZONE/SCROLL_SPEED_MAX)。
25
+ * - 键盘交互:方向键/Tab 移动选区(见 useKeyboardArrowScroll 联动)、Ctrl 切换多选、Shift 扩选。
26
+ * - 复制:通过 formatCellForClipboard 回调(若配置了 customCell 应自定义)生成剪贴板文本。
27
+ * - 选区转换:单元格的可见/数据坐标通过 getRowIndex/getColumnIndex、cellKeyGen/colKeyGen 与
28
+ * 虚拟滚动(虚拟窗口裁剪)和列宽缓存(getCalculatedColWidth)相互换算。
29
+ *
30
+ * 对外返回:选区配置/状态、选区范围读写(setAreaSelection/getAreaSelection)、复制处理、选择/取消等。
21
31
  */
22
32
  function useAreaSelectionImpl<DT extends Record<string, any>>(
23
33
  props: any,
@@ -59,7 +59,7 @@ export function useFixedCol<DT extends Record<string, any>>(
59
59
  if (fixed === 'right' && fixedBorderLeftColsValue.includes(col)) {
60
60
  classList.push('fixed-cell--border-left');
61
61
  }
62
- colMap.set(colKeyFn(col), classList);
62
+ colMap.set(colKeyFn(col), classList.join(' '));
63
63
  }
64
64
  }
65
65
  return colMap;
@@ -6,6 +6,17 @@ import { howDeepTheHeader } from './utils/index';
6
6
  /**
7
7
  * Table Columns Processing Hook
8
8
  * Handles multi-level header processing and column flattening
9
+ *
10
+ * 核心职责:
11
+ * - 将用户传入的 `columns`(可能含 children 多级表头)摊平为「按层级划分」的二维数组 `tableHeaders`,
12
+ * 每层是同一行的 th 集合;同时生成 `tableHeadersForCalc`(复制 rowSpan 位置)用于固定列计算。
13
+ * - 为每个列补充私有元数据(@private 字段):
14
+ * - __P__ 父列引用(双向链表)
15
+ * - __LF_S__ / __LF_E__ 该列在叶子列中的起止索引,用于多级表头横向虚拟滚动
16
+ * - __W__ 计算宽度(子列累加 / 叶子列取配置宽度)
17
+ * - __R_SP__ / __C_SP__ th 的 rowSpan / colSpan
18
+ * - 在 relative 模式(isRelativeMode)下,固定列不再用 sticky,而是重排到左右两侧。
19
+ * - 叶子列宽度是 X 轴虚拟滚动的依据(getColWidth)。
9
20
  */
10
21
  export function useTableColumns<DT extends Record<string, any>>(virtualX: boolean, isRelativeMode: Ref<boolean>) {
11
22
  /**
@@ -192,8 +192,7 @@ export function useVirtualScroll(
192
192
 
193
193
  const virtualX_on = computed(() => {
194
194
  return (
195
- props.virtualX &&
196
- tableHeaderLast.value.reduce((sum, col) => (sum += getCalculatedColWidth(col)), 0) > virtualScrollX.value.containerWidth + 100
195
+ props.virtualX && tableHeaderLast.value.reduce((sum, col) => (sum += getCalculatedColWidth(col)), 0) > virtualScrollX.value.containerWidth
197
196
  );
198
197
  });
199
198