@univerjs-pro/sheets-pivot 0.2.9 → 0.2.10

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.
@@ -2,6 +2,7 @@ import { IPivotViewCellData, IPivotViewValueType, PivotView, PivotViewItem } fro
2
2
  import { Injector, IRange } from '@univerjs/core';
3
3
  import { default as zhCN } from '../locale/zh-CN';
4
4
  import { IAdjustPivotTableRes, IPivotTableConfig, IThemeStyle } from './type';
5
+ export declare const PIVOT_ICON_OFFSET = 16;
5
6
  export declare const SHEET_PIVOT_TABLE_PLUGIN = "SHEET_PIVOT_TABLE_PLUGIN";
6
7
  export declare const BLANK_ROW_COUNT = 1;
7
8
  export declare const BLANK_COL_COUNT = 1;
@@ -49,7 +50,7 @@ export declare function transformErrorValue(value: IPivotViewValueType): string
49
50
  export declare function getAdjustRangesPosition(startCell: {
50
51
  row: number;
51
52
  col: number;
52
- }, view: PivotViewItem, singleCellIsRange?: boolean, useLast?: boolean): IRange[];
53
+ }, view: PivotViewItem, singleCellIsRange?: boolean, useLastRowOrCol?: boolean): IRange[];
53
54
  export declare const SHEET_PIVOT_IN_MAIN_THREAD = "SHEET_PIVOT_IN_MAIN_THREAD";
54
55
  export declare enum PivotDisplayDataType {
55
56
  Filter = "filter",
@@ -1,4 +1,4 @@
1
- import { IDataFieldManagerBaseJSON, IFieldsCollectionJSON, ILabelViewHeaderMapItem, IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableLabelFieldJSON, IPivotTableOptions, IPivotTableSnapshot, IPivotTableSortInfo, IPivotTableValueFieldJSON, IPivotViewInfo, IPivotViewJSON, IPivotViewValueType, PivotCellStyleTypeEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, PivotView } from '@univerjs-pro/engine-pivot';
1
+ import { DataField, FieldsCollection, IDataFieldManagerBaseJSON, IFieldsCollectionJSON, ILabelViewHeaderMapItem, IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableLabelFieldJSON, IPivotTableOptions, IPivotTableSnapshot, IPivotTableSortInfo, IPivotTableValueFieldJSON, IPivotViewInfo, IPivotViewJSON, IPivotViewValueType, PivotCellStyleTypeEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, PivotView } from '@univerjs-pro/engine-pivot';
2
2
  import { CellValueType, ICellData, IRange, IStyleData, IUnitRangeName, Nullable, ObjectMatrix } from '@univerjs/core';
3
3
  import { PivotDisplayDataType, PositionType } from './const';
4
4
  export interface IPivotTableConfigChangeInfo {
@@ -501,3 +501,10 @@ export interface IAddPivotTableWithConfigCommandParams {
501
501
  values?: IValueFieldConfig[];
502
502
  };
503
503
  }
504
+ export interface IUpdateInfo {
505
+ collection: FieldsCollection;
506
+ updateDataFieldList: {
507
+ index: number;
508
+ dataField: DataField;
509
+ }[];
510
+ }
@@ -1,5 +1,6 @@
1
1
  import { Nullable, ObjectMatrix, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
2
- import { IDataFieldManagerJSON, IPivotRangesInfo, IPivotTableCellData, IPivotTableConfig, IPivotTableMatrixInfo, IPivotTableRangeInfo } from '../const/type';
2
+ import { IFieldsCollectionJSON } from '@univerjs-pro/engine-pivot';
3
+ import { IDataFieldManagerJSON, IPivotCellPositionInfo, IPivotRangesInfo, IPivotTableCellData, IPivotTableConfig, IPivotTableMatrixInfo, IPivotTableRangeInfo } from '../const/type';
3
4
  export declare class SheetsPivotTableConfigModel extends Disposable {
4
5
  private _injector;
5
6
  private _commandService;
@@ -26,11 +27,11 @@ export declare class SheetsPivotTableConfigModel extends Disposable {
26
27
  private _initLocale;
27
28
  getTextInfo(): Record<string, string>;
28
29
  updateViewInfo(unitId: string, subUnitId: string, pivotTableId: string, valueMatrix: ObjectMatrix<Nullable<IPivotTableCellData>>, rangesCache: IPivotRangesInfo | undefined): void;
29
- getPivotTableConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableConfig | undefined;
30
- getTargetByPivotId(unitId: string, subUnitId: string, pivotTableId: string): import('../const/type').IPivotCellPositionInfo | undefined;
30
+ getPivotTableConfig(unitId: string, subUnitId: string, pivotTableId: string): Nullable<IPivotTableConfig>;
31
+ getTargetByPivotId(unitId: string, subUnitId: string, pivotTableId: string): Nullable<IPivotCellPositionInfo>;
31
32
  getSubUnitPivotConfigs(unitId: string, subUnitId: string): Map<string, IPivotTableConfig> | undefined;
32
33
  updateConfigCache(unitId: string, subUnitId: string, pivotTableId: string, pivotTableConfig: Nullable<IPivotTableConfig>): void;
33
- getCollection(unitId: string, pivotTableId: string): import('@univerjs-pro/engine-pivot').IFieldsCollectionJSON | undefined;
34
+ getCollection(unitId: string, pivotTableId: string): IFieldsCollectionJSON | undefined;
34
35
  updateCollectionConfig(unitId: string, collectionConfig: IDataFieldManagerJSON): void;
35
36
  private _ensurePivotMap;
36
37
  private _ensurePivotTableRangeInfo;
@@ -42,7 +43,7 @@ export declare class SheetsPivotTableConfigModel extends Disposable {
42
43
  * @param {string} unitId - the unit id
43
44
  * @param {string} subUnitId - the sub unit id
44
45
  * @param {string} pivotTableId - the pivot table id
45
- * @returns {IPivotRangesInfo} - the pivot table range info
46
+ * @returns {IPivotTableRangeInfo} - the pivot table range info
46
47
  */
47
48
  getPivotTableRangeInfo(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableRangeInfo | undefined;
48
49
  /**
@@ -1,7 +1,7 @@
1
1
  import { ICellData, IRange, IUnitRangeName, IUniverInstanceService, Nullable, ObjectMatrix, Styles, Worksheet } from '@univerjs/core';
2
- import { IDataFieldValue, IFieldsCollectionJSON, DataField, DataFieldManager, FieldsCollection } from '@univerjs-pro/engine-pivot';
2
+ import { IDataFieldValue, IFieldsCollectionJSON, PivotSubtotalTypeEnum, DataField, DataFieldManager, FieldsCollection } from '@univerjs-pro/engine-pivot';
3
3
  import { IRuntimeUnitDataType } from '@univerjs/engine-formula';
4
- import { ICurrentDataMatrix, IDataFieldManagerJSON, IPivotCellPositionInfo, IUnitRangeNameWithSubUnitId } from '../const/type';
4
+ import { ICurrentDataMatrix, IDataFieldManagerJSON, IPivotCellPositionInfo, IUnitRangeNameWithSubUnitId, IUpdateInfo } from '../const/type';
5
5
  import { SheetsPivotDataSourceModel } from './sheets-pivot-data-source-model';
6
6
  interface IFeatureDirtyRangeType {
7
7
  [unitId: string]: Nullable<{
@@ -17,38 +17,21 @@ export declare class SheetsPivotDataFieldManager extends DataFieldManager {
17
17
  _host: SheetsPivotDataSourceModel;
18
18
  constructor(host: SheetsPivotDataSourceModel, univerInstanceService: IUniverInstanceService);
19
19
  initDataRanges(): void;
20
- getAutoDisplayNameFunction(): (baseName: string, subtotalType: import('@univerjs-pro/engine-pivot').PivotSubtotalTypeEnum) => string;
20
+ getAutoDisplayNameFunction(): (baseName: string, subtotalType: PivotSubtotalTypeEnum) => string;
21
21
  deleteDataField(dataFieldId: string): void;
22
22
  removeCollectionImp(token: string): void;
23
23
  getRangeKey(rangeInfo: IUnitRangeName, colIndex: number): string;
24
- getDataFieldByRangeKey(rangeKey: string): DataField;
24
+ getDataFieldByRangeKey(rangeKey: string): DataField | undefined;
25
25
  setRangeKeyMap(rangeKey: string, dataFieldId: string): void;
26
26
  updateRangeKeyMap(oldRangeKey: string, newRangeKey: string): void;
27
- addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo: IPivotCellPositionInfo): {
28
- collection: FieldsCollection;
29
- updateDataFieldList: {
30
- index: number;
31
- dataField: DataField;
32
- }[];
33
- };
34
- getRangeStartEndInfo(range: IRange, sheet: Worksheet): {
35
- startRow: number;
36
- startColumn: number;
37
- endRow: number;
38
- endColumn: number;
39
- };
27
+ addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo: IPivotCellPositionInfo): IUpdateInfo;
28
+ getRangeStartEndInfo(range: IRange, sheet: Worksheet): IRange;
40
29
  /**
41
30
  * - when add pivot table, we should create a collection with data range first
42
31
  * @param {IUnitRangeName} dataRangeInfo the data range info
43
32
  * @returns {FieldsCollection} the created collection
44
33
  */
45
- createCollectionWithDataRange(dataRangeInfo: IUnitRangeName): {
46
- updateDataFieldList: {
47
- index: number;
48
- dataField: DataField;
49
- }[];
50
- collection: FieldsCollection;
51
- };
34
+ createCollectionWithDataRange(dataRangeInfo: IUnitRangeName): IUpdateInfo;
52
35
  _getAutoName(colIndex: number): string;
53
36
  uniqueDataFieldName(name: IDataFieldValue, colIndex: number): string;
54
37
  getCollection(token: string): FieldsCollection;
@@ -69,17 +52,11 @@ export declare class SheetsPivotDataFieldManager extends DataFieldManager {
69
52
  * @returns {Nullable<ICellData>} the cell data
70
53
  */
71
54
  getMatrixValue(matrix: ObjectMatrix<Nullable<ICellData>>, arrayFormulaCellDataMatrix: ObjectMatrix<Nullable<ICellData>> | undefined, unitDataMatrix: ObjectMatrix<Nullable<ICellData>> | undefined, rowIndex: number, colIndex: number): Nullable<ICellData>;
72
- refreshDataField(dataFieldId: string, dataRangeInfo: IUnitRangeNameWithSubUnitId, index: number, currentDataMatrix?: ICurrentDataMatrix): {
73
- header: never[];
74
- data: never[];
75
- } | undefined;
55
+ refreshDataField(dataFieldId: string, dataRangeInfo: IUnitRangeNameWithSubUnitId, index: number, currentDataMatrix?: ICurrentDataMatrix): void;
76
56
  refreshData(collection: FieldsCollection, list: {
77
57
  index: number;
78
58
  dataField: DataField;
79
- }[], dataRangeInfo: IUnitRangeName): {
80
- header: never[];
81
- data: never[];
82
- } | undefined;
59
+ }[], dataRangeInfo: IUnitRangeNameWithSubUnitId): void;
83
60
  getRangeKeyList(dataRangeInfo: IUnitRangeName): string[];
84
61
  /**
85
62
  * - adjust sheet cell value to the type that pivot engine can recognize
@@ -91,7 +68,7 @@ export declare class SheetsPivotDataFieldManager extends DataFieldManager {
91
68
  adjustSheetCellData(cellData: Nullable<ICellData>, styles: Styles, patternInfoRecord: Record<string, any>): IDataFieldValue;
92
69
  getRangeData(dataRangeInfo: IUnitRangeName): {
93
70
  header: (string | null)[];
94
- data: (string | number | boolean | import('@univerjs-pro/engine-pivot').IDateValue | null | undefined)[][];
71
+ data: IDataFieldValue[][];
95
72
  };
96
73
  toJSON(): IDataFieldManagerJSON;
97
74
  fromJSON(jsonData: IDataFieldManagerJSON): void;
@@ -1,7 +1,7 @@
1
1
  import { IUnitRangeName, Nullable, Disposable, ICommandService, IConfigService, Injector, IResourceManagerService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
2
2
  import { DataField, FieldsCollection, IFieldsCollectionJSON, IPivotTableSnapshot, PivotView, PivotTable } from '@univerjs-pro/engine-pivot';
3
3
  import { IMoveRangeMutationParams } from '@univerjs/sheets';
4
- import { ICollectionChangeInfo, IDataFieldManagerJSON, IPivotCellPositionInfo, IPivotMutationDirtyViewInfo, IPivotTableConfig, IPivotTableJson, IPivotWorkerItemCache, ISendPivotConfigLocalMutationParams, IUnitRangeNameWithSubUnitId, PivotTableOperationEnum } from '../const/type';
4
+ import { ICollectionChangeInfo, IDataFieldManagerJSON, IPivotCellPositionInfo, IPivotMutationDirtyViewInfo, IPivotTableConfig, IPivotTableJson, IPivotWorkerItemCache, ISendPivotConfigLocalMutationParams, IUnitRangeNameWithSubUnitId, IUpdateInfo, PivotTableOperationEnum } from '../const/type';
5
5
  import { SheetsPivotDataFieldManager } from './sheets-pivot-data-field-manager';
6
6
  import { IViewTranslateCtx } from './view-util';
7
7
  export declare class SheetsPivotDataSourceModel extends Disposable {
@@ -34,32 +34,7 @@ export declare class SheetsPivotDataSourceModel extends Disposable {
34
34
  */
35
35
  private _queryingMap;
36
36
  constructor(_injector: Injector, _univerInstanceService: IUniverInstanceService, _lifecycleService: LifecycleService, _configService: IConfigService, _commandService: ICommandService, _resourceManagerService: IResourceManagerService);
37
- getTextInfo(): Record<string, string> | {
38
- 'sheets-pivot.blankValue': string;
39
- 'sheets-pivot.columnName': string;
40
- 'sheets-pivot.subTotalText': string;
41
- 'sheets-pivot.grandTotalText': string;
42
- 'sheets-pivot.valueText': string;
43
- 'sheets-pivot.averageName': string;
44
- 'sheets-pivot.countName': string;
45
- 'sheets-pivot.countNumsName': string;
46
- 'sheets-pivot.maxName': string;
47
- 'sheets-pivot.minName': string;
48
- 'sheets-pivot.productName': string;
49
- 'sheets-pivot.stdDevName': string;
50
- 'sheets-pivot.stdDevpName': string;
51
- 'sheets-pivot.sumName': string;
52
- 'sheets-pivot.varName': string;
53
- 'sheets-pivot.varpName': string;
54
- 'sheets-pivot.subTotal': string;
55
- 'sheets-pivot.grandTotal': string;
56
- 'sheets-pivot.value': string;
57
- 'sheets-pivot.blank': string;
58
- 'sheets-pivot.emptyPivot.filter': string;
59
- 'sheets-pivot.emptyPivot.row': string;
60
- 'sheets-pivot.emptyPivot.column': string;
61
- 'sheets-pivot.emptyPivot.values': string;
62
- };
37
+ getTextInfo(): Record<string, string>;
63
38
  setTextInfo(textInfo: Record<string, string>): void;
64
39
  handleMoveRange(params: IMoveRangeMutationParams): void;
65
40
  broadcastCollectionChange(info: ICollectionChangeInfo): void;
@@ -83,7 +58,7 @@ export declare class SheetsPivotDataSourceModel extends Disposable {
83
58
  addPivotTable(unitId: string, subUnitId: string, pivotTableId: string, pivotTable: PivotTable, pivotTableConfig: IPivotTableConfig): void;
84
59
  removePivotTable(unitId: string, subUnitId: string, pivotTableId: string): void;
85
60
  setPivotTable(unitId: string, subUnitId: string, pivotTableId: string, pivotTableConfig: IPivotTableConfig): void;
86
- getPivotTableConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableConfig | null;
61
+ getPivotTableConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableConfig | undefined;
87
62
  /**
88
63
  * - get the pivot table model json config
89
64
  * @param {string} unitId
@@ -94,27 +69,15 @@ export declare class SheetsPivotDataSourceModel extends Disposable {
94
69
  getPivotTableModelConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableSnapshot | undefined;
95
70
  getPivotTableInstance(pivotTableId: string): PivotTable | undefined;
96
71
  deleteUnitId(unitId: string): void;
97
- addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo: IPivotCellPositionInfo): {
98
- collection: FieldsCollection;
99
- updateDataFieldList: {
100
- index: number;
101
- dataField: DataField;
102
- }[];
103
- };
72
+ addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo: IPivotCellPositionInfo): IUpdateInfo;
104
73
  /**
105
74
  * - this function just create a collection with data range info, but wil not add it to the dataFieldManager
106
75
  */
107
- createCollectionWithDataRange(dataRangeInfo: IUnitRangeNameWithSubUnitId): {
108
- updateDataFieldList: {
109
- index: number;
110
- dataField: DataField;
111
- }[];
112
- collection: FieldsCollection;
113
- };
76
+ createCollectionWithDataRange(dataRangeInfo: IUnitRangeNameWithSubUnitId): IUpdateInfo;
114
77
  refreshData(collection: FieldsCollection, updateDataFieldList: {
115
78
  index: number;
116
79
  dataField: DataField;
117
- }[], dataRangeInfo: IUnitRangeName): void;
80
+ }[], dataRangeInfo: IUnitRangeNameWithSubUnitId): void;
118
81
  removeDataField(unitId: string, dataFieldId: string): void;
119
82
  removeCollections(unitId: string, token: string): void;
120
83
  getSubUnitPivotConfigs(unitId: string, subUnitId: string): Map<string, IPivotTableConfig> | undefined;
@@ -1,4 +1,4 @@
1
- import { Nullable, Disposable, Injector, IUniverInstanceService, LocaleService, ObjectMatrix } from '@univerjs/core';
1
+ import { IRange, Nullable, Disposable, Injector, IUniverInstanceService, LocaleService, ObjectMatrix } from '@univerjs/core';
2
2
  import { IPivotRangesInfo, IPivotRenderCache, IPivotTableCellData, IPivotTableConfigChangeInfo, PivotTableOperationEnum } from '../const/type';
3
3
  import { SheetsPivotTableConfigModel } from './sheets-pivot-config-model';
4
4
  export declare class SheetsPivotTableAdaptorModel extends Disposable {
@@ -27,16 +27,24 @@ export declare class SheetsPivotTableAdaptorModel extends Disposable {
27
27
  private _initUnitDisposed;
28
28
  private _initLocale;
29
29
  updateRenderCache(config: IPivotTableConfigChangeInfo): {
30
- rangeCache: IPivotRangesInfo;
30
+ rangeCache: IPivotRangesInfo | undefined;
31
31
  matrix: ObjectMatrix<Nullable<IPivotTableCellData>>;
32
32
  } | undefined;
33
33
  clearRenderCache(config: IPivotTableConfigChangeInfo): void;
34
34
  private _ensurePivotItemRenderInfoCache;
35
35
  private _ensurePivotItemRenderValueMatrixCache;
36
36
  getPivotTableCellData(unitId: string, subUnitId: string, row: number, col: number): IPivotTableCellData | undefined;
37
- getPivotTableIdByCell(unitId: string, subUnitId: string, row: number, col: number): string | undefined;
37
+ getPivotTableIdByCell(unitId: string, subUnitId: string, row: number, col: number): Nullable<string>;
38
+ /**
39
+ * Get pivot table ids that intersect with the range
40
+ * @param {string} unitId The test unit id of range
41
+ * @param {string} subUnitId The sub unit id of range
42
+ * @param {IRange} range The range to check
43
+ * @returns {string[]} The pivot table ids that intersect with the range
44
+ */
45
+ getIntersectsPivotTable(unitId: string, subUnitId: string, range: IRange): string[];
38
46
  getSubUnitPivotMatrix(unitId: string, subUnitId: string): ObjectMatrix<Nullable<IPivotTableCellData>>;
39
- getPivotItemRenderInfoCache(unitId: string, subUnitId: string, pivotTableId: string): IPivotRenderCache | undefined;
47
+ getPivotItemRenderInfoCache(unitId: string, subUnitId: string, pivotTableId: string): Nullable<IPivotRenderCache>;
40
48
  deleteUnitId(unitId: string): void;
41
49
  markDirty(unitId: string, subUnitId: string): void;
42
50
  }