@omnigrid/core 0.1.26 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/columns.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CellSpanningParams, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, RowId, RowSpanLayout } from "./types";
1
+ import type { CellSpanningParams, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, DefaultColumnDef, RowId, RowSpanLayout } from "./types";
2
2
  /**
3
3
  * Runtime narrowing: does the column definition describe a GROUP
4
4
  * (it carries `children`) rather than a leaf column?
@@ -6,6 +6,15 @@ import type { CellSpanningParams, ColumnDef, ColumnGroupDef, ColumnGroupViewport
6
6
  export declare function isColumnGroup<T>(column: ColumnDef<T>): column is ColumnGroupDef<T>;
7
7
  /** Inverse of `isColumnGroup` — handy for filters over the flat working set. */
8
8
  export declare function isColumnLeaf<T>(column: ColumnDef<T>): column is ColumnLeafDef<T>;
9
+ /**
10
+ * Applies shared defaults to leaf columns while preserving column-level overrides.
11
+ *
12
+ * @param columns - Column definitions to process.
13
+ * @param defaultColumnDef - Properties inherited by leaf columns, when supplied.
14
+ * @returns Column definitions with defaults applied recursively.
15
+ * @api
16
+ */
17
+ export declare function applyDefaultColumnDef<T>(columns: ColumnDef<T>[], defaultColumnDef: DefaultColumnDef<T> | undefined): ColumnDef<T>[];
9
18
  /**
10
19
  * Depth-first flattening of the hierarchical column definitions into the
11
20
  * flat array of LEAF columns.
package/dist/columns.js CHANGED
@@ -9,6 +9,21 @@ export function isColumnGroup(column) {
9
9
  export function isColumnLeaf(column) {
10
10
  return !isColumnGroup(column);
11
11
  }
12
+ /**
13
+ * Applies shared defaults to leaf columns while preserving column-level overrides.
14
+ *
15
+ * @param columns - Column definitions to process.
16
+ * @param defaultColumnDef - Properties inherited by leaf columns, when supplied.
17
+ * @returns Column definitions with defaults applied recursively.
18
+ * @api
19
+ */
20
+ export function applyDefaultColumnDef(columns, defaultColumnDef) {
21
+ if (!defaultColumnDef)
22
+ return columns;
23
+ return columns.map((column) => isColumnGroup(column)
24
+ ? { ...column, children: applyDefaultColumnDef(column.children, defaultColumnDef) }
25
+ : { ...defaultColumnDef, ...column });
26
+ }
12
27
  /**
13
28
  * Depth-first flattening of the hierarchical column definitions into the
14
29
  * flat array of LEAF columns.
package/dist/grid.d.ts CHANGED
@@ -4,7 +4,7 @@ import { IconRegistry } from "./icons";
4
4
  import { SlotManager } from "./slots";
5
5
  import { type StateUpdater } from "./store";
6
6
  import { DataPipeline } from "./pipeline";
7
- import type { AggregationFunc, ColumnLeafDef, DataProcessor, GridApi, GridEvents, GridOptions, GridPlugin, GridState, RowClickEvent, RowHeightUpdateOptions, RowHoverEvent, RowHierarchy, RowId, RowSpanLayout, ScrollPosition, SlotMount, SlotName, TransactionResult, TreeRowNode, RowTransaction, ViewportData, ViewportState } from "./types";
7
+ import type { AggregationFunc, ColumnLeafDef, DataProcessor, DefaultColumnDef, GridApi, GridEvents, GridOptions, GridPlugin, GridState, RowClickEvent, RowHeightUpdateOptions, RowHoverEvent, RowHierarchy, RowId, RowSpanLayout, ScrollPosition, SlotMount, SlotName, TransactionResult, TreeRowNode, RowTransaction, ViewportData, ViewportState } from "./types";
8
8
  import type { OverlayOptions, OverlayState } from "./overlays";
9
9
  export declare class Grid<T> implements GridApi<T> {
10
10
  private readonly store;
@@ -40,6 +40,7 @@ export declare class Grid<T> implements GridApi<T> {
40
40
  * disables auto-evaluation until hideOverlay re-enables it.
41
41
  */
42
42
  private readonly licenseKey;
43
+ private defaultColumnDef;
43
44
  private loading;
44
45
  private hasData;
45
46
  private loadError;
@@ -315,7 +316,14 @@ export declare class Grid<T> implements GridApi<T> {
315
316
  * structural changes.
316
317
  */
317
318
  refresh(): void;
318
- setColumns(columns: GridState<T>["columns"]): void;
319
+ /**
320
+ * Replaces the column definitions and optionally updates shared leaf-column defaults.
321
+ *
322
+ * @param columns - New column definitions.
323
+ * @param defaultColumnDef - Updated defaults; pass `undefined` to clear existing defaults.
324
+ * @api
325
+ */
326
+ setColumns(columns: GridState<T>["columns"], defaultColumnDef?: DefaultColumnDef<T>): void;
319
327
  registerDataProcessor(processor: DataProcessor<T>): () => void;
320
328
  headerClick(columnId: string, multiSort?: boolean): void;
321
329
  rowClick(row: RowClickEvent<T>): void;
package/dist/grid.js CHANGED
@@ -1,4 +1,4 @@
1
- import { applyWrapText, flattenColumns, getColumnGroups, getCellValue, getRowSpans, resolveColSpan } from "./columns";
1
+ import { applyDefaultColumnDef, applyWrapText, flattenColumns, getColumnGroups, getCellValue, getRowSpans, resolveColSpan } from "./columns";
2
2
  import { EventBus } from "./events";
3
3
  import { applyFilterModel, applyQuickFilter, isActiveCondition } from "./filtering";
4
4
  import { PopupManager } from "./ui";
@@ -49,7 +49,7 @@ export class Grid {
49
49
  this.scrollPosition = { scrollTop: 0, scrollLeft: 0 };
50
50
  const state = {
51
51
  data: options.data ?? [],
52
- columns: applyWrapText(options.columns, options.wrapText),
52
+ columns: applyWrapText(applyDefaultColumnDef(options.columns, options.defaultColumnDef), options.wrapText),
53
53
  viewport: { width: 0, height: 0, scrollTop: 0, scrollLeft: 0 },
54
54
  rowHeight: options.rowHeight ?? 32,
55
55
  groupBy: [],
@@ -66,6 +66,7 @@ export class Grid {
66
66
  };
67
67
  this.store = new Store(state);
68
68
  this.licenseKey = options.licenseKey;
69
+ this.defaultColumnDef = options.defaultColumnDef;
69
70
  this.resolveRowId = options.getRowId ?? ((_row, index) => index);
70
71
  this.loading = options.loading ?? false;
71
72
  this.hasData = options.data !== undefined && options.data !== null;
@@ -1078,14 +1079,23 @@ export class Grid {
1078
1079
  this.revision += 1;
1079
1080
  this.store.setState({});
1080
1081
  }
1081
- setColumns(columns) {
1082
+ /**
1083
+ * Replaces the column definitions and optionally updates shared leaf-column defaults.
1084
+ *
1085
+ * @param columns - New column definitions.
1086
+ * @param defaultColumnDef - Updated defaults; pass `undefined` to clear existing defaults.
1087
+ * @api
1088
+ */
1089
+ setColumns(columns, defaultColumnDef) {
1082
1090
  this.assertActive();
1091
+ if (arguments.length > 1)
1092
+ this.defaultColumnDef = defaultColumnDef;
1083
1093
  this.filteredDataCache = null;
1084
1094
  this.processedDataCache = null;
1085
1095
  this.groupedRowsCache = null;
1086
1096
  this.groupedRowsRevision = -1;
1087
1097
  this.revision += 1;
1088
- this.store.setState({ columns: applyWrapText(columns, this.wrapTextAll) });
1098
+ this.store.setState({ columns: applyWrapText(applyDefaultColumnDef(columns, this.defaultColumnDef), this.wrapTextAll) });
1089
1099
  this.recomputeOverlay();
1090
1100
  }
1091
1101
  registerDataProcessor(processor) {
package/dist/index.d.ts CHANGED
@@ -14,6 +14,6 @@ export { applyFilterModel, applyQuickFilter, isActiveCondition, isFilterModelAct
14
14
  export type { ColumnFilterModel, FilterCondition, FilterModel, FilterOperator } from "./filtering";
15
15
  export type { UIButtonControl, UICheckboxDescriptor, UIControlBase, UIControlDescriptor, UIGroupControl, UIInputControl, UIPopupAnchor, UIPopupDescriptor, UISelectControl, UISelectOption, UITextBlockControl, UIMultiSelectControl, UIMultiSelectOption, } from "./ui";
16
16
  export type { OverlayOptions, OverlayScope, OverlayState, OverlayType } from "./overlays";
17
- export type { BlockConfig, CellAlign, AggregationFunc, CellRenderParams, CellClassRules, CellSpan, CellSpanningParams, CheckboxControl, CheckboxRenderParams, ColSpanDef, ColumnClassRules, ColumnDataType, ColumnFilterType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DataRowNode, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GroupRowNode, GroupRowRenderParams, GroupRowRenderer, CoreGridApi, CoreGridState, GridApi, GridEvents, GridOptions, GridPlugin, GridState, PluginApiExtensions, PluginStateExtensions, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHeightUpdateOptions, RowHost, RowHoverEvent, RowId, RowHierarchy, RowHierarchyScope, RowNode, RowRenderParams, RowSpanLayout, RowStyle, RowTransaction, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, TransactionResult, TreeRowNode, ViewportData, ViewportState, VirtualItem, } from "./types";
18
- export { getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue, getCellSpanningParams, resolveColSpan, getRowSpans } from "./columns";
17
+ export type { BlockConfig, CellAlign, AggregationFunc, CellRenderParams, CellClassRules, CellSpan, CellSpanningParams, CheckboxControl, CheckboxRenderParams, ColSpanDef, ColumnClassRules, ColumnDataType, DefaultColumnDef, ColumnFilterType, ColumnDef, ColumnGroupDef, ColumnGroupViewport, ColumnLeafDef, ColumnStyle, ColumnStyleParams, DataProcessor, DataRowNode, DomPoolBindings, DomPoolUpdate, DomPoolUpdateOptions, GroupRowNode, GroupRowRenderParams, GroupRowRenderer, CoreGridApi, CoreGridState, GridApi, GridEvents, GridOptions, GridPlugin, GridState, PluginApiExtensions, PluginStateExtensions, HeaderClassRules, HeaderGroupClassRules, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, OverlayComponent, OverlayComponentProps, PooledRow, Range, RowClassRules, RowClickEvent, RowHeightUpdateOptions, RowHost, RowHoverEvent, RowId, RowHierarchy, RowHierarchyScope, RowGroupContext, RowGroupContextChild, RowNode, RowRenderParams, RowSpanLayout, RowStyle, RowTransaction, ScrollPosition, SlotComponentContent, SlotContent, SlotHtmlContent, SlotMount, SlotMountOptions, SlotName, SlotNodeContent, SlotNodeEvent, SlotNodeEventName, SlotPosition, SlotProvider, SlotRenderContext, SortDirection, TransactionResult, TreeRowNode, ViewportData, ViewportState, VirtualItem, } from "./types";
18
+ export { applyDefaultColumnDef, getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue, getCellSpanningParams, resolveColSpan, getRowSpans } from "./columns";
19
19
  export { Virtualizer, RowHeightRegistry } from "./virtualizer";
package/dist/index.js CHANGED
@@ -8,5 +8,5 @@ export { SlotManager } from "./slots";
8
8
  export { Store } from "./store";
9
9
  export { DataPipeline, PIPELINE_STAGE_ORDER } from "./pipeline";
10
10
  export { applyFilterModel, applyQuickFilter, isActiveCondition, isFilterModelActive, matchesColumnFilter } from "./filtering";
11
- export { getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue, getCellSpanningParams, resolveColSpan, getRowSpans } from "./columns";
11
+ export { applyDefaultColumnDef, getColumnGroups, flattenColumns, isColumnGroup, isColumnLeaf, getCellValue, getCellSpanningParams, resolveColSpan, getRowSpans } from "./columns";
12
12
  export { Virtualizer, RowHeightRegistry } from "./virtualizer";
package/dist/types.d.ts CHANGED
@@ -54,7 +54,7 @@ export type ColumnFilterType = "text" | "number" | "date" | "boolean" | "set" |
54
54
  *
55
55
  * `RowNode` is a lightweight view over a single processed row: the stable
56
56
  * `id` (from `getRowId`), the zero-based `index` in the processed dataset,
57
- * and the raw `data` object itself.
57
+ * the raw `data` object, and optional grouping context.
58
58
  *
59
59
  * @api
60
60
  */
@@ -65,6 +65,10 @@ export interface RowNode<T> {
65
65
  index: number;
66
66
  /** Raw row data object. */
67
67
  data: T;
68
+ /** Whether this row represents a collapsed single-child group. */
69
+ isCollapsedGroup?: boolean;
70
+ /** Immediate parent group and its acyclic child context, when grouped. */
71
+ parentGroup?: RowGroupContext<T>;
68
72
  }
69
73
  /** Aggregation function applied to column values within a group. */
70
74
  export type AggregationFunc<T = unknown> = (values: unknown[]) => unknown;
@@ -142,6 +146,8 @@ export interface DataRowNode<T> {
142
146
  level: number;
143
147
  /** The group this row belongs to. */
144
148
  parent: GroupRowNode<T>;
149
+ /** A cycle-free snapshot of the immediate parent group and its children. */
150
+ parentGroup?: RowGroupContext<T>;
145
151
  /**
146
152
  * Set when this leaf row is displayed as a collapsed single-child group
147
153
  * (`collapseSingleChildGroups: true`). Contains the grouping field, value,
@@ -155,6 +161,25 @@ export interface DataRowNode<T> {
155
161
  }
156
162
  /** A row in the flattened grouped output — either a group or a data row. */
157
163
  export type TreeRowNode<T> = GroupRowNode<T> | DataRowNode<T>;
164
+ /**
165
+ * A direct child in a cycle-free row group context.
166
+ *
167
+ * Leaf snapshots omit their parent references; nested groups retain their
168
+ * own child contexts.
169
+ *
170
+ * @api
171
+ */
172
+ export type RowGroupContextChild<T> = RowGroupContext<T> | Omit<DataRowNode<T>, "parent" | "parentGroup">;
173
+ /**
174
+ * A snapshot of a group and its immediate children, including nested groups
175
+ * and leaf snapshots without parent back-references.
176
+ *
177
+ * @api
178
+ */
179
+ export type RowGroupContext<T> = Omit<GroupRowNode<T>, "children"> & {
180
+ /** Immediate subgroup contexts and parent-free leaf snapshots. */
181
+ children: RowGroupContextChild<T>[];
182
+ };
158
183
  /**
159
184
  * Context passed to the `colSpan` resolver of a column.
160
185
  *
@@ -221,6 +246,8 @@ export interface RowSpanLayout {
221
246
  * `rowClassRules`, `checkboxDisabled`, ...).
222
247
  *
223
248
  * `rowType` distinguishes ordinary data rows from synthetic group rows.
249
+ * Leaf rows also report whether they represent a collapsed single-child group
250
+ * and include their immediate parent group context when grouping is active.
224
251
  * Group rows do not have raw row data.
225
252
  *
226
253
  * @api
@@ -232,6 +259,8 @@ export type RowRenderParams<T> = (RowNode<T> & {
232
259
  index: number;
233
260
  rowType: "group";
234
261
  data?: never;
262
+ isCollapsedGroup?: false;
263
+ parentGroup?: never;
235
264
  };
236
265
  export interface RowStyle {
237
266
  [property: string]: string | number | undefined;
@@ -395,6 +424,14 @@ export interface ColumnLeafDef<T> extends BaseColumnDef<T> {
395
424
  align?: CellAlign;
396
425
  /** Enables automatic text wrapping instead of ellipsis truncation. @default false @api */
397
426
  wrapText?: boolean;
427
+ /**
428
+ * Maximum number of visible lines for wrapped cell content. Cells exceeding
429
+ * this limit are truncated and can reveal their full text in the React adapter tooltip.
430
+ * Requires `wrapText: true`.
431
+ *
432
+ * @api
433
+ */
434
+ maxLines?: number;
398
435
  /**
399
436
  * Controls whether the cell keeps the theme's internal padding or removes it
400
437
  * so custom content can fill the cell.
@@ -480,6 +517,12 @@ export interface ColumnGroupDef<T> extends BaseColumnDef<T> {
480
517
  }
481
518
  /** Leaf or grouped column definition accepted by the grid. */
482
519
  export type ColumnDef<T> = ColumnLeafDef<T> | ColumnGroupDef<T>;
520
+ /**
521
+ * Properties inherited by leaf columns unless overridden by the column.
522
+ *
523
+ * @api
524
+ */
525
+ export type DefaultColumnDef<T> = Partial<Omit<ColumnLeafDef<T>, "id" | "header">>;
483
526
  /**
484
527
  * Props supplied to a framework-specific overlay renderer.
485
528
  *
@@ -531,6 +574,8 @@ export interface GridOptions<T> {
531
574
  /** Row data; omitted or null means an initial load is pending. */
532
575
  data?: T[] | null;
533
576
  columns: ColumnDef<T>[];
577
+ /** Properties applied to every leaf column unless overridden. @api */
578
+ defaultColumnDef?: DefaultColumnDef<T>;
534
579
  /** Returns a stable row ID; defaults to the row's current index. Use a stable ID to preserve row identity when rows are reordered. */
535
580
  getRowId?: (row: T, index: number) => RowId;
536
581
  rowHeight?: number;
@@ -1277,7 +1322,13 @@ export interface CoreGridApi<T> {
1277
1322
  emit<EventName extends keyof GridEvents<T>>(event: EventName, payload: GridEvents<T>[EventName]): void;
1278
1323
  registerPlugin(plugin: GridPlugin<T>): () => void;
1279
1324
  registerDataProcessor(processor: DataProcessor<T>): () => void;
1280
- setColumns(columns: ColumnDef<T>[]): void;
1325
+ /**
1326
+ * Replaces the column definitions. Pass a second argument to update the shared leaf-column defaults.
1327
+ * @param columns - New column definitions.
1328
+ * @param defaultColumnDef - Updated defaults; pass `undefined` to clear existing defaults.
1329
+ * @api
1330
+ */
1331
+ setColumns(columns: ColumnDef<T>[], defaultColumnDef?: DefaultColumnDef<T>): void;
1281
1332
  headerClick(columnId: string, multiSort?: boolean): void;
1282
1333
  rowClick(row: RowClickEvent<T>): void;
1283
1334
  rowHover(row: RowHoverEvent<T>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/core",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Framework-agnostic core engine for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",