@univerjs/sheets
Version:
UniverSheet normal base-sheets
67 lines (66 loc) • 2.59 kB
TypeScript
import { Direction, IAccessor, ICellData, IMutationInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
import { IDiscreteRange } from '../../basics';
export declare enum AUTO_FILL_APPLY_TYPE {
COPY = "COPY",
SERIES = "SERIES",
ONLY_FORMAT = "ONLY_FORMAT",
NO_FORMAT = "NO_FORMAT"
}
export declare enum AUTO_FILL_DATA_TYPE {
NUMBER = "number",
DATE = "date",
EXTEND_NUMBER = "extendNumber",
CHN_NUMBER = "chnNumber",
CHN_WEEK2 = "chnWeek2",
CHN_WEEK3 = "chnWeek3",
LOOP_SERIES = "loopSeries",
FORMULA = "formula",
OTHER = "other"
}
export declare enum AUTO_FILL_HOOK_TYPE {
APPEND = "APPEND",
DEFAULT = "DEFAULT",
ONLY = "ONLY"
}
export interface IAutoFillLocation {
source: IDiscreteRange;
target: IDiscreteRange;
unitId: string;
subUnitId: string;
}
export interface ISheetAutoFillHook {
id: string;
priority?: number;
type?: AUTO_FILL_HOOK_TYPE;
bindUnit?: string;
disable?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE) => boolean;
onBeforeFillData?(location: IAutoFillLocation, direction: Direction): AUTO_FILL_APPLY_TYPE | void;
onFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): {
undos: IMutationInfo[];
redos: IMutationInfo[];
};
onAfterFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): boolean | void;
onBeforeSubmit?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>) => void;
}
export type IAutoFillCopyDataInTypeIndexInfo = number[];
export interface IAutoFillCopyDataInType {
data: Array<Nullable<ICellData>>;
index: IAutoFillCopyDataInTypeIndexInfo;
}
export interface IAutoFillCopyDataPiece {
[key: string]: IAutoFillCopyDataInType[];
}
export interface IAutoFillRuleConfirmedData {
type?: string;
cellData: Nullable<ICellData>;
}
export type AUTO_FILL_APPLY_FUNCTIONS = {
[key in AUTO_FILL_APPLY_TYPE]?: (dataWithIndex: IAutoFillCopyDataInType, len: number, direction: Direction, copyDataPiece: IAutoFillCopyDataPiece, location?: IAutoFillLocation) => Array<Nullable<ICellData>>;
};
export interface IAutoFillRule {
type: string;
match: (cellData: Nullable<ICellData>, accessor: IAccessor) => boolean;
isContinue: (prev: IAutoFillRuleConfirmedData, cur: Nullable<ICellData>) => boolean;
applyFunctions?: AUTO_FILL_APPLY_FUNCTIONS;
priority: number;
}