@antv/s2-vue 1.2.0-alpha.1 → 1.3.0-alpha.1

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/esm/index.d.ts CHANGED
@@ -143,7 +143,7 @@ declare abstract class BaseCell<T extends SimpleBBox> extends Group {
143
143
  protected abstract getTextPosition(): Point;
144
144
  getStyle<K extends keyof S2Theme = keyof CellThemes>(name?: K): DefaultCellTheme | S2Theme[K];
145
145
  protected getResizeAreaStyle(): ResizeArea;
146
- protected shouldDrawResizeAreaByType(type: keyof ResizeActiveOptions): boolean | ResizeType;
146
+ protected shouldDrawResizeAreaByType(type: keyof ResizeInteractionOptions, cell: S2CellType): boolean | ((cell: S2CellType<ViewMeta_2>) => boolean) | ResizeType | ((resizeInfo: ResizeInfo_2) => boolean);
147
147
  protected getCellArea(): {
148
148
  x: number;
149
149
  y: number;
@@ -310,6 +310,8 @@ declare abstract class BaseFacet {
310
310
  get scrollBarSize(): number;
311
311
  protected preCellIndexes: PanelIndexes;
312
312
  constructor(cfg: SpreadSheetFacetCfg);
313
+ protected getCellCustomWidth(node: Node_2_2, width: CellCustomWidth): number;
314
+ protected getCellDraggedWidth(node: Node_2_2): number;
313
315
  hideScrollBar: () => void;
314
316
  delayHideScrollBar: DebouncedFunc<() => void>;
315
317
  delayHideScrollbarOnMobile: () => void;
@@ -375,24 +377,16 @@ declare abstract class BaseFacet {
375
377
  private getScrollbarPosition;
376
378
  renderVScrollBar: (height: number, realHeight: number, scrollY: number) => void;
377
379
  getScrollBarOffset: (offset: number, scrollbar: ScrollBar) => number;
378
- isScrollOverThePanelArea: ({ layerX, layerY }: Partial<S2WheelEvent>) => boolean;
379
- isScrollOverTheCornerArea: ({ layerX, layerY }: Partial<S2WheelEvent>) => boolean;
380
- updateHorizontalRowScrollOffset: ({ offset, layerX, layerY }: {
381
- offset: any;
382
- layerX: any;
383
- layerY: any;
384
- }) => void;
385
- updateHorizontalScrollOffset: ({ offset, layerX, layerY }: {
386
- offset: any;
387
- layerX: any;
388
- layerY: any;
389
- }) => void;
390
- isScrollToLeft: (deltaX: number) => boolean;
391
- isScrollToRight: (deltaX: number) => boolean;
380
+ isScrollOverThePanelArea: ({ offsetX, offsetY }: CellScrollOffset) => boolean;
381
+ isScrollOverTheCornerArea: ({ offsetX, offsetY }: CellScrollOffset) => boolean;
382
+ updateHorizontalRowScrollOffset: ({ offset, offsetX, offsetY, }: CellScrollOffset) => void;
383
+ updateHorizontalScrollOffset: ({ offset, offsetX, offsetY, }: CellScrollOffset) => void;
384
+ isScrollToLeft: ({ deltaX, offsetX, offsetY }: CellScrollOffset) => boolean;
385
+ isScrollToRight: ({ deltaX, offsetX, offsetY }: CellScrollOffset) => boolean;
392
386
  isScrollToTop: (deltaY: number) => boolean;
393
387
  isScrollToBottom: (deltaY: number) => boolean;
394
388
  isVerticalScrollOverTheViewport: (deltaY: number) => boolean;
395
- isHorizontalScrollOverTheViewport: (deltaX: number) => boolean;
389
+ isHorizontalScrollOverTheViewport: (scrollOffset: CellScrollOffset) => boolean;
396
390
  /**
397
391
  在当前表格滚动分两种情况:
398
392
  1. 当前表格无滚动条: 无需阻止外部容器滚动
@@ -400,7 +394,7 @@ declare abstract class BaseFacet {
400
394
  - 未滚动到顶部或底部: 当前表格滚动, 阻止外部容器滚动
401
395
  - 滚动到顶部或底部: 恢复外部容器滚动
402
396
  */
403
- isScrollOverTheViewport: (deltaX: number, deltaY: number, layerY: number) => boolean;
397
+ isScrollOverTheViewport: (scrollOffset: CellScrollOffset) => boolean;
404
398
  cancelScrollFrame: () => boolean;
405
399
  clearScrollFrameIdOnMobile: () => void;
406
400
  /**
@@ -413,7 +407,7 @@ declare abstract class BaseFacet {
413
407
  */
414
408
  private stopScrollChainingIfNeeded;
415
409
  private stopScrollChaining;
416
- onWheel: (event: S2WheelEvent) => void;
410
+ onWheel: (event: WheelEvent) => void;
417
411
  protected clip(scrollX: number, scrollY: number): void;
418
412
  /**
419
413
  * Translate panelGroup, rowHeader, cornerHeader, columnHeader ect
@@ -454,14 +448,13 @@ declare abstract class BaseFacet {
454
448
  cols: number[];
455
449
  rows: any[];
456
450
  };
457
- drawGrid(): void;
451
+ updatePanelScrollGroup(): void;
458
452
  /**
459
453
  * When scroll behavior happened, only render one time in a period,
460
454
  * but render immediately in initiate
461
455
  * @protected
462
456
  */
463
457
  protected dynamicRenderCell(): void;
464
- private putMergedCellsGroupToFront;
465
458
  private emitScrollEvent;
466
459
  protected onAfterScroll: DebouncedFunc<() => void>;
467
460
  protected saveInitColumnLeafNodes(columnNodes?: Node_2_2[]): void;
@@ -1070,6 +1063,8 @@ declare interface CellCfg {
1070
1063
  };
1071
1064
  }
1072
1065
 
1066
+ declare type CellCustomWidth = number | ((node: Node_2_2) => number);
1067
+
1073
1068
  declare interface CellDataParams {
1074
1069
  query: DataType_2;
1075
1070
  isTotals?: boolean;
@@ -1085,6 +1080,14 @@ declare interface CellMeta_2 {
1085
1080
  [key: string]: unknown;
1086
1081
  }
1087
1082
 
1083
+ declare interface CellScrollOffset {
1084
+ deltaX?: number;
1085
+ deltaY?: number;
1086
+ offset?: number;
1087
+ offsetX: number;
1088
+ offsetY: number;
1089
+ }
1090
+
1088
1091
  declare interface CellScrollPosition_2 {
1089
1092
  scrollX: number;
1090
1093
  scrollY: number;
@@ -1161,6 +1164,7 @@ declare class ColCell extends HeaderCell {
1161
1164
  }
1162
1165
 
1163
1166
  declare interface ColCfg {
1167
+ width?: CellCustomWidth;
1164
1168
  height?: number;
1165
1169
  widthByFieldValue?: Record<string, number>;
1166
1170
  heightByField?: Record<string, number>;
@@ -1593,7 +1597,7 @@ declare interface FormatResult {
1593
1597
  value: DataItem;
1594
1598
  }
1595
1599
 
1596
- declare type Formatter = (v: unknown, data?: Data_2 | Data_2[]) => string;
1600
+ declare type Formatter = (v: unknown, data?: Data_2 | Data_2[], meta?: Node_2_2 | ViewMeta_2) => string;
1597
1601
 
1598
1602
  declare class Frame extends Group {
1599
1603
  cfg: FrameConfig;
@@ -1655,10 +1659,10 @@ declare interface GridAnalysisCellTheme {
1655
1659
  }
1656
1660
 
1657
1661
  declare class GridGroup extends Group {
1658
- private s2;
1662
+ protected s2: SpreadSheet_2;
1659
1663
  constructor(cfg: any);
1660
- private gridGroup;
1661
- private gridInfo;
1664
+ protected gridGroup: IGroup;
1665
+ protected gridInfo: GridInfo;
1662
1666
  updateGrid: (gridInfo: GridInfo, id?: string) => void;
1663
1667
  }
1664
1668
 
@@ -1822,10 +1826,11 @@ declare interface InteractionOptions {
1822
1826
  hoverFocus?: boolean | HoverFocusOptions;
1823
1827
  enableCopy?: boolean;
1824
1828
  copyWithFormat?: boolean;
1829
+ copyWithHeader?: boolean;
1825
1830
  autoResetSheetStyle?: boolean;
1826
1831
  hiddenColumnFields?: string[];
1827
1832
  scrollSpeedRatio?: ScrollSpeedRatio;
1828
- resize?: boolean | ResizeActiveOptions;
1833
+ resize?: boolean | ResizeInteractionOptions;
1829
1834
  brushSelection?: boolean;
1830
1835
  multiSelection?: boolean;
1831
1836
  rangeSelection?: boolean;
@@ -2183,6 +2188,12 @@ declare type PanelIndexes = {
2183
2188
  };
2184
2189
 
2185
2190
  declare class PanelScrollGroup extends GridGroup {
2191
+ protected mergedCellsGroup: IGroup;
2192
+ constructor(cfg: any);
2193
+ protected initMergedCellsGroup(): void;
2194
+ updateMergedCells(): void;
2195
+ addMergeCell(mergeCell: MergedCell): void;
2196
+ update(gridInfo: GridInfo): void;
2186
2197
  }
2187
2198
 
2188
2199
  declare interface PartDrillDown {
@@ -2515,18 +2526,11 @@ declare interface RequiredPropOption<T = any> {
2515
2526
  required: true;
2516
2527
  }
2517
2528
 
2518
- declare interface ResizeActiveOptions {
2519
- rowCellVertical?: boolean;
2520
- cornerCellHorizontal?: boolean;
2521
- colCellHorizontal?: boolean;
2522
- colCellVertical?: boolean;
2523
- rowResizeType?: ResizeType;
2524
- }
2525
-
2526
2529
  declare interface ResizeArea {
2527
2530
  size?: number;
2528
2531
  background?: string;
2529
2532
  guideLineColor?: string;
2533
+ guideLineDisableColor?: string;
2530
2534
  guideLineDash?: number[];
2531
2535
  backgroundOpacity?: number;
2532
2536
  interactionState?: InteractionState;
@@ -2563,11 +2567,27 @@ declare interface ResizeInfo_2 {
2563
2567
  isResizeArea?: boolean;
2564
2568
  /** 字段id */
2565
2569
  id?: string;
2570
+ /** 当前拖拽热区对应的节点信息 */
2571
+ meta: Node_2_2 | ViewMeta_2;
2572
+ /** 拖拽后的宽度 */
2573
+ resizedWidth?: number;
2574
+ /** 拖拽后的高度 */
2575
+ resizedHeight?: number;
2576
+ }
2577
+
2578
+ declare interface ResizeInteractionOptions {
2579
+ rowCellVertical?: boolean;
2580
+ cornerCellHorizontal?: boolean;
2581
+ colCellHorizontal?: boolean;
2582
+ colCellVertical?: boolean;
2583
+ rowResizeType?: ResizeType;
2584
+ disable?: (resizeInfo: ResizeInfo_2) => boolean;
2585
+ visible?: (cell: S2CellType) => boolean;
2566
2586
  }
2567
2587
 
2568
2588
  declare interface ResizeParams_2 {
2569
- resizeInfo?: ResizeInfo_2;
2570
- style?: Style;
2589
+ info: ResizeInfo_2;
2590
+ style: Style;
2571
2591
  }
2572
2592
 
2573
2593
  declare enum ResizeType {
@@ -2676,9 +2696,12 @@ declare type RowCellCollapseTreeRowsType = {
2676
2696
  };
2677
2697
 
2678
2698
  declare interface RowCfg {
2679
- width?: number;
2699
+ width?: CellCustomWidth;
2680
2700
  widthByField?: Record<string, number>;
2681
2701
  heightByField?: Record<string, number>;
2702
+ /**
2703
+ * @deprecated (已废弃, 请使用 style.treeRowsWidth 代替) tree row width(拖拽产生的,无需主动设置)
2704
+ */
2682
2705
  treeRowsWidth?: number;
2683
2706
  }
2684
2707
 
@@ -2881,11 +2904,6 @@ declare interface S2Theme extends CellThemes {
2881
2904
  background?: Background;
2882
2905
  }
2883
2906
 
2884
- declare interface S2WheelEvent extends WheelEvent {
2885
- layerX: number;
2886
- layerY: number;
2887
- }
2888
-
2889
2907
  declare class ScrollBar extends Group {
2890
2908
  isHorizontal: boolean;
2891
2909
  trackLen: number;
@@ -2904,19 +2922,16 @@ declare class ScrollBar extends Group {
2904
2922
  private eventHandlers;
2905
2923
  private scrollFrameId;
2906
2924
  constructor(scrollBarCfg: ScrollBarCfg);
2907
- getCoordinates: () => {
2908
- from: string;
2909
- to: string;
2910
- };
2925
+ private getCoordinatesName;
2911
2926
  /**
2912
- * 当前滑块滑动的位置 0 ~ 1
2927
+ * Antv/g 4.x 版本计算 bbox 有bug, 实际渲染的宽度会比给定的宽度大, 需要对其做修正
2928
+ * 详情: https://github.com/antvis/S2/pull/1566/files#diff-3f08348041906ddf1e4f094bfe2ac32b35ff668918d3fbb952e9227ae462cc08R52
2913
2929
  */
2914
- current: () => number;
2930
+ private getCoordinatesWithBBoxExtraPadding;
2915
2931
  /**
2916
- * 更新滑道长度
2917
- * @param newTrackLen 新的滑块长度
2932
+ * 当前滑块滑动的位置 0 ~ 1
2918
2933
  */
2919
- updateTrackLen: (newTrackLen: number) => void;
2934
+ current: () => number;
2920
2935
  /**
2921
2936
  * 更新滑块长度
2922
2937
  * @param newThumbLen 新的滑道长度
@@ -3821,7 +3836,6 @@ declare abstract class SpreadSheet_2 extends EE {
3821
3836
  backgroundGroup: IGroup;
3822
3837
  panelGroup: IGroup;
3823
3838
  panelScrollGroup: PanelScrollGroup;
3824
- mergedCellsGroup: IGroup;
3825
3839
  frozenRowGroup: FrozenGroup_2;
3826
3840
  frozenColGroup: FrozenGroup_2;
3827
3841
  frozenTrailingRowGroup: FrozenGroup_2;
@@ -3963,6 +3977,20 @@ declare abstract class SpreadSheet_2 extends EE {
3963
3977
  clearColumnLeafNodes(): void;
3964
3978
  private initHiddenColumnsDetail;
3965
3979
  private clearCanvasEvent;
3980
+ /**
3981
+ * 计算文本在画布中的宽度
3982
+ * @param text 待计算的文本
3983
+ * @param font 文本 css 样式
3984
+ * @returns 文本宽度
3985
+ */
3986
+ measureTextWidth: ((text: number | string, font: unknown) => number) & MemoizedFunction;
3987
+ /**
3988
+ * 粗略计算文本在画布中的宽度
3989
+ * @param text 待计算的文本
3990
+ * @param font 文本 css 样式
3991
+ * @returns 文本宽度
3992
+ */
3993
+ measureTextWidthRoughly: (text: any, font?: any) => number;
3966
3994
  }
3967
3995
 
3968
3996
  /**
package/esm/index.js CHANGED
@@ -1619,17 +1619,20 @@ function size(collection) {
1619
1619
  }
1620
1620
  return baseKeys(collection).length;
1621
1621
  }
1622
- const analyzeAdaptive = (paramsContainer, adaptive) => {
1622
+ const analyzeAdaptive = (defaultContainer, adaptive) => {
1623
1623
  var _a, _b, _c;
1624
- let container = paramsContainer;
1625
- let adaptiveWidth = true;
1626
- let adaptiveHeight = false;
1627
- if (typeof adaptive !== "boolean") {
1628
- container = ((_a = adaptive == null ? void 0 : adaptive.getContainer) == null ? void 0 : _a.call(adaptive)) || paramsContainer;
1629
- adaptiveWidth = (_b = adaptive == null ? void 0 : adaptive.width) != null ? _b : true;
1630
- adaptiveHeight = (_c = adaptive == null ? void 0 : adaptive.height) != null ? _c : true;
1631
- }
1632
- return { container, adaptiveWidth, adaptiveHeight };
1624
+ if (isBoolean(adaptive)) {
1625
+ return {
1626
+ container: defaultContainer,
1627
+ adaptiveWidth: true,
1628
+ adaptiveHeight: false
1629
+ };
1630
+ }
1631
+ return {
1632
+ container: ((_a = adaptive == null ? void 0 : adaptive.getContainer) == null ? void 0 : _a.call(adaptive)) || defaultContainer,
1633
+ adaptiveWidth: (_b = adaptive == null ? void 0 : adaptive.width) != null ? _b : true,
1634
+ adaptiveHeight: (_c = adaptive == null ? void 0 : adaptive.height) != null ? _c : true
1635
+ };
1633
1636
  };
1634
1637
  const createResizeObserver = (params) => {
1635
1638
  let isFirstRender = true;
@@ -2703,6 +2706,8 @@ const initBaseSheetEmits = () => {
2703
2706
  "selected",
2704
2707
  "reset",
2705
2708
  "linkFieldJump",
2709
+ "click",
2710
+ "doubleClick",
2706
2711
  "scroll"
2707
2712
  ];
2708
2713
  return keys2;
@@ -2975,7 +2980,7 @@ var DrillDown = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render
2975
2980
  const _sfc_main$2 = defineComponent({
2976
2981
  name: "PivotSheet",
2977
2982
  props: initBaseSheetProps(),
2978
- emits: initBaseSheetEmits(),
2983
+ emits: [],
2979
2984
  setup(props, ctx) {
2980
2985
  const s2Ref = useExpose(ctx.expose);
2981
2986
  const { options: pivotOptions } = toRefs(props);