Features
This page is the Elm counterpart of TanStack Table's Features Guide. In
TanStack v9 a table declares the capabilities it uses with a tableFeatures({...})
call, and each feature it registers adds its own state, options, and APIs to the
table instance. That page explains what to register and why.
There is nothing to register here. Every feature in this package is a set of
plain functions on Table.Config, Table.State, and the row model, and they are
all available the moment you import Table.
Why There Is No features Option
TanStack's features option exists to keep bundles small. A plugin that is not
registered is not imported, so its code is not shipped, and its APIs do not
appear in the TypeScript types either.
Elm gets the same result from the compiler. elm make --optimize drops every
function your program never calls, so an unused feature costs nothing at
runtime and nothing in the build. That removes the registration step, and with
it the type errors TanStack raises when a row model is registered without its
feature.
One consequence is worth knowing. Table.rows
runs all six pipeline stages, so it references all six, and the compiler keeps
them. Calling only the stages you want keeps the rest out of the build:
sortedOnly : Table.State -> Table.RowModel Person
sortedOnly state =
Table.coreRowModelFromList config state people
|> Table.sortedRowModel config state
See Row Models for the stages and what each one does.
Features, Row Models, and Functions Are Separate
TanStack draws a line between three things: a feature (state and APIs), a row model (the client-side work), and a function registry (named sort, filter, and aggregation implementations). The same line exists here, drawn differently.
- State and transitions. Every feature owns one slice of
Table.Stateand a set of... -> State -> Statetransitions. They work whether or not the matching pipeline stage runs. - Pipeline stages. The six stages, in order, are core, filtered, grouped,
sorted, expanded, paginated. Each is a function from a
RowModelto aRowModel. Amanual*flag on theConfigskips its stage and passes the rows through untouched, which is how you hand the work to a server. See Client-Side vs Server-Side. - Functions. A
SortFn,FilterFn, orAggregationFnis a value you pass to a column builder, not a string looked up in a registry. There is no registry to include or tree-shake, and no name that can be spelled wrong.
Nothing is opt-in. Sorting works because the sorted stage is always part of the
pipeline, not because you registered rowSortingFeature:
config : Table.Config Person
config =
Table.config
[ Table.column "firstName" (.firstName >> Value.String)
|> Table.withHeader "First name"
, Table.column "department" (.department >> Value.String)
|> Table.withHeader "Department"
, Table.column "salary" (.salary >> Value.Number)
|> Table.withHeader "Salary"
]
rowModel : Table.State -> Table.RowModel Person
rowModel state =
Table.rowsFromList config state people
The Feature List
These are TanStack's stock features and where each one lives here.
| TanStack feature | Guide | What it is |
|---|---|---|
cellSelectionFeature |
Cell Selection | Rectangular cell ranges, keyboard navigation, and the focused cell. |
cellSpanningFeature |
Cell Spanning | Cells that span rows or columns. |
columnFacetingFeature |
Faceting | Unique values, counts, and min/max ranges for building filter controls. |
columnFilteringFeature |
Column Filtering | Per-column filters and the filtered stage. |
columnGroupingFeature |
Grouping | Group rows by one or more column values. |
columnOrderingFeature |
Column Ordering | The order columns are drawn in. |
columnPinningFeature |
Column Pinning | Columns held to the left or right edge. |
columnResizingFeature |
Column Resizing | Turning a drag into a new column width. |
columnSizingFeature |
Column Sizing | Column widths, minimums, maximums, and offsets. |
columnVisibilityFeature |
Column Visibility | Showing and hiding columns. |
globalFilteringFeature |
Global Filtering | One filter value applied across columns. |
rowAggregationFeature |
Aggregation | The values a group row reports for its children. |
rowExpandingFeature |
Expanding | Which rows show their sub-rows. |
rowPaginationFeature |
Pagination | Page index, page size, and the paginated stage. |
rowPinningFeature |
Row Pinning | Rows held at the top or bottom. |
rowSelectionFeature |
Row Selection | Selected row ids, including sub-row rules. |
rowSortingFeature |
Sorting | Sort state, multi-sorting, and the sorted stage. |
Two more pages match TanStack's, and neither is a feature there either. Fuzzy Filtering is a recipe built from filtering and sorting. Virtualization is a rendering technique that lives outside the package.
TanStack's stockFeatures bundle, which registers all of the above at once,
has no counterpart: everything above is already available.
What TanStack Has That This Package Does Not
Five parts of TanStack Table have no Elm counterpart. Each one exists because of something that is not true here.
- Devtools. TanStack's devtools panel inspects a live table instance. There
is no instance to inspect.
Config,State, andRowModelare ordinary values, so you can print one, store it, or compare two. flexRender. In TanStack acellorheaderoption can be a string, a value, or a component, andflexRenderdecides how to render whichever one it was given. In Elm you write theHtmlyourself from the cell value, so there is nothing to dispatch on. See Cells.- Custom features and plugins. A TanStack plugin attaches new state and new
methods to the table instance. With no instance, there is nothing to attach
to. A behaviour this package does not have is a function you write over the
RowModelit returns. - Table and column meta.
metais a place to hang your own typed data on a table or a column so a render function can read it back off the instance. Keep that data in your own model and read it there; column ids are strings you can key aDictby. - Type helpers.
createColumnHelper,createTableHook, and the registry types exist to recover type information TypeScript cannot infer on its own. Elm infers the row type from your accessors, soTable.columnneeds no helper and no type parameters beyondrow. See Column Definitions.
Where to Go Next
Config and State covers the two values every feature
reads. Table State covers owning the State in your
model. Each feature guide above follows the same shape: the state slice, the
config and column options, the transitions, and the queries used while
rendering.