diff --git a/packages/s2-core/__tests__/unit/utils/frozen-util-spec.ts b/packages/s2-core/__tests__/unit/utils/frozen-util-spec.ts index abca118ebf..b98c8ba491 100644 --- a/packages/s2-core/__tests__/unit/utils/frozen-util-spec.ts +++ b/packages/s2-core/__tests__/unit/utils/frozen-util-spec.ts @@ -1,5 +1,5 @@ import { FrozenGroupType } from '../../../src'; -import type { S2TableSheetFrozenOptions } from '@/common/interface/s2Options'; +import type { S2BaseFrozenOptions } from '@/common/interface/s2Options'; import { getValidFrozenOptions } from '@/utils/layout/frozen'; import { getFrozenGroupTypeByCell, @@ -44,7 +44,7 @@ describe('Frozen util test', () => { start: 0, end: 499, }; - const frozenOptions: S2TableSheetFrozenOptions = { + const frozenOptions: S2BaseFrozenOptions = { colCount: 2, rowCount: 2, trailingColCount: 2, @@ -151,7 +151,7 @@ describe('Frozen util test', () => { describe('calculateFrozenCornerCells', () => { it('should return correct frozen corner cell', () => { - const frozenOptions: S2TableSheetFrozenOptions = { + const frozenOptions: S2BaseFrozenOptions = { colCount: 1, rowCount: 2, trailingColCount: 1, @@ -206,7 +206,7 @@ describe('Frozen util test', () => { start: 0, end: 999, }; - const frozenOptions: S2TableSheetFrozenOptions = { + const frozenOptions: S2BaseFrozenOptions = { colCount: 1, rowCount: 2, trailingColCount: 1, diff --git a/packages/s2-core/src/common/constant/options.ts b/packages/s2-core/src/common/constant/options.ts index c80a6e9fbb..2ba11244f5 100644 --- a/packages/s2-core/src/common/constant/options.ts +++ b/packages/s2-core/src/common/constant/options.ts @@ -8,10 +8,7 @@ import { ScrollbarPositionType, } from '../constant/interaction'; import type { CellTextWordWrapStyle, S2Style } from '../interface'; -import type { - S2Options, - S2TableSheetFrozenOptions, -} from '../interface/s2Options'; +import type { S2Options, S2BaseFrozenOptions } from '../interface/s2Options'; import { DeviceType } from '../interface/s2Options'; import { EMPTY_PLACEHOLDER } from './basic'; @@ -62,7 +59,7 @@ export const DEFAULT_STYLE: S2Style = { }, } as const; -export const DEFAULT_FROZEN_COUNTS: Required = { +export const DEFAULT_FROZEN_COUNTS: Required = { rowCount: 0, colCount: 0, trailingRowCount: 0, diff --git a/packages/s2-core/src/common/interface/s2Options.ts b/packages/s2-core/src/common/interface/s2Options.ts index a948ee5b8c..4b51622e92 100644 --- a/packages/s2-core/src/common/interface/s2Options.ts +++ b/packages/s2-core/src/common/interface/s2Options.ts @@ -291,7 +291,7 @@ export enum DeviceType { MOBILE = 'mobile', } -export interface S2PivotSheetFrozenOptions extends S2TableSheetFrozenOptions { +export interface S2PivotSheetFrozenOptions extends S2BaseFrozenOptions { /** * 是否冻结行头 (含角头区域, 透视表有效), * 当值为 number 时,标识行头冻结的最大区域,取值范围: (0, 1),0 表示不固定行头 @@ -300,7 +300,7 @@ export interface S2PivotSheetFrozenOptions extends S2TableSheetFrozenOptions { rowHeader?: boolean | number; } -export interface S2TableSheetFrozenOptions { +export interface S2BaseFrozenOptions { /** * 行头冻结数量 */ @@ -361,7 +361,7 @@ export interface S2Options< /** * 行列冻结 */ - frozen?: S2PivotSheetFrozenOptions & S2TableSheetFrozenOptions; + frozen?: S2PivotSheetFrozenOptions & S2BaseFrozenOptions; } export interface S2RenderOptions { diff --git a/packages/s2-core/src/facet/frozen-facet.ts b/packages/s2-core/src/facet/frozen-facet.ts index 40080b25ac..ae314ab0b3 100644 --- a/packages/s2-core/src/facet/frozen-facet.ts +++ b/packages/s2-core/src/facet/frozen-facet.ts @@ -25,7 +25,7 @@ import type { FrozenGroupAreas, FrozenGroups, } from '../common/interface/frozen'; -import type { S2TableSheetFrozenOptions } from '../common'; +import type { S2BaseFrozenOptions } from '../common'; import { BaseFacet } from './base-facet'; import { Node } from './layout/node'; import { @@ -73,7 +73,7 @@ export abstract class FrozenFacet extends BaseFacet { }, } satisfies FrozenGroupAreas; - protected validFrozenOptions: Required; + protected validFrozenOptions: Required; public panelScrollGroupIndexes: Indexes = [0, 0, 0, 0]; diff --git a/packages/s2-core/src/facet/utils.ts b/packages/s2-core/src/facet/utils.ts index 83b91899fe..1477cf2369 100644 --- a/packages/s2-core/src/facet/utils.ts +++ b/packages/s2-core/src/facet/utils.ts @@ -7,7 +7,7 @@ import type { CustomHeaderFields, Fields, Pagination, - S2TableSheetFrozenOptions, + S2BaseFrozenOptions, ScrollSpeedRatio, } from '../common/interface'; import type { Indexes } from '../utils/indexes'; @@ -154,7 +154,7 @@ export const getFrozenGroupTypeByCell = ( colIndex: number; rowIndex: number; }, - frozenOptions: S2TableSheetFrozenOptions, + frozenOptions: S2BaseFrozenOptions, colLength: number, cellRange: { start: number; @@ -192,7 +192,7 @@ export const getFrozenGroupTypeByCell = ( * @description calculate all cells in frozen group's intersection region */ export const calculateFrozenCornerCells = ( - frozenOptions: S2TableSheetFrozenOptions, + frozenOptions: S2BaseFrozenOptions, colLength: number, cellRange: { start: number; @@ -265,7 +265,7 @@ export const calculateFrozenCornerCells = ( */ export const splitInViewIndexesWithFrozen = ( indexes: Indexes, - frozenOptions: S2TableSheetFrozenOptions, + frozenOptions: S2BaseFrozenOptions, colLength: number, cellRange: { start: number; diff --git a/packages/s2-core/src/utils/layout/frozen.ts b/packages/s2-core/src/utils/layout/frozen.ts index e1f75f1efb..32163a0e33 100644 --- a/packages/s2-core/src/utils/layout/frozen.ts +++ b/packages/s2-core/src/utils/layout/frozen.ts @@ -1,15 +1,12 @@ import { DEFAULT_FROZEN_COUNTS } from '../../common'; -import type { - S2Options, - S2TableSheetFrozenOptions, -} from '../../common/interface'; +import type { S2Options, S2BaseFrozenOptions } from '../../common/interface'; export const getValidFrozenOptions = ( - defaultFrozenOptions: S2TableSheetFrozenOptions = {}, + defaultFrozenOptions: S2BaseFrozenOptions = {}, colLength: number, dataLength = 0, -): Required => { - const frozenOptions: Required = { +): Required => { + const frozenOptions: Required = { ...DEFAULT_FROZEN_COUNTS, ...defaultFrozenOptions, }; @@ -43,9 +40,9 @@ export const getValidFrozenOptions = ( * @returns */ export const getValidFrozenOptionsForPivot = ( - frozen: Required, + frozen: Required, options: S2Options, -): Required => { +): Required => { /** * series number cell 可以自定义布局,和 row cell 不一定是 1 对 1 的关系 * seriesNumber 暂时禁用 首行冻结 diff --git a/packages/s2-react/playground/config.tsx b/packages/s2-react/playground/config.tsx index cf96cc5d61..19bb24afd5 100644 --- a/packages/s2-react/playground/config.tsx +++ b/packages/s2-react/playground/config.tsx @@ -7,7 +7,7 @@ import { type CustomHeaderField, type CustomTreeNode, type S2DataConfig, - type S2TableSheetFrozenOptions, + type S2BaseFrozenOptions, type ThemeCfg, } from '@antv/s2'; import { getBaseSheetComponentOptions } from '@antv/s2-shared'; @@ -253,12 +253,12 @@ export const s2ConditionsOptions: SheetComponentOptions['conditions'] = { ], }; -export const TableSheetFrozenOptions: S2TableSheetFrozenOptions = { +export const TableSheetFrozenOptions: S2BaseFrozenOptions = { colCount: 1, trailingColCount: 1, }; -export const PivotSheetFrozenOptions: S2TableSheetFrozenOptions = { +export const PivotSheetFrozenOptions: S2BaseFrozenOptions = { rowCount: 1, trailingRowCount: 1, }; diff --git a/s2-site/docs/api/basic-class/node.zh.md b/s2-site/docs/api/basic-class/node.zh.md index 7cf7cda88c..d90c6f65fa 100644 --- a/s2-site/docs/api/basic-class/node.zh.md +++ b/s2-site/docs/api/basic-class/node.zh.md @@ -40,3 +40,4 @@ node.isTotals // false | padding | 间距 | `number` | | children | 子节点 | [Node[]](/docs/api/basic-class/node) | | extra | 节点额外信息 | `Record` | +| relatedNode | 给序号列单元格用,标识该序号单元格对应了行头节点,有了关联关系后,就可以在行头冻结时做区分 | [Node[]](/docs/api/basic-class/node) |