import type { ColumnPinningPosition } from '@tanstack/react-table'; /** * The left and right pinned child columns. * @public */ export interface DataTablePinnedColumnState { /** * Set of left pinned column IDs. */ left?: string[]; /** * Set of right pinned column IDs. */ right?: string[]; } /** * Props for column pinning. * @public */ export type DataTableColumnPinningProps = DataTableColumnPinningControlledProps | DataTableColumnPinningUncontrolledProps; /** * Options for DataTable column pinning. * @public */ export interface DataTableColumnPinningBaseProps { /** * Enables column pinning for custom columns. * @remarks Built-in columns like the selection column are always pinned and can not be unpinned. * @defaultValue false */ columnPinning?: boolean; /** * Callback triggered when pinned columns changed. * Provides the custom left and right pinned child columns. */ onPinnedColumnsChange?: (pinnedColumns: DataTablePinnedColumnState) => void; } /** * Controlled props for column pinning. * @public */ export interface DataTableColumnPinningControlledProps extends DataTableColumnPinningBaseProps { /** * Set of left and right pinned column IDs. */ pinnedColumns?: DataTablePinnedColumnState; /** * Initial set of left and right pinned column IDs. */ defaultPinnedColumns?: never; } /** * Uncontrolled props for column pinning. * @public */ export interface DataTableColumnPinningUncontrolledProps extends DataTableColumnPinningBaseProps { /** * Initial set of left and right pinned column IDs. */ defaultPinnedColumns?: DataTablePinnedColumnState; /** * Set of left and right pinned column IDs. */ pinnedColumns?: never; } /** * Extension interface to extend the TanStack table column pinning state. * @internal */ export interface DataTableColumnPinningOptions { /** * Original set of left and right pinned column IDs (used to reset column pinning). */ originalColumnPinning?: DataTablePinnedColumnState; } /** * @internal */ export interface DataTableColumnPinningInstance { getLeftLeafColumns: () => TColumn[]; getRightLeafColumns: () => TColumn[]; getCenterLeafColumns: () => TColumn[]; /** * Gets all header groups (left, center, right) for a given group index. */ getOrderedHeaderGroups: () => THeader[][]; } /** * @internal * Extension interface to extend the types of the `HeaderCell` from the tanstack table. */ export interface DataTableColumnPinningHeader { /** * Gets the pinned state of a header column. * If this is group header the pinned state is taken from its visible subHeaders, * as part of the group can be pinned while the rest is unpinned. */ getIsPinned: () => ColumnPinningPosition; /** * Returns the css left position for left pinned headers. */ getLeftPinnedPosition: () => number | undefined; /** * Returns the css right position for right pinned headers. */ getRightPinnedPosition: () => number | undefined; /** * Returns whether the header is the last visible left pinned header. * If it is a nested header, this is true for both header and sub header. */ getIsLastVisibleLeftPinnedHeader: () => boolean; /** * Returns whether the header is the first unpinned header. * If it is a nested header, this is true for both header and sub header. */ getIsFirstVisibleUnpinnedHeader: () => boolean; /** * Returns whether the header is the last unpinned header. * If it is a nested header, this is true for both header and sub header. */ getIsLastVisibleUnpinnedHeader: () => boolean; /** * Returns whether the header is the first right pinned header. * If it is a nested header, this is true for both header and sub header. */ getIsFirstVisibleRightPinnedHeader: () => boolean; /** * Pins a header to the `'left'` or `'right'`, * or unpins the header to the center if `false` is passed. * @remarks If the header has sub-headers, those are pinned as well. */ pin: (position: ColumnPinningPosition) => void; } /** * @internal */ export interface DataTableColumnPinningColumn { /** * Returns the css left position for left pinned columns. */ getLeftPinnedPosition: () => number | undefined; /** * Returns the css right position for right pinned columns. */ getRightPinnedPosition: () => number | undefined; /** * Returns whether the column is the last visible left pinned column. * If the last left pinned column is a nested header, this is true for both parent and child columns. */ getIsLastVisibleLeftPinnedColumn: () => boolean; /** * Returns whether the column is the first unpinned column. * If the first unpinned column is a nested header, this is true for both parent and child columns. */ getIsFirstVisibleUnpinnedColumn: () => boolean; /** * Returns whether the column is the last unpinned column. * If the last unpinned column is a nested header, this is true for both parent and child columns. */ getIsLastVisibleUnpinnedColumn: () => boolean; /** * Returns whether the column is the first right pinned column. * If the first right pinned column is a nested header, this is true for both parent and child columns. */ getIsFirstVisibleRightPinnedColumn: () => boolean; }