@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.
- 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/model/filter-util/condition.d.ts +27 -0
- package/lib/types/model/filter-util/date-filter-util.d.ts +225 -0
- package/lib/types/model/filter-util/number-filter-util.d.ts +47 -0
- package/lib/types/model/filter-util/text-filter-util.d.ts +23 -0
- package/lib/types/model/filter-util/top-n.d.ts +29 -0
- package/lib/types/model/table-column.d.ts +39 -0
- package/lib/types/model/table-filter.d.ts +42 -0
- package/lib/types/model/table-manager.d.ts +97 -0
- package/lib/types/model/table.d.ts +96 -0
- 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
|
@@ -0,0 +1,97 @@
|
|
|
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 { IRange } from '@univerjs/core';
|
|
17
|
+
import type { ITableAddedEvent, ITableDeletedEvent, ITableFilterChangedEvent, ITableFilterItem, ITableInfoWithUnitId, ITableNameChangedEvent, ITableOptions, ITableRange, ITableRangeChangedEvent, ITableRangeRowColOperation, ITableRangeUpdate, ITableRangeWithState, ITableResource, ITableSetConfig, ITableThemeChangedEvent } from '../types/type';
|
|
18
|
+
import { Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
19
|
+
import { Table } from './table';
|
|
20
|
+
export declare class TableManager extends Disposable {
|
|
21
|
+
private readonly _univerInstanceService;
|
|
22
|
+
private readonly _localeService;
|
|
23
|
+
private _tableMap;
|
|
24
|
+
private _tableAdd$;
|
|
25
|
+
tableAdd$: import("rxjs").Observable<ITableAddedEvent>;
|
|
26
|
+
private _tableDelete$;
|
|
27
|
+
tableDelete$: import("rxjs").Observable<ITableDeletedEvent>;
|
|
28
|
+
private _tableNameChanged$;
|
|
29
|
+
tableNameChanged$: import("rxjs").Observable<ITableNameChangedEvent>;
|
|
30
|
+
private _tableRangeChanged$;
|
|
31
|
+
tableRangeChanged$: import("rxjs").Observable<ITableRangeChangedEvent>;
|
|
32
|
+
private _tableThemeChanged$;
|
|
33
|
+
tableThemeChanged$: import("rxjs").Observable<ITableThemeChangedEvent>;
|
|
34
|
+
private _tableFilterChanged$;
|
|
35
|
+
tableFilterChanged$: import("rxjs").Observable<ITableFilterChangedEvent>;
|
|
36
|
+
private _tableInitStatus;
|
|
37
|
+
tableInitStatus$: import("rxjs").Observable<boolean>;
|
|
38
|
+
constructor(_univerInstanceService: IUniverInstanceService, _localeService: LocaleService);
|
|
39
|
+
private _ensureUnit;
|
|
40
|
+
getColumnHeader(unitId: string, subUnitId: string, range: ITableRange, prefixText?: string): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Add a table to univer.
|
|
43
|
+
* @param {string} unitId The unit id of the table.
|
|
44
|
+
* @param {string} subUnitId The subunit id of the table.
|
|
45
|
+
* @param {string} name The table name, it should be unique in the unit or it will be appended with a number.
|
|
46
|
+
* @param {ITableRange} range The range of the table, it contains the unit id and subunit id.
|
|
47
|
+
* @param {string[]} [header] The header of the table, if not provided, it will be generated based on the range.
|
|
48
|
+
* @param {string} [initId] The initial id of the table, if not provided, a random id will be generated.
|
|
49
|
+
* @param {ITableOptions} [options] Other options of the table.
|
|
50
|
+
* @returns {string} The table id.
|
|
51
|
+
*/
|
|
52
|
+
addTable(unitId: string, subUnitId: string, name: string, range: ITableRange, header?: string[], initId?: string, options?: ITableOptions): string;
|
|
53
|
+
addFilter(unitId: string, tableId: string, column: number, filter: ITableFilterItem | undefined): void;
|
|
54
|
+
getFilterRanges(unitId: string, subUnitId: string): IRange[];
|
|
55
|
+
getSheetFilterRangeWithState(unitId: string, subUnitId: string): ITableRangeWithState[];
|
|
56
|
+
getTable(unitId: string, tableId: string): Table | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Get the unique table name, in excel, the table name should be unique because it is used as a reference.
|
|
59
|
+
* @param {string} unitId The unit id of the table.
|
|
60
|
+
* @param {string} baseName The base name of the table.
|
|
61
|
+
* @returns {string} The unique table name
|
|
62
|
+
*/
|
|
63
|
+
getUniqueTableName(unitId: string, baseName: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Get table by unit id and table id.
|
|
66
|
+
* @param {string} unitId The unit id of the table.
|
|
67
|
+
* @param {string} tableId The table id.
|
|
68
|
+
* @returns {Table} The table.
|
|
69
|
+
*/
|
|
70
|
+
getTableById(unitId: string, tableId: string): Table | undefined;
|
|
71
|
+
getTableList(unitId: string): ITableInfoWithUnitId[];
|
|
72
|
+
/**
|
|
73
|
+
* Get the table list by unit id and subunit id.
|
|
74
|
+
* @param {string} unitId The unit id of the table.
|
|
75
|
+
* @param {string} subUnitId The subunit id of the table.
|
|
76
|
+
* @returns {Table[]} The table list.
|
|
77
|
+
*/
|
|
78
|
+
getTablesBySubunitId(unitId: string, subUnitId: string): Table[];
|
|
79
|
+
getTablesInfoBySubunitId(unitId: string, subUnitId: string): {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
range: {
|
|
83
|
+
startRow: number;
|
|
84
|
+
startColumn: number;
|
|
85
|
+
endRow: number;
|
|
86
|
+
endColumn: number;
|
|
87
|
+
};
|
|
88
|
+
}[];
|
|
89
|
+
deleteTable(unitId: string, tableId: string): void;
|
|
90
|
+
operationTableRowCol(unitId: string, tableId: string, config: ITableRangeRowColOperation): void;
|
|
91
|
+
updateTableRange(unitId: string, tableId: string, config: ITableRangeUpdate): void;
|
|
92
|
+
setTableByConfig(unitId: string, tableId: string, config: ITableSetConfig): void;
|
|
93
|
+
toJSON(unitId: string): ITableResource;
|
|
94
|
+
fromJSON(unitId: string, data: ITableResource): void;
|
|
95
|
+
deleteUnitId(unitId: string): void;
|
|
96
|
+
dispose(): void;
|
|
97
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 { ITableColumnJson, ITableFilterItem, ITableInfo, ITableJson, ITableOptions, ITableRange } from '../types/type';
|
|
17
|
+
import { TableColumn } from './table-column';
|
|
18
|
+
import { TableFilters } from './table-filter';
|
|
19
|
+
export declare class Table {
|
|
20
|
+
private _id;
|
|
21
|
+
private _name;
|
|
22
|
+
/**
|
|
23
|
+
* @property {string} tableStyleId The table style id. If the property is empty, the default style will be used.
|
|
24
|
+
*/
|
|
25
|
+
private _tableStyleId?;
|
|
26
|
+
private _showHeader;
|
|
27
|
+
private _showFooter;
|
|
28
|
+
private _range;
|
|
29
|
+
private _columns;
|
|
30
|
+
private _columnOrder;
|
|
31
|
+
tableMeta: Record<string, any>;
|
|
32
|
+
private _tableFilters;
|
|
33
|
+
private _subUnitId;
|
|
34
|
+
constructor(id: string, name: string, range: ITableRange, header: string[], options?: ITableOptions);
|
|
35
|
+
_init(header: string[], options: ITableOptions): void;
|
|
36
|
+
setTableFilterColumn(columnIndex: number, filter: ITableFilterItem): void;
|
|
37
|
+
getTableFilterColumn(columnIndex: number): ITableFilterItem | undefined;
|
|
38
|
+
getTableFilters(): TableFilters;
|
|
39
|
+
getTableFilterRange(): {
|
|
40
|
+
startRow: number;
|
|
41
|
+
startColumn: number;
|
|
42
|
+
endRow: number;
|
|
43
|
+
endColumn: number;
|
|
44
|
+
};
|
|
45
|
+
setColumns(columns: ITableColumnJson[]): void;
|
|
46
|
+
getColumnsCount(): number;
|
|
47
|
+
insertColumn(index: number, column: TableColumn): void;
|
|
48
|
+
removeColumn(index: number): void;
|
|
49
|
+
setTableMeta(meta: Record<string, any>): void;
|
|
50
|
+
getTableMeta(): Record<string, any>;
|
|
51
|
+
getColumn(columnId: string): TableColumn | undefined;
|
|
52
|
+
getTableColumnByIndex(index: number): TableColumn | undefined;
|
|
53
|
+
getColumnNameByIndex(index: number): string;
|
|
54
|
+
getId(): string;
|
|
55
|
+
getRangeInfo(): {
|
|
56
|
+
startRow: number;
|
|
57
|
+
startColumn: number;
|
|
58
|
+
endRow: number;
|
|
59
|
+
endColumn: number;
|
|
60
|
+
};
|
|
61
|
+
getRange(): {
|
|
62
|
+
startRow: number;
|
|
63
|
+
startColumn: number;
|
|
64
|
+
endRow: number;
|
|
65
|
+
endColumn: number;
|
|
66
|
+
};
|
|
67
|
+
setRange(range: ITableRange): void;
|
|
68
|
+
setDisplayName(name: string): void;
|
|
69
|
+
getDisplayName(): string;
|
|
70
|
+
getSubunitId(): string;
|
|
71
|
+
setSubunitId(subUnitId: string): void;
|
|
72
|
+
getTableStyleId(): string;
|
|
73
|
+
setTableStyleId(tableStyleId: string): void;
|
|
74
|
+
isShowHeader(): boolean;
|
|
75
|
+
setShowHeader(showHeader: boolean): void;
|
|
76
|
+
isShowFooter(): boolean;
|
|
77
|
+
getTableInfo(): ITableInfo;
|
|
78
|
+
getTableConfig(): {
|
|
79
|
+
name: string;
|
|
80
|
+
range: {
|
|
81
|
+
startRow: number;
|
|
82
|
+
startColumn: number;
|
|
83
|
+
endRow: number;
|
|
84
|
+
endColumn: number;
|
|
85
|
+
};
|
|
86
|
+
options: {
|
|
87
|
+
showHeader: boolean;
|
|
88
|
+
showFooter: boolean;
|
|
89
|
+
};
|
|
90
|
+
tableStyleId: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
getFilterStates(range: ITableRange): import("..").SheetsTableButtonStateEnum[];
|
|
93
|
+
toJSON(): ITableJson;
|
|
94
|
+
fromJSON(json: ITableJson): void;
|
|
95
|
+
dispose(): void;
|
|
96
|
+
}
|
|
@@ -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)});
|