import type { provideExpanded } from './composables/expand.js'; import type { Group, GroupableItem, GroupSummary, provideGroupBy } from './composables/group.js'; import type { provideSelection, SelectableItem } from './composables/select.js'; import type { FilterFunction, InternalItem } from '../../composables/filter.js'; import type { SelectItemKey } from '../../util/index.js'; export type DataTableCompareFunction = (a: T, b: T) => number | null; export type DataTableHeader> = { key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {}); value?: SelectItemKey; title?: string; fixed?: boolean | 'start' | 'end'; align?: 'start' | 'end' | 'center'; width?: number | string; minWidth?: number | string; maxWidth?: number | string; nowrap?: boolean; indent?: number; headerProps?: Record; cellProps?: HeaderCellProps; sortable?: boolean; sort?: DataTableCompareFunction; sortRaw?: DataTableCompareFunction; filter?: FilterFunction; children?: DataTableHeader[]; }; export type InternalDataTableHeader = Omit & { key: string | null; value: SelectItemKey | null; sortable: boolean; fixedOffset?: number; fixedEndOffset?: number; lastFixed?: boolean; firstFixedEnd?: boolean; nowrap?: boolean; colspan?: number; rowspan?: number; children?: InternalDataTableHeader[]; }; export interface DataTableItem extends Omit, 'type'>, GroupableItem, SelectableItem { key: any; index: number; virtualIndex?: number; columns: { [key: string]: any; }; } export type GroupHeaderSlot = { index: number; item: Group; columns: InternalDataTableHeader[]; isExpanded: ReturnType['isExpanded']; toggleExpand: ReturnType['toggleExpand']; isSelected: ReturnType['isSelected']; toggleSelect: ReturnType['toggleSelect']; toggleGroup: ReturnType['toggleGroup']; isGroupOpen: ReturnType['isGroupOpen']; }; export type GroupSummarySlot = { index: number; item: GroupSummary; columns: InternalDataTableHeader[]; toggleGroup: ReturnType['toggleGroup']; }; type ItemSlotBase = { index: number; item: T; internalItem: DataTableItem; isExpanded: ReturnType['isExpanded']; toggleExpand: ReturnType['toggleExpand']; isSelected: ReturnType['isSelected']; toggleSelect: ReturnType['toggleSelect']; }; export type ItemSlot = ItemSlotBase & { columns: InternalDataTableHeader[]; }; export type ItemKeySlot = ItemSlotBase & { value: any; column: InternalDataTableHeader; }; export type RowProps = Record | RowPropsFunction; export type RowPropsFunction = (data: Pick, 'index' | 'item' | 'internalItem'>) => Record; export type CellProps = Record | CellPropsFunction; export type CellPropsFunction = (data: Pick, 'index' | 'item' | 'internalItem' | 'value' | 'column'>) => Record; export type HeaderCellProps = Record | HeaderCellPropsFunction; export type HeaderCellPropsFunction = (data: Pick, 'index' | 'item' | 'internalItem' | 'value'>) => Record;