API Reference
Everything the package exports, in one place. The surface is deliberately small: enough to render a grid, enough to write a feature module, and nothing else.
Entry Points
Three, and nothing else is importable. There is no demo to run here: an import either resolves or it does not.
| Specifier | Holds |
|---|---|
@sv5ui/datagrid | createDataGrid, DataGrid, Grid, every feature and every accessor, plus the types behind them |
@sv5ui/datagrid/locales | The twelve language packs, imported one at a time so only what you use ships |
@sv5ui/datagrid/theme.css | The stylesheet, imported once in your app |
// Everything public comes from the package root
import {
DataGrid, Grid, createDataGrid,
sorting, filtering, selection, getSorting, getSelection,
type ColumnDef, type GridState
} from '@sv5ui/datagrid';
// Except the language packs, which have their own entry point so that a
// pack nobody imports is never bundled
import { enUS, viVN } from '@sv5ui/datagrid/locales';
// And the stylesheet, next to the sv5ui one
// @import '@sv5ui/datagrid/theme.css';Components and Theming
| Export | What it is |
|---|---|
DataGrid | The whole grid, in either the shorthand or the instance form |
Grid | Root, Viewport, Header, FilterRow, Body, Toolbar, QuickFilter, FilterChips, ColumnChooser, DensityToggle, ExportMenu, ContextMenu, StatusBar, Pagination. Header draws FilterRow itself, so that part is only for a header of your own |
defineDataGridConfig | App-wide defaults for density and slots |
resetDataGridConfig | Restores the built-in defaults. Mainly for tests |
registerDataGridIcons | Registers the bundled icons. Idempotent, and only needed for a grid behind a dynamic import that may load after your own icons render |
datagridIcons | The icon set itself, for an app that registers icons its own way |
The Grid and Its Constants
| Export | What it is |
|---|---|
createDataGrid | Creates a grid: state plus a derived row pipeline |
getCellValue | A cell value from a row and a column definition |
PIPELINE_ORDER | filter 100, sort 200, group 300, flatten 400, pinSplit 500, window 900 |
SNAPSHOT_VERSION | The version a snapshot is written with |
SELECTION_COLUMN_ID | The id of the synthetic checkbox column |
defaultLabels / mergeLabels | The English strings, and how overrides fold onto a pack |
Feature Modules
Each pairs a factory with an accessor: the factory registers it, the accessor is the typed way back to its state.
| Factory and accessor | Adds |
|---|---|
sorting / getSorting | Multi-sort, cycles, null ordering |
filtering / getFiltering | Quick filter and five column filter kinds |
columnOps / getColumnOps | Resize, reorder, pin, hide, autosize |
selection / getSelection | Selection, clipboard and CSV export |
editing / getEditing | Cell and row editing with validation and undo |
pagination / getPagination | Client paging and the server hooks |
virtualization / getVirtualization | Row and column virtualization |
rowPinning / getRowPinning | Rows pinned outside filter and sort |
rowReorder / getRowReorder | Drag and keyboard row reorder |
Helpers
The pieces the grid uses on itself, exported so a custom renderer or a custom export path can use the same ones.
| Export | What it does |
|---|---|
getValue(node, column, purpose?) | One cell as a purpose is allowed to see it. The default is what the cell draws; 'export', 'clipboard', 'search', 'facet' and 'edit' are the other ways out |
readerFor(columnId, purpose?) | The cellValue gate standing in front of one column, or undefined. Hoist it out of a loop over rows: it is fixed for the column |
toggleGroup / setGroupCollapsed | Folds a header group, on grid.api and on getColumnOps(grid). Both announce and emit columnGroupToggled |
toFilterRequest(model, quickFields?) | The filter as it leaves for a server: always a list and a join, plus the fields a bare query applies to |
toSortRequest(sort, defs, nulls?) | The sort as it leaves for a server: each column's sortField in priority order, with the side blanks land on written on every entry |
toCsv / toTsv | A matrix into a CSV or TSV string. toCsv takes its delimiter as an argument and neutralizes spreadsheet formulas itself |
rowsToMatrix / withHeaderRow / pickColumns | The export path in pieces, for a format the grid does not produce. pickColumns may name hidden columns |
getCellValue | A cell value from a row and a column definition, accessor included |
registerDataGridIcons / datagridIcons | The bundled icon set. The import registers it; only a grid behind a dynamic import needs the call |
Types
Grouped by what they describe. Feature state classes and grid models are exported as types only.
| Types | Describe |
|---|---|
ColumnDef / ColumnState / ColumnType / ColumnTypeOptions / ColumnAlign / PinnedSide | Columns as declared and as resolved, with the two enums they read from |
DataGridCellContext / HeaderContext / HeaderGroupCell / HeaderGroupContext | What a cell snippet, a header snippet and a group header snippet receive, and the group cell itself |
BadgeColor / RowAction / EditorOption / Density | The small unions the built-in renderers, the actions column and density read |
DataGridProps / GridRootProps / GridBodyProps / GridPaginationProps / GridQuickFilterProps / GridFilterRowProps / GridExportMenuProps / GridContextMenuProps / GridParts / DataGridFullWidthContext | Component props worth naming, the Grid namespace itself, and the context a full-width row snippet receives. Everything else takes ComponentProps |
DataGridUi / DataGridSlots / DataGridConfig | Theming |
GridState / GridApi / GridFeature / GridEventMap / GridSnapshot / DataGridOptions / PersistStateOptions | The grid, its api, a feature, its events, its snapshot, what createDataGrid takes and what persistState takes |
PipelineStage / MenuContext / MenuItem / Keybinding / CellDecoration / CellDecorationContext / EventHandler | Everything a feature module declares, and the handler an event takes |
CellValuePurpose / CellValueScope / CellValueReader | The cellValue gate: which way out of the grid is being asked about, what the hook is handed, and the reader it returns |
CellPosition / GridSection / VirtualRange / ColumnVirtualizer / ColumnVirtualizationOptions | Where focus is, which band it is in, and the windows the virtualizers expose |
RowNode / RowMeta / RowModel / RowPinSide | Rows as the pipeline sees them |
SortState / SortDirection / SortRequestEntry / SortNulls / SortCycle / ToggleSortOptions | Sorting, including the wire shape and what toggleSort takes |
FilterModel / ColumnFilter / ColumnFilterEntry / ColumnFilterGroup / ColumnFilterDef / FilterType / FilterJoin / SetFilterValue | Filtering as the model holds it, per column and per condition |
FilterRequest / FilterRequestEntry / TextFilterOp / NumberFilterOp / DateFilterOp / PresenceFilterOp | The wire shape a server row model sends, and every operator name in it |
EditorType / EditorContext / ColumnEditorDef / EditTransaction / Editable / EditMode | Editing, from what opens to what a commit produces |
SelectionMode / SelectAllState / CopyOptions / ExportCsvOptions / ExportFormatter / CellMatrix | Selection and the clipboard and CSV paths it drives |
RowDragState | The drag in flight, for a row reorder indicator of your own |
DataGridLabels / DataGridLabelsInput / DataGridLocalePack / DataGridAnnouncerStrings | Localization |
Sorting / Filtering / Selection / Editing / Pagination / Virtualization / ColumnOps / RowPinning / RowReorder | Feature state classes, as types only |
ColumnModel / FocusModel / ExpansionModel / Announcer / EventBus / Virtualizer | Models reachable from a grid, as types only |
Stability
Everything above is public and covered by semver. This is version 1.3.0, so a breaking change to any of it waits for 2.0. Internal helpers stay unexported and change freely between releases.
Semver is a promise about numbering rather than about mileage. The surface below is what the library commits to; how much of it has been through a real application is another question, so pin the exact version and read the changelog before upgrading.
If you need something unexported in order to build a feature, that is a gap in the extension
points rather than a reason to reach into dist.
Row grouping, tree data, master and detail rows, range selection and infinite scroll are not in this package, and are planned for a separate pro package.
// Public and covered by semver from 1.0 on: everything exported from the
// package root, and the two entry points above.
// Not public, and free to change between releases: pipeline transforms,
// filter compilation, the undo stack, column sizing maths, scroll
// normalization, and every file path inside dist.
// Classes the grid constructs are exported as types only. You reach an
// instance through the grid or through its accessor:
import { getSelection, type Selection } from '@sv5ui/datagrid';
const selection: Selection<Person> | undefined = getSelection(grid);
// new Selection(...) is not something the package offers.