UNPKG

@shridey/intelligentable

Version:

Intelligentable is a highly customizable, fully-types, performant, and feature-rich React component library built on top of handpicked industry-level production-grade UI Components for modern web applications.

59 lines (58 loc) 2.09 kB
import type { AnyObject } from "antd/es/_util/type"; /** * Aggregated & grouped node, ready for AntD table. */ export interface AggregatedNode extends AnyObject { key: string; totalValue: number; totalCount: number; averageValue: number; percentageOfParentRaw: number; percentageOfParent: string; percentageOfRootRaw: number; percentageOfRoot: string; children?: AggregatedNode[]; } /** * Options to configure which fields are value/count in raw data. */ export interface AggregationConfig { valueField: string; countField?: string; } /** * Groups data by multiple keys recursively. */ export declare function groupByKeysWithKey(data: AnyObject[], keys: string[], config: AggregationConfig, parentKey?: string): AggregatedNode[]; /** * Recursively computes totals, averages, parent/root percentages. */ export declare function addAggregatesWithDerived(node: AggregatedNode, parentTotalValue?: number, rootTotalValue?: number): AggregatedNode; /** * Recursively sorts children arrays in tree. */ export declare function sortGroups(node: AggregatedNode, compareFn: (a: AggregatedNode, b: AggregatedNode) => number): AggregatedNode; /** * Pivot flat data into wide rows: rowKey → pivotKey values → valueField. */ export interface PivotOptions { rowKey: string; pivotKey: string; valueField: string; transformValue?: (value: unknown, item: AnyObject) => unknown; addAverageField?: boolean; orderedPivotKeys?: string[]; } export declare function pivotData(data: AnyObject[], options: PivotOptions): AnyObject[]; /** * Functional pipeline: apply transformations. Compose multiple transform steps. */ export declare function transformPipeline(data: AnyObject[], steps: ((data: AnyObject[]) => AnyObject[])[]): AnyObject[]; /** * Filter flat array. */ export declare function filterData(data: AnyObject[], predicate: (item: AnyObject) => boolean): AnyObject[]; /** * Sort flat array. */ export declare function sortData(data: AnyObject[], compareFn: (a: AnyObject, b: AnyObject) => number): AnyObject[];