@univerjs-pro/engine-pivot 1.1.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { PivotDateGroupFieldDateSystemEnum } from './types';
1
+ import { DateSystem } from '@univerjs/core';
2
2
  /**
3
3
  * @description blank placeholder for empty cells
4
4
  * the get/set functions are used to allow for customization
@@ -12,7 +12,7 @@ export declare const GlobalConfig: {
12
12
  BLANK_PLACEHOLDER: string;
13
13
  isDev: boolean;
14
14
  defaultSortType: string;
15
- dateSystem: PivotDateGroupFieldDateSystemEnum;
15
+ dateSystem: DateSystem;
16
16
  maxLimitItemCount: number;
17
17
  otherDataKey: string;
18
18
  };
@@ -28,7 +28,7 @@ export declare const setDefaultSortType: (type: "ascending" | "descending" | "de
28
28
  * @param value The date system to use, either date1900 ,date1904
29
29
  * @returns {void}
30
30
  */
31
- export declare const setDateSystem: (value: PivotDateGroupFieldDateSystemEnum) => PivotDateGroupFieldDateSystemEnum;
31
+ export declare const setDateSystem: (value: DateSystem) => DateSystem;
32
32
  /**
33
33
  * allows to set the max limit count for row/col fields
34
34
  * @param value The max limit count, must be greater than 0, the default value is 1000
@@ -1,4 +1,4 @@
1
- import type { IBaseGroupFieldInfo, IBaseGroupFieldJSON, IPivotTableDateGroupInfo, PivotDataFieldTypeEnum } from '../types';
1
+ import type { IBaseGroupFieldInfo, IBaseGroupFieldJSON, IPivotTableGroupInfo, PivotDataFieldTypeEnum } from '../types';
2
2
  import { DataField } from './data-field';
3
3
  export declare abstract class BaseGroupField extends DataField {
4
4
  protected originalFieldId: string;
@@ -7,9 +7,15 @@ export declare abstract class BaseGroupField extends DataField {
7
7
  * @returns {PivotDataFieldTypeEnum} - The group type
8
8
  */
9
9
  abstract getDataFieldType(): PivotDataFieldTypeEnum;
10
- abstract getGroupInfo(): IPivotTableDateGroupInfo;
10
+ abstract getGroupInfo(): IPivotTableGroupInfo | undefined;
11
11
  abstract getOriginFieldId(): string;
12
12
  abstract refreshGroupField(originalField: DataField): void;
13
+ getTupleKey(index: number): string;
14
+ getTupleItemsMap(): Record<string, number>;
15
+ getTupleIndexesByKey(key: string): number[];
16
+ getTupleLabel(key: string): string;
17
+ getTupleType(key: string): import("..").PivotDataFieldDataTypeEnum;
18
+ getTupleKeysByLabel(label: string): string[];
13
19
  getFieldInfo(): IBaseGroupFieldInfo;
14
20
  toJSON(): IBaseGroupFieldJSON;
15
21
  }
@@ -0,0 +1,3 @@
1
+ import type { IDataFieldJSON } from '../types';
2
+ import { DataField } from './data-field';
3
+ export declare function createDataFieldFromJSON(json: IDataFieldJSON): DataField;
@@ -1,4 +1,4 @@
1
- import type { IDataFieldManagerBaseJSON, IDataFieldValue, PivotSubtotalTypeEnum } from '../types';
1
+ import type { IDataFieldManagerBaseJSON, IDataFieldValue, IPivotTableRecordFilter, PivotSubtotalTypeEnum } from '../types';
2
2
  import { DataField } from './data-field';
3
3
  import { FieldsCollection } from './fields-collection';
4
4
  type autoDisplayNameFunction = (name: string, subtotalType: PivotSubtotalTypeEnum) => string;
@@ -6,6 +6,7 @@ export declare abstract class DataFieldManager {
6
6
  dataFields: Record<string, DataField>;
7
7
  collections: Record<string, FieldsCollection>;
8
8
  constructor();
9
+ compileRecordFilter(_filter: IPivotTableRecordFilter): (value: IDataFieldValue) => boolean;
9
10
  createDataFieldId(): string;
10
11
  getAutoDisplayNameFunction(): autoDisplayNameFunction | null;
11
12
  getNoUsedDataFieldIds(excludeCollectionToken: string): string[];
@@ -1,5 +1,6 @@
1
- import type { IDataFieldInfo, IDataFieldJSON, IDataFieldValue } from '../types';
2
- import { PivotDataFieldDataTypeEnum, PivotDataFieldTypeEnum } from '../types';
1
+ import type { IDataFieldInfo, IDataFieldValue } from '../types/interface';
2
+ import type { IDataFieldJSON } from '../types/json-types';
3
+ import { PivotDataFieldDataTypeEnum, PivotDataFieldTypeEnum } from '../types/enum';
3
4
  /**
4
5
  * Represents a data field in a pivot table , it match the excel pivot cache field data structure.
5
6
  * @param {string} id - The unique identifier of the data field.
@@ -59,6 +60,10 @@ export declare class DataField {
59
60
  * @property {boolean} hasText - Whether the data field has text value.
60
61
  */
61
62
  hasText: boolean;
63
+ /** Whether the data field contains boolean values. */
64
+ hasBoolean: boolean;
65
+ /** Whether the data field contains formula error values. */
66
+ hasError: boolean;
62
67
  /**
63
68
  * @property {string} format - The format of the data field. only date field has format property, the format is the date format string.
64
69
  */
@@ -88,6 +93,21 @@ export declare class DataField {
88
93
  */
89
94
  private _itemsMap;
90
95
  private _keyCounter;
96
+ private readonly _tupleItemsMap;
97
+ private readonly _tupleIndexMap;
98
+ private readonly _tupleLabels;
99
+ private readonly _tupleTypes;
100
+ private readonly _recordTupleKeys;
101
+ private readonly _tupleKeysByLabel;
102
+ private readonly _overflowRecordIndexes;
103
+ private _tupleKeyCounter;
104
+ private _tupleItemCounter;
105
+ getTupleKey(index: number): string;
106
+ getTupleItemsMap(): Record<string, number>;
107
+ getTupleIndexesByKey(key: string): number[];
108
+ getTupleLabel(key: string): string;
109
+ getTupleType(key: string): PivotDataFieldDataTypeEnum;
110
+ getTupleKeysByLabel(label: string): string[];
91
111
  constructor(id: string, name: string, hexCode: string);
92
112
  /**
93
113
  * - Returns the name of the data field.
@@ -115,7 +135,7 @@ export declare class DataField {
115
135
  getDataFieldType(): PivotDataFieldTypeEnum;
116
136
  /**
117
137
  * - Returns the shared key with the data field item, this can be combined in the tuple group with other data field item key to create a unique path.
118
- * @param {string} dataIndex the index in data records
138
+ * @param {string} key the item key
119
139
  * @returns {string} key with field and item info
120
140
  */
121
141
  getItemSharedKey(key: string): string;
@@ -144,6 +164,7 @@ export declare class DataField {
144
164
  * @returns {void}
145
165
  */
146
166
  addRecord(record: IDataFieldValue, index: number): void;
167
+ private _addTupleRecord;
147
168
  getIndexesByKey(key: string): number[];
148
169
  getAllIndexMap(): Record<string, number[]>;
149
170
  /**
@@ -156,6 +177,8 @@ export declare class DataField {
156
177
  private _updateBlankItemKey;
157
178
  private _updateStringItemKey;
158
179
  private _updateNumberItemKey;
180
+ private _updateBooleanItemKey;
181
+ private _updateErrorItemKey;
159
182
  private _updateOtherItemKey;
160
183
  private _updateItemKey;
161
184
  getItemsMap(): Record<string, number>;
@@ -1,15 +1,21 @@
1
- import type { IDateGroupFieldInfo, IDateGroupFieldJSON, IPivotTableDateGroupInfo } from '../types';
1
+ import type { IDateGroupFieldInfo, IExcelDateGroupFieldSpec, IExcelDateGrouping, IPivotTableDateGroupInfo } from '../types/interface';
2
+ import type { IDateGroupFieldJSON } from '../types/json-types';
2
3
  import type { DataField } from './data-field';
3
- import { PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum } from '../types';
4
+ import { PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum } from '../types/enum';
4
5
  import { BaseGroupField } from './base-group-field';
6
+ export declare const EXCEL_DATE_BEFORE_KEY = -1;
7
+ export declare const EXCEL_DATE_AFTER_KEY = 1000000000;
8
+ export declare function normalizeExcelDateGrouping(grouping: IExcelDateGrouping, originalField: DataField): IExcelDateGrouping | undefined;
5
9
  export declare class DateGroupField extends BaseGroupField {
6
10
  private _dataIsValid;
7
11
  private _dateType;
8
- constructor(id: string, name: string, hexCode: string, originalFieldId: string, dateType?: PivotDateGroupFieldDateTypeEnum);
12
+ private _excelLike?;
13
+ constructor(id: string, name: string, hexCode: string, originalFieldId: string, dateType?: PivotDateGroupFieldDateTypeEnum, excelLike?: IExcelDateGroupFieldSpec);
9
14
  setDateType(dateType: PivotDateGroupFieldDateTypeEnum): void;
10
15
  getDateType(): PivotDateGroupFieldDateTypeEnum;
11
16
  getDateGroupValid(): boolean;
12
17
  refreshGroupField(originalField: DataField): void;
18
+ private _refreshExcelLike;
13
19
  getGroupInfo(): IPivotTableDateGroupInfo;
14
20
  getDataFieldType(): PivotDataFieldTypeEnum;
15
21
  getOriginFieldId(): string;
@@ -1,6 +1,6 @@
1
1
  import type { IDataFieldInfo, IFieldsCollectionJSON } from '../types';
2
+ import type { DataField } from './data-field';
2
3
  import type { DataFieldManager } from './data-field-manager';
3
- import { DataField } from './data-field';
4
4
  /**
5
5
  * Represents the collection of fields in the pivot table. which one to one with a pivot table.
6
6
  * @description The collection of fields in the pivot table. The fields collection uses shared the base data field id.For Grouped fields or calculated fields, it will save in custom field.
@@ -61,6 +61,7 @@ export declare class FieldsCollection {
61
61
  getDisplayName(fieldId: string): string;
62
62
  setDisplayName(fieldId: string, fieldName: string, displayNameRecord?: Record<string, string>): void;
63
63
  getUniqueDataFieldName(displayName: string, displayNameRecord?: Record<string, string>): string;
64
+ static getUniqueDataFieldName(displayName: string, record: Record<string, string>): string;
64
65
  /**
65
66
  * @description remove the field from the collection.
66
67
  */
@@ -0,0 +1,26 @@
1
+ import type { IManualGrouping } from '../types/interface';
2
+ import type { IManualGroupFieldJSON } from '../types/json-types';
3
+ import type { DataField } from './data-field';
4
+ import { PivotDataFieldTypeEnum } from '../types/enum';
5
+ import { BaseGroupField } from './base-group-field';
6
+ export declare function normalizeManualGrouping(grouping: IManualGrouping, sourceField?: DataField, existingGrouping?: IManualGrouping): IManualGrouping | undefined;
7
+ export declare class ManualGroupField extends BaseGroupField {
8
+ private _grouping;
9
+ private _dataIsValid;
10
+ private _recordKeys;
11
+ private _displayNames;
12
+ constructor(id: string, name: string, hexCode: string, originalFieldId: string, grouping: IManualGrouping);
13
+ getManualGroupValid(): boolean;
14
+ getGrouping(): IManualGrouping;
15
+ setGrouping(grouping: IManualGrouping): void;
16
+ reset(): void;
17
+ getItemKey(index: number): string;
18
+ getDisplayNameByKey(key: string): string;
19
+ refreshGroupField(originalField: DataField): void;
20
+ private _getMemberType;
21
+ getGroupInfo(): undefined;
22
+ getDataFieldType(): PivotDataFieldTypeEnum.textGroupField;
23
+ getOriginFieldId(): string;
24
+ toJSON(): IManualGroupFieldJSON;
25
+ fromJSON(data: IManualGroupFieldJSON): void;
26
+ }
@@ -0,0 +1,22 @@
1
+ import type { INumberGrouping, IPivotTableNumberGroupInfo } from '../types/interface';
2
+ import type { INumberGroupFieldJSON } from '../types/json-types';
3
+ import type { DataField } from './data-field';
4
+ import { PivotDataFieldTypeEnum } from '../types/enum';
5
+ import { BaseGroupField } from './base-group-field';
6
+ export declare const NUMBER_GROUP_BEFORE_KEY = "__number_before__";
7
+ export declare const NUMBER_GROUP_AFTER_KEY = "__number_after__";
8
+ export declare function normalizeNumberGrouping(grouping: INumberGrouping, originalField: DataField): INumberGrouping | undefined;
9
+ export declare function getDefaultNumberGrouping(originalField: DataField): INumberGrouping | undefined;
10
+ export declare class NumberGroupField extends BaseGroupField {
11
+ private _grouping;
12
+ private _dataIsValid;
13
+ private _bounds;
14
+ constructor(id: string, name: string, hexCode: string, originalFieldId: string, grouping: INumberGrouping);
15
+ getNumberGroupValid(): boolean;
16
+ refreshGroupField(originalField: DataField): void;
17
+ getGroupInfo(): IPivotTableNumberGroupInfo;
18
+ getDataFieldType(): PivotDataFieldTypeEnum.numberGroupField;
19
+ getOriginFieldId(): string;
20
+ toJSON(): INumberGroupFieldJSON;
21
+ fromJSON(data: INumberGroupFieldJSON): void;
22
+ }
@@ -1,16 +1,21 @@
1
1
  export { GlobalConfig, setDateSystem, setMaxLimitItemCount, } from './const';
2
2
  export { BaseGroupField } from './field/base-group-field';
3
+ export { createDataFieldFromJSON } from './field/create-data-field';
3
4
  export { DataField } from './field/data-field';
4
5
  export { DataFieldManager } from './field/data-field-manager';
5
- export { DateGroupField } from './field/date-group-field';
6
+ export { DateGroupField, EXCEL_DATE_AFTER_KEY, EXCEL_DATE_BEFORE_KEY, normalizeExcelDateGrouping, } from './field/date-group-field';
6
7
  export { FieldsCollection } from './field/fields-collection';
8
+ export { ManualGroupField, normalizeManualGrouping } from './field/manual-group-field';
9
+ export { getDefaultNumberGrouping, normalizeNumberGrouping, NUMBER_GROUP_AFTER_KEY, NUMBER_GROUP_BEFORE_KEY, NumberGroupField, } from './field/number-group-field';
7
10
  export { isValueFilterOperator } from './filter-util';
8
11
  export { isErrorValue, isPrefixValue, LabelViewItem, PivotView, PivotViewItem, } from './layout/pivot-view';
9
12
  export { PivotTable } from './pivot/pivot-table';
10
13
  export { createLabelField, createValueField, PivotTableLabelField, PivotTableValueField, } from './pivot/table-field';
11
- export { PivotCallbackEnum, PivotDataFieldDataTypeEnum, PivotDataFieldSortOperatorEnum, PivotDataFieldSortTypeEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateSystemEnum, PivotDateGroupFieldDateTypeEnum, PivotErrorTypeEnum, PivotFilterTypeEnum, PivotLayoutTypeEnum, PivotShowAsBaseItemTypeEnum, PivotShowAsTypeEnum, PivotSubtotalPositionEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, ST_PivotFilterOperatorEnum, } from './types/enum';
12
- export type { IDataFieldValue, IDateValue, IPivotTableDateGroupInfo, IPivotTableFilterInfo, IPivotTableManualFilter, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem, } from './types/interface';
13
- export type { IBaseGroupFieldJSON, IDataFieldManagerBaseJSON, IFieldsCollectionJSON, IPivotTableLabelFieldJSON, IPivotTableSnapshot, IPivotTableValueFieldJSON, } from './types/json-types';
14
+ export { getPivotRecordMember, isPivotTableFilterRestrictive } from './record-filter';
15
+ export { isDateValue, isRecordErrorValue } from './record-value';
16
+ export { PivotCallbackEnum, PivotDataFieldDataTypeEnum, PivotDataFieldSortOperatorEnum, PivotDataFieldSortTypeEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotDateGroupingMode, PivotErrorTypeEnum, PivotExcelDateGroupUnit, PivotFilterTypeEnum, PivotLayoutTypeEnum, PivotShowAsBaseItemTypeEnum, PivotShowAsTypeEnum, PivotSubtotalPositionEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum, ST_PivotFilterOperatorEnum, } from './types/enum';
17
+ export type { IDataFieldInfo, IDataFieldValue, IDateValue, IErrorValue, IExcelDateGrouping, IManualGroup, IManualGrouping, INumberGrouping, IPivotTableDateGroupInfo, IPivotTableFilterInfo, IPivotTableGroupInfo, IPivotTableManualFilter, IPivotTableNumberGroupInfo, IPivotTableRecordFilter, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem, } from './types/interface';
18
+ export type { IBaseGroupFieldJSON, IDataFieldManagerBaseJSON, IFieldsCollectionJSON, IManualGroupFieldJSON, INumberGroupFieldJSON, IPivotTableLabelFieldJSON, IPivotTableSnapshot, IPivotTableValueFieldJSON, } from './types/json-types';
14
19
  export { PivotTableChangeTypeEnum } from './types/json-types';
15
20
  export type { IPivotTableAddFieldChange, IPivotTableChangeSet, IPivotTableRemoveFieldChange, IPivotTableRenameFieldChange, IPivotTableSetCollapseChange, IPivotTableSetFilterInfoChange, IPivotTableSetFormatChange, IPivotTableSetLayoutChange, IPivotTableSetOptionsChange, IPivotTableSetShowDataAsChange, IPivotTableSetSortInfoChange, IPivotTableSetSubtotalTypeChange, IPivotTableSetValueFilterChange, IPivotTableUpdatePositionChange, IPivotTableUpdateValuePositionChange, IPivotUpdateSourceChange, } from './types/json-types';
16
21
  export type { IPivotViewCellData, IPivotViewValueType, } from './types/layout-type';
@@ -18,4 +23,5 @@ export { PivotViewCellValueTypeEnum } from './types/layout-type';
18
23
  export type { IPivotViewInfo } from './types/layout-type';
19
24
  export { PivotCellStyleTypeEnum } from './types/layout-type';
20
25
  export type { ILabelViewHeaderMapItem, IPivotTableOptions, IPivotViewJSON, } from './types/layout-type';
21
- export { excelDateToUnixMilliseconds, generateHexNumber, getAutoDisplayName, isBaseGroupField, isDateGroupField, isDateGroupFieldJSON, isDateValue, isManualPivotFilter, } from './util';
26
+ export { createPivotSortCompare } from './util';
27
+ export { excelDateToUnixMilliseconds, generateHexNumber, getAutoDisplayName, getPivotDateGroupingMode, isBaseGroupField, isDateGroupField, isDateGroupFieldJSON, isManualPivotFilter, } from './util';
@@ -1,5 +1,5 @@
1
1
  import type { PivotModel } from '../pivot/model';
2
- import type { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotTableDateGroupInfo, IPivotTableValueFieldQueryData, IPivotViewCellData, IPivotViewErrorValue, IPivotViewInfo, IPivotViewItemData, IPivotViewItemJSON, IPivotViewJSON, IPivotViewPrefixValue, IPivotViewValueType, PivotCellStyleTypeEnum } from '../types';
2
+ import type { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotTableGroupInfo, IPivotTableValueFieldQueryData, 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
@@ -25,10 +25,6 @@ export declare class PivotView {
25
25
  * the corner view of the pivot table
26
26
  */
27
27
  cornerView: PivotViewItem;
28
- /**
29
- * the version of the pivot view, it will be used to check the view is the latest
30
- */
31
- version: number;
32
28
  /**
33
29
  * the format map of the table field id, it will be used to store the format of the pivot view
34
30
  */
@@ -36,16 +32,13 @@ export declare class PivotView {
36
32
  /**
37
33
  * the group info map of the table field id, it will be used to store the group info of the pivot view
38
34
  */
39
- groupInfo: Record<string, IPivotTableDateGroupInfo>;
40
- constructor();
41
- setVersion(version?: number): void;
42
- setGroupInfo(groupInfo: Record<string, IPivotTableDateGroupInfo>): void;
35
+ groupInfo: Record<string, IPivotTableGroupInfo>;
36
+ setGroupInfo(groupInfo: Record<string, IPivotTableGroupInfo>): void;
43
37
  /**
44
38
  * - the func effect is to set the format code , for label view, it will used to format the header , such as date type data, in the data view, it will used to format the data of show data as
45
39
  * @param model the pivot model, it will be used to set the format of the pivot view
46
40
  */
47
41
  setFormat(model: PivotModel, valueQueryInfo: IPivotTableValueFieldQueryData[]): void;
48
- getVersion(): number;
49
42
  toJSON(): IPivotViewJSON;
50
43
  formJSON(data: IPivotViewJSON): void;
51
44
  }
@@ -92,9 +92,10 @@ export declare class PivotModel {
92
92
  /**
93
93
  * - Set the options of the pivot table.
94
94
  * @param {IPivotTableOptions} options - The options to be set.
95
+ * @param {boolean} replace - Replace a complete options snapshot instead of merging a patch.
95
96
  * @returns {void}
96
97
  */
97
- setOptions(options: IPivotTableOptions): void;
98
+ setOptions(options: IPivotTableOptions, replace?: boolean): void;
98
99
  /**
99
100
  * - Get the options of the pivot table. It is a copy of the options.
100
101
  * @returns {IPivotTableOptions} - The options of the pivot table.
@@ -15,7 +15,6 @@ import { PivotTableLabelField, PivotTableValueField } from './table-field';
15
15
  */
16
16
  export declare class PivotTable {
17
17
  dataFieldsCollection: FieldsCollection;
18
- private _viewVersion;
19
18
  private _model;
20
19
  _bufferModel?: PivotModel;
21
20
  private _tupleGroupCache?;
@@ -38,6 +37,11 @@ export declare class PivotTable {
38
37
  static unRegisterCallbackWithEvent(event: PivotCallbackEnum, callback: (id?: string) => void): void;
39
38
  constructor(dataFieldsCollection: FieldsCollection, model?: PivotModel, id?: string);
40
39
  updateDataFieldsCollection(dataFieldsCollection: FieldsCollection): void;
40
+ /** Evaluate raw-record constraints without changing the report or its aggregate cache. */
41
+ getFilteredRecordIndexes(sourceFieldId: string, excludedCondition: 'selection' | 'dateRange'): {
42
+ isAll: boolean;
43
+ list: number[];
44
+ };
41
45
  private _getModel;
42
46
  startCollectChangeset(): void;
43
47
  endCollectChangeset(): IPivotTableChangeSet[];
@@ -146,7 +150,7 @@ export declare class PivotTable {
146
150
  * @returns {PivotTableLabelField|PivotTableValueField} the added field
147
151
  */
148
152
  addFieldWithSourceId(dataFieldId: string, area: PivotTableFiledAreaEnum, index?: number, provideTableFieldId?: string): PivotTableLabelField | PivotTableValueField | undefined;
149
- setOptions(options: IPivotTableOptions): void;
153
+ setOptions(options: IPivotTableOptions, replace?: boolean): void;
150
154
  setLayout(layout: PivotLayoutTypeEnum): void;
151
155
  getLayout(): PivotLayoutTypeEnum;
152
156
  /**
@@ -250,12 +254,6 @@ export declare class PivotTable {
250
254
  * @returns {boolean} Whether the target is a row field.
251
255
  */
252
256
  setRowCollapseLevel(fieldId: string): boolean;
253
- /**
254
- * - get the pivot view need query or not
255
- * @param {number} viewVersion
256
- * @returns {boolean} - need query or not
257
- */
258
- getNeedQuery(viewVersion: number): boolean;
259
257
  /**
260
258
  * @description Get the field position information by the field id.
261
259
  * @param {string} fieldId the field id
@@ -0,0 +1,7 @@
1
+ import type { RecordValue } from '@univerjs/core';
2
+ import type { IDataFieldValue, IPivotTableFilterInfo, IPivotTableRecordFilter } from './types/interface';
3
+ export declare function getPivotRecordMember(value: IDataFieldValue): RecordValue;
4
+ export declare function isPivotRecordFilter(filterInfo: IPivotTableFilterInfo | undefined): filterInfo is IPivotTableRecordFilter;
5
+ export declare function isPivotTableFilterRestrictive(filterInfo: IPivotTableFilterInfo): boolean;
6
+ export declare function isPivotRecordFilterRestrictive(filterInfo: IPivotTableRecordFilter): boolean;
7
+ export declare function clonePivotTableFilterInfo(filterInfo: IPivotTableFilterInfo | undefined): IPivotTableFilterInfo | undefined;
@@ -0,0 +1,3 @@
1
+ import type { IDataFieldValue, IDateValue, IErrorValue } from './types/interface';
2
+ export declare function isDateValue(value: IDataFieldValue): value is IDateValue;
3
+ export declare function isRecordErrorValue(value: IDataFieldValue): value is IErrorValue;
@@ -19,6 +19,8 @@ export declare class NodeTree {
19
19
  * @property {string} name - The name of the node tree.
20
20
  */
21
21
  name: string;
22
+ displayName: string;
23
+ displayPaths: string[];
22
24
  fieldId: string;
23
25
  collapse: boolean;
24
26
  sortedList: string[];
@@ -43,7 +45,7 @@ export declare class NodeTree {
43
45
  setLeaf(): void;
44
46
  getIsLeaf(): boolean;
45
47
  setName(name: string): void;
46
- addNode(node: NodeTree, path: string, sortMap: Record<string, number> | undefined, sortType: PivotDataFieldSortOperatorEnum): void;
48
+ addNode(node: NodeTree, path: string, sortMap: Record<string, number> | undefined, sortType: PivotDataFieldSortOperatorEnum, displayName?: string): void;
47
49
  sortNode(path: string, sortedMap: Record<string, number>, sortType: PivotDataFieldSortOperatorEnum): void;
48
50
  sortChildrenByValue(fieldId: string, sortType: PivotDataFieldSortOperatorEnum, getValue: (index: number) => number | undefined, compareLabels: (a: string, b: string) => number): void;
49
51
  resetSort(): void;
@@ -23,6 +23,7 @@ export declare class ShowDataAsResolver {
23
23
  private readonly _parentFieldIndexes;
24
24
  private readonly _parentFieldIndexByValueField;
25
25
  private readonly _peerIndexesByValueField;
26
+ private readonly _peerUnionsByValueField;
26
27
  private readonly _derivedValuesByValueField;
27
28
  constructor(_summaryManager: SummaryManager, _queryData: IPivotTableQueryData);
28
29
  prepare(): void;
@@ -35,6 +35,7 @@ export declare class TupleGroup {
35
35
  * @property The colDeep, the deep of col fields.
36
36
  */
37
37
  colDeep: number;
38
+ private _fieldsCollection?;
38
39
  constructor();
39
40
  /**
40
41
  * - prepare the measuresMap and dimensionMap, it will prepare the measuresMap and dimensionMap based on the query data
@@ -171,7 +171,11 @@ export declare enum PivotFilterTypeEnum {
171
171
  /**
172
172
  *- the manual filter
173
173
  */
174
- ManualFilter = 3
174
+ ManualFilter = 3,
175
+ /**
176
+ * An internal typed predicate evaluated against raw pivot records.
177
+ */
178
+ RecordFilter = 4
175
179
  }
176
180
  /**
177
181
  * Enum for pivot table field types.
@@ -701,6 +705,21 @@ export declare enum PivotDataFieldTypeEnum {
701
705
  */
702
706
  customGroupField = 5
703
707
  }
708
+ /** Date-grouping semantics for a single pivot table. */
709
+ export declare enum PivotDateGroupingMode {
710
+ Legacy = "legacy",
711
+ ExcelLike = "excel-like"
712
+ }
713
+ /** Individual calendar units used by Excel-like date grouping. */
714
+ export declare enum PivotExcelDateGroupUnit {
715
+ Year = "year",
716
+ Quarter = "quarter",
717
+ Month = "month",
718
+ Day = "day",
719
+ Hour = "hour",
720
+ Minute = "minute",
721
+ Second = "second"
722
+ }
704
723
  /**
705
724
  * Enum for representing different date group field types in a pivot table.
706
725
  */
@@ -761,7 +780,3 @@ export declare enum PivotDateGroupFieldDateTypeEnum {
761
780
  */
762
781
  YearMonthDate = "year-month-date"
763
782
  }
764
- export declare enum PivotDateGroupFieldDateSystemEnum {
765
- Date1900 = "date1900",
766
- Date1904 = "date1904"
767
- }
@@ -1,4 +1,5 @@
1
- import type { PivotDataFieldDataTypeEnum, PivotDataFieldSortOperatorEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotFilterTypeEnum, PivotShowAsBaseItemTypeEnum, PivotShowAsTypeEnum, PivotSubtotalTypeEnum, ST_PivotFilterOperatorEnum } from './enum';
1
+ import type { RecordSelection, RecordValue } from '@univerjs/core';
2
+ import type { PivotDataFieldDataTypeEnum, PivotDataFieldSortOperatorEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotExcelDateGroupUnit, PivotFilterTypeEnum, PivotShowAsBaseItemTypeEnum, PivotShowAsTypeEnum, PivotSubtotalTypeEnum, ST_PivotFilterOperatorEnum } from './enum';
2
3
  export interface IDateValue {
3
4
  /**
4
5
  * @description the date value, it stores the number of seconds since January 1, 1970, 00:00:00 UTC, it is same to excel date value
@@ -9,11 +10,14 @@ export interface IDateValue {
9
10
  */
10
11
  f: string;
11
12
  }
13
+ export interface IErrorValue {
14
+ error: string;
15
+ }
12
16
  type IBlankValue = null | undefined;
13
17
  /**
14
18
  * Represents the value of a data field in a pivot table data field
15
19
  */
16
- export type IDataFieldValue = string | number | boolean | IDateValue | IBlankValue;
20
+ export type IDataFieldValue = string | number | boolean | IDateValue | IErrorValue | IBlankValue;
17
21
  export interface IDataFieldInfo {
18
22
  id: string;
19
23
  name: string;
@@ -41,6 +45,34 @@ export interface IDateGroupFieldInfo extends IBaseGroupFieldInfo {
41
45
  * @description the date type of the date group field
42
46
  */
43
47
  dateType?: PivotDateGroupFieldDateTypeEnum;
48
+ excelLike?: IExcelDateGroupFieldSpec;
49
+ }
50
+ export interface IExcelDateGrouping {
51
+ units: PivotExcelDateGroupUnit[];
52
+ autoStart: boolean;
53
+ autoEnd: boolean;
54
+ start?: number;
55
+ end?: number;
56
+ daysInterval?: number;
57
+ }
58
+ export interface IExcelDateGroupFieldSpec extends Omit<IExcelDateGrouping, 'units'> {
59
+ unit: PivotExcelDateGroupUnit;
60
+ groupByDate?: boolean;
61
+ }
62
+ export interface INumberGrouping {
63
+ autoStart: boolean;
64
+ autoEnd: boolean;
65
+ start?: number;
66
+ end?: number;
67
+ interval: number;
68
+ }
69
+ export interface IManualGroup {
70
+ id: string;
71
+ name: string;
72
+ members: RecordValue[];
73
+ }
74
+ export interface IManualGrouping {
75
+ groups: IManualGroup[];
44
76
  }
45
77
  export interface IPivotField {
46
78
  id: string;
@@ -67,12 +99,18 @@ export interface IPivotTuple {
67
99
  max: number;
68
100
  squareSum: number;
69
101
  }
70
- export type IPivotTableFilterInfo = IPivotTableManualFilter | IPivotTableCustomFilter | IPivotTableValueFilter;
102
+ export type IPivotTableFilterInfo = IPivotTableManualFilter | IPivotTableCustomFilter | IPivotTableValueFilter | IPivotTableRecordFilter;
71
103
  export type IPivotTableSortInfo = IPivotTableLabelSortInfo | IPivotTableValueSortInfo | IPivotTableLabelCustomSortInfo;
72
104
  export interface IPivotTableDateGroupInfo {
73
105
  type: PivotDataFieldTypeEnum.dateGroupField;
74
106
  dateType: PivotDateGroupFieldDateTypeEnum;
107
+ excelLike?: IExcelDateGroupFieldSpec;
108
+ }
109
+ export interface IPivotTableNumberGroupInfo {
110
+ type: PivotDataFieldTypeEnum.numberGroupField;
111
+ grouping: INumberGrouping;
75
112
  }
113
+ export type IPivotTableGroupInfo = IPivotTableDateGroupInfo | IPivotTableNumberGroupInfo;
76
114
  export interface IPivotTableLabelSortInfo {
77
115
  type: PivotDataFieldSortOperatorEnum;
78
116
  sortLocale?: string;
@@ -125,6 +163,11 @@ export interface IPivotTableValueFilter {
125
163
  /** Whether a count/percent rank filter keeps the bottom values instead of the top values. */
126
164
  isBottom?: boolean;
127
165
  }
166
+ export interface IPivotTableRecordFilter {
167
+ type: PivotFilterTypeEnum.RecordFilter;
168
+ selection?: RecordSelection;
169
+ dateRange?: IPivotDateRange;
170
+ }
128
171
  export interface IPivotTableShowDataAsInfo {
129
172
  type: PivotShowAsTypeEnum;
130
173
  baseFieldId: string;
@@ -172,6 +215,10 @@ export interface IPivotTableQueryData {
172
215
  * The query info of filter fields in the pivot table.
173
216
  */
174
217
  filterQueryInfo: IPivotTableLabelFieldQueryData[];
218
+ /**
219
+ * The query info of hidden fields in the pivot table.
220
+ */
221
+ hiddenQueryInfo?: IPivotTableLabelFieldQueryData[];
175
222
  /**
176
223
  * The query info of value fields in the pivot table.
177
224
  */
@@ -236,4 +283,8 @@ export interface IValueFilterInfoItem {
236
283
  */
237
284
  filterInfo: IPivotTableValueFilter;
238
285
  }
286
+ export interface IPivotDateRange {
287
+ startDate: number;
288
+ endDate: number;
289
+ }
239
290
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { PivotDataFieldDataTypeEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotLayoutTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from './enum';
2
- import type { IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem } from './interface';
2
+ import type { IExcelDateGroupFieldSpec, IManualGrouping, INumberGrouping, IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem } from './interface';
3
3
  import type { IPivotTableOptions } from './layout-type';
4
4
  export interface IPivotTableValueFieldJSON {
5
5
  dataFieldId: string;
@@ -106,6 +106,15 @@ export interface IDateGroupFieldJSON extends IBaseGroupFieldJSON {
106
106
  * @description the date type of the date group field
107
107
  */
108
108
  dateType?: PivotDateGroupFieldDateTypeEnum;
109
+ excelLike?: IExcelDateGroupFieldSpec;
110
+ }
111
+ export interface INumberGroupFieldJSON extends IBaseGroupFieldJSON {
112
+ dataFieldType: PivotDataFieldTypeEnum.numberGroupField;
113
+ grouping: INumberGrouping;
114
+ }
115
+ export interface IManualGroupFieldJSON extends IBaseGroupFieldJSON {
116
+ dataFieldType: PivotDataFieldTypeEnum.textGroupField;
117
+ grouping: IManualGrouping;
109
118
  }
110
119
  export interface IDataFieldManagerBaseJSON {
111
120
  collections: Record<string, IFieldsCollectionJSON>;
@@ -1,8 +1,8 @@
1
1
  import type { PivotView } from '../layout/pivot-view';
2
2
  import type { NodeTree } from '../summary/node-tree';
3
3
  import type { SummaryManager } from '../summary/summary-manager';
4
- import type { PivotErrorTypeEnum, PivotSubtotalPositionEnum } from './enum';
5
- import type { IPivotTableDateGroupInfo, IPivotTableQueryData, IPivotTableValueFieldQueryData, IValueFilterInfoItem } from './interface';
4
+ import type { PivotDateGroupingMode, PivotErrorTypeEnum, PivotSubtotalPositionEnum } from './enum';
5
+ import type { IPivotTableGroupInfo, IPivotTableQueryData, IPivotTableValueFieldQueryData, IValueFilterInfoItem } from './interface';
6
6
  export interface IPivotViewItemData {
7
7
  [row: number]: IPivotViewColData;
8
8
  }
@@ -161,6 +161,8 @@ export declare enum PivotCellStyleTypeEnum {
161
161
  * Represents the data structure for a pivot table config, which is match CT_pivotTableDefinition
162
162
  */
163
163
  export interface IPivotTableOptions {
164
+ /** Missing in older snapshots; readers treat it as Legacy without rewriting the snapshot. */
165
+ dateGroupingMode?: PivotDateGroupingMode;
164
166
  /**
165
167
  * The page wrap, it is the wrap of page, the page will wrap to next row when the wrapCursor is equal to pageWrap
166
168
  */
@@ -290,8 +292,7 @@ export interface IPivotViewJSON {
290
292
  colView: ILabelViewItemJSON;
291
293
  dataView: IPivotViewItemJSON;
292
294
  cornerView: IPivotViewItemJSON;
293
- version: number;
294
295
  formatMap: Record<string, string>;
295
- groupInfo: Record<string, IPivotTableDateGroupInfo>;
296
+ groupInfo: Record<string, IPivotTableGroupInfo>;
296
297
  }
297
298
  export {};
@@ -2,18 +2,19 @@ import type { BaseGroupField } from './field/base-group-field';
2
2
  import type { DataField } from './field/data-field';
3
3
  import type { DateGroupField } from './field/date-group-field';
4
4
  import type { PivotErrorTypeEnum, ST_PivotFilterOperatorEnum } from './types/enum';
5
- import type { IDataFieldValue, IDateValue, IPivotTableCustomFilter, IPivotTableDateGroupInfo, IPivotTableFilterInfo, IPivotTableLabelCustomSortInfo, IPivotTableManualFilter, IPivotTableSortInfo, IValueFilterInfoItem } from './types/interface';
5
+ import type { IPivotTableCustomFilter, IPivotTableDateGroupInfo, IPivotTableFilterInfo, IPivotTableLabelCustomSortInfo, IPivotTableManualFilter, IPivotTableSortInfo, IValueFilterInfoItem } from './types/interface';
6
6
  import type { IBaseGroupFieldJSON, IDataFieldJSON, IDateGroupFieldJSON } from './types/json-types';
7
+ import type { IPivotTableOptions } from './types/layout-type';
7
8
  import type { IMeasuresMapItem, ITupleItem } from './types/summary-type';
8
9
  import { PivotTuple } from './summary/pivot-tuple';
9
- import { PivotDataFieldDataTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum } from './types/enum';
10
+ import { PivotDataFieldDataTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotDateGroupingMode, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum } from './types/enum';
10
11
  import { PivotCellStyleTypeEnum } from './types/layout-type';
12
+ export declare function getPivotDateGroupingMode(options?: IPivotTableOptions): PivotDateGroupingMode;
11
13
  /**
12
14
  * - judge the value is date like type
13
15
  * @param {IDataFieldValue} value the date like value
14
16
  * @returns {boolean} - return true if the value is date like type
15
17
  */
16
- export declare function isDateValue(value: IDataFieldValue): value is IDateValue;
17
18
  /**
18
19
  * - judge the value is blank
19
20
  * @param {any} value the value to be test