@gridkitjs/core v0.11.0
Minor Changes#
-
6af35c6: Columns gain a plain-text
header, and values gain an opt-in formatting layer.ColumnDefinition.headernames a column as text. The header shows it when there is noheaderTemplate;resolveColumnHeaderText(column)returns it (or a text label, or the field path) for announcements and exports.ColumnDefinition.formattakesIntl.NumberFormatOptionsorIntl.DateTimeFormatOptions, andColumnDefinition.valueFormatter((value, row) => string) overrides it outright.formatCellValue(value, column, locale?, row?)turns a value into the text a cell shows: booleans as"true"/"false",nullas empty text. Dates and numbers go throughIntlonly once the column has aformator alocaleis passed — dates bytype(date,time, otherwise date and time), numeric types throughIntl.NumberFormat(currencywithformat.currency,percentreading0.25as 25%). Without either, a number prints as-is and a date throughtoLocaleString().formatAggregateValuedoes the same for aggregate results, reading acountas a plain number and, without aformatorlocale, a numeric result throughtoLocaleString().
-
6af35c6: Columns can be hidden.
ColumnDefinition.hiddensets where a column starts, and acolumnVisibilityslice onGridState(ColumnVisibilityState, column id →trueshown /falsehidden) records what the user changed.resolveGridViewdrops hidden columns fromcolumnsafter ordering and before sizing; they stay indataColumns, so a sort, filter or grouping on a hidden column still applies and the column keeps its slot in the order.New helpers:
isColumnVisible(column, visibility),applyColumnVisibility(dataColumns, visibility)andsetColumnVisibility(dataColumns, visibility, columnIds, visible), plus theColumnVisibilityEventtype ({ columnIds, visibility }). -
bad8ea3: The grid controller now also owns the filter, column widths, column order and column visibility. New actions:
setFilter,resizeColumn(columnId, width, phase),cancelColumnResize,setColumnSizing,moveColumn(columnId, beforeId),setColumnOrder,showColumns,hideColumnsandsetColumnVisibility, each reporting through the slice's existing callback.GridOptionsgains controlledfilter,columnSizing,columnOrderandcolumnVisibilityoptions, andonFilterChangewith the newFilterChangeEventtype ({ filter }). A filter change sends an uncontrolled pagination back to the first page, as a sort or grouping change does. -
bad8ea3: The grid controller now owns row, column and cell selection.
GridStategainsrowSelection,columnSelectionandcellSelection;GridOptionsgains controlled props for each beside theirdefault*ones; and the selection callbacks move into core asSelectionCallbacks<Row, Node>, fired from one diff per change exactly as@gridkitjs/reactfired them. New actions:selectRow,selectRows(ids, intent?),selectAllRows,clearSelection,setRowSelection,selectColumn,setColumnSelection,selectCellandsetCellSelection.GridControllerOptions.onSelectionDiffreports each row or column change by id, for a renderer's own feedback.resolveGridView'sstateis now typedGridViewState<Row>—GridStatewithout the selections, which the view never reads; a wholeGridStatestill fits. -
78e10e5: Add
DataColumn—{ id, column }, a column without its width — andresolveDataColumns(columns, order), which orders column definitions and pairs each with its id.filterRows,sortRows,resolveShownRows,groupRows,computeAggregatesandwithGroupAggregatesnow acceptDataColumn[]in place ofResolvedColumn[]; aResolvedColumn[]still fits, so no call site changes. -
44759b4: The headless model a column's filter editor is drawn over, so a checklist or condition editor needs no logic of its own:
describeColumnFilter(filter, columnId)reads which form the column's filter is in —none, avalueschecklist, one or twoconditions, orcustom.columnValueOptions(rows, dataColumns, filter, columnId, { search, limit, locale })lists the column's distinct values with labels and counts, cascaded over the rows every other column's filter keeps.initialFilterEditorDraft,filterEditorReducer,visibleFilterOptionsandselectAllStatehold an editor's draft — checked values, search, blanks, a tri-state select-all, conditions — anddraftToFilterapplies it: everything checked removes the column's filter, a partial pick is oneinentry.
New types:
ColumnFilterShape,ColumnValueOption,ColumnValueOptions,ColumnValueQuery,FilterEditorAction,FilterEditorDraft,SelectAllState. -
bad8ea3: Add
createGridController(options), a grid without a renderer: it holds the grid's state, derives the view withresolveGridView, and carries the sort, grouping, expansion and paging actions (toggleColumnSort,setColumnSort,toggleGroupBy,moveGroupBy,setGroupBy,toggleGroupExpansion,expandAllGroups,collapseAllGroups,setGroupExpansion,goToPage,nextPage,previousPage,setPageSize,setPagination). Each action fires the same callback, with the same payload, a user's interaction does.getState()andgetView()keep their identity until something changes, andsubscribe(listener)is called after each change, so either can back auseSyncExternalStore-style subscription. Columns are inferred fromdataSourcewhen none are given.GridOptionsgains controlledcolumnSort,groupBy,groupExpansionandpaginationoptions beside theirdefault*counterparts: given, the grid shows that value and an action only asks for a change through the matchingon*Changecallback.defineColumnsFromRowstakes an optionalNodetype parameter, so its result can be typed for any renderer's columns. -
8d411eb:
GridOptionsgainsmessages, a partialGridMessagesreplacing the grid's own English strings key by key — the pager, the group-by bar, the loading row, boolean and blank values, and every live-region announcement.defaultMessagesholds the English defaults andresolveMessages(messages)lays a partial set over them.formatCellValuetakes an optional fifthmessagesargument for a boolean's words. -
bad8ea3:
@gridkitjs/coreexportsGridOptions<Row>: every grid setting that names no renderer type — data, row identity, what the user may do, starting state and change callbacks — in one interface, with theBorders,HoverableConfigandGroupByBarVisibilitytypes it uses.DataGridProps<Row>is now composed from it plusReactRenderSlots<Row>(columns,pager,infiniteScroll), the selection callbacks andref; every prop keeps its name and type.@gridkitjs/reactstill exportsBorders,HoverableConfigandGroupByBarVisibility, and now alsoGridOptionsandReactRenderSlots. -
78e10e5: Add
resolveGridView(input), which derives everything a grid shows in one call: rows filtered, sorted, grouped, aggregated and paginated, and columns ordered and sized, returned as aGridView(dataColumns,columns,rows,displayRows,pageRows,displayDataRows,pageCount,pageIndex,grandTotal).createGridViewResolver()returns a memoised version that recomputes only the stages a change touches — a column resize or a viewport change leaves every row list and the grand total untouched. New types:GridState,GridViewInput,GridViewOptions,GridView, andResizeMode(moved from@gridkitjs/react, which still exports it). -
44759b4: A fifth filter entry kind,
OperatorFilterEntry—{ columnId, operator, value }witheq,ne,contains,notContains,startsWith,endsWith,gt,gte,lt,lte,between,in,isEmptyandisNotEmpty— expresses a range, a value list or a blank check as plain data, so a filter that needed a predicate can now be saved:{ columnId: "amount", operator: "between", value: [10, 100] }Blank cells (
null,undefined,"") match onlyisEmpty,neandnotContains.serializeGridStatewrites an operator entry'sDates as ISO strings, andrestoreStateturns them back intoDates on date, date-time and time columns. New types:FilterOperator,FilterScalar,OperatorFilterEntry,SerializedFilterScalar,SerializedOperatorFilterEntry. -
bad8ea3: Grid state can be saved and put back.
serializeGridState(state)returns aSerializedGridStatethat survivesJSON.stringifyand back — aDatefilter value becomes its ISO string, and a predicate filter entry, which cannot be written down, is left out with aconsole.errornaming its column. The controller'srestoreState(saved)applies a full or partial state, fromgetState()or from JSON: each slice that changes fires its callback, subscribers are called once, and a restored page survives a restored sort.The controller's
setFilternow compares filters by content rather than by entry identity, so setting a filter equal to the current one reports nothing. -
8d411eb:
GridOptionsgainsonRowClickandonRowDoubleClick, called with aRowPointerEvent(the row, the column clicked and the modifiers, no DOM event), andgetRowProps, which returns a class name anddata-*attributes for each data row.SelectableConfiggainstoggleOnClick, under which a plain click toggles a row instead of selecting it alone, andintentOftakes it as an optional second argument:intentOf(event, { toggleOnClick: true }).
Patch Changes#
- 78e10e5:
collapseAllGroupsno longer lists a group twice when given display rows that carry summary rows (groupAggregateDisplay: "row"), such asDataGridApi.getDisplayRows().