UNPKG

hightable

Version:

A dynamic windowed scrolling table component for react

36 lines (35 loc) 1.93 kB
import type { ReactNode } from 'react'; /** * The width of a column depends on several factors. * Some are given: * - the number of columns * - the global minimum width (minWidth prop, 50px by default) * - the minimum width for a specific column, which overrides the default one (see ColumnParametersContext, optional) * - the available width in the table (depends on the component resizes) * Others are a state: * - the fixed width, when a user resizes the column (note: it is stored in the local storage, and we don't adjust other columns when setting a fixed column) * - the measured width (obtained by releasing any restriction on the column and measuring the content width - CSS max-width and other rules apply) * - the adjusted width, computed to fill the available width when there are measured columns - not set if the column has a fixed width * * The width must be at least the minimum width. There is no maximum width. * * The priority order to decide the width of a column, based on these factors, is: * 1. fixed width * 2. measured width * 3. adjusted width (if the column has been measured, and had to be adjusted) * 4. undefined (free width, respects the CSS style rules if any) * * If any of the factors change, the widths of all the columns are recomputed. Special rules: * - if a fixed or measured width does not respect the minimum width anymore, it is deleted. * - when a column is resized manually (ie. fixed), the other columns remain unchanged and are not adjusted. */ interface ColumnWidthsProviderProps { viewportWidth?: number; tableCornerWidth?: number; localStorageKey?: string; numColumns: number; minWidth?: number; children: ReactNode; } export declare function ColumnWidthsProvider({ children, localStorageKey, numColumns, minWidth, viewportWidth, tableCornerWidth }: ColumnWidthsProviderProps): import("react/jsx-runtime").JSX.Element; export {};