Documentation
¶
Overview ¶
Package datatable provides a reusable table component wrapping github.com/charmbracelet/bubbles/table. It adds column sorting, pagination, a configurable empty state, optional multi-row selection and an optional per-column filter prompt. All view state (sort, page, filter) lives on the component and can be persisted/restored via State/SetState so a hosting page can keep it across navigation.
Index ¶
Constants ¶
const DefaultPageSize = 25
DefaultPageSize is the number of rows shown per page.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Table)
Option configures a Table.
func WithEmptyMessage ¶
WithEmptyMessage sets the message shown when there are no rows.
func WithFilter ¶
WithFilter enables the per-column filter prompt on the given column index.
func WithSelection ¶
WithSelection enables multi-row selection. hint is shown in the batch-actions line when at least one row is selected.
type Pagination ¶
Pagination holds paging state.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the reusable table component.
func (*Table) SelectedRows ¶
SelectedRows returns the raw rows currently selected on this page.
func (*Table) SetDimensions ¶
SetDimensions sets the component size.
func (*Table) SetRows ¶
SetRows replaces the full dataset. Selection is cleared and the page clamped.
func (*Table) SetState ¶
func (t *Table) SetState(s TableState)
SetState restores previously captured view state.
func (*Table) State ¶
func (t *Table) State() TableState
State returns the current persistable view state.
type TableState ¶
type TableState struct {
SortCol int // sorted column index, -1 when unsorted
SortDir SortDir
Pagination Pagination
Filter string
FilterCol int
}
TableState is the persistable view state of a Table.