@univerjs-pro/engine-pivot 0.6.1 → 0.6.2

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.
@@ -0,0 +1,2 @@
1
+ import { IPivotTableCustomFilter, IPivotTableValueFilter } from './types';
2
+ export declare function getFilterExecuteFunc(filterInfo: IPivotTableValueFilter | IPivotTableCustomFilter): (value: number) => boolean;
@@ -1,4 +1,4 @@
1
- import { IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotSubtotalTypeEnum, PivotLayoutTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
1
+ import { IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem, PivotSubtotalTypeEnum, PivotLayoutTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '../types';
2
2
  import { PivotTableLabelField, PivotTableValueField } from './table-field';
3
3
  /**
4
4
  * @class PivotModel represents a config model for a pivot table.
@@ -71,6 +71,7 @@ export declare class PivotModel {
71
71
  * the dirty status is used to flag the pivot table need to be queried data from the data source or just use cached tuple data.
72
72
  */
73
73
  private _isDirty;
74
+ private _valueFilterInfo;
74
75
  constructor();
75
76
  startChangeStack(): void;
76
77
  endChangeStack(): IPivotTableChangeSet[];
@@ -102,7 +103,12 @@ export declare class PivotModel {
102
103
  * @param {string} [item] - The item of the field.
103
104
  */
104
105
  setCollapse(fieldId: string, collapse: boolean, item?: string): void;
105
- setFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
106
+ setLabelFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
107
+ setValueFilterInfo(fieldId: string, filterInfo: IPivotTableValueFilter | undefined): void;
108
+ getValueFilterInfo(fieldId: string): IPivotTableValueFilter | undefined;
109
+ getValueFilterInfos(): IValueFilterInfoItem[];
110
+ removeValueFilterInfo(fieldId: string): void;
111
+ removeValueFilterInfoByValueFieldId(valueFieldId: string): void;
106
112
  getFieldFormat(fieldId: string): string | undefined;
107
113
  setFieldFormat(fieldId: string, format: string | undefined): void;
108
114
  setSortInfo(fieldId: string, sortInfo: IPivotTableSortInfo | undefined): void;
@@ -1,7 +1,7 @@
1
1
  import { DataField } from '../field/data-field';
2
2
  import { FieldsCollection } from '../field/fields-collection';
3
3
  import { PivotView } from '../layout/pivot-view';
4
- import { IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, PivotCallbackEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum } from '../types';
4
+ import { IPivotTableChangeSet, IPivotTableFilterInfo, IPivotTableOptions, IPivotTableQueryData, IPivotTableSnapshot, IPivotTableSortInfo, IPivotTableValueFilter, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, PivotCallbackEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum } from '../types';
5
5
  import { PivotModel } from './model';
6
6
  import { PivotTableLabelField, PivotTableValueField } from './table-field';
7
7
  /**
@@ -21,7 +21,7 @@ export declare class PivotTable {
21
21
  * Register callback functions that are executed at certain times
22
22
  * @param {PivotCallbackEnum} event - Enumeration of execution time
23
23
  * @param {(id?: string) => void} callback - Callback Function
24
- */
24
+ */
25
25
  static registerCallbackWithEvent(event: PivotCallbackEnum, callback: (id?: string) => void): void;
26
26
  /**
27
27
  * Unregisters the callback function from the specified event.
@@ -35,8 +35,8 @@ export declare class PivotTable {
35
35
  startCollectChangeset(): void;
36
36
  endCollectChangeset(): IPivotTableChangeSet[];
37
37
  _generateModel(): void;
38
- createLabelFieldByDataFieldId(dataFieldId: string, tableName?: string): PivotTableLabelField | undefined;
39
- createValueFieldByDataFieldId(dataFieldId: string): PivotTableValueField | undefined;
38
+ createLabelFieldByDataFieldId(dataFieldId: string, tableName?: string, provideTableFieldId?: string): PivotTableLabelField | undefined;
39
+ createValueFieldByDataFieldId(dataFieldId: string, provideTableFieldId?: string): PivotTableValueField | undefined;
40
40
  updateValuePosition(valuePosition: PivotTableValuePositionEnum, valueIndex: number): void;
41
41
  isColMultiMeasure(): boolean;
42
42
  isRowMultiMeasure(): boolean;
@@ -137,7 +137,7 @@ export declare class PivotTable {
137
137
  * @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.
138
138
  * @returns {PivotTableLabelField|PivotTableValueField} the added field
139
139
  */
140
- addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number): PivotTableLabelField | PivotTableValueField | undefined;
140
+ addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number, provideTableFieldId?: string): PivotTableLabelField | PivotTableValueField | undefined;
141
141
  setOptions(options: IPivotTableOptions): void;
142
142
  /**
143
143
  * the func is only use for when refresh
@@ -163,7 +163,7 @@ export declare class PivotTable {
163
163
  * @param fieldId
164
164
  * @param filterInfo
165
165
  */
166
- setFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
166
+ setLabelFilterInfo(fieldId: string, filterInfo: IPivotTableFilterInfo): void;
167
167
  /**
168
168
  * - Set the sort information of the dimension field. only the dimension field can set the sort information.
169
169
  * @param {string} fieldId - The id of the field.
@@ -242,6 +242,33 @@ export declare class PivotTable {
242
242
  index: number;
243
243
  };
244
244
  private _getTupleCache;
245
+ /**
246
+ * Set the value filter information of the pivot table.
247
+ * @param {string} fieldId The base label field id of the value filter.
248
+ * @param {IPivotTableValueFilter} filterInfo The value filter information.
249
+ */
250
+ setValueFilterInfo(fieldId: string, filterInfo: IPivotTableValueFilter | undefined): void;
251
+ /**
252
+ * Get the value filter information list of the pivot table.
253
+ * @returns {IPivotTableValueFilter[]} The value filter information list.
254
+ */
255
+ getValueFilterInfos(): import('..').IValueFilterInfoItem[];
256
+ /**
257
+ * Get the value filter information of the pivot table by the field id.
258
+ * @param {string} fieldId The base label field id of the value filter.
259
+ * @returns {IPivotTableValueFilter | undefined} The value filter information.
260
+ */
261
+ getValueFilterInfo(fieldId: string): IPivotTableValueFilter | undefined;
262
+ /**
263
+ * Remove the value filter information of the pivot table by the field id.
264
+ * @param fieldId
265
+ */
266
+ removeValueFilterInfo(fieldId: string): void;
267
+ /**
268
+ * Remove the value filter information of the pivot table by the value field id.
269
+ * @param {string} valueFieldId The value field id of the value filter.
270
+ */
271
+ removeValueFilterInfoByValueFieldId(valueFieldId: string): void;
245
272
  /**
246
273
  * Find the tupleItem in the cache that matches the position order according to the passed array,
247
274
  * and after obtaining the row number array marked on it,
@@ -249,7 +276,7 @@ export declare class PivotTable {
249
276
  *
250
277
  * The key point here is that `dimensionIdList` and `dimensionTableIdList` are one-to-one index corresponding
251
278
  *
252
- * @param {string[][]} -A two-dimensional array with path and tableFieldId
279
+ * @param {string[][]} tuple -A two-dimensional array with path and tableFieldId
253
280
  * @returns {number[]} -Sorted row numbers
254
281
  */
255
282
  getIndexesByPathStr(tuple: string[][]): number[];
@@ -1,7 +1,7 @@
1
1
  import { DataField } from '../field/data-field';
2
- import { IDimensionMapItem, IMeasuresMapItem, IPivotSummaryLevelPool, IPivotTableQueryData, ITupleItem, PivotErrorTypeEnum, PivotSubtotalTypeEnum, PivotDataFieldSortOperatorEnum } from '../types';
3
- import { NodeTree } from './node-tree';
2
+ import { IDimensionMapItem, IMeasuresMapItem, IPivotSummaryLevelPool, IPivotTableQueryData, IPivotTableValueFilter, ITupleItem, IValueFilterInfoItem, PivotErrorTypeEnum, PivotSubtotalTypeEnum, PivotDataFieldSortOperatorEnum } from '../types';
4
3
  import { TupleGroup } from './tuple-group';
4
+ import { NodeTree } from './node-tree';
5
5
  export declare class SummaryManager {
6
6
  counter: number;
7
7
  rowDimOrder: number[];
@@ -44,6 +44,11 @@ export declare class SummaryManager {
44
44
  type: PivotDataFieldSortOperatorEnum;
45
45
  sortMap: Record<string, number>;
46
46
  }>;
47
+ valueFilterInfo: IValueFilterInfoItem[];
48
+ subtotalMap: Record<string, {
49
+ subTotal: PivotSubtotalTypeEnum;
50
+ dataFieldId: string;
51
+ }>;
47
52
  constructor(queryData: IPivotTableQueryData, tupleGroup: TupleGroup);
48
53
  createSummaryLabelSortedMap(queryData: IPivotTableQueryData): void;
49
54
  getCellValue(index: number, id: string, subtotal: PivotSubtotalTypeEnum): number | {
@@ -52,12 +57,12 @@ export declare class SummaryManager {
52
57
  getSortedMap(tableFieldId: string, dataField: DataField): Record<string, number>;
53
58
  doSummary(): void;
54
59
  private _getIndex;
55
- buildNodeTree(): void;
60
+ buildNodeTree(ignoreLeafSet: Set<number>): void;
56
61
  createTupleWithoutCheck(paths: string[], nodeIndex: number, tupleKey: string): void;
57
- _buildNodeTreeImp(dimOrder: number[], tableIdList: string[], levelPool: IPivotSummaryLevelPool, nodePathStr: string): NodeTree;
62
+ _buildNodeTreeImp(dimOrder: number[], tableIdList: string[], levelPool: IPivotSummaryLevelPool, nodePathStr: string, ignoreLeafSet: Set<number>): NodeTree;
58
63
  combinePathMapList(colPathMapList: Record<string, number>[], basePath: string): Record<string, number>;
59
64
  calculateListSubtotal(tupleItem: ITupleItem, indexes: number[]): void;
60
- calculateSubtotal(): void;
65
+ calculateSubtotal(ignoreLeafSet: Set<number>): void;
61
66
  getPathKeyWithFiledId(paths: string[], tableIdList: string[]): string;
62
67
  ensureTupleItem(index: number, paths: string[], tableIdList: string[]): void;
63
68
  ensureTupleItemByString(index: number, pathString: string): void;
@@ -68,5 +73,15 @@ export declare class SummaryManager {
68
73
  * @returns {void}
69
74
  */
70
75
  createTuple(paths: string[], pathsStr?: string, nodeIndex?: number): void;
71
- _calculateSubtotalImp(levelPool: IPivotSummaryLevelPool): void;
76
+ _calculateValueFilter(): Set<number>;
77
+ _doValueFilter(fieldId: string, valueFieldId: string, filterInfo: IPivotTableValueFilter, leafSet: Set<number>): void;
78
+ /**
79
+ * get the filter tree by fieldId, if the fieldId is in rowTableIdList, return rowNodeTree, if the fieldId is in colTableIdList, return colNodeTree
80
+ * @param fieldId The base field id of the value filter.
81
+ */
82
+ _getValueFilterTree(fieldId: string): {
83
+ pool: IPivotSummaryLevelPool;
84
+ fieldIdList: string[];
85
+ } | null;
86
+ _calculateSubtotalImp(levelPool: IPivotSummaryLevelPool, ignoreLeafSet: Set<number>): void;
72
87
  }
@@ -93,6 +93,7 @@ export interface IPivotTableValueFilter {
93
93
  type: PivotFilterTypeEnum.ValueFilter;
94
94
  operator: ST_PivotFilterOperatorEnum;
95
95
  expected: any;
96
+ valueFieldId: string;
96
97
  }
97
98
  export interface IPivotTableShowDataAsInfo {
98
99
  type: PivotShowAsTypeEnum;
@@ -149,6 +150,10 @@ export interface IPivotTableQueryData {
149
150
  * @property {Record<string, boolean|Record<string, boolean>>} - The collapse state of the pivot table.
150
151
  */
151
152
  collapseInfo: Record<string, boolean | Record<string, boolean>>;
153
+ /**
154
+ * The value filter info of the pivot table. The ordered should be ensured, because the value filter must be applied in order.
155
+ */
156
+ valueFilterInfo: IValueFilterInfoItem[];
152
157
  }
153
158
  /**
154
159
  * Represents the query data for a value field in a pivot table.
@@ -184,4 +189,17 @@ export interface IPivotTableMeasureData {
184
189
  */
185
190
  values: IPivotTableValueFieldQueryData[];
186
191
  }
192
+ /**
193
+ * Represents the value filer item of the pivot table.
194
+ */
195
+ export interface IValueFilterInfoItem {
196
+ /**
197
+ * @property {string} - The base field id of the value filter.
198
+ */
199
+ fieldId: string;
200
+ /**
201
+ * @property {string} - The value field item of the value filter.
202
+ */
203
+ filterInfo: IPivotTableValueFilter;
204
+ }
187
205
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PivotDataFieldDataTypeEnum, PivotLayoutTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from './enum';
2
- import { IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo } from './interface';
2
+ import { IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem } from './interface';
3
3
  import { IPivotTableOptions } from './layout-type';
4
4
  export interface IPivotTableValueFieldJSON {
5
5
  dataFieldId: string;
@@ -68,6 +68,10 @@ export interface IPivotTableSnapshot {
68
68
  */
69
69
  collapseInfo: Record<string, any>;
70
70
  options: IPivotTableOptions;
71
+ /**
72
+ * Represents the value filter information of the pivot table.The ordered should be ensured, because the value filter must be applied in order.
73
+ */
74
+ valueFilter: IValueFilterInfoItem[];
71
75
  }
72
76
  export interface IFieldsCollectionJSON {
73
77
  fieldIds: string[];
@@ -142,7 +146,11 @@ export declare enum PivotTableChangeTypeEnum {
142
146
  /**
143
147
  * Update source of the field in the pivot table.
144
148
  */
145
- UpdateSource = 11
149
+ UpdateSource = 11,
150
+ /**
151
+ * Set value filter to the field in the pivot table.
152
+ */
153
+ SetValueFilter = 12
146
154
  }
147
155
  /**
148
156
  * The change of adding field to the pivot table.
@@ -353,6 +361,24 @@ export interface IPivotTableSetFilterInfoChange {
353
361
  */
354
362
  newFilterInfo: IPivotTableFilterInfo;
355
363
  }
364
+ export interface IPivotTableSetValueFilterChange {
365
+ /**
366
+ * @property {PivotTableChangeTypeEnum} type The type of the change.
367
+ */
368
+ type: PivotTableChangeTypeEnum.SetValueFilter;
369
+ /**
370
+ * @property {string} fieldId The pivot table field id.
371
+ */
372
+ fieldId: string;
373
+ /**
374
+ * @property {IPivotTableValueFilter} oldFilterInfo The old filter information.
375
+ */
376
+ oldFilterInfo: IPivotTableValueFilter | undefined;
377
+ /**
378
+ * @property {IPivotTableValueFilter} filterInfo The new filter information.
379
+ */
380
+ filterInfo: IPivotTableValueFilter | undefined;
381
+ }
356
382
  /**
357
383
  * The change of setting sort information to the field in the pivot table.
358
384
  */
@@ -416,4 +442,4 @@ export interface IPivotTableSetCollapseChange {
416
442
  */
417
443
  item?: string;
418
444
  }
419
- export type IPivotTableChangeSet = IPivotTableAddFieldChange | IPivotTableSetSubtotalTypeChange | IPivotTableRemoveFieldChange | IPivotTableRenameFieldChange | IPivotTableSetFilterInfoChange | IPivotTableSetSortInfoChange | IPivotTableUpdatePositionChange | IPivotTableUpdateValuePositionChange | IPivotTableSetOptionsChange | IPivotTableSetFormatChange | IPivotTableSetCollapseChange | IPivotUpdateSourceChange;
445
+ export type IPivotTableChangeSet = IPivotTableAddFieldChange | IPivotTableSetSubtotalTypeChange | IPivotTableRemoveFieldChange | IPivotTableRenameFieldChange | IPivotTableSetFilterInfoChange | IPivotTableSetSortInfoChange | IPivotTableUpdatePositionChange | IPivotTableUpdateValuePositionChange | IPivotTableSetOptionsChange | IPivotTableSetFormatChange | IPivotTableSetCollapseChange | IPivotUpdateSourceChange | IPivotTableSetValueFilterChange;
@@ -2,7 +2,7 @@ import { PivotView } from '../layout/pivot-view';
2
2
  import { NodeTree } from '../summary/node-tree';
3
3
  import { SummaryManager } from '../summary/summary-manager';
4
4
  import { PivotErrorTypeEnum } from './enum';
5
- import { IPivotTableQueryData, IPivotTableValueFieldQueryData } from './interface';
5
+ import { IPivotTableQueryData, IPivotTableValueFieldQueryData, IValueFilterInfoItem } from './interface';
6
6
  export interface IPivotViewItemData {
7
7
  [row: number]: IPivotViewColData;
8
8
  }
@@ -201,6 +201,7 @@ export interface IPivotLayoutCtx {
201
201
  measureIndexesMap: Record<string, number>;
202
202
  collapseInfo: Record<string, boolean | Record<string, boolean>>;
203
203
  repeatRowLabels: boolean;
204
+ valueFilterMap: Record<string, IValueFilterInfoItem>;
204
205
  }
205
206
  export interface IPageViewItemRange {
206
207
  row: number;
@@ -1,4 +1,5 @@
1
- import { IDataFieldValue, IDateValue, IMeasuresMapItem, IPivotTableCustomFilter, IPivotTableFilterInfo, IPivotTableManualFilter, IPivotTableSortInfo, ITupleItem, PivotCellStyleTypeEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, ST_PivotFilterOperatorEnum } from './types';
1
+ import { IDataFieldValue, IDateValue, IMeasuresMapItem, IPivotTableCustomFilter, IPivotTableFilterInfo, IPivotTableManualFilter, IPivotTableSortInfo, ITupleItem, IValueFilterInfoItem, PivotErrorTypeEnum, ST_PivotFilterOperatorEnum, PivotCellStyleTypeEnum, PivotDataFieldDataTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum } from './types';
2
+ import { PivotTuple } from './summary/pivot-tuple';
2
3
  /**
3
4
  * - judge the value is date like type
4
5
  * @param {IDataFieldValue} value the date like value
@@ -100,7 +101,7 @@ export declare function getFilterStatusAndValue(filterInfo: IPivotTableFilterInf
100
101
  * @param {IPivotTableSortInfo} sortInfo the sort info
101
102
  * @returns {PivotCellStyleTypeEnum} the cell style type
102
103
  */
103
- export declare function getDimFilterSortStatus(filterInfo: IPivotTableFilterInfo | undefined, sortInfo: IPivotTableSortInfo): PivotCellStyleTypeEnum;
104
+ export declare function getDimFilterSortStatus(filterInfo: IPivotTableFilterInfo | undefined, sortInfo: IPivotTableSortInfo, valueFilterInfo: IValueFilterInfoItem): PivotCellStyleTypeEnum;
104
105
  /**
105
106
  * - use the paths and value index to get the unique key of in layout pivot view, which use same rule to create the key in pivot engine
106
107
  * @param {string[]} paths - the paths of the cell
@@ -123,3 +124,12 @@ export declare function unionSortedList(arrays: number[][]): number[];
123
124
  */
124
125
  export declare function sortLabelItem(items: string[], itemTypes: PivotDataFieldDataTypeEnum[], itemsMap: Record<string, number>): Record<string, number>;
125
126
  export declare function getCustomNumberFilterResultTemp(indexesMap: Record<string, number[]>, operator: ST_PivotFilterOperatorEnum, expected: number | [number, number]): number[][];
127
+ export interface IValueFilterSummaryListItem {
128
+ tuple: PivotTuple;
129
+ }
130
+ export declare function subtotalTupleItemForValueFilter(summaryList: IValueFilterSummaryListItem[], tupleItem: ITupleItem | undefined, fieldId: string, subtotal: PivotSubtotalTypeEnum, v: number, p: number): void;
131
+ export declare function isErrorTypeSubtotal(subtotal: number | {
132
+ errorType: PivotErrorTypeEnum;
133
+ }): subtotal is {
134
+ errorType: PivotErrorTypeEnum;
135
+ };