@univerjs-pro/engine-pivot 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { IFieldsCollectionJSON } from '../types';
1
+ import { IDataFieldInfo, IFieldsCollectionJSON } from '../types';
2
2
  import { DataFieldManager } from './data-field-manager';
3
3
  import { DataField } from './data-field';
4
4
  /**
@@ -28,8 +28,8 @@ export declare class FieldsCollection {
28
28
  hasField(fieldId: string): boolean;
29
29
  /**
30
30
  * find the is there has a data field whose name is the same as the sourceName.
31
- * @param sourceName
32
- * @returns
31
+ * @param {string} sourceName - the source name of the field.
32
+ * @returns {boolean} - true if has the field, otherwise false.
33
33
  */
34
34
  hasSourceName(sourceName: string): boolean;
35
35
  setRange(range: any): void;
@@ -63,7 +63,7 @@ export declare class FieldsCollection {
63
63
  * @description Gets the field by the specified name.
64
64
  * @returns {IDataFieldInfo[]} -returns the field infos.
65
65
  */
66
- getFieldInfo(): import('../types').IDataFieldInfo[];
66
+ getFieldInfo(): IDataFieldInfo[];
67
67
  toJSON(): IFieldsCollectionJSON;
68
68
  fromJSON(jsonData: IFieldsCollectionJSON): void;
69
69
  dispose(): void;
@@ -1,4 +1,4 @@
1
- import { IColumnNodeSizeInfo, INodeSizeInfo, IPivotLayoutCtx, IPivotTableLabelFieldQueryData, IPivotTableQueryData } from '../types';
1
+ import { IColumnNodeSizeInfo, INodeSizeInfo, IPivotLayoutCtx, IPivotTableLabelFieldQueryData, IPivotTableQueryData, PivotErrorTypeEnum } from '../types';
2
2
  import { SummaryManager } from '../summary/summary-manager';
3
3
  import { NodeTree } from '../summary/node-tree';
4
4
  import { PivotTable } from '../pivot/pivot-table';
@@ -18,12 +18,7 @@ export declare class BaseLayout {
18
18
  static layoutCorner(ctx: IPivotLayoutCtx): void;
19
19
  static layoutColHeader(ctx: IPivotLayoutCtx): void;
20
20
  static setValueSize(ctx: IPivotLayoutCtx): void;
21
- static layoutNoneColFields(ctx: IPivotLayoutCtx, nodeTree: NodeTree): {
22
- itemSize: number;
23
- topTotalSize: number;
24
- bottomTotalSize: number;
25
- colPathMap: Record<string, number>;
26
- };
21
+ static layoutNoneColFields(ctx: IPivotLayoutCtx, nodeTree: NodeTree): IColumnNodeSizeInfo;
27
22
  static layoutColFields(ctx: IPivotLayoutCtx): void;
28
23
  /**
29
24
  * - the node is leaf node when the level of the node is equal to the deep, but the node is not the real leaf node
@@ -41,7 +36,7 @@ export declare class BaseLayout {
41
36
  * @returns {number} - the value of the node
42
37
  */
43
38
  static getNodeValue(ctx: IPivotLayoutCtx, nodeTree: NodeTree, measureIndex: number): number | {
44
- errorType: import('../types').PivotErrorTypeEnum;
39
+ errorType: PivotErrorTypeEnum;
45
40
  } | undefined;
46
41
  static doColLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, col: number, valueIds: string[]): IColumnNodeSizeInfo;
47
42
  static buildColPathMap(ctx: IPivotLayoutCtx, nodeTree: NodeTree): Record<string, number>;
@@ -2,7 +2,8 @@ import { PivotTable } from '../pivot/pivot-table';
2
2
  import { SummaryManager } from '../summary/summary-manager';
3
3
  import { IPivotLayoutCtx, IPivotTableQueryData } from '../types';
4
4
  import { BaseLayout } from './base-layout';
5
+ import { PivotView } from './pivot-view';
5
6
  export declare class CompactLayout extends BaseLayout {
6
- static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
7
+ static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): PivotView;
7
8
  static layoutRow(ctx: IPivotLayoutCtx): void;
8
9
  }
@@ -2,7 +2,8 @@ import { PivotTable } from '../pivot/pivot-table';
2
2
  import { SummaryManager } from '../summary/summary-manager';
3
3
  import { IPivotLayoutCtx, IPivotTableQueryData } from '../types';
4
4
  import { BaseLayout } from './base-layout';
5
+ import { PivotView } from './pivot-view';
5
6
  export declare class OutlineLayout extends BaseLayout {
6
- static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
7
+ static layout(pivotTable: PivotTable, SummaryManager: SummaryManager, queryData: IPivotTableQueryData): PivotView;
7
8
  static layoutRow(ctx: IPivotLayoutCtx): void;
8
9
  }
@@ -1,5 +1,5 @@
1
1
  import { PivotModel } from '../pivot/model';
2
- import { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotViewErrorValue, IPivotViewInfo, IPivotViewItemData, IPivotViewItemJSON, IPivotViewJSON, IPivotViewPrefixValue, IPivotViewValueType, PivotCellStyleTypeEnum } from '../types';
2
+ import { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotViewCellData, IPivotViewErrorValue, IPivotViewInfo, IPivotViewItemData, IPivotViewItemJSON, IPivotViewJSON, IPivotViewPrefixValue, IPivotViewValueType, PivotCellStyleTypeEnum } from '../types';
3
3
  /**
4
4
  * @class PivotView
5
5
  * @description the view of pivot table, which contains the page, row, col, data view, the page view separation the pivot table to two areas, the row and col view as the header of data area
@@ -63,14 +63,18 @@ export declare class PivotViewItem {
63
63
  info: IPivotViewInfo[];
64
64
  lastCol: number;
65
65
  lastRow: number;
66
+ getLastCol(): number;
67
+ getLastRow(): number;
66
68
  setValue(row: number, col: number, value: IPivotViewValueType): void;
67
69
  setStyle(row: number, col: number, styleType: PivotCellStyleTypeEnum): void;
68
70
  setBlank(row: number, col: number): void;
69
- protected getCell(row: number, col: number): import('../types').IPivotViewCellData;
71
+ protected getCell(row: number, col: number): IPivotViewCellData;
70
72
  setInfo(index: number, info: IPivotViewInfo): void;
71
73
  buildPathMap(considerValue: boolean): Record<string, number>;
72
74
  setRowCount(rowCount: number): void;
73
75
  setColCount(colCount: number): void;
76
+ getRowCount(): number;
77
+ getColCount(): number;
74
78
  getValue(row: number, col: number): IPivotViewValueType;
75
79
  getStyle(row: number, col: number): PivotCellStyleTypeEnum | undefined;
76
80
  toJSON(): IPivotViewItemJSON;
@@ -111,6 +115,12 @@ export declare class LabelViewItem extends PivotViewItem {
111
115
  toJSON(): ILabelViewItemJSON;
112
116
  fromJSON(json: ILabelViewItemJSON): void;
113
117
  }
118
+ export declare class RowViewItem extends LabelViewItem {
119
+ getLastCol(): number;
120
+ }
121
+ export declare class ColViewItem extends LabelViewItem {
122
+ getLastRow(): number;
123
+ }
114
124
  /**
115
125
  * judge the value is the prefix value, once when the value is a subtotal and there are multiple value field, the value will be the prefix value
116
126
  * @param {IPivotViewValueType} value the pivot view value
@@ -1,23 +1,14 @@
1
1
  import { PivotTable } from '../pivot/pivot-table';
2
2
  import { NodeTree } from '../summary/node-tree';
3
3
  import { SummaryManager } from '../summary/summary-manager';
4
- import { INodeSizeInfo, IPivotLayoutCtx, IPivotTableQueryData, IPivotTableValueFieldQueryData, IPivotViewInfo } from '../types';
4
+ import { INodeSizeInfo, IPivotLayoutCtx, IPivotTableQueryData, IPivotTableValueFieldQueryData, IPivotViewInfo, IRowNodeSizeInfo } from '../types';
5
5
  import { BaseLayout } from './base-layout';
6
+ import { PivotView } from './pivot-view';
6
7
  export declare class TabularLayout extends BaseLayout {
7
- static layout(pivotTable: PivotTable, summaryManager: SummaryManager, queryData: IPivotTableQueryData): import('./pivot-view').PivotView;
8
+ static layout(pivotTable: PivotTable, summaryManager: SummaryManager, queryData: IPivotTableQueryData): PivotView;
8
9
  static layoutCorner(ctx: IPivotLayoutCtx): void;
9
10
  static layoutRowFields(ctx: IPivotLayoutCtx): void;
10
- static doRowLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): {
11
- itemSize: number;
12
- topTotalSize: number;
13
- bottomTotalSize: number;
14
- valueIndex?: undefined;
15
- } | {
16
- itemSize: number;
17
- topTotalSize: number;
18
- bottomTotalSize: number;
19
- valueIndex: number;
20
- };
11
+ static doRowLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): IRowNodeSizeInfo;
21
12
  /**
22
13
  * - layout the data area of the pivot table
23
14
  * @param {IPivotLayoutCtx} ctx the context of layout
@@ -31,11 +22,7 @@ export declare class TabularLayout extends BaseLayout {
31
22
  static getMeasureInfoByIndex(ctx: IPivotLayoutCtx, valueQueryInfo: IPivotTableValueFieldQueryData[], rowInfo: IPivotViewInfo, colInfo: IPivotViewInfo): IPivotTableValueFieldQueryData;
32
23
  static layoutValueLeafNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, paths: string[], measureIndex: number): void;
33
24
  static getColIndexForRowHeader(nodeLevel: number, valueIndex: number, hasMultiValue: boolean): number;
34
- static doRowBrachNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): {
35
- itemSize: number;
36
- topTotalSize: number;
37
- bottomTotalSize: number;
38
- };
25
+ static doRowBrachNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): INodeSizeInfo;
39
26
  static layoutRowNode(ctx: IPivotLayoutCtx, nodeTree: NodeTree, row: number, valueIds: string[]): INodeSizeInfo;
40
27
  static updateRowSubtotal(ctx: IPivotLayoutCtx, row: number, nodeTree: NodeTree, valueIds: string[]): void;
41
28
  }
@@ -94,16 +94,7 @@ export declare class PivotModel {
94
94
  * - Get the options of the pivot table. It is a copy of the options.
95
95
  * @returns {IPivotTableOptions} - The options of the pivot table.
96
96
  */
97
- getOptions(): {
98
- pageWrap?: number;
99
- pageOverThenDown?: boolean;
100
- showColHeaders?: boolean;
101
- showColStripes?: boolean;
102
- showLastColumn?: boolean;
103
- showRowHeaders?: boolean;
104
- showRowStripes?: boolean;
105
- mergeItems?: boolean;
106
- };
97
+ getOptions(): IPivotTableOptions;
107
98
  /**
108
99
  * @description Set the collapse status of the field. Those properties are used to save the collapse status of the field in the pivot table.
109
100
  * @param {string} fieldId - The id of the field.
@@ -115,7 +106,7 @@ export declare class PivotModel {
115
106
  getFieldFormat(fieldId: string): string | undefined;
116
107
  setFieldFormat(fieldId: string, format: string | undefined): void;
117
108
  setSortInfo(fieldId: string, sortInfo: IPivotTableSortInfo | undefined): void;
118
- getSortInfo(fieldId: string): import('../types').IPivotTableLabelSortInfo | undefined;
109
+ getSortInfo(fieldId: string): IPivotTableSortInfo | undefined;
119
110
  getFilterInfo(fieldId: string): IPivotTableFilterInfo | undefined;
120
111
  iterateField(callback: (field: PivotTableLabelField | PivotTableValueField) => void): void;
121
112
  iterateFieldDim(callback: (field: PivotTableLabelField) => void): void;
@@ -129,12 +120,12 @@ export declare class PivotModel {
129
120
  */
130
121
  addField(field: PivotTableLabelField | PivotTableValueField, area: PivotTableFiledAreaEnum, index?: number): void;
131
122
  /**
132
- * @description get where the field bo be position info by field id.
123
+ * @description Get where the field bo be position info by field id.
133
124
  * @param {string} fieldId - The id of the field.
134
- * @typedef
125
+ * @typedef PositionInfo
135
126
  * @property {PivotTableFiledAreaEnum} area - The area of the field.
136
127
  * @property {number} index - The index of the field in the area.
137
- * @returns PivotTableFiledAreaEnum
128
+ * @returns PositionInfo - The position info of the field. if the field is not in the pivot table, the area will be undefined and the index will be -1.
138
129
  */
139
130
  getFieldPositionInfoById(fieldId: string): {
140
131
  area: PivotTableFiledAreaEnum | undefined;
@@ -142,7 +133,7 @@ export declare class PivotModel {
142
133
  };
143
134
  updateFieldSourceInfo(fieldId: string, sourceName: string, dataFieldId: string): void;
144
135
  getFieldsAreaByType(type: PivotTableFiledAreaEnum): string[];
145
- getFieldById(fieldId: string): PivotTableValueField | PivotTableLabelField | undefined;
136
+ getFieldById(fieldId: string): PivotTableLabelField | PivotTableValueField | undefined;
146
137
  isExistFieldName(fieldName: string): boolean;
147
138
  /**
148
139
  * @description Rename a field in the pivot table.
@@ -1,6 +1,7 @@
1
1
  import { FieldsCollection } from '../field/fields-collection';
2
- import { PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
2
+ import { PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
3
3
  import { DataField } from '../field/data-field';
4
+ import { PivotView } from '../layout/pivot-view';
4
5
  import { PivotModel } from './model';
5
6
  import { PivotTableLabelField, PivotTableValueField } from './table-field';
6
7
  /**
@@ -18,7 +19,7 @@ export declare class PivotTable {
18
19
  updateDataFieldsCollection(dataFieldsCollection: FieldsCollection): void;
19
20
  private _getModel;
20
21
  startCollectChangeset(): void;
21
- endCollectChangeset(): import('../types').IPivotTableChangeSet[];
22
+ endCollectChangeset(): IPivotTableChangeSet[];
22
23
  _generateModel(): void;
23
24
  createLabelFieldByDataFieldId(dataFieldId: string, tableName?: string): PivotTableLabelField | undefined;
24
25
  createValueFieldByDataFieldId(dataFieldId: string): PivotTableValueField | undefined;
@@ -98,7 +99,7 @@ export declare class PivotTable {
98
99
  * @param {string} dataFieldId the data field id
99
100
  * @returns {DataField|undefined} the data field or undefined
100
101
  */
101
- getDataFieldByDataFieldId(dataFieldId: string): DataField;
102
+ getDataFieldByDataFieldId(dataFieldId: string): DataField | undefined;
102
103
  getDataFieldItemInfo(dataField: DataField): {
103
104
  items: string[];
104
105
  itemTypes: PivotDataFieldDataTypeEnum[];
@@ -111,7 +112,7 @@ export declare class PivotTable {
111
112
  * @param {number} [index] the position of the field in the area, if not set, the field will be added to the end of the area.
112
113
  * @returns {PivotTableLabelField|PivotTableValueField} the added field
113
114
  */
114
- addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number): PivotTableValueField | PivotTableLabelField | undefined;
115
+ addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number): PivotTableLabelField | PivotTableValueField | undefined;
115
116
  setOptions(options: IPivotTableOptions): void;
116
117
  /**
117
118
  * the func is only use for when refresh
@@ -149,14 +150,14 @@ export declare class PivotTable {
149
150
  * @param fieldId - The id of the field.
150
151
  * @returns {IPivotTableSortInfo} -The sort information of the field.
151
152
  */
152
- getSortInfo(fieldId: string): import('../types').IPivotTableLabelSortInfo | undefined;
153
+ getSortInfo(fieldId: string): IPivotTableSortInfo | undefined;
153
154
  getFilterInfo(fieldId: string): IPivotTableFilterInfo | undefined;
154
155
  /**
155
156
  * get the filter information by the filter index
156
157
  * @param {number} index - The index of the filter field.
157
158
  * @returns {string | undefined} the table field id
158
159
  */
159
- getFilterFieldIdByIndex(index: number): string;
160
+ getFilterFieldIdByIndex(index: number): string | undefined;
160
161
  /**
161
162
  * - set the position of the field in the pivot table. which used in pivot panel drag field.
162
163
  * @param {string} fieldId - The id of the pivot table field.
@@ -189,16 +190,7 @@ export declare class PivotTable {
189
190
  */
190
191
  addField(field: PivotTableLabelField | PivotTableValueField, area: PivotTableFiledAreaEnum, index?: number): void;
191
192
  removeField(fieldId: string): void;
192
- getOptions(): {
193
- pageWrap?: number;
194
- pageOverThenDown?: boolean;
195
- showColHeaders?: boolean;
196
- showColStripes?: boolean;
197
- showLastColumn?: boolean;
198
- showRowHeaders?: boolean;
199
- showRowStripes?: boolean;
200
- mergeItems?: boolean;
201
- };
193
+ getOptions(): IPivotTableOptions;
202
194
  /**
203
195
  * @description Set the collapse status of the field. Those properties are used to save the collapse status of the field in the pivot table.
204
196
  * @param {string} fieldId - The id of the field.
@@ -212,12 +204,17 @@ export declare class PivotTable {
212
204
  * @returns {boolean} - need query or not
213
205
  */
214
206
  getNeedQuery(viewVersion: number): boolean;
207
+ /**
208
+ * @description Get the field position information by the field id.
209
+ * @param {string} fieldId the field id
210
+ * @returns {PositionInfo} - The position information of the field or undefined.
211
+ */
215
212
  getFieldPositionInfoById(fieldId: string): {
216
213
  area: PivotTableFiledAreaEnum | undefined;
217
214
  index: number;
218
215
  };
219
216
  private _getTupleCache;
220
- query(config?: IPivotTableQueryData): import('..').PivotView;
217
+ query(config?: IPivotTableQueryData): PivotView;
221
218
  toJSON(): IPivotTableSnapshot;
222
219
  fromJSON(data: IPivotTableSnapshot): void;
223
220
  dispose(): void;
@@ -44,5 +44,5 @@ export declare class NodeTree {
44
44
  setName(name: string): void;
45
45
  addNode(node: NodeTree, path: string, sortMap: Record<string, number> | undefined, isAsc: boolean): void;
46
46
  sortNode(path: string, sortedMap: Record<string, number>, isAsc: boolean): void;
47
- getNode(path: string): NodeTree;
47
+ getNode(path: string): NodeTree | undefined;
48
48
  }
@@ -1,5 +1,5 @@
1
1
  import { DataField } from '../field/data-field';
2
- import { IDimensionMapItem, IMeasuresMapItem, IPivotSummaryLevelPool, IPivotTableQueryData, ITupleItem, PivotSubtotalTypeEnum, PivotDataFieldSortOperatorEnum } from '../types';
2
+ import { IDimensionMapItem, IMeasuresMapItem, IPivotSummaryLevelPool, IPivotTableQueryData, ITupleItem, PivotErrorTypeEnum, PivotSubtotalTypeEnum, PivotDataFieldSortOperatorEnum } from '../types';
3
3
  import { NodeTree } from './node-tree';
4
4
  import { TupleGroup } from './tuple-group';
5
5
  export declare class SummaryManager {
@@ -47,7 +47,7 @@ export declare class SummaryManager {
47
47
  constructor(queryData: IPivotTableQueryData, tupleGroup: TupleGroup);
48
48
  createSummaryLabelSortedMap(queryData: IPivotTableQueryData): void;
49
49
  getCellValue(index: number, id: string, subtotal: PivotSubtotalTypeEnum): number | {
50
- errorType: import('../types').PivotErrorTypeEnum;
50
+ errorType: PivotErrorTypeEnum;
51
51
  } | undefined;
52
52
  getSortedMap(tableFieldId: string, dataField: DataField): Record<string, number>;
53
53
  doSummary(): void;
@@ -174,6 +174,9 @@ export interface INodeSizeInfo {
174
174
  export interface IColumnNodeSizeInfo extends INodeSizeInfo {
175
175
  colPathMap: Record<string, number>;
176
176
  }
177
+ export interface IRowNodeSizeInfo extends INodeSizeInfo {
178
+ valueIndex?: number;
179
+ }
177
180
  export interface IPivotLayoutCtx {
178
181
  view: PivotView;
179
182
  rowDeep: number;