@univerjs/sheets 0.15.4 → 0.15.5

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,4 +1,4 @@
1
- import { ICommandInfo, IRange } from '@univerjs/core';
1
+ import { ICommandInfo, IRange, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';
3
3
  import { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../../commands/mutations/move-rows-cols.mutation';
4
4
  import { IReorderRangeMutationParams } from '../../commands/mutations/reorder-range.mutation';
@@ -139,7 +139,7 @@ export type CommandListenerValueChange = {
139
139
  id: SheetValueChangeType.DELETE_WORKSHEET_RANGE_THEME_STYLE;
140
140
  params: IWorksheetRangeThemeStyleMutationParams;
141
141
  };
142
- export declare function getValueChangedEffectedRange(commandInfo: ICommandInfo): {
142
+ export declare function getValueChangedEffectedRange(univerInstanceService: IUniverInstanceService, commandInfo: ICommandInfo): {
143
143
  unitId: string;
144
144
  subUnitId: string;
145
145
  range: IRange;
@@ -17,5 +17,6 @@ export declare function generateNullCell(range: IRange[]): IObjectMatrixPrimitiv
17
17
  export declare function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData>;
18
18
  export declare function generateNullCellStyle(ranges: IRange[]): IObjectMatrixPrimitiveType<ICellData>;
19
19
  export declare function getActiveWorksheet(instanceService: UniverInstanceService): [Nullable<Workbook>, Nullable<Worksheet>];
20
+ export declare function discreteRangeToRange(discreteRange: IDiscreteRange): IRange;
20
21
  export declare function rangeToDiscreteRange(range: IRange, accessor: IAccessor, unitId?: string, subUnitId?: string): IDiscreteRange | null;
21
22
  export declare function getVisibleRanges(ranges: IRange[], accessor: IAccessor, unitId?: string, subUnitId?: string): IRange[];
@@ -0,0 +1,15 @@
1
+ import { ICommand, IRange } from '@univerjs/core';
2
+ import { AUTO_FILL_APPLY_TYPE } from '../../services/auto-fill/type';
3
+ export interface IAutoFillCommandParams {
4
+ sourceRange: IRange;
5
+ targetRange: IRange;
6
+ unitId?: string;
7
+ subUnitId?: string;
8
+ applyType?: AUTO_FILL_APPLY_TYPE;
9
+ }
10
+ export declare const AutoFillCommand: ICommand;
11
+ export interface IAutoClearContentCommand {
12
+ clearRange: IRange;
13
+ selectionRange: IRange;
14
+ }
15
+ export declare const AutoClearContentCommand: ICommand;
@@ -0,0 +1,6 @@
1
+ import { ICommand } from '@univerjs/core';
2
+ import { AUTO_FILL_APPLY_TYPE } from '../../services/auto-fill/type';
3
+ export interface IRefillCommandParams {
4
+ type: AUTO_FILL_APPLY_TYPE;
5
+ }
6
+ export declare const RefillCommand: ICommand;
@@ -0,0 +1,22 @@
1
+ import { Disposable, Injector, IUniverInstanceService } from '@univerjs/core';
2
+ import { IAutoFillService } from '../services/auto-fill/auto-fill.service';
3
+ export declare class AutoFillController extends Disposable {
4
+ private readonly _univerInstanceService;
5
+ private readonly _autoFillService;
6
+ private readonly _injector;
7
+ private _beforeApplyData;
8
+ private _copyData;
9
+ constructor(_univerInstanceService: IUniverInstanceService, _autoFillService: IAutoFillService, _injector: Injector);
10
+ private _init;
11
+ quit(): void;
12
+ private _initDefaultHook;
13
+ private _presetAndCacheData;
14
+ private _getApplyData;
15
+ private _applyFunctions;
16
+ private _getCopyData;
17
+ private _getEmptyCopyDataPiece;
18
+ private _getMergeApplyData;
19
+ private _fillData;
20
+ private _shouldDisableSeries;
21
+ private _getPreferredApplyType;
22
+ }
@@ -30,4 +30,5 @@ export declare class SheetPermissionCheckController extends Disposable {
30
30
  private _permissionCheckByMoveRangeCommand;
31
31
  private _permissionCheckBySetRangeValue;
32
32
  private _permissionCheckWithFormula;
33
+ private _permissionCheckByAutoFillCommand;
33
34
  }
@@ -1,5 +1,5 @@
1
1
  import { AbsoluteRefType, BorderStyleTypes, BorderType, CellValue, CustomData, ICellData, IDocumentData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, Dimension, ICommandService, Injector, RichTextValue, TextStyleValue, WrapStrategy } from '@univerjs/core';
2
- import { IMergeCellsUtilOptions, SplitDelimiterEnum } from '@univerjs/sheets';
2
+ import { AUTO_FILL_APPLY_TYPE, IMergeCellsUtilOptions, SplitDelimiterEnum } from '@univerjs/sheets';
3
3
  import { IFacadeClearOptions } from './f-worksheet';
4
4
  import { FHorizontalAlignment, FVerticalAlignment } from './utils';
5
5
  import { FBaseInitialable } from '@univerjs/core/facade';
@@ -1591,4 +1591,43 @@ export declare class FRange extends FBaseInitialable {
1591
1591
  * ```
1592
1592
  */
1593
1593
  getRangePermission(): FRangePermission;
1594
+ /**
1595
+ * Fills the target range with data based on the data in the current range.
1596
+ * @param {FRange} targetRange - The range to be filled with data.
1597
+ * @param {AUTO_FILL_APPLY_TYPE} [applyType] - The type of data fill to be applied.
1598
+ * @returns {Promise<boolean>} A promise that resolves to true if the fill operation was successful, false otherwise.
1599
+ * @example
1600
+ * ```ts
1601
+ * // Auto-fill the range D1:D10 based on the data in the range C1:C2
1602
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1603
+ * const fWorksheet = fWorkbook.getActiveSheet();
1604
+ * const fRange = fWorksheet.getRange('A1:A4');
1605
+ *
1606
+ * // Auto-fill without specifying applyType (default behavior)
1607
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'))
1608
+ *
1609
+ * // Auto-fill with 'COPY' type
1610
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'COPY')
1611
+ *
1612
+ * // Auto-fill with 'SERIES' type
1613
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'SERIES')
1614
+ * ```
1615
+ *
1616
+ * ```ts
1617
+ * // Operate on a specific worksheet
1618
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1619
+ * const fWorksheet = fWorkbook.getSheetBySheetId('sheetId');
1620
+ * const fRange = fWorksheet.getRange('A1:A4');
1621
+ *
1622
+ * // Auto-fill without specifying applyType (default behavior)
1623
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'))
1624
+ *
1625
+ * // Auto-fill with 'COPY' type
1626
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'COPY')
1627
+ *
1628
+ * // Auto-fill with 'SERIES' type
1629
+ * await fRange.autoFill(fWorksheet.getRange('A1:A20'), 'SERIES')
1630
+ * ```
1631
+ */
1632
+ autoFill(targetRange: FRange, applyType?: AUTO_FILL_APPLY_TYPE): Promise<boolean>;
1594
1633
  }
@@ -17,17 +17,18 @@ export type { ICellOverGridPosition, ISheetOverGridPosition } from './basics/cel
17
17
  export { checkCellValueType } from './basics/cell-type';
18
18
  export { COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, type CommandListenerSkeletonChange, type CommandListenerValueChange, getSkeletonChangedEffectedRange, getValueChangedEffectedRange, SheetSkeletonChangeType, SheetValueChangeType, } from './basics/const/command-listener-const';
19
19
  export { expandToContinuousRange } from './basics/expand-range';
20
- export { type IAddWorksheetMergeMutationParams, type IDeleteRangeMutationParams, type IInsertColMutationParams, type IInsertRangeMutationParams, type IInsertRowMutationParams, type IInsertSheetMutationParams, type IRemoveColMutationParams, type IRemoveRowsMutationParams, type IRemoveSheetMutationParams, type IRemoveWorksheetMergeMutationParams, type IWorksheetRangeThemeStyleMutationParams, } from './basics/interfaces/mutation-interface';
20
+ export { type IAddWorksheetMergeMutationParams, type IDeleteRangeMutationParams, type IDiscreteRange, type IInsertColMutationParams, type IInsertRangeMutationParams, type IInsertRowMutationParams, type IInsertSheetMutationParams, type IRemoveColMutationParams, type IRemoveRowsMutationParams, type IRemoveSheetMutationParams, type IRemoveWorksheetMergeMutationParams, type IWorksheetRangeThemeStyleMutationParams, } from './basics/interfaces';
21
21
  export { createTopMatrixFromMatrix, createTopMatrixFromRanges, findAllRectangle, rangeMerge, RangeMergeUtil } from './basics/range-merge';
22
22
  export { convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, type ISelectionStyle, type ISelectionWidgetConfig, type ISelectionWithCoord, type ISelectionWithStyle, type ISheetRangeLocation, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, } from './basics/selection';
23
23
  export { SplitDelimiterEnum, splitRangeText } from './basics/split-range-text';
24
24
  export { findFirstNonEmptyCell } from './basics/utils';
25
- export { generateNullCell, generateNullCellValue, getVisibleRanges, rangeToDiscreteRange } from './basics/utils';
25
+ export { discreteRangeToRange, generateNullCell, generateNullCellValue, getVisibleRanges, rangeToDiscreteRange } from './basics/utils';
26
26
  export { AddRangeProtectionCommand, type IAddRangeProtectionCommandParams } from './commands/commands/add-range-protection.command';
27
27
  export { addMergeCellsUtil, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand, getClearContentMutationParamForRange, getClearContentMutationParamsForRanges, type IMergeCellsUtilOptions, } from './commands/commands/add-worksheet-merge.command';
28
28
  export { AddWorksheetProtectionCommand } from './commands/commands/add-worksheet-protection.command';
29
29
  export { SetWorksheetRangeThemeStyleCommand } from './commands/commands/add-worksheet-range-theme.command';
30
30
  export { AppendRowCommand, type IAppendRowCommandParams } from './commands/commands/append-row.command';
31
+ export { AutoClearContentCommand, AutoFillCommand, type IAutoClearContentCommand, type IAutoFillCommandParams } from './commands/commands/auto-fill.command';
31
32
  export { ClearSelectionAllCommand } from './commands/commands/clear-selection-all.command';
32
33
  export { ClearSelectionContentCommand, type IClearSelectionContentCommandParams } from './commands/commands/clear-selection-content.command';
33
34
  export { ClearSelectionFormatCommand } from './commands/commands/clear-selection-format.command';
@@ -45,6 +46,7 @@ export { type IInsertColCommandParams, type IInsertRowCommandParams, InsertColAf
45
46
  export { type IInsertSheetCommandParams, InsertSheetCommand } from './commands/commands/insert-sheet.command';
46
47
  export { getMoveRangeUndoRedoMutations, type IMoveRangeCommandParams, MoveRangeCommand } from './commands/commands/move-range.command';
47
48
  export { type IMoveColsCommandParams, type IMoveRowsCommandParams, MoveColsCommand, MoveRowsCommand, } from './commands/commands/move-rows-cols.command';
49
+ export { type IRefillCommandParams, RefillCommand } from './commands/commands/refill.command';
48
50
  export { RegisterWorksheetRangeThemeStyleCommand } from './commands/commands/register-range-theme.command';
49
51
  export type { IRegisterWorksheetRangeThemeStyleCommandParams } from './commands/commands/register-range-theme.command';
50
52
  export { RemoveDefinedNameCommand } from './commands/commands/remove-defined-name.command';
@@ -64,7 +66,7 @@ export { type ISetRangeCustomMetadataCommandParams, SetRangeCustomMetadataComman
64
66
  export { type ISetRangeValuesCommandParams, SetRangeValuesCommand } from './commands/commands/set-range-values.command';
65
67
  export { type ISetRowDataCommandParams, SetRowDataCommand } from './commands/commands/set-row-data.command';
66
68
  export { type ISetSpecificRowsVisibleCommandParams, SetRowHiddenCommand, SetSelectedRowsVisibleCommand, SetSpecificRowsVisibleCommand, } from './commands/commands/set-row-visible.command';
67
- export { type ISetColorCommandParams, type ISetFontFamilyCommandParams, type ISetFontSizeCommandParams, type ISetHorizontalTextAlignCommandParams, type ISetStyleCommandParams, type ISetTextRotationCommandParams, type ISetTextWrapCommandParams, type ISetVerticalTextAlignCommandParams, type IStyleTypeValue, ResetBackgroundColorCommand, ResetTextColorCommand, SetBackgroundColorCommand, SetBoldCommand, SetFontFamilyCommand, SetFontSizeCommand, SetHorizontalTextAlignCommand, SetItalicCommand, SetOverlineCommand, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, } from './commands/commands/set-style.command';
69
+ export { AFFECT_LAYOUT_STYLES, type ISetColorCommandParams, type ISetFontFamilyCommandParams, type ISetFontSizeCommandParams, type ISetHorizontalTextAlignCommandParams, type ISetStyleCommandParams, type ISetTextRotationCommandParams, type ISetTextWrapCommandParams, type ISetVerticalTextAlignCommandParams, type IStyleTypeValue, ResetBackgroundColorCommand, ResetTextColorCommand, SetBackgroundColorCommand, SetBoldCommand, SetFontFamilyCommand, SetFontSizeCommand, SetHorizontalTextAlignCommand, SetItalicCommand, SetOverlineCommand, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, } from './commands/commands/set-style.command';
68
70
  export { SetTabColorCommand } from './commands/commands/set-tab-color.command';
69
71
  export { type ISetWorkbookNameCommandParams, SetWorkbookNameCommand } from './commands/commands/set-workbook-name.command';
70
72
  export { type ISetWorksheetActivateCommandParams, SetWorksheetActivateCommand } from './commands/commands/set-worksheet-activate.command';
@@ -157,6 +159,7 @@ export { getInsertRangeMutations, getRemoveRangeMutations } from './commands/uti
157
159
  export { handleInsertRangeMutation } from './commands/utils/handle-range-mutation';
158
160
  export { type ISheetCommandSharedParams } from './commands/utils/interface';
159
161
  export { getSelectionsService } from './commands/utils/selection-command-util';
162
+ export { AutoFillController } from './controllers/auto-fill.controller';
160
163
  export { defaultLargeSheetOperationConfig, type ILargeSheetOperationConfig, type IUniverSheetsConfig, SHEETS_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
161
164
  export { MAX_CELL_PER_SHEET_KEY } from './controllers/config/config';
162
165
  export { DefinedNameDataController } from './controllers/defined-name-data.controller';
@@ -175,6 +178,10 @@ export type { IRangeThemeStyleJSON } from './model/range-theme-util';
175
178
  export { RangeThemeStyle } from './model/range-theme-util';
176
179
  export type { IRangeThemeStyleItem } from './model/range-theme-util';
177
180
  export { UniverSheetsPlugin } from './plugin';
181
+ export { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service';
182
+ export { default as AutoFillRules } from './services/auto-fill/rules';
183
+ export { default as AutoFillTools } from './services/auto-fill/tools';
184
+ export { type AUTO_FILL_APPLY_FUNCTIONS, AUTO_FILL_APPLY_TYPE, AUTO_FILL_DATA_TYPE, AUTO_FILL_HOOK_TYPE, type IAutoFillCopyDataInType, type IAutoFillCopyDataInTypeIndexInfo, type IAutoFillCopyDataPiece, type IAutoFillLocation, type IAutoFillRule, type IAutoFillRuleConfirmedData, type ISheetAutoFillHook, } from './services/auto-fill/type';
178
185
  export { BorderStyleManagerService, type IBorderInfo } from './services/border-style-manager.service';
179
186
  export { ExclusiveRangeService, IExclusiveRangeService } from './services/exclusive-range/exclusive-range-service';
180
187
  export { SheetLazyExecuteScheduleService } from './services/lazy-execute-schedule.service';
@@ -0,0 +1,72 @@
1
+ import { IDisposable, IRange, Nullable, Direction, Disposable, ICommandService, Injector, IUndoRedoService, IUniverInstanceService } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
3
+ import { IAutoFillLocation, IAutoFillRule, ISheetAutoFillHook, AUTO_FILL_APPLY_TYPE } from './type';
4
+ export interface IAutoFillService {
5
+ applyType$: Observable<AUTO_FILL_APPLY_TYPE>;
6
+ applyType: AUTO_FILL_APPLY_TYPE;
7
+ direction: Direction;
8
+ menu$: Observable<IApplyMenuItem[]>;
9
+ menu: IApplyMenuItem[];
10
+ showMenu$: Observable<boolean>;
11
+ setShowMenu: (show: boolean) => void;
12
+ setDisableApplyType: (type: AUTO_FILL_APPLY_TYPE, disable: boolean) => void;
13
+ getRules(): IAutoFillRule[];
14
+ isFillingStyle(): boolean;
15
+ autoFillLocation$: Observable<Nullable<IAutoFillLocation>>;
16
+ autoFillLocation: Nullable<IAutoFillLocation>;
17
+ setFillingStyle(isFillingStyle: boolean): void;
18
+ registerRule(rule: IAutoFillRule): void;
19
+ getAllHooks(): ISheetAutoFillHook[];
20
+ getActiveHooks(): ISheetAutoFillHook[];
21
+ addHook(hook: ISheetAutoFillHook): IDisposable;
22
+ fillData(applyType: AUTO_FILL_APPLY_TYPE): boolean;
23
+ triggerAutoFill(unitId: string, subUnitId: string, source: IRange, target: IRange, manualApplyType?: AUTO_FILL_APPLY_TYPE): Promise<boolean>;
24
+ }
25
+ export interface IApplyMenuItem {
26
+ label: string;
27
+ value: AUTO_FILL_APPLY_TYPE;
28
+ disable: boolean;
29
+ }
30
+ export declare class AutoFillService extends Disposable implements IAutoFillService {
31
+ private _commandService;
32
+ private _undoRedoService;
33
+ private _univerInstanceService;
34
+ private readonly _injector;
35
+ private _rules;
36
+ private _hooks;
37
+ private readonly _applyType$;
38
+ private _isFillingStyle;
39
+ private _prevUndos;
40
+ private readonly _autoFillLocation$;
41
+ readonly autoFillLocation$: Observable<Nullable<IAutoFillLocation>>;
42
+ private readonly _showMenu$;
43
+ readonly showMenu$: Observable<boolean>;
44
+ private _direction;
45
+ readonly applyType$: Observable<AUTO_FILL_APPLY_TYPE>;
46
+ private readonly _menu$;
47
+ readonly menu$: Observable<IApplyMenuItem[]>;
48
+ constructor(_commandService: ICommandService, _undoRedoService: IUndoRedoService, _univerInstanceService: IUniverInstanceService, _injector: Injector);
49
+ private _init;
50
+ private _getOneByPriority;
51
+ private _initPrevUndo;
52
+ triggerAutoFill(unitId: string, subUnitId: string, source: IRange, selection: IRange, manualApplyType?: AUTO_FILL_APPLY_TYPE): Promise<boolean>;
53
+ addHook(hook: ISheetAutoFillHook): IDisposable;
54
+ registerRule(rule: IAutoFillRule): void;
55
+ getRules(): IAutoFillRule[];
56
+ getAllHooks(): ISheetAutoFillHook[];
57
+ getActiveHooks(): ISheetAutoFillHook[];
58
+ get applyType(): AUTO_FILL_APPLY_TYPE;
59
+ set applyType(type: AUTO_FILL_APPLY_TYPE);
60
+ get menu(): IApplyMenuItem[];
61
+ get direction(): Direction;
62
+ set direction(direction: Direction);
63
+ isFillingStyle(): boolean;
64
+ setFillingStyle(isFillingStyle: boolean): void;
65
+ get autoFillLocation(): Nullable<IAutoFillLocation>;
66
+ set autoFillLocation(location: Nullable<IAutoFillLocation>);
67
+ setDisableApplyType(type: AUTO_FILL_APPLY_TYPE, disable: boolean): void;
68
+ setShowMenu(show: boolean): void;
69
+ fillData(applyType: AUTO_FILL_APPLY_TYPE): boolean;
70
+ private _getAutoHeightUndoRedos;
71
+ }
72
+ export declare const IAutoFillService: import('@wendellhu/redi').IdentifierDecorator<IAutoFillService>;
@@ -0,0 +1,12 @@
1
+ import { IAutoFillRule } from './type';
2
+ declare const AutoFillRules: {
3
+ dateRule: IAutoFillRule;
4
+ numberRule: IAutoFillRule;
5
+ extendNumberRule: IAutoFillRule;
6
+ chnNumberRule: IAutoFillRule;
7
+ chnWeek2Rule: IAutoFillRule;
8
+ chnWeek3Rule: IAutoFillRule;
9
+ loopSeriesRule: IAutoFillRule;
10
+ otherRule: IAutoFillRule;
11
+ };
12
+ export default AutoFillRules;
@@ -0,0 +1,141 @@
1
+ import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, CellValueType, Direction } from '@univerjs/core';
2
+ import { IDiscreteRange } from '../../basics';
3
+ import { IAutoFillCopyDataInTypeIndexInfo } from './type';
4
+ declare function chineseToNumber(chnStr?: Nullable<string>): number;
5
+ declare function sectionToChinese(section: number): string;
6
+ declare function numberToChinese(num: number): string;
7
+ declare function isChnNumber(txt?: string): boolean;
8
+ declare function matchExtendNumber(txt?: string): {
9
+ isExtendNumber: boolean;
10
+ matchTxt?: undefined;
11
+ beforeTxt?: undefined;
12
+ afterTxt?: undefined;
13
+ } | {
14
+ isExtendNumber: boolean;
15
+ matchTxt: number;
16
+ beforeTxt: string;
17
+ afterTxt: string;
18
+ };
19
+ declare function isChnWeek1(txt: string): boolean;
20
+ declare function isChnWeek2(txt: string): boolean;
21
+ declare function isChnWeek3(txt: string): boolean;
22
+ declare function getLenS(indexArr: any[], rsd: number): number;
23
+ /**
24
+ * equal diff
25
+ */
26
+ declare function isEqualDiff(arr: number[]): boolean;
27
+ declare function getDataIndex(csLen: number, asLen: number, indexArr: number[]): IAutoFillCopyDataInTypeIndexInfo;
28
+ declare function fillCopy(data: Array<Nullable<ICellData>>, len: number): {
29
+ p: import('@univerjs/core').IDocumentData | null;
30
+ s: string | import('@univerjs/core').IStyleData | null;
31
+ v: import('@univerjs/core').CellValue | null;
32
+ t: CellValueType | null;
33
+ f: string | null;
34
+ ref?: Nullable<string>;
35
+ xf?: Nullable<string>;
36
+ si: string | null;
37
+ custom?: import('@univerjs/core').CustomData;
38
+ }[];
39
+ declare function fillCopyStyles(data: Array<Nullable<ICellData>>, len: number): {
40
+ s: Nullable<string | import('@univerjs/core').IStyleData>;
41
+ }[];
42
+ declare function isEqualRatio(arr: number[]): boolean;
43
+ declare function getXArr(len: number): number[];
44
+ declare function fillSeries(data: Array<Nullable<ICellData>>, len: number, direction: Direction): ICellData[];
45
+ declare function forecast(x: number, yArr: number[], xArr: number[], forward?: boolean): number;
46
+ declare function fillExtendNumber(data: Array<Nullable<ICellData>>, len: number, step: number): ICellData[];
47
+ declare function fillOnlyFormat(data: Array<Nullable<ICellData>>, len: number): ICellData[];
48
+ declare function fillChnWeek(data: Array<Nullable<ICellData>>, len: number, step: number, weekType?: number): ICellData[];
49
+ declare function fillChnNumber(data: Array<Nullable<ICellData>>, len: number, step: number): ICellData[];
50
+ declare function isLoopSeries(txt: string): boolean;
51
+ declare function getLoopSeriesInfo(txt: string): {
52
+ name: string;
53
+ series: string[];
54
+ };
55
+ declare function fillLoopSeries(data: Array<Nullable<ICellData>>, len: number, step: number, series: string[]): ICellData[];
56
+ declare function getAutoFillRepeatRange(sourceRange: IRange, targetRange: IRange): {
57
+ repeatStartCell: {
58
+ col: number;
59
+ row: number;
60
+ };
61
+ relativeRange: IRange;
62
+ }[];
63
+ /**
64
+ * Formulas or Boolean values do not need to update cell.v
65
+ */
66
+ declare function needsUpdateCellValue(cell: ICellData): boolean;
67
+ /**
68
+ * Remove cell.custom
69
+ */
70
+ declare function removeCellCustom(cell: Nullable<ICellData>): void;
71
+ declare function reverseIfNeed<T>(data: T[], reverse: boolean): T[];
72
+ declare function generateNullCellValueRowCol(range: IDiscreteRange[]): IObjectMatrixPrimitiveType<ICellData>;
73
+ declare const AutoFillTools: {
74
+ chnNumChar: {
75
+ 零: number;
76
+ 一: number;
77
+ 二: number;
78
+ 三: number;
79
+ 四: number;
80
+ 五: number;
81
+ 六: number;
82
+ 七: number;
83
+ 八: number;
84
+ 九: number;
85
+ };
86
+ chnNumChar2: string[];
87
+ chnUnitSection: string[];
88
+ chnUnitChar: string[];
89
+ chnNameValue: {
90
+ 十: {
91
+ value: number;
92
+ secUnit: boolean;
93
+ };
94
+ 百: {
95
+ value: number;
96
+ secUnit: boolean;
97
+ };
98
+ 千: {
99
+ value: number;
100
+ secUnit: boolean;
101
+ };
102
+ 万: {
103
+ value: number;
104
+ secUnit: boolean;
105
+ };
106
+ 亿: {
107
+ value: number;
108
+ secUnit: boolean;
109
+ };
110
+ };
111
+ chineseToNumber: typeof chineseToNumber;
112
+ sectionToChinese: typeof sectionToChinese;
113
+ numberToChinese: typeof numberToChinese;
114
+ isChnNumber: typeof isChnNumber;
115
+ matchExtendNumber: typeof matchExtendNumber;
116
+ isChnWeek1: typeof isChnWeek1;
117
+ isChnWeek2: typeof isChnWeek2;
118
+ isChnWeek3: typeof isChnWeek3;
119
+ getLenS: typeof getLenS;
120
+ isEqualDiff: typeof isEqualDiff;
121
+ getDataIndex: typeof getDataIndex;
122
+ fillCopy: typeof fillCopy;
123
+ fillCopyStyles: typeof fillCopyStyles;
124
+ isEqualRatio: typeof isEqualRatio;
125
+ getXArr: typeof getXArr;
126
+ fillSeries: typeof fillSeries;
127
+ forecast: typeof forecast;
128
+ fillExtendNumber: typeof fillExtendNumber;
129
+ fillOnlyFormat: typeof fillOnlyFormat;
130
+ fillChnWeek: typeof fillChnWeek;
131
+ fillChnNumber: typeof fillChnNumber;
132
+ isLoopSeries: typeof isLoopSeries;
133
+ getLoopSeriesInfo: typeof getLoopSeriesInfo;
134
+ fillLoopSeries: typeof fillLoopSeries;
135
+ getAutoFillRepeatRange: typeof getAutoFillRepeatRange;
136
+ needsUpdateCellValue: typeof needsUpdateCellValue;
137
+ removeCellCustom: typeof removeCellCustom;
138
+ reverseIfNeed: typeof reverseIfNeed;
139
+ generateNullCellValueRowCol: typeof generateNullCellValueRowCol;
140
+ };
141
+ export default AutoFillTools;
@@ -0,0 +1,66 @@
1
+ import { Direction, IAccessor, ICellData, IMutationInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
2
+ import { IDiscreteRange } from '../../basics';
3
+ export declare enum AUTO_FILL_APPLY_TYPE {
4
+ COPY = "COPY",
5
+ SERIES = "SERIES",
6
+ ONLY_FORMAT = "ONLY_FORMAT",
7
+ NO_FORMAT = "NO_FORMAT"
8
+ }
9
+ export declare enum AUTO_FILL_DATA_TYPE {
10
+ NUMBER = "number",
11
+ DATE = "date",
12
+ EXTEND_NUMBER = "extendNumber",
13
+ CHN_NUMBER = "chnNumber",
14
+ CHN_WEEK2 = "chnWeek2",
15
+ CHN_WEEK3 = "chnWeek3",
16
+ LOOP_SERIES = "loopSeries",
17
+ FORMULA = "formula",
18
+ OTHER = "other"
19
+ }
20
+ export declare enum AUTO_FILL_HOOK_TYPE {
21
+ APPEND = "APPEND",
22
+ DEFAULT = "DEFAULT",
23
+ ONLY = "ONLY"
24
+ }
25
+ export interface IAutoFillLocation {
26
+ source: IDiscreteRange;
27
+ target: IDiscreteRange;
28
+ unitId: string;
29
+ subUnitId: string;
30
+ }
31
+ export interface ISheetAutoFillHook {
32
+ id: string;
33
+ priority?: number;
34
+ type?: AUTO_FILL_HOOK_TYPE;
35
+ bindUnit?: string;
36
+ disable?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE) => boolean;
37
+ onBeforeFillData?(location: IAutoFillLocation, direction: Direction): AUTO_FILL_APPLY_TYPE | void;
38
+ onFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): {
39
+ undos: IMutationInfo[];
40
+ redos: IMutationInfo[];
41
+ };
42
+ onAfterFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): boolean | void;
43
+ onBeforeSubmit?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>) => void;
44
+ }
45
+ export type IAutoFillCopyDataInTypeIndexInfo = number[];
46
+ export interface IAutoFillCopyDataInType {
47
+ data: Array<Nullable<ICellData>>;
48
+ index: IAutoFillCopyDataInTypeIndexInfo;
49
+ }
50
+ export interface IAutoFillCopyDataPiece {
51
+ [key: string]: IAutoFillCopyDataInType[];
52
+ }
53
+ export interface IAutoFillRuleConfirmedData {
54
+ type?: string;
55
+ cellData: Nullable<ICellData>;
56
+ }
57
+ export type AUTO_FILL_APPLY_FUNCTIONS = {
58
+ [key in AUTO_FILL_APPLY_TYPE]?: (dataWithIndex: IAutoFillCopyDataInType, len: number, direction: Direction, copyDataPiece: IAutoFillCopyDataPiece, location?: IAutoFillLocation) => Array<Nullable<ICellData>>;
59
+ };
60
+ export interface IAutoFillRule {
61
+ type: string;
62
+ match: (cellData: Nullable<ICellData>, accessor: IAccessor) => boolean;
63
+ isContinue: (prev: IAutoFillRuleConfirmedData, cur: Nullable<ICellData>) => boolean;
64
+ applyFunctions?: AUTO_FILL_APPLY_FUNCTIONS;
65
+ priority: number;
66
+ }
@@ -5,8 +5,8 @@ import { IRemoveRowColCommandInterceptParams } from '../../commands/commands/rem
5
5
  import { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';
6
6
  import { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../../commands/mutations/move-rows-cols.mutation';
7
7
  import { ISheetCommandSharedParams } from '../../commands/utils/interface';
8
- import { EffectRefRangeParams, IDeleteRangeMoveLeftCommand, IDeleteRangeMoveUpCommand, IInsertColCommand, IInsertRangeMoveDownCommand, IInsertRangeMoveRightCommand, IInsertRowCommand, IMoveColsCommand, IMoveRangeCommand, IMoveRowsCommand, IOperator, IRemoveRowColCommand, IReorderRangeCommand } from './type';
9
8
  import { SheetsSelectionsService } from '../selections/selection.service';
9
+ import { EffectRefRangeParams, IDeleteRangeMoveLeftCommand, IDeleteRangeMoveUpCommand, IInsertColCommand, IInsertRangeMoveDownCommand, IInsertRangeMoveRightCommand, IInsertRowCommand, IMoveColsCommand, IMoveRangeCommand, IMoveRowsCommand, IOperator, IRemoveRowColCommand, IReorderRangeCommand } from './type';
10
10
  export declare const handleRangeTypeInput: (range: IRange) => {
11
11
  rangeType?: RANGE_TYPE;
12
12
  startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
@@ -118,5 +118,5 @@ export declare function getSeparateEffectedRangesOnCommand(accessor: IAccessor,
118
118
  unitId: string;
119
119
  subUnitId: string;
120
120
  ranges: IRange[];
121
- };
121
+ } | undefined;
122
122
  export {};