import { FC, Ref } from "react"; import { IconProps, PaginatorProps, SearchProps, SortColumn, SplitButtonProps, TableProps, TableSelectionCellProps } from ".."; import { ButtonProps } from "../button"; import { BaseElementProps } from "../../types"; /** Table item type */ export type ComplexTableItem = { /** Unique item identifier */ id: string; }; /** {@link ComplexTable} component props type */ export type ComplexTableProps = Pick & { /** Table items */ items: Array; /** Text to display when there are no items */ noItemsCaption: string; /** * Total number of pages. Used for pagination. * Must be passed from the hook {@link useComplexTable} to work correctly. */ pagesCount: number; /** * Current page number. Used for pagination. * Must be passed from the hook {@link useComplexTable} to work correctly. */ currentPage: number; /** * Keys of currently selected rows. * @description Values correspond to `key` props of child row elements * Must be passed from the hook {@link useComplexTable} to work correctly. */ selectedRows?: Array; /** Component for rendering a table item */ itemComponent?: FC>; /** Configuration for the inner table */ tableConfig?: ComplexTableInnerTableProps; /** Configuration for the paginator */ paginatorConfig?: ComplexTablePaginatorConfig; /** * Configuration for selection bar. * If not provided, a default selection bar with the same actions as in `selection` is rendered. */ selectionBarConfig?: ComplexTableSelectionBarConfig; /** * Configuration for the search field. If provided, a search bar is displayed */ searchConfig?: ComplexTableSearchConfig; /** Row actions */ actions?: Array; /** * Whether an active search query is present. Affects the text displayed when no items are found. * Must be passed from the hook {@link useComplexTable} to work correctly. */ hasActiveSearch?: boolean; /** * Data loading flag. Displays an overlay over the table when `true`. * Must be passed from the hook {@link useComplexTable} to work correctly. */ loading?: boolean; /** Ref for the table container (scroll management) */ /** * Ref for the table container. Used for scroll management in the hook. * Must be passed from the hook {@link useComplexTable} to work correctly. */ containerRef?: Ref; /** Ref for the inner table element */ tableRef?: Ref; /** * Page change handler * Must be passed from the hook {@link useComplexTable} to work correctly. * @param page Page number */ onPageChange: (page: number) => void; /** * Search handler. * Must be passed from the hook {@link useComplexTable} to work correctly. * @param query Search query */ onSearch: (query: string) => void; /** * Sort change handler. * Called when a sortable column header is clicked. * Toggle order: ascending → descending → no sorting * Must be passed from the hook {@link useComplexTable} to work correctly. * @param sortColumn Current sort or `undefined` when reset */ onSortChange: (sortColumn?: SortColumn) => void; /** * Selected items change handler. * Called when the set of selected rows changes * Must be passed from the hook {@link useComplexTable} to work correctly when row selection is enabled. * @param selectedIds Selected item identifiers */ onSelectionChange?: (selectedIds: Array) => void; /** * Table row click handler * @param itemId Item identifier */ onRowClick?: (itemId: string) => void; /** * Callback invoked after a page has successfully loaded (page change, search, or sort). * When provided, replaces the default scroll-to-top behavior performed by the hook. * @see {@link useComplexTable} `afterPageLoad` option */ afterPageLoad?: () => void; }; /** {@link ComplexTableItem} component props type */ export type ComplexTableItemProps = TableSelectionCellProps & Pick & { /** Table item */ item: TItem; /** Row actions */ actions?: Array; /** * Table row click handler * @param itemId Item identifier */ onRowClick?: (itemId: string) => void; }; /** Table row action type */ export type ComplexTableAction = Omit & { /** Action icon click handler */ onClick: (itemId: string) => void; }; /** {@link ComplexTable} search configuration */ export type ComplexTableSearchConfig = { /** Search field placeholder */ searchPlaceholder: string; /** Text to display when no items match the search query */ noItemsFoundBySearchCaption: string; /** Configuration for the search field */ searchProps?: Omit; /** CSS class for the search container */ containerClassName?: string; /** CSS class for the wrapper element around the search field */ wrapperClassName?: string; /** * Debounce delay in milliseconds before the search handler is called. * When not provided or `<= 0`, the search handler is called immediately on every input change. */ debounceTime?: number; }; /** Props for the inner table of {@link ComplexTable} */ export type ComplexTableInnerTableProps = Omit; /** Props for the paginator of {@link ComplexTable} */ export type ComplexTablePaginatorConfig = Omit; /** Common props for the selection bar of {@link ComplexTable} */ export type ComplexTableSelectionBarBase = BaseElementProps & { /** * Placeholder for the selected items count in the selection bar. * @param count Selected items count * @return Placeholder text */ selectedCountPlaceholder: (count: number) => string; }; /** Selection bar rendered as a list of separate buttons */ export type ComplexTableSelectionBarButtonList = ComplexTableSelectionBarBase & { /** Type of the selection bar */ type: "Button list"; /** Actions rendered as individual buttons */ actions: Array; }; /** Selection bar rendered as a split button */ export type ComplexTableSelectionBarSplitButton = ComplexTableSelectionBarBase & { /** Type of the selection bar */ type: "SplitButton"; /** Configuration for the split button */ splitButtonConfig: SplitButtonProps; }; /** Props for the selection bar of {@link ComplexTable} */ export type ComplexTableSelectionBarConfig = ComplexTableSelectionBarButtonList | ComplexTableSelectionBarSplitButton; //# sourceMappingURL=types.d.ts.map