stk-table-vue 1.2.0-beta.2 → 1.2.0

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,5 +1,5 @@
1
1
  import { FilterStatus } from './custom-cells/FilterCell/types';
2
- import { AreaSelectionConfig, AreaSelectionRange, AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, ExperimentalConfig, FooterConfig, HeaderDragConfig, HighlightConfig, Order, PrivateRowDT, PrivateStkTableColumn, RowActiveOption, SeqConfig, SortConfig, StkTableColumn, TreeConfig, UniqKey, UniqKeyProp } from './types/index';
2
+ import { AreaSelectionConfig, AreaSelectionRange, AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, ExperimentalConfig, FooterConfig, HeaderDragConfig, HighlightConfig, Order, PrivateRowDT, PrivateStkTableColumn, RowActiveOption, ScrollToOptions, SeqConfig, SortConfig, StkTableColumn, TreeConfig, UniqKey, UniqKeyProp } from './types/index';
3
3
  import { ScrollbarOptions } from './useScrollbar';
4
4
 
5
5
  declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
@@ -338,11 +338,16 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
338
338
  resetSorter: () => void;
339
339
  /**
340
340
  * 滚动至
341
+ * - 数字参数:scrollTo(top, left),null 表示不改变该轴
342
+ * - 对象参数:scrollTo({ top, left, behavior }),top/left 可传像素数字或 { index, key, px } 目标
341
343
  *
342
- * en: Scroll to
344
+ * en: Scroll to position or target row/column
343
345
  * @see {@link scrollTo}
344
346
  */
345
- scrollTo: (top?: number | null, left?: number | null) => void;
347
+ scrollTo: {
348
+ (top?: number | null, left?: number | null): void;
349
+ (options: ScrollToOptions): void;
350
+ };
346
351
  /**
347
352
  * 获取表格数据
348
353
  *
@@ -765,12 +770,12 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
765
770
  sortConfig: SortConfig<any>;
766
771
  colKey: UniqKeyProp;
767
772
  headless: boolean;
773
+ rowHeight: number;
768
774
  autoRowHeight: boolean | AutoRowHeightConfig<any>;
769
775
  stripe: boolean;
770
776
  optimizeVue2Scroll: boolean;
771
777
  rowKey: UniqKeyProp;
772
778
  headerRowHeight: number | string;
773
- rowHeight: number;
774
779
  scrollbar: boolean | ScrollbarOptions;
775
780
  fixedMode: boolean;
776
781
  theme: "light" | "dark";
@@ -7,7 +7,7 @@ import { VirtualScrollStore, VirtualScrollXStore } from '../useVirtualScroll';
7
7
  * 支持鼠标拖拽选择、键盘导航、复制粘贴等功能
8
8
  * en: Cell area selection feature with mouse drag, keyboard navigation, copy-paste, etc.
9
9
  */
10
- export declare function useAreaSelection<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): {
10
+ 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
11
  config: import('vue').ComputedRef<AreaSelectionConfig>;
12
12
  isSelecting: Ref<boolean, boolean>;
13
13
  get: () => {
@@ -21,3 +21,5 @@ export declare function useAreaSelection<DT extends Record<string, any>>(props:
21
21
  onMD: (e: MouseEvent) => void;
22
22
  };
23
23
  export declare const useAreaSelectionName = "useAreaSelection";
24
+ export declare const useAreaSelection: typeof useAreaSelectionImpl;
25
+ export {};
@@ -1,7 +1,7 @@
1
1
  export { useAreaSelection } from './features/index';
2
2
  export { registerFeature } from './registerFeature';
3
3
  export { default as StkTable } from './StkTable.vue';
4
- export type { AreaSelectionRange, Order, SortConfig, SortOption, SortState, StkTableColumn } from './types/index';
4
+ export type { AreaSelectionRange, Order, ScrollAxisTarget, ScrollToFn, ScrollToOptions, SortConfig, SortOption, SortState, StkTableColumn } from './types/index';
5
5
  export { binarySearch, insertToOrderedArray, strCompare, tableSort } from './utils';
6
6
  export { createFilterCell } from './custom-cells/FilterCell/index';
7
7
  export type { CreateFilterCellOption, FilterStatus } from './custom-cells/FilterCell/index';
@@ -434,4 +434,43 @@ export type FooterConfig = {
434
434
  */
435
435
  position?: 'bottom' | 'top';
436
436
  };
437
+ /**
438
+ * scrollTo options 重载中单个滚动轴的定位目标。
439
+ * 最终坐标 = `index` 或 `key` 解析出的基准偏移 + `px` 附加偏移。
440
+ */
441
+ export interface ScrollAxisTarget {
442
+ /**
443
+ * 目标索引(0 起始)
444
+ * - `top` 轴:当前展示顺序(排序/筛选/树展开后)的行索引
445
+ * - `left` 轴:叶子列(最深层表头列)索引
446
+ * 与 `key` 同时给出时 `index` 优先
447
+ */
448
+ index?: number;
449
+ /**
450
+ * 目标键值
451
+ * - `top` 轴:`props.rowKey` 对应的行键值
452
+ * - `left` 轴:列的 `dataIndex`
453
+ */
454
+ key?: string | number;
455
+ /** 在基准偏移之上叠加的像素偏移,可为负值。仅传 `px` 时基准为 0 */
456
+ px?: number;
457
+ }
458
+ /** scrollTo 实例方法 options 重载的参数 */
459
+ export interface ScrollToOptions {
460
+ /** 纵向目标:像素坐标或行定位目标。省略表示不改变纵向位置 */
461
+ top?: number | ScrollAxisTarget;
462
+ /** 横向目标:像素坐标或列定位目标。省略表示不改变横向位置 */
463
+ left?: number | ScrollAxisTarget;
464
+ /** 滚动行为,同原生 ScrollToOptions.behavior,默认 'auto'(立即跳转) */
465
+ behavior?: ScrollBehavior;
466
+ }
467
+ /**
468
+ * scrollTo 实例方法的函数签名(数字重载 + options 重载)。
469
+ * - 数字重载中 `null` 表示不改变对应轴,省略默认 0
470
+ * - options 重载中省略的轴表示不改变位置
471
+ */
472
+ export interface ScrollToFn {
473
+ (top?: number | null, left?: number | null): void;
474
+ (options: ScrollToOptions): void;
475
+ }
437
476
  export {};
@@ -50,7 +50,7 @@ export declare function useVirtualScroll(props: any, tableContainerRef: Ref<HTML
50
50
  /** 全局最大 rowspan(限定跨界修正扫描范围用) */
51
51
  getMaxRowSpanValue: () => number, scrollbarOptions: Ref<Required<ScrollbarOptions>>, isExperimentalScrollY: Ref<boolean | undefined>,
52
52
  /** mergeCells 结果共享缓存(与 useMergeCells 共用,避免重复调用用户回调) */
53
- mergeCellsCache: MergeCellsCache): readonly [ShallowRef<VirtualScrollStore, VirtualScrollStore>, ShallowRef<VirtualScrollXStore, VirtualScrollXStore>, import('vue').ComputedRef<any>, import('vue').ComputedRef<PrivateRowDT[]>, import('vue').ComputedRef<number>, import('vue').ComputedRef<any>, import('vue').ComputedRef<number>, import('vue').ComputedRef<number>, (height?: number) => void, (height?: number) => void, () => void, (sTop?: number) => void, (sLeft?: number) => void, (rowKey: UniqKey, height?: number | null) => void, () => void, () => void, import('vue').ComputedRef<PrivateStkTableColumn<PrivateRowDT>[][]>, import('vue').ComputedRef<number>, import('vue').ComputedRef<{
53
+ mergeCellsCache: MergeCellsCache): readonly [ShallowRef<VirtualScrollStore, VirtualScrollStore>, ShallowRef<VirtualScrollXStore, VirtualScrollXStore>, import('vue').ComputedRef<any>, import('vue').ComputedRef<PrivateRowDT[]>, import('vue').ComputedRef<number>, import('vue').ComputedRef<any>, import('vue').ComputedRef<number>, import('vue').ComputedRef<number>, (height?: number) => void, (height?: number) => void, () => void, (sTop?: number) => void, (sLeft?: number) => void, (rowKey: UniqKey, height?: number | null) => void, () => void, (count: number) => number, () => void, import('vue').ComputedRef<PrivateStkTableColumn<PrivateRowDT>[][]>, import('vue').ComputedRef<number>, import('vue').ComputedRef<{
54
54
  startIndex: number;
55
55
  endIndex: number;
56
56
  offsetLeft: number;
@@ -61,4 +61,9 @@ mergeCellsCache: MergeCellsCache): readonly [ShallowRef<VirtualScrollStore, Virt
61
61
  suffix: PrivateStkTableColumn<PrivateRowDT>[];
62
62
  /** leftExpand 起始的绝对叶子列索引(mergeCells 缓存键用) */
63
63
  leftExpandStart: number;
64
- } | null>];
64
+ } | null>, () => {
65
+ mapSize: number;
66
+ mapKeys: string[];
67
+ cacheSize: number;
68
+ total: number;
69
+ }];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 行高 Fenwick 树(树状数组):Float64Array 存储,维护各行高度的累计和。
3
+ * 用于变高(autoRowHeight / 展开列)模式下以 O(log n) 定位视口行范围与推导总高度,
4
+ * 替代原先每滚动帧 O(n) 的逐行累加。
5
+ * 支持:O(n) 建树、O(log n) 单点增量更新、O(log n) 前缀和查询、O(log n) 累计和下界查找(树上二分)。
6
+ */
7
+ export declare class RowHeightFenwickTree {
8
+ /** 内部 1-based 索引,bit[0] 不使用 */
9
+ private bit;
10
+ readonly size: number;
11
+ /** 全部行高之和,更新时增量维护 */
12
+ total: number;
13
+ constructor(size: number);
14
+ /** O(n) 顺序建树:heights[i] 为第 i 行(0-based)高度 */
15
+ build(heights: ArrayLike<number>): void;
16
+ /** 单点增量更新:第 index 行(0-based)高度变化 delta,O(log n) */
17
+ add(index: number, delta: number): void;
18
+ /** 前 count 行的累计高度(前缀和),O(log n);count 越界时钳制到 [0, size] */
19
+ query(count: number): number;
20
+ /**
21
+ * 累计和下界查找(树上二分,O(log n)):
22
+ * 返回首个「累计高度(含本行)≥ target」的行索引(0-based);
23
+ * 总高不足 target 时返回 size(不存在满足条件的行)。
24
+ */
25
+ findFirstPrefixGE(target: number): number;
26
+ }