import type { OnChangeFn, Updater } from '@tanstack/react-table'; /** * Defines the shape of the FontStyle state within the tanstack tables state. * @public */ export type DataTableColumnFontStyleState = Record; /** * @public */ export interface DataTableColumnFontStyleBaseProps { /** * Callback that is called when the FontStyle state of the table or any column is changed. */ onFontStyleChange?: (fontStyle: DataTableColumnFontStyleState) => void; } /** * @public */ export interface DataTableColumnFontStyleControlledProps extends DataTableColumnFontStyleBaseProps { /** * Lets you control the FontStyle state of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * FontStyles to individual columns. * @example * ```typescript * FontStyle={{ [column.id]: 'code'|'text' }} // to control the FontStyle on individual columns. * ``` */ fontStyle?: DataTableColumnFontStyleState; /** * Lets you set FontStyle state initially of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * FontStyles to individual columns. * @example * ```typescript * defaultFontStyle={{ [column.id]: 'code'|'text' }} // to control the FontStyle on individual columns. * ``` */ defaultFontStyle?: never; } /** * @public */ export interface DataTableColumnFontStyleUncontrolledProps extends DataTableColumnFontStyleBaseProps { /** * Lets you control the FontStyle state of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * FontStyles to individual columns. * @example * ```typescript * FontStyle={{ [column.id]: 'code'|'text' }} // to control the FontStyle on individual columns. * ``` */ fontStyle?: never; /** * Lets you set FontStyle state initially of the entire table or individual columns. * `boolean` values will affect the whole table, whereas `Record` values will let you assign * FontStyles to individual columns. * @example * ```typescript * defaultFontStyle={{ [column.id]: 'code'|'text' }} // to control the FontStyle on individual columns. * ``` */ defaultFontStyle?: DataTableColumnFontStyleState; } /** * Interface defining the props on the DataTable that control the font style feature. * @public */ export type DataTableColumnFontStyleProps = DataTableColumnFontStyleControlledProps | DataTableColumnFontStyleUncontrolledProps; /** * Extension interface to extend the tanstack table state with the FontStyle state. * @internal */ export interface DataTableColumnFontStyleTableState { /** * Table state extension for FontStyle */ columnFontStyle: DataTableColumnFontStyleState; } /** * Extension interface to extend the useTable hook options with the FontStyle options. * @internal */ export interface DataTableColumnFontStyleOptions { /** * Enables ćolumn font style as a feature on the table. */ enableFontStyle?: boolean; /** * Exposes the onFontStyleChange function to the Table options. */ onColumnFontStyleChange?: OnChangeFn; } /** * Extension interface to extend the types of the tanstack table instance. * @internal */ export interface DataTableColumnFontStyleInstance { /** * Helper function to update the global table states `columnFontStyle` portion. */ setColumnFontStyle: (updater: Updater) => void; } /** * Extension interface to extend the types exposed on the tanstack column object. * @internal */ export interface DataTableColumnFontStyleColumn { /** * Return a boolean value that will represent the current fontStyle state of a column. */ getFontStyle: () => 'text' | 'code'; /** * Toggles the fontStyle property of the column * @param value - If a value is provided, this function behaves like a setter instead of a toggle. */ toggleFontStyle: (value?: 'text' | 'code') => void; }