You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates and returns a table instance. This is the main entry point for @zvndev/yable-core. The table instance provides all APIs for reading and manipulating table state.
Example:
import{createTable,createColumnHelper}from'@zvndev/yable-core'consttable=createTable({data: myData,columns: myColumns,onStateChange: (updater)=>{/* handle state updates */},})
The configuration object passed to createTable() or useTable().
Required
Option
Type
Description
data
TData[]
The data array to display
columns
ColumnDef<TData, any>[]
Column definitions
State Management
Option
Type
Description
state
Partial<TableState>
Controlled state (merged with internal state)
onStateChange
OnChangeFn<TableState>
Called when any state changes
initialState
Partial<TableState>
Initial state values
Row Identity
Option
Type
Default
Description
getRowId
(row, index, parent?) => string
String(index)
Custom row ID generator
Sorting Options
Option
Type
Default
Description
enableSorting
boolean
true
Enable sorting globally
enableMultiSort
boolean
true
Allow multi-column sorting
enableSortingRemoval
boolean
true
Allow removing sort on third click
maxMultiSortColCount
number
Infinity
Max simultaneous sort columns
manualSorting
boolean
false
Disable client-side sorting (for server-side)
sortingFns
Record<string, SortingFn>
--
Additional named sorting functions
onSortingChange
OnChangeFn<SortingState>
--
Sorting state change callback
isMultiSortEvent
(e) => boolean
Shift key
Multi-sort modifier key test
Filtering Options
Option
Type
Default
Description
enableFilters
boolean
true
Enable all filtering
enableColumnFilters
boolean
true
Enable per-column filters
enableGlobalFilter
boolean
true
Enable global search
manualFiltering
boolean
false
Disable client-side filtering
filterFns
Record<string, FilterFn>
--
Additional named filter functions
globalFilterFn
FilterFnOption
--
Custom global filter function
onColumnFiltersChange
OnChangeFn<ColumnFiltersState>
--
Column filters change callback
onGlobalFilterChange
OnChangeFn<string>
--
Global filter change callback
getColumnCanGlobalFilter
(column) => boolean
--
Per-column global filter opt-out
Pagination Options
Option
Type
Default
Description
manualPagination
boolean
false
Disable client-side pagination
pageCount
number
--
Total page count (server-side)
rowCount
number
--
Total row count (server-side)
autoResetPageIndex
boolean
true
Reset to page 0 on data change
onPaginationChange
OnChangeFn<PaginationState>
--
Pagination change callback
Server State
Yable treats server-backed tables as the same table model with controlled data state. Column
definitions do not change. Instead, turn on the manual row-model flags and fetch rows when table
state changes:
For React apps, useServerTable packages that controlled-state pattern into a reusable controller:
constserverTable=useServerTable({
columns,getRowId: (row)=>row.id,fetchData: async({ sorting, globalFilter, cursor, signal })=>{constresponse=awaitapi.accounts.list({ sorting,q: globalFilter, cursor, signal })return{rows: response.rows,cursor: response.nextCursor,hasMore: response.hasMore,rowCount: response.total,}},updateRow: async({ rowId, patch, signal })=>{returnapi.accounts.update(rowId,patch,{ signal })},})return<Tabletable={serverTable.table}/>
API
Description
useServerTable().table
Normal Yable table instance configured for manual server state
useServerTable().rows
Current loaded server window
useServerTable().refresh()
Replace the loaded window using current sorting/filtering/pagination state
useServerTable().loadMore()
Append the next cursor/page for infinite-scroll flows
useServerTable().updateRow()
Optimistically patch a row, call the server, then merge or roll back result
Selection Options
Option
Type
Default
Description
enableRowSelection
boolean | (row) => boolean
true
Enable row selection
enableMultiRowSelection
boolean | (row) => boolean
true
Allow selecting multiple rows
enableSubRowSelection
boolean | (row) => boolean
true
Auto-select sub-rows
onRowSelectionChange
OnChangeFn<RowSelectionState>
--
Selection change callback
Visibility Options
Option
Type
Default
Description
enableHiding
boolean
true
Enable column visibility toggling
onColumnVisibilityChange
OnChangeFn<VisibilityState>
--
Visibility change callback
Column Ordering
Option
Type
Description
onColumnOrderChange
OnChangeFn<ColumnOrderState>
Column order change callback
Column Pinning
Option
Type
Default
Description
enableColumnPinning
boolean
--
Enable column pinning
onColumnPinningChange
OnChangeFn<ColumnPinningState>
--
Pinning change callback
Column Sizing
Option
Type
Default
Description
enableColumnResizing
boolean
true
Enable column drag-to-resize
columnResizeMode
'onChange' | 'onEnd'
'onChange'
When to update widths
columnResizeDirection
'ltr' | 'rtl'
'ltr'
Resize direction
onColumnSizingChange
OnChangeFn<ColumnSizingState>
--
Sizing change callback
onColumnSizingInfoChange
OnChangeFn<ColumnSizingInfoState>
--
Resize info change callback
Use column definition sizing options (size, minSize, maxSize, flex,
enableResizing) or defaultColumnDef to configure column widths. Call
table.sizeColumnsToFit(width) to write fitted widths into columnSizing.
When any visible column has flex, non-flex columns keep their current width
and flex columns divide the remaining width by flex weight. Without flex,
visible columns scale proportionally. Hidden columns are ignored, and
minSize/maxSize are always enforced.
The React renderer keeps header and body widths synchronized internally,
including during horizontal scroll, so consumers should not need custom CSS
width overrides or manual <colgroup> synchronization.
Configuration Profiles
React exports a layered config API for site-wide defaults, named table profiles,
and reusable named cell configs.
Precedence is intentionally local-friendly: global defaults are lowest, named
profiles sit above them, table defaultColumnDef sits above profile defaults,
named cellConfig is applied per column, and explicit column definition fields
or explicit <Table> props always win. Use a provider for site-wide consistency,
named profiles for reusable variants, and inline column config for one-off cells.
Selection APIs
Row selection lives in table.getState().rowSelection. Use
onRowSelectionChange for controlled state, table.events.on('selection:change', handler) for event-style subscriptions, and table.getSelectedRowModel() when
you need the current selected rows.
Checkbox columns are opt-in. Add one with selectColumn(); it renders a larger
click target, supports selected-state sorting, and does not appear unless you add
it to columns.
Commit all pending changes (triggers onEditCommit)
discardAllPending()
void
Discard all pending changes
getValidationErrors()
Record<string, Record<string, string>>
Get validation errors
isValid()
boolean
All pending values valid?
setEditing(updater)
void
Set editing state directly
resetEditing(defaultState?)
void
Reset editing state
startRowEditing(rowId)
void
Start full-row editing and seed editable values
commitRowEdit(rowId)
void
Validate and commit all pending values for a row
cancelRowEdit(rowId)
void
Discard all pending values for a row
isRowEditing(rowId)
boolean
Check whether a row is in full-row edit mode
getEditingRows()
string[]
Get row IDs currently in full-row edit mode
getEditableColumnIds(rowId)
string[]
Get editable column IDs for a row
Async Commit API
Method
Return
Description
getCellRenderValue(rowId, columnId)
unknown
Returns pending value if commit is in-flight, otherwise saved value
getCellStatus(rowId, columnId)
CellStatus
Returns 'idle' | 'pending' | 'error' | 'conflict'
getCellErrorMessage(rowId, columnId)
string | undefined
Error message from failed commit
getCellConflictWith(rowId, columnId)
unknown
The server value that conflicts with the pending value
commit()
Promise<void>
Dispatch all pending edits (used when autoCommit: false)
retryCommit(rowId, columnId)
Promise<void>
Retry a failed commit
dismissCommit(rowId, columnId)
void
Dismiss an error/conflict and revert to saved value
dismissAllCommits()
void
Dismiss all errors and conflicts
Export API
Method
Return
Description
exportData(options?)
string
Export table data as CSV or JSON string
Event Emitter
Property
Type
Description
events
EventEmitter<YableEventMap>
Typed event emitter
events.on(event, handler)
() => void
Subscribe (returns unsubscribe function)
events.off(event, handler)
void
Unsubscribe
events.emit(event, payload)
void
Emit an event
events.removeAllListeners(event?)
void
Remove all listeners
Column Instance
Returned by table.getColumn(id) or accessed from table.getAllColumns().
Properties
Property
Type
Description
id
string
Unique column identifier
depth
number
Nesting depth (0 for top-level)
columnDef
ColumnDef
The original column definition
columns
Column[]
Child columns (for group columns)
parent
Column | undefined
Parent column (if nested)
accessorFn
(row, index) => TValue
Value accessor function
Traversal
Method
Return
Description
getFlatColumns()
Column[]
This column + all nested flat columns
getLeafColumns()
Column[]
Leaf columns in this column's tree
Sizing
Method
Return
Description
getSize()
number
Current width in px
getStart(position?)
number
Start offset in px
getAfter(position?)
number
Remaining space after this column
getCanResize()
boolean
Can this column be resized?
getIsResizing()
boolean
Is this column currently being resized?
resetSize()
void
Reset to default size
The configured width comes from state.columnSizing[columnId], then
columnDef.size, then the default size. minSize and maxSize are enforced
during drag resizing and table.sizeColumnsToFit(width).
Sorting
Method
Return
Description
getCanSort()
boolean
Can this column be sorted?
getCanMultiSort()
boolean
Can participate in multi-sort?
getSortingFn()
SortingFn
Get the active sorting function
getNextSortingOrder()
SortDirection | false
What the next click would do
getIsSorted()
false | SortDirection
Current sort direction
getSortIndex()
number
Sort priority index (multi-sort)
clearSorting()
void
Remove sort from this column
toggleSorting(desc?, isMulti?)
void
Toggle or set sort direction
getToggleSortingHandler()
(event) => void
Event handler for sort toggle
Filtering
Method
Return
Description
getCanFilter()
boolean
Can this column be filtered?
getCanGlobalFilter()
boolean
Included in global filter?
getIsFiltered()
boolean
Is a filter active on this column?
getFilterValue()
unknown
Current filter value
getFilterIndex()
number
Index in the column filters array
setFilterValue(value)
void
Set filter value for this column
getFilterFn()
FilterFn | undefined
Get the active filter function
Visibility
Method
Return
Description
getCanHide()
boolean
Can this column be hidden?
getIsVisible()
boolean
Is this column visible?
toggleVisibility(value?)
void
Show/hide this column
getToggleVisibilityHandler()
(event) => void
Event handler for visibility toggle
Pinning
Method
Return
Description
getCanPin()
boolean
Can this column be pinned?
getIsPinned()
ColumnPinningPosition | false
'left', 'right', or false
pin(position)
void
Pin to 'left', 'right', or false (unpin)
getPinnedIndex()
number
Index among pinned columns
Faceting
Method
Return
Description
getFacetedRowModel()
RowModel
Faceted row model for this column
getFacetedUniqueValues()
Map<unknown, number>
Unique values and counts
getFacetedMinMaxValues()
[number, number] | undefined
Min/max for numeric columns
Grouping
Method
Return
Description
getCanGroup()
boolean
Can this column be grouped?
getIsGrouped()
boolean
Is this column currently grouped?
getGroupedIndex()
number
Index in grouping array
toggleGrouping()
void
Toggle grouping on this column
getAggregationFn()
AggregationFn | undefined
Get the aggregation function
Row Instance
Accessed via table.getRowModel().rows or table.getRow(id).
Properties
Property
Type
Description
id
string
Unique row identifier
index
number
Row index in the current array
original
TData
The original data object
depth
number
Nesting depth (0 for top-level)
parentId
string | undefined
Parent row ID (tree data)
subRows
Row[]
Child rows (tree data)
groupingColumnId
string | undefined
Column ID this row groups by
groupingValue
unknown
Group key value
Value Access
Method
Return
Description
getValue<TValue>(columnId)
TValue
Get the typed value for a column
renderValue<TValue>(columnId)
TValue
Get render-ready value
Cell Access
Method
Return
Description
getAllCells()
Cell[]
All cells in this row
getVisibleCells()
Cell[]
Visible cells only
getLeftVisibleCells()
Cell[]
Left-pinned visible cells
getRightVisibleCells()
Cell[]
Right-pinned visible cells
getCenterVisibleCells()
Cell[]
Unpinned visible cells
Selection
Method
Return
Description
getIsSelected()
boolean
Is this row selected?
getIsSomeSelected()
boolean
Some sub-rows selected?
getIsAllSubRowsSelected()
boolean
All sub-rows selected?
getCanSelect()
boolean
Can this row be selected?
getCanMultiSelect()
boolean
Can participate in multi-select?
getCanSelectSubRows()
boolean
Can sub-rows be auto-selected?
toggleSelected(value?, opts?)
void
Select/deselect this row
getToggleSelectedHandler()
(event) => void
Event handler for selection toggle
Expanding
Method
Return
Description
getIsExpanded()
boolean
Is this row expanded?
getCanExpand()
boolean
Can this row be expanded?
getIsGrouped()
boolean
Is this a group row?
toggleExpanded(expanded?)
void
Toggle expansion
getToggleExpandedHandler()
(event) => void
Event handler for expand toggle
Pinning
Method
Return
Description
getIsPinned()
RowPinningPosition | false
'top', 'bottom', or false
getCanPin()
boolean
Can this row be pinned?
pin(position, includeLeaf?, includeParent?)
void
Pin to 'top', 'bottom', or unpin
Grouping
Method
Return
Description
getGroupingValue(columnId)
unknown
Get the grouping value for a column
getLeafRows()
Row[]
Get all leaf rows under this group
Cell Instance
Accessed via row.getVisibleCells() or row.getAllCells().
Properties
Property
Type
Description
id
string
Unique cell identifier ({rowId}_{columnId})
row
Row
Parent row
column
Column
Parent column
Methods
Method
Return
Description
getValue()
TValue
Get the typed cell value
renderValue()
TValue
Get render-ready value
getContext()
CellContext
Get full render context (table, row, column, cell)
interfaceCellPatch<TData,TValue=unknown>{rowId: stringcolumnId: string/** The value the user typed. */value: TValue/** The most recent saved value at the moment we dispatched. */previousValue: TValue/** The full row snapshot at dispatch time. */row: TData/** Aborts when the user starts a new commit on the same cell. */signal: AbortSignal}
Throw from onCommit to mark specific cells as failed. Throw a generic Error to fail all cells in the batch.
CommitRecord
interfaceCommitRecord{status: 'pending'|'error'|'conflict'pendingValue: unknownpreviousValue: unknownopId: numbererrorMessage?: string// only when status === 'error'conflictWith?: unknown// only when status === 'conflict'abortController: AbortController}