@univerjs/sheets-table 1.0.0-rc.0 → 1.0.1
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.
- package/lib/cjs/facade.js +23 -1
- package/lib/cjs/index.js +484 -74
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/facade.js +25 -3
- package/lib/es/index.js +484 -78
- package/lib/facade.js +25 -3
- package/lib/index.js +484 -78
- package/lib/types/commands/mutations/set-table-filter.mutation.d.ts +3 -0
- package/lib/types/commands/utils/calculated-column.d.ts +20 -0
- package/lib/types/controllers/sheet-table-formula.controller.d.ts +4 -1
- package/lib/types/controllers/table-filter.controller.d.ts +4 -1
- package/lib/types/facade/f-enum.d.ts +5 -0
- package/lib/types/facade/f-workbook.d.ts +6 -6
- package/lib/types/facade/f-worksheet.d.ts +22 -3
- package/lib/types/index.d.ts +3 -2
- package/lib/types/models/filter-util/record-filter.d.ts +24 -0
- package/lib/types/models/table-column.d.ts +11 -0
- package/lib/types/models/table-filter.d.ts +1 -0
- package/lib/types/models/table.d.ts +4 -0
- package/lib/types/types/enum.d.ts +2 -1
- package/lib/types/types/type.d.ts +55 -2
- package/lib/types/util.d.ts +2 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- 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
|
-
|
|
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 {
|
|
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 {
|
|
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}
|
|
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
|
|
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):
|
|
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}
|
|
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>}
|
|
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>}
|
|
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>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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,24 @@
|
|
|
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 { ITableRecordFilterItem, TableRecordValue } from '../../types/type';
|
|
18
|
+
/**
|
|
19
|
+
* Formula errors are recognized when the cell retains formula, shared-formula, or intercepted array-formula context.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getTableRecordValue(sheet: Worksheet, row: number, column: number): TableRecordValue;
|
|
22
|
+
export declare function getTableRecordValueKey(_value: TableRecordValue): string;
|
|
23
|
+
export declare function compileTableRecordFilter(_filter: ITableRecordFilterItem): (value: TableRecordValue) => boolean;
|
|
24
|
+
export declare function cloneTableRecordFilter(filter: ITableRecordFilterItem): ITableRecordFilterItem;
|
|
@@ -21,6 +21,11 @@ export declare class TableColumn {
|
|
|
21
21
|
id: string;
|
|
22
22
|
displayName: string;
|
|
23
23
|
formula: string;
|
|
24
|
+
formulaIsArray?: boolean;
|
|
25
|
+
totalsRowLabel?: string;
|
|
26
|
+
totalsRowFunction?: string;
|
|
27
|
+
totalsRowFormula?: string;
|
|
28
|
+
showFilterButton: boolean;
|
|
24
29
|
meta: TableMetaType;
|
|
25
30
|
style: IStyleData;
|
|
26
31
|
constructor(id: string, name: string);
|
|
@@ -32,8 +37,14 @@ export declare class TableColumn {
|
|
|
32
37
|
displayName: string;
|
|
33
38
|
dataType: TableColumnDataTypeEnum;
|
|
34
39
|
formula: string;
|
|
40
|
+
formulaIsArray: boolean | undefined;
|
|
41
|
+
totalsRowLabel: string | undefined;
|
|
42
|
+
totalsRowFunction: string | undefined;
|
|
43
|
+
totalsRowFormula: string | undefined;
|
|
44
|
+
showFilterButton: boolean;
|
|
35
45
|
meta: TableMetaType;
|
|
36
46
|
style: IStyleData;
|
|
37
47
|
};
|
|
38
48
|
fromJSON(json: any): void;
|
|
49
|
+
isShowFilterButton(): boolean;
|
|
39
50
|
}
|
|
@@ -31,6 +31,7 @@ export declare class TableFilters {
|
|
|
31
31
|
getSortState(): {};
|
|
32
32
|
getFilterStates(range: ITableRange): SheetsTableButtonStateEnum[];
|
|
33
33
|
getFilterOutRows(): Set<number>;
|
|
34
|
+
setFilterOutRows(rows: Iterable<number>): void;
|
|
34
35
|
doFilter(sheet: Worksheet, range: ITableRange, dateSystem?: DateSystem): Set<number>;
|
|
35
36
|
doColumnFilter(sheet: Worksheet, range: ITableRange, columnIndex: number, filterOutRows: Set<number>, dateSystem?: DateSystem): void;
|
|
36
37
|
private _getNumberCalculatedOptions;
|
|
@@ -25,6 +25,7 @@ export declare class Table {
|
|
|
25
25
|
private _tableStyleId?;
|
|
26
26
|
private _showHeader;
|
|
27
27
|
private _showFooter;
|
|
28
|
+
private _showAutoFilter;
|
|
28
29
|
private _range;
|
|
29
30
|
private _columns;
|
|
30
31
|
private _columnOrder;
|
|
@@ -74,6 +75,8 @@ export declare class Table {
|
|
|
74
75
|
isShowHeader(): boolean;
|
|
75
76
|
setShowHeader(showHeader: boolean): void;
|
|
76
77
|
isShowFooter(): boolean;
|
|
78
|
+
isShowAutoFilter(): boolean;
|
|
79
|
+
setShowAutoFilter(showAutoFilter: boolean): void;
|
|
77
80
|
getTableInfo(): ITableInfo;
|
|
78
81
|
getTableConfig(): {
|
|
79
82
|
name: string;
|
|
@@ -86,6 +89,7 @@ export declare class Table {
|
|
|
86
89
|
options: {
|
|
87
90
|
showHeader: boolean;
|
|
88
91
|
showFooter: boolean;
|
|
92
|
+
showAutoFilter: boolean;
|
|
89
93
|
};
|
|
90
94
|
tableStyleId: string | undefined;
|
|
91
95
|
};
|
|
@@ -25,7 +25,8 @@ export declare enum TableColumnDataTypeEnum {
|
|
|
25
25
|
export declare enum TableColumnFilterTypeEnum {
|
|
26
26
|
manual = "manual",
|
|
27
27
|
condition = "condition",
|
|
28
|
-
color = "color"
|
|
28
|
+
color = "color",
|
|
29
|
+
record = "record"
|
|
29
30
|
}
|
|
30
31
|
export declare enum TableConditionTypeEnum {
|
|
31
32
|
Date = "date",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IRange, IStyleData, Nullable } from '@univerjs/core';
|
|
16
|
+
import type { FilterSelectionMode, IRange, IStyleData, Nullable, RecordValueType } from '@univerjs/core';
|
|
17
17
|
import type { SheetsTableButtonStateEnum, SheetsTableSortStateEnum, TableColumnDataTypeEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableNumberCompareTypeEnum, TableStringCompareTypeEnum } from './enum';
|
|
18
18
|
export interface ITableRange {
|
|
19
19
|
startRow: number;
|
|
@@ -32,6 +32,11 @@ export interface ITableOptions {
|
|
|
32
32
|
* @todo not support yet
|
|
33
33
|
*/
|
|
34
34
|
showFooter?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the table has an AutoFilter control.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
showAutoFilter?: boolean;
|
|
35
40
|
/**
|
|
36
41
|
* The table style id. If the property is empty, the default style will be used.
|
|
37
42
|
* @default: table-default-0 ~ table-default-5
|
|
@@ -58,7 +63,22 @@ export interface ITableFilterJSON {
|
|
|
58
63
|
sortState: SheetsTableSortStateEnum;
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
|
-
export type
|
|
66
|
+
export type TableRecordValue = {
|
|
67
|
+
type: RecordValueType.Blank;
|
|
68
|
+
} | {
|
|
69
|
+
type: RecordValueType.String;
|
|
70
|
+
value: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: RecordValueType.Number | RecordValueType.Date;
|
|
73
|
+
value: number;
|
|
74
|
+
} | {
|
|
75
|
+
type: RecordValueType.Boolean;
|
|
76
|
+
value: boolean;
|
|
77
|
+
} | {
|
|
78
|
+
type: RecordValueType.Error;
|
|
79
|
+
value: string;
|
|
80
|
+
};
|
|
81
|
+
export type ITableFilterItem = ITableManualFilterItem | ITableConditionFilterItem | ITableColorFilterItem | ITableRecordFilterItem;
|
|
62
82
|
export type TableMetaType = Record<string, any>;
|
|
63
83
|
/**
|
|
64
84
|
* Represents the table filter item, filter data by provided values.
|
|
@@ -83,6 +103,14 @@ export interface ITableColorFilterItem {
|
|
|
83
103
|
cellFillColors?: Array<string | null>;
|
|
84
104
|
cellTextColors?: Array<string | null>;
|
|
85
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Represents a compact typed value filter. An absent filter represents all values.
|
|
108
|
+
*/
|
|
109
|
+
export interface ITableRecordFilterItem {
|
|
110
|
+
filterType: TableColumnFilterTypeEnum.record;
|
|
111
|
+
mode: FilterSelectionMode.Include | FilterSelectionMode.Exclude;
|
|
112
|
+
values: TableRecordValue[];
|
|
113
|
+
}
|
|
86
114
|
export interface ITableDateFilterInfo {
|
|
87
115
|
conditionType: TableConditionTypeEnum.Date;
|
|
88
116
|
compareType: TableDateCompareTypeEnum;
|
|
@@ -130,7 +158,22 @@ export interface ITableRangeRowColOperation {
|
|
|
130
158
|
count: number;
|
|
131
159
|
columnsJson?: ITableColumnJson[];
|
|
132
160
|
}
|
|
161
|
+
/** Changes button visibility without clearing existing filter criteria. */
|
|
162
|
+
export interface ITableFilterButtonConfig {
|
|
163
|
+
showAutoFilter?: boolean;
|
|
164
|
+
/** Partial update keyed by stable table column ID, not worksheet column index. */
|
|
165
|
+
columns?: Record<string, boolean>;
|
|
166
|
+
}
|
|
167
|
+
/** Formula is anchored at the first data row; an empty formula stops automatic filling. */
|
|
168
|
+
export interface ITableCalculatedColumnConfig {
|
|
169
|
+
columnId: string;
|
|
170
|
+
formula: string;
|
|
171
|
+
/** Preserve imported array semantics when omitted. */
|
|
172
|
+
formulaIsArray?: boolean;
|
|
173
|
+
}
|
|
133
174
|
export interface ITableSetConfig {
|
|
175
|
+
calculatedColumn?: ITableCalculatedColumnConfig;
|
|
176
|
+
filterButtons?: ITableFilterButtonConfig;
|
|
134
177
|
name?: string;
|
|
135
178
|
updateRange?: ITableRangeUpdate;
|
|
136
179
|
rowColOperation?: ITableRangeRowColOperation;
|
|
@@ -177,6 +220,15 @@ export interface ITableColumnJson {
|
|
|
177
220
|
id: string;
|
|
178
221
|
displayName: string;
|
|
179
222
|
formula: string;
|
|
223
|
+
formulaIsArray?: boolean;
|
|
224
|
+
totalsRowLabel?: string;
|
|
225
|
+
totalsRowFunction?: string;
|
|
226
|
+
totalsRowFormula?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Whether to show the filter button for this table column.
|
|
229
|
+
* @default true
|
|
230
|
+
*/
|
|
231
|
+
showFilterButton?: boolean;
|
|
180
232
|
meta: TableMetaType;
|
|
181
233
|
style: IStyleData;
|
|
182
234
|
}
|
|
@@ -197,6 +249,7 @@ export interface ITableInfo {
|
|
|
197
249
|
meta: TableMetaType;
|
|
198
250
|
columns: ITableColumnJson[];
|
|
199
251
|
showHeader: boolean;
|
|
252
|
+
showAutoFilter: boolean;
|
|
200
253
|
}
|
|
201
254
|
export interface ITableInfoWithUnitId extends ITableInfo {
|
|
202
255
|
unitId: string;
|
package/lib/types/util.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { ICellData, IDocumentData, IUniverInstanceService, Nullable } from '@univerjs/core';
|
|
17
17
|
import type { IDefinedNamesService } from '@univerjs/engine-formula';
|
|
18
18
|
import type { TableManager } from './models/table-manager';
|
|
19
|
-
import type { ITableColorFilterItem, ITableConditionFilterItem, ITableFilterItem, ITableManualFilterItem } from './types/type';
|
|
19
|
+
import type { ITableColorFilterItem, ITableConditionFilterItem, ITableFilterItem, ITableManualFilterItem, ITableRecordFilterItem } from './types/type';
|
|
20
20
|
import { SheetsTableButtonStateEnum, SheetsTableSortStateEnum } from './types/enum';
|
|
21
21
|
export declare function getColumnName(columnIndex: number, columnText: string): string;
|
|
22
22
|
export declare const getStringFromDataStream: (data: IDocumentData) => string;
|
|
@@ -32,6 +32,7 @@ export declare function getTableFilterState(tableFilter: ITableFilterItem | unde
|
|
|
32
32
|
export declare function isConditionFilter(filter: ITableFilterItem | undefined): filter is ITableConditionFilterItem;
|
|
33
33
|
export declare function isManualTableFilter(filter: ITableFilterItem | undefined): filter is ITableManualFilterItem;
|
|
34
34
|
export declare function isColorTableFilter(filter: ITableFilterItem | undefined): filter is ITableColorFilterItem;
|
|
35
|
+
export declare function isRecordTableFilter(filter: ITableFilterItem | undefined): filter is ITableRecordFilterItem;
|
|
35
36
|
/**
|
|
36
37
|
* Get existing names including sheet names, table names and defined names to check for duplicates table name.
|
|
37
38
|
*/
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/sheets-table"),require("@univerjs/sheets/facade"),require("@univerjs/sheets"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/sheets-table`,`@univerjs/sheets/facade`,`@univerjs/sheets`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverSheetsTable,e.UniverSheetsFacade,e.UniverSheets,e.UniverCoreFacade))})(this,function(e,t,n,r,i){var a=class extends n.FWorkbook{getTableInfo(e){let n=this.getId();return this._injector.get(t.SheetTableService).getTableInfo(n,e)}getTableList(){let e=this.getId();return this._injector.get(t.SheetTableService).getTableList(e)}async addTable(n,r,i,a,o){let s=this._injector.get(t.SheetTableService),c=this._injector.get(e.IUniverInstanceService).getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET),l=new Set;if(c&&c.getSheets().forEach(e=>{l.add(e.getName())}),!(0,e.customNameCharacterCheck)(r,l))return;let u={unitId:this.getId(),name:r,subUnitId:n,range:i,options:o,id:a};if(await this._commandService.executeCommand(t.AddSheetTableCommand.id,u)){var d;return(d=s.getTableList(this.getId()).find(e=>e.name===r))==null?void 0:d.id}}async removeTable(e){var n;let r=(n=this.getTableInfo(e))==null?void 0:n.subUnitId;if(!r)return!1;let i={unitId:this.getId(),subUnitId:r,tableId:e};return this._commandService.executeCommand(t.DeleteSheetTableCommand.id,i)}getTableInfoByName(e){return this.getTableList().find(t=>t.name===e)}setTableFilter(e,n,r){let i={unitId:this.getId(),tableId:e,column:n,tableFilter:r};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,i)}};n.FWorkbook.extend(a);var o=class extends n.FWorksheet{addTable(n,r,i,a){let o=this.getSheetId(),s=this.getWorkbook(),c=s.getUnitId()
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/sheets-table"),require("@univerjs/sheets/facade"),require("@univerjs/sheets"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/sheets-table`,`@univerjs/sheets/facade`,`@univerjs/sheets`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverSheetsTable,e.UniverSheetsFacade,e.UniverSheets,e.UniverCoreFacade))})(this,function(e,t,n,r,i){var a=class extends n.FWorkbook{getTableInfo(e){let n=this.getId();return this._injector.get(t.SheetTableService).getTableInfo(n,e)}getTableList(){let e=this.getId();return this._injector.get(t.SheetTableService).getTableList(e)}async addTable(n,r,i,a,o){let s=this._injector.get(t.SheetTableService),c=this._injector.get(e.IUniverInstanceService).getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET),l=new Set;if(c&&c.getSheets().forEach(e=>{l.add(e.getName())}),!(0,e.customNameCharacterCheck)(r,l))return;let u={unitId:this.getId(),name:r,subUnitId:n,range:i,options:o,id:a};if(await this._commandService.executeCommand(t.AddSheetTableCommand.id,u)){var d;return(d=s.getTableList(this.getId()).find(e=>e.name===r))==null?void 0:d.id}}async removeTable(e){var n;let r=(n=this.getTableInfo(e))==null?void 0:n.subUnitId;if(!r)return!1;let i={unitId:this.getId(),subUnitId:r,tableId:e};return this._commandService.executeCommand(t.DeleteSheetTableCommand.id,i)}getTableInfoByName(e){return this.getTableList().find(t=>t.name===e)}setTableFilter(e,n,r){let i={unitId:this.getId(),tableId:e,column:n,tableFilter:r};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,i)}};n.FWorkbook.extend(a);var o=class extends n.FWorksheet{setTableColumnFormula(e,n,r){let i=this.getWorkbook().getUnitId(),a=this._injector.get(t.TableManager).getTableById(i,e);return!a||a.getSubunitId()!==this.getSheetId()?!1:this._commandService.syncExecuteCommand(t.SetSheetTableCommand.id,{unitId:i,tableId:e,calculatedColumn:{columnId:n,formula:r}})}setTableFilterButtons(e,n){let r=this.getWorkbook().getUnitId(),i=this._injector.get(t.TableManager).getTableById(r,e);return!i||i.getSubunitId()!==this.getSheetId()?!1:this._commandService.syncExecuteCommand(t.SetSheetTableCommand.id,{unitId:r,tableId:e,filterButtons:n})}addTable(n,r,i,a){let o=this.getSheetId(),s=this.getWorkbook(),c=s.getUnitId(),l=new Set;if(s&&s.getSheets().forEach(e=>{l.add(e.getName())}),!(0,e.customNameCharacterCheck)(n,l))return!1;let u={unitId:c,subUnitId:o,name:n,range:r,id:i,options:a};return this._commandService.executeCommand(t.AddSheetTableCommand.id,u)}setTableFilter(e,n,r){let i={unitId:this.getWorkbook().getUnitId(),tableId:e,column:n,tableFilter:r};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,i)}removeTable(e){let n={unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),tableId:e};return this._commandService.executeCommand(t.DeleteSheetTableCommand.id,n)}setTableRange(e,n){let r={unitId:this.getWorkbook().getUnitId(),tableId:e,updateRange:{newRange:n}};return this._commandService.executeCommand(t.SetSheetTableCommand.id,r)}setTableName(n,r){let i=this.getWorkbook(),a=new Set;if(i&&i.getSheets().forEach(e=>{a.add(e.getName())}),!(0,e.customNameCharacterCheck)(r,a))return!1;let o={unitId:this.getWorkbook().getUnitId(),tableId:n,name:r};return this._commandService.executeCommand(t.SetSheetTableCommand.id,o)}getSubTableInfos(){let e=this._fWorkbook.getId();return this._injector.get(t.SheetTableService).getTableList(e).filter(e=>e.subUnitId===this.getSheetId())}resetFilter(e,n){let r={unitId:this._fWorkbook.getId(),tableId:e,column:n,tableFilter:void 0};return this._commandService.executeCommand(t.SetSheetTableFilterCommand.id,r)}getTableByCell(n,r){let i=this._fWorkbook.getId(),a=this._injector.get(t.SheetTableService).getTableList(i).filter(e=>e.subUnitId===this.getSheetId()),o=(0,e.cellToRange)(n,r);return a.find(t=>{let n=t.range;return e.Rectangle.intersects(n,o)})}addTableTheme(e,n){let i=new r.RangeThemeStyle(`table-style`);return i.fromJson(n),this._commandService.executeCommand(t.AddTableThemeCommand.id,{unitId:this._fWorkbook.getId(),tableId:e,themeStyle:i})}};n.FWorksheet.extend(o);var s=class extends i.FEnum{get TableColumnFilterTypeEnum(){return t.TableColumnFilterTypeEnum}get TableConditionTypeEnum(){return t.TableConditionTypeEnum}get TableNumberCompareTypeEnum(){return t.TableNumberCompareTypeEnum}get TableStringCompareTypeEnum(){return t.TableStringCompareTypeEnum}get TableDateCompareTypeEnum(){return t.TableDateCompareTypeEnum}};i.FEnum.extend(s)});
|