Skip to content

Commit

Permalink
refactor: rename S2TableSheetFrozenOptions to S2BaseFrozenOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed Jun 3, 2024
1 parent c5c20e7 commit 478f261
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 30 deletions.
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/unit/utils/frozen-util-spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('Frozen util test', () => {
start: 0,
end: 499,
};
const frozenOptions: S2TableSheetFrozenOptions = {
const frozenOptions: S2BaseFrozenOptions = {
colCount: 2,
rowCount: 2,
trailingColCount: 2,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Frozen util test', () => {
start: 0,
end: 999,
};
const frozenOptions: S2TableSheetFrozenOptions = {
const frozenOptions: S2BaseFrozenOptions = {
colCount: 1,
rowCount: 2,
trailingColCount: 1,
Expand Down
7 changes: 2 additions & 5 deletions packages/s2-core/src/common/constant/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -62,7 +59,7 @@ export const DEFAULT_STYLE: S2Style = {
},
} as const;

export const DEFAULT_FROZEN_COUNTS: Required<S2TableSheetFrozenOptions> = {
export const DEFAULT_FROZEN_COUNTS: Required<S2BaseFrozenOptions> = {
rowCount: 0,
colCount: 0,
trailingRowCount: 0,
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/src/common/interface/s2Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export enum DeviceType {
MOBILE = 'mobile',
}

export interface S2PivotSheetFrozenOptions extends S2TableSheetFrozenOptions {
export interface S2PivotSheetFrozenOptions extends S2BaseFrozenOptions {
/**
* 是否冻结行头 (含角头区域, 透视表有效),
* 当值为 number 时,标识行头冻结的最大区域,取值范围: (0, 1),0 表示不固定行头
Expand All @@ -300,7 +300,7 @@ export interface S2PivotSheetFrozenOptions extends S2TableSheetFrozenOptions {
rowHeader?: boolean | number;
}

export interface S2TableSheetFrozenOptions {
export interface S2BaseFrozenOptions {
/**
* 行头冻结数量
*/
Expand Down Expand Up @@ -361,7 +361,7 @@ export interface S2Options<
/**
* 行列冻结
*/
frozen?: S2PivotSheetFrozenOptions & S2TableSheetFrozenOptions;
frozen?: S2PivotSheetFrozenOptions & S2BaseFrozenOptions;
}

export interface S2RenderOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/src/facet/frozen-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -73,7 +73,7 @@ export abstract class FrozenFacet extends BaseFacet {
},
} satisfies FrozenGroupAreas;

protected validFrozenOptions: Required<S2TableSheetFrozenOptions>;
protected validFrozenOptions: Required<S2BaseFrozenOptions>;

public panelScrollGroupIndexes: Indexes = [0, 0, 0, 0];

Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/src/facet/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
CustomHeaderFields,
Fields,
Pagination,
S2TableSheetFrozenOptions,
S2BaseFrozenOptions,
ScrollSpeedRatio,
} from '../common/interface';
import type { Indexes } from '../utils/indexes';
Expand Down Expand Up @@ -154,7 +154,7 @@ export const getFrozenGroupTypeByCell = (
colIndex: number;
rowIndex: number;
},
frozenOptions: S2TableSheetFrozenOptions,
frozenOptions: S2BaseFrozenOptions,
colLength: number,
cellRange: {
start: number;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -265,7 +265,7 @@ export const calculateFrozenCornerCells = (
*/
export const splitInViewIndexesWithFrozen = (
indexes: Indexes,
frozenOptions: S2TableSheetFrozenOptions,
frozenOptions: S2BaseFrozenOptions,
colLength: number,
cellRange: {
start: number;
Expand Down
15 changes: 6 additions & 9 deletions packages/s2-core/src/utils/layout/frozen.ts
Original file line number Diff line number Diff line change
@@ -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<S2TableSheetFrozenOptions> => {
const frozenOptions: Required<S2TableSheetFrozenOptions> = {
): Required<S2BaseFrozenOptions> => {
const frozenOptions: Required<S2BaseFrozenOptions> = {
...DEFAULT_FROZEN_COUNTS,
...defaultFrozenOptions,
};
Expand Down Expand Up @@ -43,9 +40,9 @@ export const getValidFrozenOptions = (
* @returns
*/
export const getValidFrozenOptionsForPivot = (
frozen: Required<S2TableSheetFrozenOptions>,
frozen: Required<S2BaseFrozenOptions>,
options: S2Options,
): Required<S2TableSheetFrozenOptions> => {
): Required<S2BaseFrozenOptions> => {
/**
* series number cell 可以自定义布局,和 row cell 不一定是 1 对 1 的关系
* seriesNumber 暂时禁用 首行冻结
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-react/playground/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
};
Expand Down
1 change: 1 addition & 0 deletions s2-site/docs/api/basic-class/node.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ node.isTotals // false
| padding | 间距 | `number` |
| children | 子节点 | [Node[]](/docs/api/basic-class/node) |
| extra | 节点额外信息 | `Record<string, any>` |
| relatedNode | 给序号列单元格用,标识该序号单元格对应了行头节点,有了关联关系后,就可以在行头冻结时做区分 | [Node[]](/docs/api/basic-class/node) |

0 comments on commit 478f261

Please sign in to comment.