import type { PivotDataFieldDataTypeEnum, PivotDataFieldTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotLayoutTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from './enum'; import type { IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo, IPivotTableValueFilter, IValueFilterInfoItem } from './interface'; import type { IPivotTableOptions } from './layout-type'; export interface IPivotTableValueFieldJSON { dataFieldId: string; id: string; sourceName: string; displayName: string; format: string | undefined; subtotal: PivotSubtotalTypeEnum; showDataAs: IPivotTableShowDataAsInfo; } export interface IPivotTableLabelFieldJSON { dataFieldId: string; id: string; sourceName: string; displayName: string; format: string | undefined; sortInfo?: IPivotTableSortInfo; filterInfo?: IPivotTableFilterInfo; } /** * Represents a snapshot of a pivot table. */ export interface IPivotTableSnapshot { /** * Represents the label fields in the pivot table. */ dimension: Record; /** * Represents the value fields in the pivot table. */ measure: Record; /** * Represents the fields id used for grouping value in the pivot table. */ valueFields: string[]; /** * Represents the fields id used for filtering in the pivot table. */ filterFields: string[]; /** * Represents the fields id used for grouping rows in the pivot table. */ rowFields: string[]; /** * Represents the fields id used for grouping columns in the pivot table. */ columnFields: string[]; /** * Represents the fields id that are hidden in the pivot table. */ hiddenFields: string[]; /** * Represents the special ΣValue fields order index in the dimension fields. */ valueIndex: number; /** * Represents the special ΣValue fields position in row or column area. */ valuePosition: PivotTableValuePositionEnum; /** * Represents the layout of the pivot table. */ layout: PivotLayoutTypeEnum; /** * Represents the collapse information of the pivot table. */ collapseInfo: Record; options: IPivotTableOptions; /** * Represents the value filter information of the pivot table.The ordered should be ensured, because the value filter must be applied in order. */ valueFilter: IValueFilterInfoItem[]; } export interface IFieldsCollectionJSON { fieldIds: string[]; customFields: IDataFieldJSON[]; displayNameRecord: Record; dataRecordCount: number; range: unknown; fields: Record; } /** * Represents the data field serialized to JSON data structure. */ export interface IDataFieldJSON { id: string; name: string; hexCode: string; fieldDataType: PivotDataFieldDataTypeEnum; rangeKey: string; /** * @description the data field type, Used to distinguish between grouping and original data field */ dataFieldType: PivotDataFieldTypeEnum; } export interface IBaseGroupFieldJSON extends IDataFieldJSON { /** * @description the original field id of the group field */ originalFieldId: string; } export interface IDateGroupFieldJSON extends IBaseGroupFieldJSON { /** * @description the date type of the date group field */ dateType?: PivotDateGroupFieldDateTypeEnum; } export interface IDataFieldManagerBaseJSON { collections: Record; dataFields: Record; } /** * Represents the change type of the pivot table. */ export declare enum PivotTableChangeTypeEnum { /** * Add field to the pivot table. */ AddField = 0, /** * Set subtotal to the field in the pivot table. */ SetSubtotalType = 1, /** * Remove field from the pivot table. */ RemoveField = 2, /** * Rename the field in the pivot table. */ RenameField = 3, /** * Set filter information to the field in the pivot table. */ SetFilterInfo = 4, /** * Set sort information to the field in the pivot table. */ SetSortInfo = 5, /** * Update field position in the pivot table. */ UpdateFieldPosition = 6, /** * Set options to the pivot table. */ UpdateValuePosition = 7, /** * Set options to the pivot table. */ SetOptions = 8, /** * Set format to the field in the pivot table. */ SetFieldFormat = 9, /** * Set collapse to the field in the pivot table. */ SetCollapse = 10, /** * Update source of the field in the pivot table. */ UpdateSource = 11, /** * Set value filter to the field in the pivot table. */ SetValueFilter = 12 } /** * The change of adding field to the pivot table. */ export interface IPivotTableAddFieldChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.AddField; /** * @property {IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON} fieldJson The field json. */ fieldJson: IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON; /** * @property {PivotTableFiledAreaEnum} area Which area the field is added to. */ area: PivotTableFiledAreaEnum; /** * @property {number} index The index of the field in the area. */ index: number; } /** * The change of updating source of the field in the pivot table. */ export interface IPivotUpdateSourceChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.UpdateSource; /** * @property {string} tableFieldId The pivot field id. */ tableFieldId: string; /** * @property {string} oldSourceName The old source name. */ oldSourceName: string; /** * @property {string} newSourceName The new source name. */ newSourceName: string; /** * @property {string} oldDataFieldId The old data field id. */ oldDataFieldId: string; /** * @property {string} newDataFieldId The new data field id. */ newDataFieldId: string; } /** * The change of setting subtotal type to the field in the pivot table. */ export interface IPivotTableSetSubtotalTypeChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetSubtotalType; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {PivotSubtotalTypeEnum} newSubtotalType The new subtotal type. */ newSubtotalType: PivotSubtotalTypeEnum; /** * @property {PivotSubtotalTypeEnum} oldSubtotalType The old subtotal type. */ oldSubtotalType: PivotSubtotalTypeEnum; } /** * The change of removing field from the pivot table. */ export interface IPivotTableRemoveFieldChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.RemoveField; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {PivotTableFiledAreaEnum} area Which area the field is removed from. */ area: PivotTableFiledAreaEnum; /** * @property {number} index The index of the field in the area. */ index: number; /** * @property {IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON} fieldJson The field json. */ fieldJson: IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON; } /** * The change of renaming the field in the pivot table. */ export interface IPivotTableRenameFieldChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.RenameField; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {string} oldName The old name of the field. */ oldName: string; /** * @property {string} newName The new name of the field. */ newName: string; } /** * The change of updating field position in the pivot table. */ export interface IPivotTableUpdatePositionChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.UpdateFieldPosition; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {PivotTableFiledAreaEnum} oldArea The old area of the field. */ oldArea: PivotTableFiledAreaEnum; /** * @property {PivotTableFiledAreaEnum} newArea The new area of the field. */ newArea: PivotTableFiledAreaEnum; /** * @property {number} oldIndex The old index of the field in the area. */ oldIndex: number; /** * @property {number} newIndex The new index of the field in the area. */ newIndex: number; } /** * The change of setting options to the pivot table. */ export interface IPivotTableSetOptionsChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetOptions; /** * @property {IPivotTableOptions} oldOptions The old options of the pivot table. */ oldOptions: IPivotTableOptions; /** * @property {IPivotTableOptions} newOptions The new options of the pivot table. */ newOptions: IPivotTableOptions; } /** * The change of updating value position in the pivot table. */ export interface IPivotTableUpdateValuePositionChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.UpdateValuePosition; /** * @property {PivotTableValuePositionEnum} oldValuePosition The old value position. */ oldValuePosition: PivotTableValuePositionEnum; /** * @property {PivotTableValuePositionEnum} newValuePosition The new value position. */ newValuePosition: PivotTableValuePositionEnum; /** * @property {number} oldIndex The old index of the value position. */ oldIndex: number; /** * @property {number} newIndex The new index of the value position. */ newIndex: number; } /** * The change of setting filter information to the field in the pivot table. */ export interface IPivotTableSetFilterInfoChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetFilterInfo; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {IPivotTableFilterInfo} oldFilterInfo The old filter information. */ oldFilterInfo: IPivotTableFilterInfo; /** * @property {IPivotTableFilterInfo} newFilterInfo The new filter information. */ newFilterInfo: IPivotTableFilterInfo; } export interface IPivotTableSetValueFilterChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetValueFilter; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {IPivotTableValueFilter} oldFilterInfo The old filter information. */ oldFilterInfo: IPivotTableValueFilter | undefined; /** * @property {IPivotTableValueFilter} filterInfo The new filter information. */ filterInfo: IPivotTableValueFilter | undefined; } /** * The change of setting sort information to the field in the pivot table. */ export interface IPivotTableSetSortInfoChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetSortInfo; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {IPivotTableSortInfo | undefined} oldSortInfo The old sort information. */ oldSortInfo: IPivotTableSortInfo | undefined; /** * @property {IPivotTableSortInfo | undefined} newSortInfo The new sort information. */ newSortInfo: IPivotTableSortInfo | undefined; } /** * The change of setting format to the field in the pivot table. */ export interface IPivotTableSetFormatChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetFieldFormat; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {string | undefined} oldFormat The old format of the field. */ oldFormat: string | undefined; /** * @property {string | undefined} newFormat The new format of the field. */ newFormat: string | undefined; } /** * The change of setting collapse to the field in the pivot table. */ export interface IPivotTableSetCollapseChange { /** * @property {PivotTableChangeTypeEnum} type The type of the change. */ type: PivotTableChangeTypeEnum.SetCollapse; /** * @property {string} fieldId The pivot table field id. */ fieldId: string; /** * @property {boolean} collapse The collapse state of the field. */ collapse: boolean; /** * @property {string} [item] The item associated with the collapse state. */ item?: string; } export type IPivotTableChangeSet = IPivotTableAddFieldChange | IPivotTableSetSubtotalTypeChange | IPivotTableRemoveFieldChange | IPivotTableRenameFieldChange | IPivotTableSetFilterInfoChange | IPivotTableSetSortInfoChange | IPivotTableUpdatePositionChange | IPivotTableUpdateValuePositionChange | IPivotTableSetOptionsChange | IPivotTableSetFormatChange | IPivotTableSetCollapseChange | IPivotUpdateSourceChange | IPivotTableSetValueFilterChange;