API reference
@salmonui/data-grid/engine
444 exported symbols: 53 functions, 173 interfaces, 207 types and 11 constants. Each name links its page with the signature, docs and members.
import { … } from '@salmonui/data-grid/engine';Functions
clampColumnWidthClamps a px width to the column's minWidth/maxWidth (and at least 1px).columnZoneCurrent freeze zone of a visible leaf in a column snapshot (center for unknown or hidden ids).compilePatternCompiles like (% / = any sequence) or wildcard ( = any sequence, ? = one character) into an anchored RegExp.computeRangeVisible range for a scroll offset and viewport extent, widened by overscan items on each side. Works for rows and columns.createAggregatesModuleCreates the aggregates module. Options come from options.aggregates (AggregatesOptions); the initial descriptors from options.defaultQuery.aggregates.createColumnMetricscreateDataGridApicreateDataGridEngineCreates a framework-agnostic DataGrid engine. Features are modules; without modules the engine compiles columns, holds rows, and runs an empty pipeline.createDataGridQueryBuilds a complete, deeply frozen DataQuery from a partial one.createFilterModuleCreates the filter module. Options are read from options.filter (FilterOptions); initial filters from options.defaultQuery.filters. Create one module instance…createFixedRowMetricsO(1) metrics for the fixed row height fast path.createFocusModuleCreates the focus module. Options are read from options.focus (FocusOptions); the initial direction is the grid direction option.createGroupingModuleCreates the grouping module. Options come from options.grouping (GroupingOptions); the initial grouping from options.defaultQuery.grouping. Register createSort…createKeymapCompiles the binding table for one platform. User bindings replace the combos of their command; a user combo that a built-in binding also uses in the same cont…createLocalDataSourceIn-memory data source (mode: 'local'). Rows are held by reference and the array is treated as immutable: every change produces a new array and one event. The e…createPagingModuleCreates the paging module. Options are read from options.paging (PagingOptions); options.defaultQuery.paging sets the initial page.createRowModelHelper for stage authors: a model over the same source with a new visible order (source indices).createScrollMappingcreateSearchModuleCreates the search module. Options are read from options.search (SearchOptions); options.defaultQuery.search sets the initial search.createSelectionApiSelection methods over an engine with the selection module (spread into the DataGrid API).createSelectionModuleCreates the selection module. Options are read from options.selection (SelectionOptions).createSortModuleCreates the sort module. Options are read from options.sort (SortOptions); the initial sort comes from options.defaultQuery.sorting.createVariableRowMetricsBuilds variable row metrics in O(n) from a height function.dataRowCountNumber of data rows a model covers (excludes synthetic rows of a view).declaredZoneFreeze zone of a column from its definition and the runtime overrides (count shorthand excluded).defineDataGridModuleIdentity helper that keeps the module name, command union, and methods as literal types for the façade.deserializeDataGridQueryInverse of serializeDataGridQuery. Throws on malformed input.effectiveSortKeysEffective sort keys: grouped columns first (direction from the sort list, else the group descriptor, else ascending), then the remaining sort descriptors. Unkn…filtersNarrowTrue when every row passing next also passes prev, so next can run over the previous result.findColumnLeaf column by column id, else the first leaf with that field.fitColumnWidthsExpands column widths proportionally so that their sum reaches target. Columns are never shrunk: when the widths already reach target the input widths are retu…getColumnFiltersTop-level conditions on one column (filter bar / menu state for renderers).getSortInfoPer-column header state for renderers: direction and 1-based priority, or null.getSourceIndexSource index of the row at a visible index, or -1 (also for synthetic rows such as group captions).groupTargetKeyNormalizes a group target to its path key.isColumnVisibleisJsonValueTrue when value survives a JSON round trip unchanged: null, booleans, finite numbers, strings, arrays, and plain objects of those. undefined is allowed only as…keyComboFromEventCanonical combo of a key event. Letters are read from code when Alt is held (macOS Option produces composed characters: Alt+J is ∆) and from key otherwise, so…normalizeFilterOperatorCanonical built-in operator for a name (case-insensitive).normalizeKeyComboCanonical combo string: modifiers in Ctrl+Meta+Alt+Shift order, then the key. Mod resolves to Meta on macOS and Ctrl elsewhere; Cmd/Command mean Meta, Control…orderLeavesLeaves in runtime order: the explicit order first, then the remaining leaves in definition order.orderModulesDependency order, then registration order. Throws on duplicates, missing dependencies, and cycles.previewColumnsCommandPure dry run of a columns.* command: the state it would produce, or null when it would be rejected. Renderers use it to report proposed values before the engin…resolveColumnKeysResolves column keys (by id, field, or header text) to leaf column ids.resolveColumnWidthResolves a column width to pixels. Percent widths need the container width. Returns null for auto (measured by the renderer) or when a percent width has no con…rowIdFromKeyBuilds a getRowId from a primary key: a field name, several field names (joined with \u001f), or a function. The React DataGrid uses it for primaryKey columns.sameRangesearchColumnsColumns a search descriptor reads, in leaf order.searchRowOrderRows of base (null = identity over rows) matching the search in any column.serializeDataGridQueryDeterministic serialization of a query: sorted object keys, array order preserved, local-only custom aggregate functions dropped. Equal queries produce equal s…shallowEqualShallow equality for selector results: Object.is, or same keys/items with Object.is values.sortRowOrderStable multi-key sort of order (source indexes; null = identity over rows). Returns a new array; the input is never written.visibleColumnIndexDisplay position of a column among the visible leaves (left zone, center, right zone), or -1.
Interfaces
AbortSignalLikeMinimal structural view of an AbortSignal.AggregateDescriptorAggregateModelSnapshotOpaque aggregate results carried by the row model (see ./index.js aggregates).AggregatesOptionsAggregatesStateBeforeCommandEventCellRefCellSnapshotCellSpanBlockA span block in visible coordinates: its anchor (top-left) cell and its size.CellSpanResolverThe span block covering a visible cell, or null when the cell is not part of a span (a 1x1 block). Called only on user actions (moves, selection, editing), nev…ChildGridConfigOne child grid level. Child is the child row type, Parent the row type of the grid it nests in, and Nested the row type of the next level (childGrid).ChildGridDescriptorChildGridParentThe parent row a child grid belongs to.ChildRelationChildScopeClipboardCopyClipboardOptionsClipboardStateColumnDefColumnFacetColumnFlagsColumnLookupcolumn.lookup: the cell holds a value matched against keyField of the lookup rows; the grid shows, sorts, filters, searches, and groups by displayField.ColumnLookupStatusColumnMetricsHorizontal metrics for one column zone.ColumnSnapshotColumnValidationColumnWidthSpecColumnsStateColumnsStateInitInitial runtime column state (DataGridOptions.initialColumnState); applied before the server snapshot.CommandEventCommandRejectionReturned from reduce through ctx.reject(reason).CompiledColumnCompiledLookupCompiledColumn.lookup of a lookup column (filled by the lookup module).CompiledValidatorOne column's compiled rules.ConflictSnapshotA version conflict reported by a write (structural copy of @salmonui/data ConflictSnapshot).CopyOptionsCustomOperatorContextDataGridApiImperative DataGrid API over an engine (re-exported by @salmonui/data-grid as DataGridCoreApi and extended there). Every method that takes a column accepts a f…DataGridEngineDataGridInstrumentationDataGridModuleDataGridOptionsDataGridPersistenceDataGridPersistenceOptionsDataGridQueryInitPartial query accepted by createDataGridQuery and the defaultQuery option.DataGridSnapshotDataGridStateApiThe getState / restoreState / resetState instance methods.DataGridStateOptionsDataGridStateStorageAdapterInjected storage, sync or async. @salmonui/data createKeyValueStateStorage and createJsonStateStorage fit structurally.DataGridWarningDataQueryDataSourceDataSourceCapabilitiesDataSourceFacetRequestDataSourceFacetResultDataSourceRequestDataSourceResultDataStatusSnapshotDeserializeDataGridStateOptionsDetailInfoDetailLoadContextDetailLoadSnapshotDetailOptionsDetailResolverResolves which rows of an inner view get a detail row (the module's expansion state).DetailStateDropPointWhere a pointer is over the visible row model.DropTargetEditApiEdit methods. Columns are named by field or column id (the column id wins); value maps (addRow, updateRow) are keyed the same way.EditBatchChangesgetBatchChanges(): rows with the drafts applied.EditCellContextContext of isCellEditable (canEditCell policy).EditChangeEditDataChangesRows to apply with applyChanges().EditDisplayDisplay value of a draft-backed cell; identity is stable until the draft changes.EditDraftOne draft value (read-only view).EditMessagesSave and conflict texts of the edit module (localizable through EditOptions.messages).EditOptionsEditPreviewedit.getBatchPreview(): non-mutating diff for a save-review UI.EditPreviewCellEditSnapshotedit.getSnapshot().EditStateEditTargetThe row (row and dialog modes) or cell (batch and cell modes) being edited.EditWriteOutcomeOutcome of the last write (edit.getLastWrite()).ExpansionDescriptorFacetOptionsFacetValueFieldValidatorContextContext of a form field's custom validators (@salmonui/inputs/form Field). It is passed as both the row and the ctx argument, so validate(value, { formData })…FilterColumnOptionsOptions of DataGridApi.filterColumn.FilterDescriptorFilterGroupDescriptorNested AND/OR group: predicate combines its members ({ predicate: 'or', filters: [A, B] } is A OR B); member predicates are ignored. A top-level group is ANDed…FilterModuleConfigFilterOptionsFilterStateFitColumnOne visible leaf column as seen by fitColumnWidths.FocusOptionsFocusStateFormDataLikeThe read side of FormData (core has no DOM types).FormatOptionsNumber presets (N2, C, P1), custom number patterns (#,##0.00), date skeletons (yMMMd, short), or custom date patterns (dd/MM/yyyy HH:mm).FormatterFormatterOptionsGroupDescriptorGroupPathSegmentOne level of a group path: the grouped column and the group key (JSON form of the value).GroupRowSnapshotCaption or footer row of a group, for renderers and templates.GroupTreeSnapshotOpaque group structure carried by the row model (see ./index.js grouping).GroupedRowEnvelopeGroup envelope of a lazy group load (DataSourceRequest.groupPath).GroupingOptionsGroupingStateHeaderSnapshotHierarchyOptionsoptions.hierarchy: Child is the first-level child row type, Row the grid's row type.HierarchyStateKeyBindingKeyEventLikeStructural subset of a DOM KeyboardEvent (the engine compiles without the DOM lib).KeymapKeymapOptionsLocalDataPatchLocalDataSourceLocalDataSourceOptionsLocaleInputLocaleTextStateLookupRequestLookupSourceRemote (or computed) lookup. @salmonui/data ships cached implementations (createLookup, createJsonLookup).LookupStateModuleContextNotificationScopePageInfoPagingDescriptorPagingOptionsPagingStatePasteResultPipelineStageResolvedEditOptionsResolvedLocaleResolvedSelectionOptionsRestoreResultRowDeltaChange from one source rows array to the next within one data version chain (local patches, or a setRows that differs from the previous array in a few rows). R…RowDragDropOptionsRowDragDropStateRowDragEventInfoRow drag event fields the core owns (rows, target, and originalEvent are the renderer's).RowDragHandoffCaller-owned registry shared by grids that drag rows between each other (rowDragDrop.handoff).RowDragPayloadRowDragSessionRowDropStatusRowMetricsVertical metrics of the visible row model. Offsets are in virtual px.RowModelSnapshotVisible row model. Rows are stored by reference in source with parallel sourceIds; order maps a visible index to a source index (null means the identity order)…RowModelViewVisible row model of a grouped (or otherwise structured) grid.RowPlacementMoves rowIds (in this order) next to targetRowId; a null target means the start (before) or the end (after).RowSelectionRowSnapshotRowValidationContextScrollMappingMaps between the physical scroll offset of the scroll container and the virtual offset of the row model. Below maxScrollHeight the mapping is the identity. Abo…SearchDescriptorSearchOptionsSearchStateSelectionApiSelectionChangeSelectionOptionsSelectionPreviewProposed selection of a command (rows, cells and columns), computed without committing: before-events and controlled renderers. Parts the command leaves alone…SelectionStateSelectionSummarySortDescriptorSortOptionsSortStateSparseRowMetricsSparseRowsRows whose height differs from the fixed row height, ascending by index.StageContextValidationMessagesMessage templates; {0} and {1} are the rule arguments.ValidatorContextContext passed to custom validators; Column is the host's column (the Data Grid passes its compiled column).ValueContextVariableRowMetricsRow metrics with measured or per-row heights, kept in a Fenwick tree (O(log n) updates and lookups).ViewRowInfoA row the view owns or synthesizes, resolved by id.ViewportSnapshotVirtualRangeA rendered window: [start, end) is visible, [overscanStart, overscanEnd) is rendered.WriteRequestWriteResult
Types
AggregateInputSerializable aggregate descriptor of aggregates.set.AggregateScopeAggregateTypeAggregateValuesAggregate values by column and aggregate type ({ n0: { sum: 12, average: 3 } }).AggregatesCommandAggregatesMethodsAggregatesModuleAggregatesSetCommandAggregatesSetScopeCommandCellKeyA cell by ids (a type alias of the core CellKey shape, so commands stay JSON-typed).CellRangeCellSelectionModeCheckboxModeClipboardCommandClipboardFillCommandAutofill: extends the current range (or source) to target, tiling the source values.ClipboardMethodsClipboardModuleClipboardPasteCommandColumnFreezefixed keeps the leaf in the center zone, sticky at its scroll-start position.ColumnIdColumnKeyKindColumnTypeselection: the row selection checkbox column; rowNumber: the 1-based row number column (no value, rendered from the row position).ColumnTypeSourceColumnWidthColumnZoneColumnsCommandColumnsHideCommandColumnsModuleColumnsMoveCommandMoves a leaf so that its index among the visible leaves becomes toIndex. Rejected when the move crosses a freeze zone (crossesFreezeZone), moves a lockColumn c…ColumnsSetFreezeCommandPins ('left', 'right') or unpins (null) a leaf at runtime. The column moves to the inner edge of its new zone: the end of the left zone, the start of the right…ColumnsSetFrozenCountCommandFrozen column count shorthand: the first left / last right visible leaves are frozen.ColumnsSetOrderCommandReplaces the runtime leaf order. Unknown ids are ignored; missing leaves follow in definition order.ColumnsSetPinningCommandReplaces the runtime pin state as a whole (freeze overrides and counts) without moving columns; state restore uses it. Unknown ids are dropped.ColumnsSetVisibilityCommandColumnsSetWidthCommandSets one leaf width in px, clamped to minWidth/maxWidth.ColumnsSetWidthsCommandMerges widths (px) into the runtime widths; replace: true drops widths that are not listed.ColumnsShowCommandCommandResultCommandTypeCoreCommandUnion of the commands declared by the modules shipped with the core.CustomAggregateA custom aggregate (type: 'custom'): receives the group's (or the grid's) rows.CustomFilterOperatorCustom operator: a pure function of one cell value. It runs once per distinct value of the column, not once per row, so it must not depend on other fields of t…CustomValidatorCustom validator: returns an error message, or null / undefined / true when the value is valid (false uses the rule message). May return a promise (async valid…DataGridActionResultResult of a mutating DataGrid action (public name of CommandResult).DataGridCommandDataGridEngineWithModulesEngine plus the generated command façade of the built-in columns module and every registered module.DataGridStateVersioned, JSON-serializable grid state. Columns are referenced by field (falling back to the column id when a column has no field). Every part is optional on…DataGridStatePartPersisted parts. tree is read and restored by the tree entry's wrappers (withTreeState, withTreePersistence in ./tree.js), so grids without tree mode carry non…DataSourceEventChange notification from a data source. rows is always the complete new row array; the id lists let the engine update incrementally.DataSourceModeDetailCommandDetailMethodsDetailModuleDropPositionEditAddRecordCommandrelativeTo (tree positions): the anchor row; default the focused row.EditCancelBatchCommandEditCancelCommandEditCommandEditCommitAndMoveCommandEditCommitCommandEditDeleteRecordsCommandEditMessageTableEvery message key the edit module reads (EditOptions.messages).EditMethodsEditModeEditModuleEditRedoCommandRe-applies the last undone entry.EditRestoreRecordsCommandRestores rows marked deleted in batch mode.EditSaveBatchCommandEditSetOptionsCommandmessages (merged over the defaults) replaces the message overrides at runtime (locale text changes).EditSetValueCommandvalue is the editor input; the column parser converts it (dates as ISO strings).EditSetValuesCommandPaste, autofill, and bulk updates: drafts for many cells; commit writes them at once (any mode but batch). A cell takes value, or the current value (draft incl…EditSettleCommandInternal: a write or async validation settled.EditStartCommandEditStatusEditUndoCommandReverts the last history entry (needs undo: true).EditUpdateCellCommandupdateCell(): batch mode keeps a draft; other modes write at once.EditUpdateRowCommandupdateRow(): writes the values (by column id) at once, validated.EditValidateBatchCommandValidates every pending change without writing: built-in rules on every draft and every editable cell of added rows, custom validators and validateRow of every…FieldValidationRules of a form field: the column vocabulary with the field context.FilterAddCommandFilterByColumnCommandfilterByColumn(columnId, operator, value): replaces the column's top-level conditions. An array value with an operator other than in, notIn, or between becomes…FilterClearCommandclearFiltering(columnIds?).FilterCommandFilterConditionInputJSON form of a filter condition in command payloads; omitted fields take defaults (predicate: 'and', source: 'api').FilterEntryFilterEntryInputFilterGroupInputFilterMethodsFilterModuleFilterOperatorBuilt-in filter operators. like treats % and as "any sequence"; wildcard treats as "any sequence" and ? as "one character". Both match the whole value. Lowerca…FilterRemoveCommandRemoves the filters of one column.FilterSetCommandFilterSetOptionsCommandChanges enabled / caseSensitive / ignoreAccent at runtime (reactive settings props).FilterSourceFocusCommandFocusDirectionleft/right are visual and flip in RTL; the others are logical.FocusIntentFocusMethodsFocusModuleFocusMoveCommandFocusSetCommandFocusSetDirectionCommandFocusSetModeCommandFocusTargetFormatDescriptorNormalized column.format.GroupDescriptorInputGroupTargetGroups / group target: a group row id (g:...), a path key, or a path.GroupingClearCommandclearGrouping().GroupingCollapseAllCommandGroupingCommandGroupingExpandAllCommandGroupingGroupByCommandgroupColumn(): appends (or inserts at index) a grouped column.GroupingLoadMoreCommandLazy mode: load the next chunk of a group's children.GroupingMethodsGroupingModuleGroupingMoveCommandGroup chip reorder.GroupingRetryCommandLazy mode: retry a failed group (or the root level when group is omitted).GroupingSetCommandGroupingSetDirectionCommandGroupingSetEnabledCommandGroupingSetExpandedCommandControlled expansion: replaces the per-group overrides (and optionally the default).GroupingSetOptionsCommandGroupingToggleCommandToggles (or sets) one group.GroupingUngroupCommandungroupColumn().HierarchyMethodsHierarchyModuleJsonJsonObjectKeyBindingOverridesUser overrides: { [command]: combos } (keys for the current platform).KeyContextWhere focus is when the key is pressed. global bindings work from anywhere in the document.KeyPlatformLazyStatusLocaleMessageA message: a {param} template, or plural forms chosen by Intl.PluralRules for count (other is required).LocaleTextResolved text: every built-in key, plus any extra keys a bundle adds.LocaleTextCommandLocaleTextKeyLocaleTextMethodsLocaleTextModuleLocaleTextParamsLocaleTextSetCommandLookupCommandLookupLoadedCommandA lookup load settled (dispatched by the engine; part of the public command union).LookupMethodsLookupModuleLookupReloadCommandLookupStatusModuleFacadeImperative façade of one module: engine.<module>.<action>(payload) dispatches <module>.<action>; engine.<module>.<method>(...args) calls a read-only module met…ModuleMethodsRead-only module methods exposed on the façade (engine.<module>.<method>(...args)); they receive the module context first.PagingCommandPagingFirstCommandPagingGoToPageCommandPagingLastCommandPagingMethodsPagingModulePagingNextCommandPagingPreviousCommandPagingSetEnabledCommandPagingSetPageSizeCommandKeeps the first row of the current page visible, then clamps.PagingSetTotalRowCountCommandSets or clears (null) the remote total override (PagingOptions.totalRowCount).PerformedStageStages a remote source may declare as already performed.PersistedColumnA column in runtime order.PersistedFilterPersistedFilterConditionPersistedFilterGroupPersistedPinningRuntime pin state (the pinnedColumns counts and per-column pins made at runtime, pinColumn). Columns are referenced by field (id when there is none); null unpi…PipelineStageNameRowDragCommandRowDragDropMethodsRowDragDropModuleRowIdRowKindRowValidatorRuleValueA rule argument, or [argument, message] to override the message.SearchClearCommandSearchCommandSearchModuleSearchOperatorwildcard: * any sequence, ? one character; like: % (or *) any sequence. Both match the whole value.SearchSetCommandsearch(text); omitted settings keep their current values.SelectionClearCommandSelectionCommandSelectionExtendCellSelectionCommandMoves the focus end of the last range (Shift+click, Shift+Arrow in cell mode).SelectionMethodsSelectionModeSelectionModuleSelectionRestoreCommandSelectionSelectAllFilteredCommandSelectionSelectAllVisibleCommandEvery row of the current view (current page). Without paging this is selectAllFiltered.SelectionSelectCellsCommandSelectionSelectColumnsCommandSelectionSelectRangeCommandRows between fromId (default: the anchor) and toId in visible order.SelectionSelectRowsCommandSelectionSetCellRangeCommandSelectionSetOptionsCommandSelectionToggleAllCommandHeader checkbox: all → none, otherwise all filtered.SelectionToggleRowCommandSelectionTypeSerializedSelectionJSON form (getState/restore, persistence, server-side select-all).SortClearCommandSortColumnCommandSorts one column; multi keeps the other sorted columns.SortCommandSortDescriptorInputJSON form of a SortDescriptor in command payloads.SortModeSortModuleSortRemoveCommandSortSetCommandSortSetOptionsCommandChanges enabled / mode / allowUnsort at runtime (reactive settings props).SortToggleCommandHeader click: none -> asc -> desc -> none (or asc when allowUnsort is false). multi is Ctrl/Meta+click.
Constants
AGGREGATE_TYPESBLANK_FACET_KEYStable key shared by null, undefined, and empty-string values in facets.DEFAULT_DEVDevelopment default derived from process.env.NODE_ENV.DEFAULT_KEY_BINDINGSThe complete default binding table: every core keyboard row (with the macOS variant where it differs) plus the Salmon UI additions.DEFAULT_MAX_SCROLL_HEIGHTDefault physical cap, below every browser's element height limit.EMPTY_GRID_QUERYThe empty query: no search, filters, sorting, grouping, aggregates, or paging.EMPTY_RANGEGROUP_FOOTER_ID_PREFIXGROUP_ID_PREFIXPIPELINE_STAGE_RANKSFixed stage ranks of the query pipeline. The viewport range is not a row-model stage; it is computed from the final model.TYPE_INFERENCE_SAMPLERows scanned for the first non-null value when type is omitted.