import type { OnChangeFn, Updater } from '@tanstack/react-table'; /** * @public */ export interface DataTableLineWrapBaseProps { /** * Callback that is called when the lineWrap state of the table or any column is changed. */ onLineWrapChange?: (lineWrap: DataTableLineWrapState) => void; } /** * @public */ export interface DataTableLineWrapControlledProps extends DataTableLineWrapBaseProps { /** * Lets you control the lineWrap state of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * lineWraps to individual columns. * @example * ```typescript * lineWrap={true} // for forcing lineWrap on all columns in the table * lineWrap={{ [column.id]: true|false }} // to control the lineWrap on individual columns. * ``` */ lineWrap?: DataTableLineWrapState; /** * Lets you set lineWrap state initially of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * lineWraps to individual columns. * @example * ```typescript * defaultLineWrap={true} // for forcing lineWrap on all columns in the table * defaultLineWrap={{ [column.id]: true|false }} // to control the lineWrap on individual columns. * ``` */ defaultLineWrap?: never; } /** * @public */ export interface DataTableLineWrapUncontrolledProps extends DataTableLineWrapBaseProps { /** * Lets you control the lineWrap state of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * lineWraps to individual columns. * @example * ```typescript * lineWrap={true} // for forcing lineWrap on all columns in the table * lineWrap={{ [column.id]: true|false }} // to control the lineWrap on individual columns. * ``` */ lineWrap?: never; /** * Lets you set lineWrap state initially of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * lineWraps to individual columns. * @example * ```typescript * defaultLineWrap={true} // for forcing lineWrap on all columns in the table * defaultLineWrap={{ [column.id]: true|false }} // to control the lineWrap on individual columns. * ``` */ defaultLineWrap?: DataTableLineWrapState; } /** * Interface defining the props on the DataTable that control the line wrapping feature. * @public */ export type DataTableLineWrapProps = DataTableLineWrapControlledProps | DataTableLineWrapUncontrolledProps; /** * Defines the shape of the LineWrap state within the tanstack tables state. * @public */ export type DataTableLineWrapState = Record | boolean; /** * Extension interface to extend the tanstack table state with the LineWrap state. * @internal */ export interface DataTableLineWrapTableState { /** * Table state extension for lineWrap */ columnLineWrap: DataTableLineWrapState; } /** * Extension interface to extend the useTable hook options with the LineWrap options. * @internal */ export interface DataTableLineWrapOptions { /** * Enables line wrapping as a feature on the table. */ enableLineWrap?: boolean; /** * Exposes the onLineWrapChange function to the Table options. */ onColumnLineWrapChange?: OnChangeFn; } /** * Extension interface to extend the types of the tanstack table instance. * @internal */ export interface DataTableLineWrapInstance { /** * Helper function to update the global table states `columnLineWrap` portion. */ setColumnLineWrap: (updater: Updater) => void; } /** * Extension interface to extend the types exposed on the tanstack column object. * @internal */ export interface DataTableLineWrapColumn { /** * Returns a boolean value that represents if the column can be line wrapped. */ getCanLineWrap: () => boolean; /** * Returns a boolean value that represents if the column is currently line wrapped. */ getIsLineWrapped: () => boolean; /** * Toggles the line wrap state for the column. * @param value - The optional boolean to set the line wrap state to. If not provided, the current state will be toggled. */ toggleLineWrap: (value?: boolean) => void; }