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.

58 lines (57 loc) 2.49 kB
import type { AnyObject } from "antd/es/_util/type"; import type { DataIndex } from "rc-table/lib/interface"; import type { IntelligentTableColumnType } from "../../types/IntelligentTable/IntelligentTableColumnType"; /** * Detects the type of a value for sorting and formatting. * * @param {unknown} value - The value to detect. * @returns {"number" | "id" | "percentage" | "currency" | "date" | "dayOfWeek" | "string"} The detected type. */ export declare const detectType: (value: unknown) => "number" | "id" | "percentage" | "currency" | "date" | "dayOfWeek" | "string"; /** * Formats a number to a fixed number of decimal places. * * @param {number} num - The number to format. * @param {number} decimalPlaces - Number of decimal places. * @returns {string} The formatted string. */ export declare const formatValue: (num: number, decimalPlaces: number) => string; /** * Enhances columns with smart sorting, rendering, and filtering logic. * * @param {IntelligentTableColumnType[]} columns - The columns to enhance. * @returns {IntelligentTableColumnType[]} The enhanced columns. */ export declare const enhanceColumns: (columns: IntelligentTableColumnType[]) => IntelligentTableColumnType[]; /** * Gets the most frequent symbol from an array of symbols. * * @param {string[]} symbols - Array of symbols. * @returns {string} The most frequent symbol. */ export declare const getMostFrequentSymbol: (symbols: string[]) => string; /** * Parses a value to extract its numeric value and symbol (currency, percentage, etc). * * @param {unknown} value - The value to parse. * @returns {{ number: number | null; symbol: string }} The parsed number and symbol. */ export declare const parseNumericValue: (value: unknown) => { number: number | null; symbol: string; }; /** * Recursively flattens columns to get all leaf columns. * * @param {IntelligentTableColumnType[]} columns - The columns to flatten. * @returns {IntelligentTableColumnType[]} Array of leaf columns. */ export declare const getLeafColumns: (columns: IntelligentTableColumnType[]) => IntelligentTableColumnType[]; /** * Gets the value from a row by its dataIndex, supporting nested arrays. * * @param {AnyObject} row - The row object. * @param {DataIndex<AnyObject>} dataIndex - The dataIndex (string, number, or array). * @returns {unknown} The value at the given dataIndex. */ export declare function getValueByDataIndex(row: AnyObject, dataIndex: DataIndex<AnyObject>): unknown;