@univerjs-pro/engine-pivot
Version:
[](https://npmjs.org/packages/@univerjs-pro/engine-pivot) [](https://img.shields.io/npm/l/@univerjs-pro/engine-pivot)
147 lines (146 loc) • 8.42 kB
TypeScript
import { BaseGroupField } from './field/base-group-field';
import { DataField } from './field/data-field';
import { DateGroupField } from './field/date-group-field';
import { IBaseGroupFieldJSON, IDataFieldJSON, IDataFieldValue, IDateGroupFieldJSON, IDateValue, IMeasuresMapItem, IPivotTableCustomFilter, IPivotTableDateGroupInfo, IPivotTableFilterInfo, IPivotTableGroupInfo, IPivotTableLabelCustomSortInfo, IPivotTableManualFilter, IPivotTableSortInfo, ITupleItem, IValueFilterInfoItem, PivotErrorTypeEnum, ST_PivotFilterOperatorEnum, PivotCellStyleTypeEnum, PivotDataFieldDataTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum } from './types';
import { PivotTuple } from './summary/pivot-tuple';
/**
* - judge the value is date like type
* @param {IDataFieldValue} value the date like value
* @returns {boolean} - return true if the value is date like type
*/
export declare function isDateValue(value: IDataFieldValue): value is IDateValue;
/**
* - judge the value is blank
* @param {any} value the value to be test
* @returns {boolean} return true if the value is blank
*/
export declare function isBlankValue(value: unknown): value is null | undefined;
/**
* - judge the area type is in dim
* @param {PivotTableFiledAreaEnum} area - the test area
* @returns {boolean} - return true if the area is in dim
*/
export declare function isDimArea(area: PivotTableFiledAreaEnum): boolean;
/**
* - judge the area type is in row or column
* @param {PivotTableFiledAreaEnum} area - the test area
* @returns {boolean} - return true if the area is in value
*/
export declare function isRowOrColumnArea(area: PivotTableFiledAreaEnum): boolean;
/**
* - Get the auto display name of the value field.
* @description - which may use prefix text like excel
* - the prefix text is create by subtotal type
* @param {string} baseName the name without prefix text
* @param {PivotSubtotalTypeEnum} subtotalType the type of subtotal to be displayed for this value field.
* @returns {string} the auto display name of the value field.
*/
export declare function getAutoDisplayName(baseName: string, subtotalType: PivotSubtotalTypeEnum): string;
/**
* the value field name can be match with prefix rule
* @description if user set a prefix like name ,the func can not get and it will return true
* @param {string} fieldName - the given name to test
* @returns {boolean} is match to the auto name rule
*/
export declare function isAutoDisplayName(fieldName: string): boolean;
/**
* - get the field or field item collapse status
* @param {Record<string, boolean|Record<string, boolean>>} collapseInfo
* @param {string} fieldId the field id
* @param {string} [item] the field item id
* @returns {boolean} - return true if the field or field item is collapse
*/
export declare function getCollapse(collapseInfo: Record<string, boolean | Record<string, boolean>>, fieldId: string, item?: string): boolean;
/**
* -judge the filter info is manual filter
* @param {IPivotTableFilterInfo} filterInfo - the dimension filter info
* @returns {boolean} return true if the filter info is manual filter
*/
export declare function isManualFilter(filterInfo: IPivotTableFilterInfo): filterInfo is IPivotTableManualFilter;
/**
* -judge the filter info is customFilter filter
* @param {IPivotTableFilterInfo} filterInfo - the dimension filter info
* @returns {boolean} return true if the filter info is custom filter
*/
export declare function isCustomFilter(filterInfo: IPivotTableFilterInfo): filterInfo is IPivotTableCustomFilter;
/**
* -judge the filter info is customFilter filter
* @param {IPivotTableFilterInfo} filterInfo - the dimension filter info
* @returns {boolean} return true if the filter info is custom filter
*/
export declare function isValueFilter(filterInfo: IPivotTableFilterInfo): filterInfo is IPivotTableCustomFilter;
/**
* - Generate a random hex number text with specified length
* @param {number} length the length of the generated hex number
* @returns {string} the generated hex number
*/
export declare function generateHexNumber(length: number): string;
/**
* - Represents the intersection of multiple indexes, this function only works for sorted arrays.
* @param {number[][]} indexes the array of indexes to be intersected.
* @returns {number[]} the intersection of the indexes
*/
export declare function getIndexesIntersection(indexes: number[][]): number[];
/**
* - union the subtotal info to the parent tuple, we do subtotal for the deepest level tuple to the root tuple
* @param {ITupleItem} tupleItem the tuple item
* @param {ITupleItem} parenTupleItem the parent tuple item
* @param {Record<string, IMeasuresMapItem>} measuresMap the measures map
* @returns {void} - no return
*/
export declare function subTotalTupleItem(tupleItem: ITupleItem, parenTupleItem: ITupleItem | undefined, measuresMap: Record<string, IMeasuresMapItem>): void;
/**
* - Get the filter status and value for the pivot table cell
* @param {IPivotTableFilterInfo} filterInfo
* @returns { status: PivotCellStyleTypeEnum, value?: string } the filter status and value
*/
export declare function getFilterStatusAndValue(filterInfo: IPivotTableFilterInfo | undefined): {
status: PivotCellStyleTypeEnum;
value?: string;
};
/**
* - get dim cell status with filter and sort info
* @param {IPivotTableFilterInfo} filterInfo the filter info
* @param {IPivotTableSortInfo} sortInfo the sort info
* @returns {PivotCellStyleTypeEnum} the cell style type
*/
export declare function getDimFilterSortStatus(filterInfo: IPivotTableFilterInfo | undefined, sortInfo: IPivotTableSortInfo | undefined, valueFilterInfo: IValueFilterInfoItem): PivotCellStyleTypeEnum;
/**
* - 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
* @param {string[]} paths - the paths of the cell
* @param {number|undefined} valueIndex - the value index of the cell
* @returns {string} key of the path and value index
*/
export declare function getPathWithValueIndex(paths: string[], valueIndex: number | undefined, considerValue: boolean): string;
/**
* - Merge multiple sorted arrays into a single sorted array
* @param {arrays: number[][]} arrays - the arrays to be merged
* @returns {number[]} - the merged array
*/
export declare function unionSortedList(arrays: number[][]): number[];
/**
* sort the label item by the item type
* @param {string[]} items - the items to be sorted
* @param {PivotDataFieldDataTypeEnum[]} itemTypes - the item type of the items
* @param {Record<string, number>} itemsMap - the original item map
* @returns {Record<string, number>} the sorted item map
*/
export declare function sortLabelItem(items: string[], itemTypes: PivotDataFieldDataTypeEnum[], itemsMap: Record<string, number>): Record<string, number>;
export declare function getCustomNumberFilterResultTemp(indexesMap: Record<string, number[]>, operator: ST_PivotFilterOperatorEnum, expected: number | [number, number]): number[][];
export interface IValueFilterSummaryListItem {
tuple: PivotTuple;
}
export declare function subtotalTupleItemForValueFilter(summaryList: IValueFilterSummaryListItem[], tupleItem: ITupleItem | undefined, fieldId: string, subtotal: PivotSubtotalTypeEnum, v: number, p: number): void;
export declare function isErrorTypeSubtotal(subtotal: number | {
errorType: PivotErrorTypeEnum;
}): subtotal is {
errorType: PivotErrorTypeEnum;
};
export declare function isLabelCustomSortInfo(sortInfo: IPivotTableSortInfo): sortInfo is IPivotTableLabelCustomSortInfo;
export declare function excelDateToUnixMilliseconds(excelDate: number, useDefault1900DateSystem?: boolean): number;
export declare function isDateGroupField(field: DataField): field is DateGroupField;
export declare function isBaseGroupField(field: DataField): field is BaseGroupField;
export declare function isBaseGroupFieldJSON(field: IDataFieldJSON | IBaseGroupFieldJSON): field is IBaseGroupFieldJSON;
export declare function isDateGroupFieldJSON(field: IDataFieldJSON | IBaseGroupFieldJSON): field is IDateGroupFieldJSON;
export declare function isDateGroupInfo(groupInfo: IPivotTableGroupInfo): groupInfo is IPivotTableDateGroupInfo;
export declare function getDateGroupValue(excelDate: number, dateType: PivotDateGroupFieldDateTypeEnum, useDefault1900DateSystem?: boolean): string;