@univerjs/sheets-table 1.0.0-rc.0 → 1.0.0

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.
Files changed (52) hide show
  1. package/lib/cjs/facade.js +23 -1
  2. package/lib/cjs/index.js +484 -74
  3. package/lib/cjs/locale/ar-SA.js +0 -1
  4. package/lib/cjs/locale/ca-ES.js +0 -1
  5. package/lib/cjs/locale/de-DE.js +0 -1
  6. package/lib/cjs/locale/en-US.js +0 -1
  7. package/lib/cjs/locale/es-ES.js +0 -1
  8. package/lib/cjs/locale/fa-IR.js +0 -1
  9. package/lib/cjs/locale/fr-FR.js +0 -1
  10. package/lib/cjs/locale/id-ID.js +0 -1
  11. package/lib/cjs/locale/it-IT.js +0 -1
  12. package/lib/cjs/locale/ja-JP.js +0 -1
  13. package/lib/cjs/locale/ko-KR.js +0 -1
  14. package/lib/cjs/locale/pl-PL.js +0 -1
  15. package/lib/cjs/locale/pt-BR.js +0 -1
  16. package/lib/cjs/locale/ru-RU.js +0 -1
  17. package/lib/cjs/locale/sk-SK.js +0 -1
  18. package/lib/cjs/locale/vi-VN.js +0 -1
  19. package/lib/cjs/locale/zh-CN.js +0 -1
  20. package/lib/cjs/locale/zh-HK.js +0 -1
  21. package/lib/cjs/locale/zh-TW.js +0 -1
  22. package/lib/es/facade.js +25 -3
  23. package/lib/es/index.js +484 -78
  24. package/lib/facade.js +25 -3
  25. package/lib/index.js +484 -78
  26. package/lib/types/commands/mutations/set-table-filter.mutation.d.ts +3 -0
  27. package/lib/types/commands/utils/calculated-column.d.ts +20 -0
  28. package/lib/types/controllers/sheet-table-formula.controller.d.ts +4 -1
  29. package/lib/types/controllers/table-filter.controller.d.ts +4 -1
  30. package/lib/types/facade/f-enum.d.ts +5 -0
  31. package/lib/types/facade/f-workbook.d.ts +6 -6
  32. package/lib/types/facade/f-worksheet.d.ts +22 -3
  33. package/lib/types/index.d.ts +3 -2
  34. package/lib/types/model/filter-util/condition.d.ts +27 -0
  35. package/lib/types/model/filter-util/date-filter-util.d.ts +225 -0
  36. package/lib/types/model/filter-util/number-filter-util.d.ts +47 -0
  37. package/lib/types/model/filter-util/text-filter-util.d.ts +23 -0
  38. package/lib/types/model/filter-util/top-n.d.ts +29 -0
  39. package/lib/types/model/table-column.d.ts +39 -0
  40. package/lib/types/model/table-filter.d.ts +42 -0
  41. package/lib/types/model/table-manager.d.ts +97 -0
  42. package/lib/types/model/table.d.ts +96 -0
  43. package/lib/types/models/filter-util/record-filter.d.ts +24 -0
  44. package/lib/types/models/table-column.d.ts +11 -0
  45. package/lib/types/models/table-filter.d.ts +1 -0
  46. package/lib/types/models/table.d.ts +4 -0
  47. package/lib/types/types/enum.d.ts +2 -1
  48. package/lib/types/types/type.d.ts +55 -2
  49. package/lib/types/util.d.ts +2 -1
  50. package/lib/umd/facade.js +1 -1
  51. package/lib/umd/index.js +1 -1
  52. package/package.json +8 -8
@@ -20,6 +20,9 @@ export interface ISetSheetTableParams {
20
20
  tableId: string;
21
21
  column: number;
22
22
  tableFilter: ITableFilterItem | undefined;
23
+ filterOutRows?: number[];
24
+ subUnitId?: string;
25
+ tableFilteredOutRows?: number[];
23
26
  }
24
27
  export declare const SetSheetTableFilterMutation: IMutation<ISetSheetTableParams & {
25
28
  tableId: string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IMutationInfo } from '@univerjs/core';
17
+ import type { LexerTreeBuilder } from '@univerjs/engine-formula';
18
+ import type { Table } from '../../models/table';
19
+ import type { ITableCalculatedColumnConfig } from '../../types/type';
20
+ export declare function getCalculatedColumnFillMutation(table: Table, unitId: string, subUnitId: string, startRow: number, endRow: number, getLexerTreeBuilder: () => LexerTreeBuilder, config?: ITableCalculatedColumnConfig): IMutationInfo | undefined;
@@ -14,11 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Disposable, ICommandService } from '@univerjs/core';
17
+ import { IActiveDirtyManagerService } from '@univerjs/engine-formula';
17
18
  import { TableManager } from '../models/table-manager';
18
19
  export declare class SheetTableFormulaController extends Disposable {
19
20
  private _tableManager;
20
21
  private readonly _commandService;
21
- constructor(_tableManager: TableManager, _commandService: ICommandService);
22
+ private readonly _activeDirtyManagerService;
23
+ constructor(_tableManager: TableManager, _commandService: ICommandService, _activeDirtyManagerService: IActiveDirtyManagerService);
24
+ private _initFilterDirtyRange;
22
25
  private _initRangeListener;
23
26
  private _updateSuperTable;
24
27
  }
@@ -14,16 +14,19 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Disposable, IUniverInstanceService } from '@univerjs/core';
17
+ import { ISheetRowFilteredService } from '@univerjs/engine-formula';
17
18
  import { SheetInterceptorService, ZebraCrossingCacheController } from '@univerjs/sheets';
18
19
  import { TableManager } from '../models/table-manager';
19
20
  export declare class TableFilterController extends Disposable {
20
21
  private _tableManager;
21
22
  private readonly _sheetInterceptorService;
22
23
  private readonly _univerInstanceService;
24
+ private readonly _sheetRowFilteredService;
23
25
  private readonly _zebraCrossingCacheController;
24
26
  private readonly _tableFilteredOutRows;
25
27
  private _subscription;
26
- constructor(_tableManager: TableManager, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _zebraCrossingCacheController: ZebraCrossingCacheController);
28
+ constructor(_tableManager: TableManager, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _sheetRowFilteredService: ISheetRowFilteredService, _zebraCrossingCacheController: ZebraCrossingCacheController);
29
+ private _registerFormulaRowFiltered;
27
30
  initTableHiddenRowIntercept(): void;
28
31
  private _initFilteredOutRows;
29
32
  registerFilterChangeEvent(): void;
@@ -19,10 +19,15 @@ import { TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareType
19
19
  * @ignore
20
20
  */
21
21
  export interface IFSheetsTableEnumMixin {
22
+ /** Filter kinds available for table columns. */
22
23
  TableColumnFilterTypeEnum: typeof TableColumnFilterTypeEnum;
24
+ /** Value types used by table condition filters. */
23
25
  TableConditionTypeEnum: typeof TableConditionTypeEnum;
26
+ /** Comparison operators for numeric table filters. */
24
27
  TableNumberCompareTypeEnum: typeof TableNumberCompareTypeEnum;
28
+ /** Comparison operators for text table filters. */
25
29
  TableStringCompareTypeEnum: typeof TableStringCompareTypeEnum;
30
+ /** Comparison operators for date table filters. */
26
31
  TableDateCompareTypeEnum: typeof TableDateCompareTypeEnum;
27
32
  }
28
33
  export declare class FSheetsTableEnumMixin extends FEnum implements IFSheetsTableEnumMixin {
@@ -22,7 +22,7 @@ export interface IFWorkbookSheetsTableMixin {
22
22
  /**
23
23
  * Get table information
24
24
  * @param {string} tableId The table id
25
- * @returns {ITableInfo} The table information
25
+ * @returns {ITableInfoWithUnitId | undefined} The table information, including workbook and worksheet IDs, or `undefined` if not found.
26
26
  * @example
27
27
  * ```typescript
28
28
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -50,7 +50,7 @@ export interface IFWorkbookSheetsTableMixin {
50
50
  /**
51
51
  * Get table information by name
52
52
  * @param {string} tableName The table name
53
- * @returns {ITableInfo} The table information
53
+ * @returns {ITableInfoWithUnitId | undefined} The table information, including workbook and worksheet IDs, or `undefined` if not found.
54
54
  * @example
55
55
  * ```typescript
56
56
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -93,7 +93,7 @@ export interface IFWorkbookSheetsTableMixin {
93
93
  * @param {ITableRange} rangeInfo The table range information
94
94
  * @param {string} [tableId] The table id
95
95
  * @param {ITableOptions} [options] The table options
96
- * @returns {string} The table id
96
+ * @returns {Promise<string | undefined>} A promise resolving to the table ID, or `undefined` if the name is invalid or creation fails.
97
97
  * @example
98
98
  * ```typescript
99
99
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -123,7 +123,7 @@ export interface IFWorkbookSheetsTableMixin {
123
123
  * set table filter
124
124
  * @param {string} tableId The table id
125
125
  * @param {number} column The column index, starting from 0.
126
- * @param {ITableFilterItem} filter The filter item
126
+ * @param {ITableFilterItem | undefined} filter The filter to apply, or `undefined` to clear the column filter.
127
127
  * @returns {Promise<boolean>} The result of set table filter
128
128
  * @example
129
129
  * ```typescript
@@ -158,11 +158,11 @@ export interface IFWorkbookSheetsTableMixin {
158
158
  * }
159
159
  * ```
160
160
  */
161
- setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): void;
161
+ setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): Promise<boolean>;
162
162
  /**
163
163
  * Remove table
164
164
  * @param {string} tableId The table id
165
- * @returns {boolean} The result of remove table
165
+ * @returns {Promise<boolean>} A promise resolving to whether the table was removed; `false` if the table is not found.
166
166
  * @example
167
167
  * ```typescript
168
168
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -14,19 +14,36 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { IRangeThemeStyleJSON } from '@univerjs/sheets';
17
- import type { ITableFilterItem, ITableInfoWithUnitId, ITableOptions, ITableRange } from '@univerjs/sheets-table';
17
+ import type { ITableFilterButtonConfig, ITableFilterItem, ITableInfoWithUnitId, ITableOptions, ITableRange } from '@univerjs/sheets-table';
18
18
  import { FWorksheet } from '@univerjs/sheets/facade';
19
19
  /**
20
20
  * @ignore
21
21
  */
22
22
  export interface IFWorksheetTableMixin {
23
+ /**
24
+ * Apply a formula to every data row of a table column, excluding header and footer.
25
+ * References are relative to the first data row. Empty string stops future auto-fill and preserves cells.
26
+ * @param tableId Table ID in this worksheet.
27
+ * @param columnId Stable column ID from getSubTableInfos().
28
+ * @param formula Formula to apply, or an empty string to stop automatic filling.
29
+ * @returns Whether the undoable update succeeded synchronously.
30
+ */
31
+ setTableColumnFormula(tableId: string, columnId: string, formula: string): boolean;
32
+ /**
33
+ * Update table filter button visibility without clearing filter criteria.
34
+ * Column overrides use stable column IDs from getSubTableInfos().
35
+ * @param tableId Table ID in this worksheet.
36
+ * @param config Partial table and column button visibility settings.
37
+ * @returns Whether the update succeeded synchronously.
38
+ */
39
+ setTableFilterButtons(tableId: string, config: ITableFilterButtonConfig): boolean;
23
40
  /**
24
41
  * Add a table to the worksheet
25
42
  * @param {string} tableName The table name
26
43
  * @param {ITableRange} rangeInfo The table range information
27
44
  * @param {string} [tableId] The table id
28
45
  * @param {ITableOptions} [options] The table options
29
- * @returns {Promise<boolean>} Whether the table was added successfully
46
+ * @returns {Promise<boolean> | boolean} `false` for an invalid table name; otherwise, a promise resolving to whether the command succeeded.
30
47
  * @example
31
48
  * ```typescript
32
49
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -162,7 +179,7 @@ export interface IFWorksheetTableMixin {
162
179
  * Set the name of a table
163
180
  * @param {string} tableId The table id
164
181
  * @param {string} tableName The new table name
165
- * @returns {Promise<boolean>} Whether the table name was set successfully
182
+ * @returns {Promise<boolean> | boolean} `false` for an invalid table name; otherwise, a promise resolving to whether the command succeeded.
166
183
  * @example
167
184
  * ```typescript
168
185
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -324,6 +341,8 @@ export interface IFWorksheetTableMixin {
324
341
  addTableTheme(tableId: string, themeStyleJSON: IRangeThemeStyleJSON): Promise<boolean>;
325
342
  }
326
343
  export declare class FWorksheetTableMixin extends FWorksheet implements IFWorksheetTableMixin {
344
+ setTableColumnFormula(tableId: string, columnId: string, formula: string): boolean;
345
+ setTableFilterButtons(tableId: string, config: ITableFilterButtonConfig): boolean;
327
346
  addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<boolean> | boolean;
328
347
  setTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean>;
329
348
  removeTable(tableId: string): Promise<boolean>;
@@ -37,12 +37,13 @@ export { SHEET_TABLE_CUSTOM_THEME_PREFIX, TABLE_FILTER_EMPTY_VALUE } from './con
37
37
  export { SheetsTableThemeController } from './controllers/sheet-table-theme.controller';
38
38
  export { SheetsTableController } from './controllers/sheets-table.controller';
39
39
  export { customEmptyThemeWithBorderStyle, processStyleWithBorderStyle } from './controllers/table-theme.factory';
40
+ export { compileTableRecordFilter, getTableRecordValue, getTableRecordValueKey } from './models/filter-util/record-filter';
40
41
  export { TableManager } from './models/table-manager';
41
42
  export { UniverSheetsTablePlugin } from './plugin';
42
43
  export { SheetTableService } from './services/table.service';
43
44
  export { SheetsTableButtonStateEnum, SheetsTableSortStateEnum, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, } from './types/enum';
44
- export type { ITableColorFilterItem, ITableColumnJson, ITableConditionFilterItem, ITableData, ITableFilterItem, ITableInfo, ITableInfoWithUnitId, ITableManualFilterItem, ITableOptions, ITableRange, ITableRangeWithState, TableMetaType, TableRelationTupleType, } from './types/type';
45
+ export type { ITableCalculatedColumnConfig, ITableColorFilterItem, ITableColumnJson, ITableConditionFilterItem, ITableData, ITableFilterButtonConfig, ITableFilterItem, ITableInfo, ITableInfoWithUnitId, ITableManualFilterItem, ITableOptions, ITableRange, ITableRangeWithState, ITableRecordFilterItem, TableMetaType, TableRecordValue, TableRelationTupleType, } from './types/type';
45
46
  export type { ITableJson, ITableSetConfig } from './types/type';
46
- export { getExistingNamesSet, isColorTableFilter, isConditionFilter, isManualTableFilter } from './util';
47
+ export { getExistingNamesSet, isColorTableFilter, isConditionFilter, isManualTableFilter, isRecordTableFilter } from './util';
47
48
  export { validateSheetTableName } from './util/table-name';
48
49
  export type { ISheetTableNameValidationResult, SheetTableNameValidationReason } from './util/table-name';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IDocumentData, Worksheet } from '@univerjs/core';
17
+ import type { TableStringCompareTypeEnum } from '../../types/enum';
18
+ import type { ICalculatedOptions, ITableConditionFilterItem } from '../../types/type';
19
+ import { TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum } from '../../types/enum';
20
+ type TableConditionCompareType = TableNumberCompareTypeEnum | TableDateCompareTypeEnum | TableStringCompareTypeEnum;
21
+ export declare function isNumberDynamicFilter(compareType: TableConditionCompareType): compareType is TableNumberCompareTypeEnum;
22
+ export declare function isDateDynamicFilter(compareType: TableConditionCompareType): compareType is TableDateCompareTypeEnum;
23
+ export declare function getConditionExecuteFunc(filter: ITableConditionFilterItem, calculatedOptions: ICalculatedOptions | undefined): ((date: Date) => boolean) | ((value: number) => boolean) | ((value: string) => boolean);
24
+ export declare function getCellValueWithConditionType(sheet: Worksheet, row: number, col: number, conditionType: TableConditionTypeEnum): string | number | Date | null | undefined;
25
+ export declare const getStringFromDataStream: (data: IDocumentData) => string;
26
+ export declare function excelSerialToDateTime(serial: number): Date;
27
+ export {};
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ITableDateFilterInfo } from '../../types/type';
17
+ /**
18
+ * The provided date is a date in Q1 of the year.
19
+ * @param {Date} date - The date to compare.
20
+ * @returns {boolean} return the date is match
21
+ */
22
+ export declare const dateQ1: (date: Date) => boolean;
23
+ /**
24
+ * The provided date is a date in Q2 of the year.
25
+ * @param {Date} date - The date to compare.
26
+ * @returns {boolean} return the date is match
27
+ */
28
+ export declare const dateQ2: (date: Date) => boolean;
29
+ /**
30
+ * The provided date is a date in Q3 of the year.
31
+ * @param {Date} date - The date to compare.
32
+ * @returns {boolean} return the date is match
33
+ */
34
+ export declare const dateQ3: (date: Date) => boolean;
35
+ /**
36
+ * The provided date is a date in Q4 of the year.
37
+ * @param {Date} date - The date to compare.
38
+ * @returns {boolean} return the date is match
39
+ */
40
+ export declare const dateQ4: (date: Date) => boolean;
41
+ /**
42
+ * The provided date is a date in January.
43
+ * @param {Date} date - The date to compare.
44
+ * @returns {boolean} return the date is match
45
+ */
46
+ export declare const dateM1: (date: Date) => boolean;
47
+ /**
48
+ * The provided date is a date in February.
49
+ * @param {Date} date - The date to compare.
50
+ * @returns {boolean} return the date is match
51
+ */
52
+ export declare const dateM2: (date: Date) => boolean;
53
+ /**
54
+ * The provided date is a date in March.
55
+ * @param {Date} date - The date to compare.
56
+ * @returns {boolean} return the date is match
57
+ */
58
+ export declare const dateM3: (date: Date) => boolean;
59
+ /**
60
+ * The provided date is a date in April.
61
+ * @param {Date} date - The date to compare.
62
+ * @returns {boolean} return the date is match
63
+ */
64
+ export declare const dateM4: (date: Date) => boolean;
65
+ /**
66
+ * The provided date is a date in May.
67
+ * @param {Date} date - The date to compare.
68
+ * @returns {boolean} return the date is match
69
+ */
70
+ export declare const dateM5: (date: Date) => boolean;
71
+ /**
72
+ * The provided date is a date in June.
73
+ * @param {Date} date - The date to compare.
74
+ * @returns {boolean} return the date is match
75
+ */
76
+ export declare const dateM6: (date: Date) => boolean;
77
+ /**
78
+ * The provided date is a date in July.
79
+ * @param {Date} date - The date to compare.
80
+ * @returns {boolean} return the date is match
81
+ */
82
+ export declare const dateM7: (date: Date) => boolean;
83
+ /**
84
+ * The provided date is a date in August.
85
+ * @param {Date} date - The date to compare.
86
+ * @returns {boolean} return the date is match
87
+ */
88
+ export declare const dateM8: (date: Date) => boolean;
89
+ /**
90
+ * The provided date is a date in September.
91
+ * @param {Date} date - The date to compare.
92
+ * @returns {boolean} return the date is match
93
+ */
94
+ export declare const dateM9: (date: Date) => boolean;
95
+ /**
96
+ * The provided date is a date in October.
97
+ * @param {Date} date - The date to compare.
98
+ * @returns {boolean} return the date is match
99
+ */
100
+ export declare const dateM10: (date: Date) => boolean;
101
+ /**
102
+ * The provided date is a date in November.
103
+ * @param {Date} date - The date to compare.
104
+ * @returns {boolean} return the date is match
105
+ */
106
+ export declare const dateM11: (date: Date) => boolean;
107
+ /**
108
+ * The provided date is a date in December.
109
+ * @param {Date} date - The date to compare.
110
+ * @returns {boolean} return the date is match
111
+ */
112
+ export declare const dateM12: (date: Date) => boolean;
113
+ /**
114
+ * The provided date is today.
115
+ * @param {Date} expectedDate - The date to compare.
116
+ * @param {Date} [anchorTime] - The reference date.
117
+ * @returns {boolean} return the date is match
118
+ */
119
+ export declare const today: (expectedDate: Date, anchorTime?: Date) => boolean;
120
+ /**
121
+ * The provided date is tomorrow.
122
+ * @param {Date} date - The date to compare.
123
+ * @param {Date} [anchorTime] - The reference date.
124
+ * @returns {boolean} return the date is match
125
+ */
126
+ export declare const tomorrow: (date: Date, anchorTime?: Date) => boolean;
127
+ /**
128
+ * The provided date is yesterday.
129
+ * @param {Date} date - The date to compare.
130
+ * @param {Date} [anchorTime] - The reference date.
131
+ * @returns {boolean} return the date is match
132
+ */
133
+ export declare const yesterday: (date: Date, anchorTime?: Date) => boolean;
134
+ /**
135
+ * The provided date is in the current week.
136
+ * @param {Date} date - The date to compare.
137
+ * @param {Date} [anchorTime] - The reference date.
138
+ * @returns {boolean} return the date is match
139
+ */
140
+ export declare const thisWeek: (date: Date, anchorTime?: Date) => boolean;
141
+ /**
142
+ * The provided date is in the next week.
143
+ * @param {Date} date - The date to compare.
144
+ * @param {Date} [anchorTime] - The reference date.
145
+ * @returns {boolean} return the date is match
146
+ */
147
+ export declare const nextWeek: (date: Date, anchorTime?: Date) => boolean;
148
+ /**
149
+ * The provided date is in the last week.
150
+ * @param {Date} date - The date to compare.
151
+ * @param {Date} [anchorTime] - The reference date.
152
+ * @returns {boolean} return the date is match
153
+ */
154
+ export declare const lastWeek: (date: Date, anchorTime?: Date) => boolean;
155
+ /**
156
+ * The provided date is in the current month.
157
+ * @param {Date} date - The date to compare.
158
+ * @param {Date} [anchorTime] - The reference date.
159
+ * @returns {boolean} return the date is match
160
+ */
161
+ export declare const thisMonth: (date: Date, anchorTime?: Date) => boolean;
162
+ /**
163
+ * The provided date is in the next month.
164
+ * @param {Date} date - The date to compare.
165
+ * @param {Date} [anchorTime] - The reference date.
166
+ * @returns {boolean} return the date is match
167
+ */
168
+ export declare const nextMonth: (date: Date, anchorTime?: Date) => boolean;
169
+ /**
170
+ * The provided date is in the last month.
171
+ * @param {Date} date - The date to compare.
172
+ * @param {Date} [anchorTime] - The reference date.
173
+ * @returns {boolean} return the date is match
174
+ */
175
+ export declare const lastMonth: (date: Date, anchorTime?: Date) => boolean;
176
+ /**
177
+ * The provided date is in the current quarter.
178
+ * @param {Date} date - The date to compare.
179
+ * @param {Date} [anchorTime] - The reference date.
180
+ * @returns {boolean} return the date is match
181
+ */
182
+ export declare const thisQuarter: (date: Date, anchorTime?: Date) => boolean;
183
+ /**
184
+ * The provided date is in the next quarter.
185
+ * @param {Date} date - The date to compare.
186
+ * @param {Date} [anchorTime] - The reference date.
187
+ * @returns {boolean} return the date is match
188
+ */
189
+ export declare const nextQuarter: (date: Date, anchorTime?: Date) => boolean;
190
+ /**
191
+ * The provided date is in the last quarter.
192
+ * @param {Date} date - The date to compare.
193
+ * @param {Date} [anchorTime] - The reference date.
194
+ * @returns {boolean} return the date is match
195
+ */
196
+ export declare const lastQuarter: (date: Date, anchorTime?: Date) => boolean;
197
+ /**
198
+ * The provided date is in the current year.
199
+ * @param {Date} date - The date to compare.
200
+ * @param {Date} [anchorTime] - The reference date.
201
+ * @returns {boolean} return the date is match
202
+ */
203
+ export declare const thisYear: (date: Date, anchorTime?: Date) => boolean;
204
+ /**
205
+ * The provided date is in the next year.
206
+ * @param {Date} date - The date to compare.
207
+ * @param {Date} [anchorTime] - The reference date.
208
+ * @returns {boolean} return the date is match
209
+ */
210
+ export declare const nextYear: (date: Date, anchorTime?: Date) => boolean;
211
+ /**
212
+ * The provided date is in the last year.
213
+ * @param {Date} date - The date to compare.
214
+ * @param {Date} [anchorTime] - The reference date.
215
+ * @returns {boolean} return the date is match
216
+ */
217
+ export declare const lastYear: (date: Date, anchorTime?: Date) => boolean;
218
+ /**
219
+ * The provided date is in the year to date.
220
+ * @param {Date} date - The date to compare.
221
+ * @param {Date} [anchorTime] - The reference date.
222
+ * @returns {boolean} return the date is match
223
+ */
224
+ export declare const yearToDate: (date: Date, anchorTime?: Date) => boolean;
225
+ export declare function getDateFilterExecuteFunc(filterInfo: ITableDateFilterInfo): (date: Date) => boolean;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ICalculatedOptions, ITableNumberFilterInfo } from '../../types/type';
17
+ /**
18
+ * @description Checks if a value is above the average.
19
+ * @param {number} value - The value to check.
20
+ * @param {number} average - The average value.
21
+ * @returns {boolean} A boolean value indicating whether the value is above the average.
22
+ */
23
+ export declare const above: (value: number, average: number) => boolean;
24
+ /**
25
+ * @description Checks if a value is below the average.
26
+ * @param {number} value - The value to check.
27
+ * @param {number} average - The average value.
28
+ * @returns {boolean} A boolean value indicating whether the value is below the average.
29
+ */
30
+ export declare const below: (value: number, average: number) => boolean;
31
+ /**
32
+ * @description Gets the largest N values from a list and checks if the expected value is included.
33
+ * @param {number[]} list - The list of numbers.
34
+ * @param {number} top - The number of top values to retrieve.
35
+ * @param {number} expectedValue - The expected value to check for inclusion.
36
+ * @returns {boolean} A boolean value indicating whether the expected value is included in the top N values.
37
+ */
38
+ export declare const getTopN: (list: number[], top: number, expectedValue: number) => boolean;
39
+ /**
40
+ * @description Gets the smallest N values from a list and checks if the expected value is included.
41
+ * @param {number[]} list - The list of numbers.
42
+ * @param {number} bottom - The number of bottom values to retrieve.
43
+ * @param {number} expectedValue - The expected value to check for inclusion.
44
+ * @returns {boolean} A boolean value indicating whether the expected value is included in the bottom N values.
45
+ */
46
+ export declare const getBottomN: (list: number[], bottom: number, expectedValue: number) => boolean;
47
+ export declare function getNumberFilterExecuteFunc(filter: ITableNumberFilterInfo, calculatedOptions: ICalculatedOptions | undefined): (value: number) => boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ITableStringFilterInfo } from '../../types/type';
17
+ export declare const textEqual: (compareValue: string, expectedValue: string) => boolean;
18
+ export declare const textNotEqual: (compareValue: string, expectedValue: string) => boolean;
19
+ export declare const textContain: (compareValue: string, expectedValue: string) => boolean;
20
+ export declare const textNotContain: (compareValue: string, expectedValue: string) => boolean;
21
+ export declare const textStartWith: (compareValue: string, expectedValue: string) => boolean;
22
+ export declare const textEndWith: (compareValue: string, expectedValue: string) => boolean;
23
+ export declare function getTextFilterExecuteFunc(filter: ITableStringFilterInfo): (value: string) => boolean;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Returns the kth largest element from the given list using a min heap.
18
+ * @param {number[]} list The list of numbers.
19
+ * @param {number} k The value of k.
20
+ * @returns The kth largest element.
21
+ */
22
+ export declare const getLargestK: (list: number[], k: number) => number[];
23
+ /**
24
+ * Returns the kth smallest element from the given list using a max heap.
25
+ * @param {number[]} list The list of numbers.
26
+ * @param {number} k The value of k.
27
+ * @returns The kth smallest element.
28
+ */
29
+ export declare const getSmallestK: (list: number[], k: number) => number[];
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IStyleData } from '@univerjs/core';
17
+ import type { TableMetaType } from '../types/type';
18
+ import { TableColumnDataTypeEnum } from '../types/enum';
19
+ export declare class TableColumn {
20
+ dataType: TableColumnDataTypeEnum;
21
+ id: string;
22
+ displayName: string;
23
+ formula: string;
24
+ meta: TableMetaType;
25
+ style: IStyleData;
26
+ constructor(id: string, name: string);
27
+ getMeta(): TableMetaType;
28
+ setMeta(meta: TableMetaType): void;
29
+ getDisplayName(): string;
30
+ toJSON(): {
31
+ id: string;
32
+ displayName: string;
33
+ dataType: TableColumnDataTypeEnum;
34
+ formula: string;
35
+ meta: TableMetaType;
36
+ style: IStyleData;
37
+ };
38
+ fromJSON(json: any): void;
39
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { Worksheet } from '@univerjs/core';
17
+ import type { SheetsTableButtonStateEnum } from '../types/enum';
18
+ import type { ITableFilterItem, ITableFilterJSON, ITableRange } from '../types/type';
19
+ import { SheetsTableSortStateEnum } from '../types/enum';
20
+ export declare class TableFilters {
21
+ private _tableColumnFilterList;
22
+ private _tableSortInfo;
23
+ private _filterOutRows;
24
+ constructor();
25
+ setColumnFilter(columnIndex: number, filter: ITableFilterItem | undefined): void;
26
+ setSortState(columnIndex: number, sortState: SheetsTableSortStateEnum): void;
27
+ getColumnFilter(columnIndex: number): ITableFilterItem | undefined;
28
+ getFilterState(columnIndex: number): SheetsTableButtonStateEnum;
29
+ getSortState(): {
30
+ columnIndex: number;
31
+ sortState: SheetsTableSortStateEnum;
32
+ };
33
+ getFilterStates(range: ITableRange): SheetsTableButtonStateEnum[];
34
+ getFilterOutRows(): Set<number>;
35
+ doFilter(sheet: Worksheet, range: ITableRange): Set<number>;
36
+ doColumnFilter(sheet: Worksheet, range: ITableRange, columnIndex: number, filterOutRows: Set<number>): void;
37
+ private _getNumberCalculatedOptions;
38
+ getExecuteFunc(sheet: Worksheet, range: ITableRange, columnIndex: number, filter: ITableFilterItem): (value: any) => boolean;
39
+ toJSON(): ITableFilterJSON;
40
+ fromJSON(json: ITableFilterJSON): void;
41
+ dispose(): void;
42
+ }