import { DataGridProps } from '../DataGrid.types'; import { ColumnType } from '../types/column.type'; import { SortDirection } from '../types/sort.type'; /** * Error thrown when a non-unique value is found for a specified field. */ export declare class NonUniqueFieldError extends Error { /** * @param {string} field - The field that caused the error. * @param {string} duplicateValue - The non-unique value found. */ constructor(name: string, field: string, duplicateValue: string); } /** * Error thrown when an undefined, null or empty value is found for a specified field. */ export declare class EmptyFieldError extends Error { /** * @param {string} field - The field that caused the error. */ constructor(name: string, field: string); } /** * Validates that all values for a specified field in the data array are unique. * * @param {ReadonlyArray>} data - The array of data records to check. * @param {string} [field='id'] - The field property to validate for uniqueness. * @returns {boolean} - Returns true if all values are unique. * @throws {EmptyFieldError} - If any value for the field is undefined or null. * @throws {NonUniqueFieldError} - If any value for the field is not unique. * * @example * // Example usage * const data = [ * { id: '1' }, * { id: '2' }, * { id: '1' } // This will throw a NonUniqueFieldError * ]; * validUniqueData(data); */ export declare const validUniqueData: (data: ReadonlyArray, field?: string) => boolean; /** * Validates that each column in the provided array has a unique field value. * Throws errors if any field is null, undefined, or an empty string, * or if there are duplicate field values. * * @param {ColumnType[]} columns - An array of columns to validate. * @throws {EmptyFieldError} If any column's field is null, undefined, or an empty string. * @throws {NonUniqueFieldError} If any field value is duplicated among the columns. * * @example * // Example usage * const columns = [ * { field: 'name' }, * { field: 'age' }, * { field: 'name' } // This will throw a NonUniqueFieldError * ]; * validUniqueColumn(columns); */ export declare const validUniqueColumn: (columns: ReadonlyArray) => boolean; /** * Validates that all values for a specified field in the data array are unique. * * @param {ReadonlyArray>} data - The array of data records to check. * @param {string} [field='id'] - The field property to validate for uniqueness. * @returns {boolean} - Returns true if all values are unique. * @throws {EmptyFieldError} - If any value for the field is undefined or null. * @throws {NonUniqueFieldError} - If any value for the field is not unique. */ export declare const validProps: (props: DataGridProps) => void; /** * Compares two values based on the specified sort direction. * * @param {any} value1 - The first value to compare. * @param {any} value2 - The second value to compare. * @param {SortDirection} sortDirection - The direction to sort ('asc' or 'desc'). * @returns {number} - A negative number if value1 < value2, a positive number if value1 > value2, and 0 if they are equal. */ export declare const compareValues: (value1: any, value2: any, sortDirection: SortDirection) => number; /** * Deep merges two objects, giving priority to properties in the first object. * * @param {T} passedProps - The properties to merge. * @param {T} defaultProps - The default properties to merge into. * @returns {T} - The merged properties. */ export declare const deepMerge: (passedProps: T | undefined, defaultProps: T | undefined) => T; /** * Clamps a given width between a specified minimum and maximum width. * * If the maximum width is less than the minimum width, the maximum width * is ignored, and the result is clamped only by the minimum width. * * @param {number} width - The initial column width to be clamped. * @param {number} minWidth - The minimum allowable width. * @param {number} maxWidth - The maximum allowable width. * @returns {number} The clamped column width. */ export declare const clampColumnWidth: (width: number, minWidth: number, maxWidth: number) => number; /** * Calculates the height of the grid header based on the specified density. * * @param {number} rowHeight - The height of the rows. * @param {'compact' | 'standard' | 'comfortable'} [density='standard'] - The density setting for the grid. * @returns {number} - The calculated header height. */ export declare const getGridHeaderHeight: (rowHeight?: number | undefined, density?: "compact" | "standard" | "comfortable") => number; /** * Calculates the total height of the grid rows. * * @param {number} [rowCount=1] - The number of rows. * @param {number} rowHeight - The height of each row. * @param {number} expandedPanelHeight - The height of expanded row panel. * @param {'compact' | 'standard' | 'comfortable'} [density='standard'] - The density setting for the grid. * @returns {number} - The total height of the rows. */ export declare const getGridRowsHeight: (rowCount?: number | undefined, rowHeight?: number | undefined, expandedPanelHeight?: number | undefined, density?: "compact" | "standard" | "comfortable") => number; /** * Calculates the height of the grid pagination based on the specified density. * * @param {number} paginationHeight - The height of the pagination. * @param {'compact' | 'standard' | 'comfortable'} density - The density setting for the grid. * @returns {number} - The calculated pagination height. */ export declare const getGridPaginationHeight: (paginationHeight: number | undefined, density: "compact" | "standard" | "comfortable") => number; /** * Calculates the total height of the grid including header, rows, and pagination. * * @param {number} rowCount - The number of rows. * @param {number} headerHeight - The height of the header. * @param {number} rowHeight - The height of each row. * @param {number} paginationHeight - The height of the pagination. * @param {number} expandedPanelHeight - The height of expanded row panel. * @param {'compact' | 'standard' | 'comfortable'} density - The density setting for the grid. * @returns {number} - The total height of the grid. */ export declare const getGridHeight: (rowCount: number | undefined, headerHeight: number | undefined, rowHeight: number | undefined, paginationHeight: number | undefined, expandedPanelHeight: number | undefined, density: "compact" | "standard" | "comfortable") => number; /** * Calculates the total width of the grid columns based on their widths and selection mode. * * @param {number[]} [columnWidths=[]] - The widths of the columns. * @param {'checkboxSelection' | 'radioSelection' | undefined} rowSelectionMode - The selection mode for the grid. * @param {boolean} isEnabledRowExpansion - Indicate if the row expansion feature enabled. * @param {'compact' | 'standard' | 'comfortable'} density - The density setting for the grid. * @returns {number} - The total width of the grid columns. */ export declare const getGridColumnsWidth: (columnWidths: number[], rowSelectionMode: "checkboxSelection" | "radioSelection" | undefined, isEnabledRowExpansion: boolean, density: "compact" | "standard" | "comfortable") => number; /** * Calculates the widths of the columns based on their fixed and flexible settings. * * @param {ColumnType[]} columns - The columns to calculate widths for. * @param {number} gridWidth - The total width of the grid. * @param {'checkboxSelection' | 'radioSelection' | undefined} rowSelectionMode - The selection mode for the grid. * @param {'compact' | 'standard' | 'comfortable'} density - The density setting for the grid. * @param {number[]} cachedWidth - Cached widths for the columns to optimize recalculation. * @returns {number[]} - The calculated widths for each column. */ export declare const calculateWidths: (columns: ColumnType[], gridWidth: number, rowSelectionMode: "checkboxSelection" | "radioSelection" | undefined, isEnabledRowExpansion: boolean, density: "compact" | "standard" | "comfortable", cachedWidth: number[], resizedColumnWidth?: Record) => number[];