@gridkitjs/core v0.1.0
Minor Changes#
-
e0f5b59: Columns take
headerTemplatein place ofheader, and a newcellTemplaterenders a column's cells.{ field: "Id", header: "#" }becomes{ field: "Id", headerTemplate: "#" }.cellTemplatereceives{ value, row, rowIndex }and returns whatever the adapter renders — in React,cellTemplate: ({ value }) => <b>{value}</b>.valueis the cell's own value read off the field path, so a template that only formats it never repeats the path. A column without one renders the raw value as before. -
401a2cc: Address nested fields with
"Parent.Child"paths, and derive columns from dataColumnDefinition["field"]now autocompletes one level of nesting via the newFieldPath<Row>type, while still accepting any string so a path the type cannot see is never a hard error.defineColumnsFromRowsderives a column per field across a set of rows, in first-seen order and without duplicates.ColumnDefinitiontakes a second type parameter for what a header renders to. It defaults tostringin@gridkitjs/core, which stays framework-agnostic;@gridkitjs/reactexports aColumnDefinition<Row>alias bound toReactNode, so a header callback can return JSX. This replaces the untypedFunction. -
a3db97e: Resolve a column's label, resizability and alignment in core
ResolvedColumngainslabel,resizableandalignment, so it now describes a column completely rather than only its width.resolveColumnWidthsdecides all three: a header is resolved eagerly or by calling it, falling back to a label read off the field path;resizabletakes the column's own setting over the grid's; alignment falls back to the column's type. A second framework adapter renders identically without repeating any of it.resolveColumnWidthstakes aColumnResolveOptionsobject as its third argument in place of the size defaults —{ sizes: { width: 60 } }where it was{ width: 60 }— since the grid-level defaults are no longer only sizes.resolveColumnLabel,alignmentForTypeandKEYBOARD_STEPare exported for adapters that resolve columns themselves.Columns that set a numeric
typewithout an explicitalignmentnow align right, matching columns inferred from data — previously only the inferred ones did. Numeric alignment coversdecimal,currencyandpercentalongsidenumber. A column withheader: ""now renders an empty header instead of falling back to its field name. -
45e492c: Size, resize and auto-fit columns
ColumnDefinitiongainswidth,minWidth,maxWidthandresizable, plus an optionalidthat state is keyed by and that defaults tofield. Every width calculation lives in@gridkitjs/core—resolveColumnWidthsapplies the precedence (sizing state, then the column, then the default) and clamps;beginColumnResize/applyColumnResizeturn a pointer position into a width;fitColumnsToWidthdistributes a container's width across columns. A future adapter for another framework inherits all of it.DataGridComponenttakesresizableColumns,resizeMode,onColumnResizeand two sizing props that read alike but differ:defaultColumnSizingsets the starting width of specific columns, keyed by id, whilecolumnSizeDefaultssets the width and bounds used for any column that does not size itself. Columns can be dragged by their right edge, resized with the arrow keys, and sized to their content by double-clicking the handle.resizeModechooses what a resize does to the other columns. Under the default"fit", columns fill the grid: auto-fit leaves those the user has sized alone and shares the remaining width between the rest, so a column giving up space hands it to its neighbours. Under"fixed", every column keeps its own width — a resize moves one column and nothing else, and the grid scrolls or leaves a gap to suit.The grid now renders inside a scrolling wrapper and sizes its columns through a
<colgroup>withtable-layout: fixed, which is what makes a width exact. Cell content that does not fit its column is truncated with an ellipsis instead of wrapping.