@omnigrid/core 0.1.27 → 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, 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 { 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
@@ -424,6 +424,14 @@ export interface ColumnLeafDef<T> extends BaseColumnDef<T> {
424
424
  align?: CellAlign;
425
425
  /** Enables automatic text wrapping instead of ellipsis truncation. @default false @api */
426
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;
427
435
  /**
428
436
  * Controls whether the cell keeps the theme's internal padding or removes it
429
437
  * so custom content can fill the cell.
@@ -509,6 +517,12 @@ export interface ColumnGroupDef<T> extends BaseColumnDef<T> {
509
517
  }
510
518
  /** Leaf or grouped column definition accepted by the grid. */
511
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">>;
512
526
  /**
513
527
  * Props supplied to a framework-specific overlay renderer.
514
528
  *
@@ -560,6 +574,8 @@ export interface GridOptions<T> {
560
574
  /** Row data; omitted or null means an initial load is pending. */
561
575
  data?: T[] | null;
562
576
  columns: ColumnDef<T>[];
577
+ /** Properties applied to every leaf column unless overridden. @api */
578
+ defaultColumnDef?: DefaultColumnDef<T>;
563
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. */
564
580
  getRowId?: (row: T, index: number) => RowId;
565
581
  rowHeight?: number;
@@ -1306,7 +1322,13 @@ export interface CoreGridApi<T> {
1306
1322
  emit<EventName extends keyof GridEvents<T>>(event: EventName, payload: GridEvents<T>[EventName]): void;
1307
1323
  registerPlugin(plugin: GridPlugin<T>): () => void;
1308
1324
  registerDataProcessor(processor: DataProcessor<T>): () => void;
1309
- 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;
1310
1332
  headerClick(columnId: string, multiSort?: boolean): void;
1311
1333
  rowClick(row: RowClickEvent<T>): void;
1312
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.27",
3
+ "version": "0.1.28",
4
4
  "description": "Framework-agnostic core engine for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",