Skip to content

API Reference ​

This page is the behavioral reference: props, events, slots, defaults and controlled/uncontrolled rules.

For the full relationships of TypeScript types such as TableColumnsType, Breakpoint and RowSelection, see the type reference (Chinese). Complete declarations are available in Type Declarations below.

Import entry ​

Import components, constants and types from @vtable-guild/vtable-guild:

ts
import {
  VTable,
  VTableSummary,
  EXPAND_COLUMN,
  SELECTION_COLUMN,
  type TableColumnsType,
  type RowSelection,
  type Expandable,
} from '@vtable-guild/vtable-guild'

VTable Props ​

Data and structure ​

PropTypeDefaultDescription
dataSourceTRecord[][]Table data source.
paginationfalse | TablePaginationConfigfalsePass {} to enable local or remote pagination; see pagination.
columnsTableColumnsType<TRecord>[]Column configuration: leaf columns, column groups and sentinel constants.
columnOrderKey[]-Column display order. See column display (Chinese).
rowKeystring | ((record: TRecord) => Key)-Unique row identity; passing it explicitly is recommended.
childrenColumnNamestring'children'Child field name for tree data.
indentSizenumber15Tree data indent width in px.

Visuals and layout ​

PropTypeDefaultDescription
size'small' | 'middle' | 'large''large'Table size, aligned with ant-design-vue naming.
loadingboolean | { spinning?: boolean; indicator?: VNodeChild; tip?: string }falseLoading state; the object form accepts spinning, indicator, tip.
borderedbooleanfalseShow borders.
stripedbooleanfalseZebra striping.
hoverablebooleantrueRow hover highlight.
tableLayout'auto' | 'fixed'-Table layout mode.
showHeaderbooleantrueWhether to show the header.
headerEllipsisbooleanfalseAlso ellipsize headers of columns with column.ellipsis.
classstring-Extra class on the root node.

Scrolling and positioning ​

PropTypeDefaultDescription
scroll{ x?: number | string; y?: number | string; scrollToFirstRowOnChange?: boolean }-Horizontal and vertical scroll config; providing y creates a fixed-header scroll area. A numeric y sets a fixed viewport; y: 'auto' fills a parent with a definite height and deducts the header and external summary. In virtual mode, other strings must be positive pixel values; relative units fall back to 400px with a development warning. scrollToFirstRowOnChange resets vertical scroll after sort/filter/paginate; defaults to true with pagination and false otherwise.
stickyboolean | TableStickyfalseSticky header, summary or horizontal scrollbar config.
virtualbooleanfalseEnable virtual scrolling; requires scroll.y.
virtualColumnbooleanfalseHorizontal virtualization: render only columns in the viewport; requires virtual. Pays off with many columns, see virtualization (Chinese).
rowHeightnumber-Fixed row height (px), only in virtual mode. Declaring it skips all row measurement and makes viewport math O(1) — only pass it if every row truly has that height.
getPopupContainer(triggerNode: HTMLElement) => HTMLElement-Mount container for filter, selection and page-size menus.

Theming and locale ​

PropTypeDefaultDescription
uiSlotProps<{ slots: Record<TableSlots, string> }>-Theme slot class overrides for this table instance. See the ui slot reference (Chinese).
localeLocaleNameglobal config or 'zh-CN'Locale identifier for this table instance.
localesLocaleRegistry{}Extra locale packs registered on this instance.
localeOverridesDeepPartial<VTableGuildTableLocale>{}Partial locale overrides for this instance.

Interactive capabilities ​

PropTypeDefaultDescription
rowSelectionRowSelection<TRecord>-Enable the selection column.
expandableExpandable<TRecord>-Enable expandable rows.
rowDraggablebooleanfalseEnable row drag sorting, see row drag sort (Chinese).
expandedRowKeysKey[]-Controlled expanded keys for tree data.
defaultExpandedRowKeysKey[]-Default expanded keys for tree data.
defaultExpandAllRowsbooleanfalseExpand all tree nodes by default.
onExpand(expanded: boolean, record: TRecord) => void-Tree expand/collapse callback.
onExpandedRowsChange(expandedKeys: Key[]) => void-Tree expanded-keys callback.
transformCellTextTransformCellText<TRecord>-Transform cell text; opt contains text, column, record and index.
showSorterTooltipbooleantrueTable-level sorter tooltip switch, overridable per column.
sortDirectionsSortOrder[]-Table-level sort direction list, used as the default for columns.

Custom structure ​

PropTypeDefaultDescription
rowClassNamestring | RowClassName<TRecord>-Extra class for body rows.
customRowGetComponentProps<TRecord>-Inject attributes, events and styles on body rows.
customHeaderRow(columns: (ColumnType<TRecord> | ColumnGroupType<TRecord>)[], index?: number) => CellAdditionalProps-Inject attributes, events and styles on header rows.
title(data: TRecord[]) => VNodeChild-Table title render function.
footer(data: TRecord[]) => VNodeChild-Table footer render function.

Column behavior ​

Basics ​

FieldTypeDefaultDescription
keyKey-Unique column identity; passing it explicitly is recommended.
titleColumnTitle<TRecord>-Column title: text, VNode or render function.
dataIndexDataIndex-Data field path, e.g. 'name' or ['address', 'city'].
widthnumber | string-Column width; numbers are treated as px.
alignAlignType-Cell content alignment.
ellipsisboolean | { showTitle?: boolean }falseEllipsize overflowing cell content; showTitle: false disables the hover tooltip.
classNamestring-Extra class for the column's cells.
colSpannumber-Header cell colSpan.
visiblebooleantrueWhether the column is shown, see column display (Chinese).
responsiveBreakpoint[]-Show the column when any listed breakpoint matches the screen.

Custom rendering ​

FieldTypeDefaultDescription
customRender(ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell-Custom body cell content. Returning RenderedCell also sets cell props.
customCellGetComponentProps<TRecord, TRecord>-Inject attributes, events and styles on body cells.
customHeaderCellGetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord>-Inject attributes, events and styles on header cells.
ts
import type { TableColumnType } from '@vtable-guild/vtable-guild'

interface NameRow {
  key: number
  name: string
}

const nameColumn: TableColumnType<NameRow> = {
  key: 'name',
  dataIndex: 'name',
  customRender: ({ text, index }) =>
    index === 0
      ? { children: String(text), props: { colSpan: 2, style: { fontWeight: 'bold' } } }
      : String(text),
}

Fixed columns and resizing ​

FieldTypeDefaultDescription
fixed'left' | 'right' | true-Fixed side; true equals 'left'.
resizablebooleanfalseWhether the column width is drag-adjustable.
minWidthnumber-Leaf-column minimum in auto/fixed layouts and resizing, in finite nonnegative CSS pixels. Unset values add no layout minimum; resizing alone defaults to 50px.
maxWidthnumber-Maximum resize target only; minWidth wins if the two conflict.

width is a target and cannot override a valid minWidth, including explicit 0. Negative or non-finite minimums are treated as unset. All visible leaf columns retain their minimums while another column is resized, regardless of resizable. If their total minimum exceeds the container, the table scrolls horizontally even without scroll.x. Group-header widths follow their children. Updating or removing a minimum recalculates the layout.

Resizing starts from the measured cell width and emits (column: ColumnType<TRecord>, width: number) => void on release after a valid move. The event reports the constrained target; auto-layout content can make the rendered column wider. The component does not mutate the supplied column configuration. Existing minimums may now cause wider columns or earlier horizontal overflow.

Sorting ​

FieldTypeDefaultDescription
sorterColumnSorter<TRecord>-Enable sorting: default compare, custom compare fn or multi-column object.
sortOrderSortOrder-Controlled sort order.
defaultSortOrderSortOrder-Uncontrolled default order, effective on first render only.
sortDirectionsSortOrder[]['ascend', 'descend']Sort directions available for this column.
showSorterTooltipbooleaninherits table configColumn-level sorter tooltip switch.

Table-level sortDirections and showSorterTooltip act as defaults; column-level config wins.

Filtering ​

FieldTypeDefaultDescription
filtersColumnFilterItem[]-Filter menu items; renders the filter icon in the header.
onFilter(value: string | number | boolean, record: TRecord) => boolean-Filter function; return true to keep the row.
filterMultiplebooleantrueWhether multiple filter values can be picked.
filteredValueArray<string | number | boolean> | null-Controlled filter values.
defaultFilteredValueArray<string | number | boolean>-Uncontrolled default filter values.
customFilterDropdownbooleanfalseUse the table-level customFilterDropdown slot.
filterSearchboolean | ((input: string, filter: ColumnFilterItem) => boolean)falseSearch within filter items.
filterMode'menu' | 'tree''menu'Filter item presentation mode.
filterResetToDefaultFilteredValuebooleanfalseReset restores the default filter values.
filterDropdownOpenboolean-Controlled filter dropdown visibility.
onFilterDropdownOpenChange(visible: boolean) => void-Filter dropdown visibility callback.
filteredboolean-Externally control the filter icon highlight; does not filter.
filterIcon(opt: { filtered: boolean }) => VNodeChild-Custom filter icon.
filterDropdownVNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild)-Column-level custom filter panel; overrides the table slot.

Column groups ​

FieldTypeDefaultDescription
childrenArray<ColumnType<TRecord> | ColumnGroupType<TRecord>>-Child columns. With children present the column is a group.

Column groups do not receive leaf-column behaviors such as sorting, filtering, dataIndex and customRender.

Row Selection ​

rowSelection enables the selection column: multiple, single, tree-linked, batch menus and controlled state.

FieldTypeDefaultDescription
type'checkbox' | 'radio''checkbox'Selection type.
selectedRowKeysKey[]-Controlled selected keys.
defaultSelectedRowKeysKey[]-Default selected keys.
onChange(selectedRowKeys: Key[], selectedRows: TRecord[]) => void-Selection change callback.
onSelect(record: TRecord, selected: boolean, selectedRows: TRecord[]) => void-Single-row selection callback.
onSelectMultiple(selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void-Shift multi-select callback.
onSelectAll(selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void-Select-all callback.
onSelectInvert(selectedRowKeys: Key[]) => void-Invert-selection callback.
onSelectNone() => void-Clear-selection callback.
getCheckboxProps(record: TRecord) => { disabled?: boolean; name?: string }-Inject attributes on selection controls.
columnWidthnumber | string-Selection column width.
fixedboolean | 'left' | 'right'-Fixed position of the selection column.
columnTitlestring | VNodeChild-Selection column header content.
renderCell(value: boolean, record: TRecord, index: number, originNode: VNodeChild) => VNodeChild | RenderedCell-Custom selection cell.
checkStrictlybooleantrueParent/child independent selection in tree data.
selectionsboolean | (SelectionItem | SelectionSentinel)[]falseDefault or custom batch-selection menu.
hideSelectAllbooleanfalseHide the select-all checkbox and dropdown.
preserveSelectedRowKeysbooleanfalseKeep selected keys when the data source changes.

Default batch-selection constants: see SelectionSentinel (Chinese).

With pagination enabled, the header checkbox and invert selection affect the current page. The “Select all data” menu (selections: true or [SELECTION_ALL]) selects all loaded, selectable records after filtering. Use preserveSelectedRowKeys: true to retain selected keys and records across remote pages; unloaded pages are never fetched automatically. See pagination.

Expandable ​

expandable configures expandable row content. Tree-data expand props live at the VTable top level.

FieldTypeDefaultDescription
expandedRowRender(record: TRecord, index: number, indent: number, expanded: boolean) => VNodeChild-Expanded row content render function.
expandedRowKeysKey[]-Controlled expanded row keys.
defaultExpandedRowKeysKey[]-Default expanded row keys.
expandRowByClickbooleanfalseExpand on full-row click.
expandIcon(props: { expanded: boolean; record: TRecord; expandable: boolean; onExpand: (record: TRecord, e: Event) => void }) => VNodeChild-Custom expand icon.
onExpand(expanded: boolean, record: TRecord) => void-Expand/collapse callback.
onExpandedRowsChange(expandedKeys: Key[]) => void-Expanded-keys callback.
columnWidthnumber | string-Expand column width.
fixed'left' | 'right' | true-Fixed position of the expand column; true = 'left'.
defaultExpandAllRowsbooleanfalseExpand all rows by default.
rowExpandable(record: TRecord) => boolean-Whether a row is expandable.
showExpandColumnbooleantrueWhether to show the expand column.
expandedRowClassNamestring | RowClassName<TRecord>-Class for expanded rows.

Events ​

TRecord is your business row type. VTableEventProps<TRecord> provides callback types for template listeners and event props. For pagination only, use pagination.onChange(page, pageSize); the table event reads pagination from extra.pagination.

EventPayloadDescription
change(filters: TableFiltersInfo, sorter: VTableSorterResult<TRecord>, extra: TableChangeExtra<TRecord>) => voidUnified event after sorting, filtering, selection and pagination.
resizeColumn(column: ColumnType<TRecord>, width: number) => voidFired after a column resize drag ends.
rowDragEnd(newData: TRecord[], info: RowDragSortInfo) => voidFired when row drag sorting finishes with a changed order, see row drag sort (Chinese).

change keeps its three arguments. Enabled pagination adds extra.pagination; actions are 'sort', 'filter', 'select' and 'paginate'.

extra.currentDataSource contains processed data before pagination for sort/filter/paginate, and displayed page data for selection. Remote data is limited to loaded records.

ts
import { ref } from 'vue'
import type { VTableEventProps } from '@vtable-guild/vtable-guild'

interface Row {
  key: number
  name: string
}

const current = ref(1)
const pageSize = ref(10)

const handleChange: NonNullable<VTableEventProps<Row>['onChange']> = (_filters, _sorter, extra) => {
  if (extra.action !== 'paginate' || !extra.pagination) return
  current.value = extra.pagination.current
  pageSize.value = extra.pagination.pageSize
}

Slots ​

SlotPayload typeDescription
bodyCellTableBodyCellSlotProps<TRecord>Custom cell content.
headerCellTableHeaderCellSlotProps<TRecord>Custom header cell content.
empty()Custom empty state.
loading()Custom loading state.
customFilterDropdownCustomFilterDropdownSlotProps<TRecord>Table-level custom filter panel.
customFilterIcon{ column: ColumnType<TRecord>; filtered: boolean }Table-level custom filter icon.
titleTableDataSlotProps<TRecord>Custom title area.
footerTableDataSlotProps<TRecord>Custom footer area.
summary()Custom summary area.
paginationItemTablePaginationSlotPropsContent at { slot: 'name' } in pagination.layout.

These are Vue slots. To restyle structure via classes, see the ui slot reference (Chinese).

paginationItem receives the extension name, effective pagination state, pageCount, range, disabled, position and region. Keep selection and request functions in the parent; bind disabled to application buttons as needed. Extensions share the pagination row's visibility, including empty-data and single-page hiding. See composable layouts and content slots.

VTableSummary ​

VTableSummary renders summary rows.

ComponentCommon propsDescription
VTableSummaryfixed?: SummaryFixedSummary container; fixed accepts true, 'top', 'bottom'.
VTableSummary.Row-Summary row.
VTableSummary.Cellindex: number (required), colSpan?: number, rowSpan?: number, align?: AlignTypeSummary cell.

Pagination ​

pagination?: false | TablePaginationConfig defaults to disabled. Pass {} to enable. See configuration and examples. scroll.scrollToFirstRowOnChange?: boolean controls vertical scroll reset on sort/filter/paginate; enabled pagination defaults to true, other tables retain their previous behavior.

Type Declarations ​

Types are imported from @vtable-guild/vtable-guild. Shared supporting types are indexed in the type reference (Chinese). Summary props below are documentation helper types, not named package exports.

Props and columns
ts
export interface TableProps<TRecord extends object = Record<string, any>> {
  pagination?: false | TablePaginationConfig
  dataSource: TRecord[]
  columns: ColumnsType<TRecord>
  columnOrder?: Key[]
  rowKey?: string | ((record: TRecord) => Key)
  loading?: boolean | { spinning?: boolean; indicator?: VNodeChild; tip?: string }
  size?: 'small' | 'middle' | 'large'
  bordered?: boolean
  striped?: boolean
  hoverable?: boolean
  rowDraggable?: boolean
  ui?: SlotProps<{ slots: Record<TableSlots, string> }>
  class?: string
  tableLayout?: TableLayout
  showHeader?: boolean
  headerEllipsis?: boolean
  rowClassName?: string | RowClassName<TRecord>
  customRow?: GetComponentProps<TRecord>
  customHeaderRow?: (
    columns: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>,
    index?: number,
  ) => CellAdditionalProps
  showSorterTooltip?: boolean
  sortDirections?: SortOrder[]
  locale?: LocaleName
  locales?: LocaleRegistry
  localeOverrides?: DeepPartial<VTableGuildTableLocale>
  sticky?: boolean | TableSticky
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement
  transformCellText?: TransformCellText<TRecord>
  rowSelection?: RowSelection<TRecord>
  expandable?: Expandable<TRecord>
  title?: (data: TRecord[]) => VNodeChild
  footer?: (data: TRecord[]) => VNodeChild
  scroll?: { x?: number | string; y?: number | string; scrollToFirstRowOnChange?: boolean }
  virtual?: boolean
  rowHeight?: number
  virtualColumn?: boolean
  childrenColumnName?: string
  indentSize?: number
  expandedRowKeys?: Key[]
  defaultExpandedRowKeys?: Key[]
  defaultExpandAllRows?: boolean
  onExpand?: (expanded: boolean, record: TRecord) => void
  onExpandedRowsChange?: (expandedKeys: Key[]) => void
}
ts
export interface ColumnType<TRecord extends object = Record<string, any>> {
  key?: Key
  title?: ColumnTitle<TRecord>
  dataIndex?: DataIndex
  width?: number | string
  align?: AlignType
  ellipsis?: boolean | { showTitle?: boolean }
  className?: string
  colSpan?: number
  customRender?: (ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell
  customCell?: GetComponentProps<TRecord, TRecord>
  customHeaderCell?: GetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord>
  fixed?: 'left' | 'right' | true
  resizable?: boolean
  minWidth?: number
  maxWidth?: number
  sorter?: ColumnSorter<TRecord>
  sortOrder?: SortOrder
  defaultSortOrder?: SortOrder
  sortDirections?: SortOrder[]
  filters?: ColumnFilterItem[]
  onFilter?: (value: string | number | boolean, record: TRecord) => boolean
  filterMultiple?: boolean
  filteredValue?: (string | number | boolean)[] | null
  defaultFilteredValue?: (string | number | boolean)[]
  customFilterDropdown?: boolean
  filterSearch?: boolean | ((input: string, filter: ColumnFilterItem) => boolean)
  filterMode?: 'menu' | 'tree'
  filterResetToDefaultFilteredValue?: boolean
  filterDropdownOpen?: boolean
  onFilterDropdownOpenChange?: (visible: boolean) => void
  filtered?: boolean
  filterIcon?: (opt: { filtered: boolean }) => VNodeChild
  filterDropdown?: VNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild)
  showSorterTooltip?: boolean
  visible?: boolean
  responsive?: Breakpoint[]
}
ts
export interface ColumnGroupType<TRecord extends object = Record<string, any>> extends Omit<
  ColumnType<TRecord>,
  | 'dataIndex'
  | 'customRender'
  | 'sorter'
  | 'sortOrder'
  | 'defaultSortOrder'
  | 'sortDirections'
  | 'filters'
  | 'onFilter'
  | 'filterMultiple'
  | 'filteredValue'
  | 'defaultFilteredValue'
  | 'customFilterDropdown'
  | 'filterSearch'
  | 'filterMode'
  | 'filterResetToDefaultFilteredValue'
  | 'filterDropdownOpen'
  | 'onFilterDropdownOpenChange'
  | 'filtered'
  | 'filterIcon'
  | 'filterDropdown'
> {
  children: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>
}
ts
export type ColumnsType<TRecord extends object = Record<string, any>> = Array<
  ColumnType<TRecord> | ColumnGroupType<TRecord> | ColumnSentinel
>
ts
export interface ColumnTitleProps<TRecord extends object = Record<string, any>> {
  sortOrder?: SortOrder
  sortColumn?: ColumnType<TRecord>
  sortColumns?: Array<{ column: ColumnType<TRecord>; order: SortOrder }>
  filters?: Record<string, (string | number | boolean)[] | null>
}
ts
export type ColumnTitle<TRecord extends object = Record<string, any>> =
  | VNodeChild
  | ((props: ColumnTitleProps<TRecord>) => VNodeChild)
ts
export type GetComponentProps<TData, TRecord extends object = Record<string, any>> = (
  data: TData,
  index: number,
  column?: ColumnType<TRecord>,
) => CellAdditionalProps | undefined
ts
export interface CustomRenderContext<TRecord extends object = Record<string, any>> {
  text: unknown
  value: unknown
  record: TRecord
  index: number
  renderIndex: number
  column: ColumnType<TRecord>
}
ts
export interface RenderedCell {
  props?: CellAdditionalProps
  children?: VNodeChild
}
ts
export interface CellAdditionalProps {
  class?: string
  className?: string
  style?: CSSProperties
  colSpan?: number
  rowSpan?: number
  colspan?: number
  rowspan?: number
  onClick?: (event: MouseEvent) => void
  onMouseenter?: (event: MouseEvent) => void
  onMouseleave?: (event: MouseEvent) => void
  [key: string]: unknown
}
ts
export type RowClassName<TRecord = Record<string, any>> = (
  record: TRecord,
  index: number,
  indent: number,
) => string
ts
export type TransformCellText<TRecord extends object = Record<string, any>> = (opt: {
  text: unknown
  column: ColumnType<TRecord>
  record: TRecord
  index: number
}) => unknown
ts
export interface TableSticky {
  offsetHeader?: number
  offsetSummary?: number
  offsetScroll?: number
  getContainer?: () => Window | HTMLElement
}
Selection and expansion
ts
export interface RowSelection<TRecord extends object = Record<string, any>> {
  preserveSelectedRowKeys?: boolean
  type?: RowSelectionType
  selectedRowKeys?: Key[]
  defaultSelectedRowKeys?: Key[]
  onChange?: (selectedRowKeys: Key[], selectedRows: TRecord[]) => void
  onSelect?: (record: TRecord, selected: boolean, selectedRows: TRecord[]) => void
  onSelectMultiple?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
  onSelectAll?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
  onSelectInvert?: (selectedRowKeys: Key[]) => void
  onSelectNone?: () => void
  getCheckboxProps?: (record: TRecord) => { disabled?: boolean; name?: string }
  columnWidth?: number | string
  fixed?: boolean | 'left' | 'right'
  columnTitle?: string | VNodeChild
  renderCell?: (
    value: boolean,
    record: TRecord,
    index: number,
    originNode: VNodeChild,
  ) => VNodeChild | RenderedCell
  checkStrictly?: boolean
  selections?: boolean | (SelectionItem | SelectionSentinel)[]
  hideSelectAll?: boolean
}
ts
export interface SelectionItem {
  key: string
  text: string | VNodeChild
  onSelect?: (changeableRowKeys: Key[]) => void
}
ts
export interface Expandable<TRecord extends object = Record<string, any>> {
  expandedRowRender?: (
    record: TRecord,
    index: number,
    indent: number,
    expanded: boolean,
  ) => VNodeChild
  expandedRowKeys?: Key[]
  defaultExpandedRowKeys?: Key[]
  expandRowByClick?: boolean
  expandIcon?: (props: {
    expanded: boolean
    record: TRecord
    expandable: boolean
    onExpand: (record: TRecord, e: Event) => void
  }) => VNodeChild
  onExpand?: (expanded: boolean, record: TRecord) => void
  onExpandedRowsChange?: (expandedKeys: Key[]) => void
  columnWidth?: number | string
  fixed?: 'left' | 'right' | true
  defaultExpandAllRows?: boolean
  rowExpandable?: (record: TRecord) => boolean
  showExpandColumn?: boolean
  expandedRowClassName?: string | RowClassName<TRecord>
}
Events and slots
ts
export type TableFiltersInfo = Record<string, (string | number | boolean)[] | null>
ts
export interface SorterResultLike<TRecord extends object = Record<string, any>> {
  column: ColumnType<TRecord> | undefined
  columnKey: Key | undefined
  order: SortOrder
  field: ColumnType<TRecord>['dataIndex']
}
ts
export type VTableSorterResult<TRecord extends object = Record<string, any>> =
  | SorterResultLike<TRecord>
  | Array<SorterResultLike<TRecord>>
ts
export interface TableChangeExtra<TRecord extends object = Record<string, any>> {
  action: 'sort' | 'filter' | 'select' | 'paginate'
  /** Available only when pagination is enabled. */
  pagination?: TablePaginationState
  currentDataSource: TRecord[]
}
ts
export interface RowDragSortInfo {
  draggedKey: Key
  targetKey: Key
  orderedKeys: Key[]
}
ts
export interface VTableEventProps<TRecord extends object = Record<string, any>> {
  onChange?: (
    filters: TableFiltersInfo,
    sorter: VTableSorterResult<TRecord>,
    extra: TableChangeExtra<TRecord>,
  ) => void
  onResizeColumn?: (column: ColumnType<TRecord>, width: number) => void
  onRowDragEnd?: (newData: TRecord[], info: RowDragSortInfo) => void
}
ts
export interface TableBodyCellSlotProps<TRecord extends object = Record<string, any>> {
  text: unknown
  record: TRecord
  index: number
  column: ColumnType<TRecord>
}
ts
export interface TableHeaderCellSlotProps<TRecord extends object = Record<string, any>> {
  title: VNodeChild | undefined
  column: ColumnType<TRecord> | ColumnGroupType<TRecord>
  index: number
}
ts
export interface CustomFilterDropdownSlotProps<TRecord extends object = Record<string, any>> {
  column: ColumnType<TRecord>
  selectedKeys: (string | number | boolean)[]
  setSelectedKeys: (keys: (string | number | boolean)[]) => void
  confirm: (options?: { closeDropdown?: boolean }) => void
  clearFilters: (options?: { confirm?: boolean; closeDropdown?: boolean }) => void
  filters: ColumnFilterItem[]
  visible: boolean
  close: () => void
}
ts
export interface TableDataSlotProps<TRecord extends object = Record<string, any>> {
  data: TRecord[]
}
ts
export interface TableSlotsDecl<TRecord extends object = Record<string, any>> {
  bodyCell?: (props: TableBodyCellSlotProps<TRecord>) => VNodeChild
  headerCell?: (props: TableHeaderCellSlotProps<TRecord>) => VNodeChild
  empty?: () => VNodeChild
  loading?: () => VNodeChild
  customFilterDropdown?: (props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild
  customFilterIcon?: (props: { column: ColumnType<TRecord>; filtered: boolean }) => VNodeChild
  title?: (props: TableDataSlotProps<TRecord>) => VNodeChild
  footer?: (props: TableDataSlotProps<TRecord>) => VNodeChild
  paginationItem?: (props: TablePaginationSlotProps) => VNodeChild
  summary?: () => VNodeChild
}
Pagination
ts
export interface TablePaginationConfig {
  current?: number
  defaultCurrent?: number
  pageSize?: number
  defaultPageSize?: number
  total?: number
  disabled?: boolean
  hideOnSinglePage?: boolean
  showSizeChanger?: boolean
  pageSizeOptions?: (string | number)[]
  totalBoundaryShowSizeChanger?: number
  buildOptionText?: (option: { value: string | number }) => VNodeChild
  showQuickJumper?: boolean | { goButton?: VNodeChild }
  showTotal?: (total: number, range: [number, number]) => VNodeChild
  size?: 'default' | 'small'
  simple?: boolean
  showLessItems?: boolean
  pagerCount?: number
  responsive?: boolean
  itemRender?: (item: {
    page: number
    type: PaginationItemType
    originalElement: VNodeChild
  }) => VNodeChild
  locale?: Partial<VTableGuildPaginationLocale>
  class?: string
  style?: CSSProperties
  position?: TablePaginationPosition[]
  layout?: TablePaginationLayout
  onChange?: (page: number, pageSize: number) => void
  onShowSizeChange?: (current: number, size: number) => void
  'onUpdate:current'?: (current: number) => void
  'onUpdate:pageSize'?: (pageSize: number) => void
}
ts
export interface TablePaginationState {
  current: number
  pageSize: number
  total: number
}
ts
export type TablePaginationPosition =
  | 'topLeft'
  | 'topCenter'
  | 'topRight'
  | 'bottomLeft'
  | 'bottomCenter'
  | 'bottomRight'
  | 'none'
ts
export type PaginationItemType = 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next'
ts
export type TablePaginationBuiltinLayoutItem =
  | 'total'
  | 'sizes'
  | 'prev'
  | 'pager'
  | 'next'
  | 'jumper'
ts
export type TablePaginationLayoutItem = TablePaginationBuiltinLayoutItem | { readonly slot: string }
ts
export type TablePaginationLayout =
  | readonly TablePaginationLayoutItem[]
  | {
      readonly left?: readonly TablePaginationLayoutItem[]
      readonly right?: readonly TablePaginationLayoutItem[]
    }
ts
export type TablePaginationSlotProps = Readonly<
  TablePaginationState & {
    name: string
    pageCount: number
    range: readonly [number, number]
    disabled: boolean
    position: Exclude<TablePaginationPosition, 'none'>
    region: 'inline' | 'left' | 'right'
  }
>
Summary components
ts
export type SummaryFixed = boolean | 'top' | 'bottom'
ts
/** 文档说明用辅助接口,不是包导出。 */
export interface VTableSummaryProps {
  fixed?: SummaryFixed
}
ts
/** 文档说明用辅助接口,不是包导出。index 是必填的列索引。 */
export interface VTableSummaryCellProps {
  index: number
  colSpan?: number
  rowSpan?: number
  align?: AlignType
}