@omnigrid/react 0.1.12 → 0.1.14

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/README.md CHANGED
@@ -1,59 +1,62 @@
1
- # @omnigrid/react
2
-
3
- React adapter and renderer for OmniGrid. Renders the headless core engine into the DOM using React.
4
-
5
- ## What it provides
6
-
7
- - **`<OmniGrid />`** — React component that accepts `GridOptions` and renders a fully virtualized, 2D scrolled data grid
8
- - **`useGrid()`** — hook that creates and manages a `GridCore` instance with full lifecycle handling
9
- - **Cell / Row pooling** — reusable React content via DOM-pool integration for minimal re-renders
10
- - **Styles and default theme** — required structural styles and light/dark default colors are included automatically
11
- - **`transpilePackages`-ready** — works out of the box with Next.js and other bundlers
12
-
13
- ## Usage
14
-
15
- ```tsx
16
- import { OmniGrid } from "@omnigrid/react";
17
- import { useMemo } from "react";
18
-
19
- const columns = useMemo(() => [...], []);
20
- const data = [...];
21
-
22
- <OmniGrid columns={columns} data={data} />;
23
- ```
24
-
25
- ## Overlays
26
-
27
- The adapter renders body-only overlays below the sticky header. While one is active, vertical
28
- scrolling and its scrollbar are disabled; horizontal scrolling remains available for
29
- `noMatchingRows` (or when `blockScroll: false`). Use `scope: "full"` to cover the header and
30
- body as well.
31
-
32
- ```tsx
33
- import { OmniGrid, type OverlayComponentProps } from "@omnigrid/react";
34
-
35
- function LoadError<T>({ message }: OverlayComponentProps<T>) {
36
- return <div role="alert">{message ?? "Unable to load rows"}</div>;
37
- }
38
-
39
- <OmniGrid
40
- columns={columns}
41
- data={data}
42
- overlayComponents={{ error: LoadError }}
43
- onGridReady={(grid) => grid.showOverlay({ type: "error", message: "Please retry" })}
44
- />;
45
- ```
46
-
47
- To customize the table's color style, install a compatible `@omnigrid/*-theme`
48
- package and import it in the application after `@omnigrid/react`. Theme packages
49
- include their own light and dark variants; they are not light/dark mode toggles.
50
-
51
- ## Links
52
-
53
- - **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react
54
- - **Demo:** https://omnigrid-demo.vercel.app/
55
- - **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
56
-
57
- ## License
58
-
59
- MIT © KRZK Apps
1
+ # @omnigrid/react
2
+
3
+ React adapter and renderer for OmniGrid. Renders the headless core engine into the DOM using React.
4
+
5
+ ## What it provides
6
+
7
+ - **`<OmniGrid />`** — React component that accepts `GridOptions` and renders a fully virtualized, 2D scrolled data grid
8
+ - **`useGrid()`** — hook that creates and manages a `GridCore` instance with full lifecycle handling
9
+ - **Cell / Row pooling** — reusable React content via DOM-pool integration for minimal re-renders
10
+ - **Styles and default theme** — required structural styles and light/dark default colors are included automatically
11
+ - **`transpilePackages`-ready** — works out of the box with Next.js and other bundlers
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { OmniGrid } from "@omnigrid/react";
17
+ import { useMemo } from "react";
18
+
19
+ const columns = useMemo(() => [...], []);
20
+ const data = [...];
21
+
22
+ <OmniGrid columns={columns} data={data} />;
23
+ ```
24
+
25
+ ## Overlays
26
+
27
+ Automatic loading, no-rows, and no-matching-rows overlays cover the body below the sticky
28
+ header. They hide vertical scrolling while preserving its gutter, so columns do not shift;
29
+ horizontal scrolling remains available. Automatic error overlays cover the full grid.
30
+ Any active overlay hides vertical scrolling and preserves its gutter, regardless of scope.
31
+ Manual overlays default to body-only, except errors default to full-grid; set `scope` to
32
+ `"bodyOnly"` or `"full"` to choose the placement. `blockScroll: true` locks horizontal
33
+ scrolling; vertical scrolling is always locked while an overlay is active.
34
+
35
+ ```tsx
36
+ import { OmniGrid, type OverlayComponentProps } from "@omnigrid/react";
37
+
38
+ function LoadError<T>({ message }: OverlayComponentProps<T>) {
39
+ return <div role="alert">{message ?? "Unable to load rows"}</div>;
40
+ }
41
+
42
+ <OmniGrid
43
+ columns={columns}
44
+ data={data}
45
+ overlayComponents={{ error: LoadError }}
46
+ onGridReady={(grid) => grid.showOverlay({ type: "error", message: "Please retry" })}
47
+ />;
48
+ ```
49
+
50
+ To customize the table's color style, install a compatible `@omnigrid/*-theme`
51
+ package and import it in the application after `@omnigrid/react`. Theme packages
52
+ include their own light and dark variants; they are not light/dark mode toggles.
53
+
54
+ ## Links
55
+
56
+ - **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react
57
+ - **Demo:** https://omnigrid-demo.vercel.app/
58
+ - **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
59
+
60
+ ## License
61
+
62
+ MIT © KRZK Apps
package/dist/OmniGrid.js CHANGED
@@ -7,6 +7,7 @@ import { computeGroupSegments } from "./groupHeader";
7
7
  import { PooledRowPane } from "./pooledRow";
8
8
  import { createCellRoot } from "./reactRoot";
9
9
  import { renderDefaultOverlay } from "./overlays";
10
+ import { resolveCellClasses, resolveCellStyle, resolveColumnPresentation, resolveGroupHeaderClasses, resolveGroupHeaderStyle, resolveHeaderClasses, resolveHeaderStyle, } from "./styling";
10
11
  import { useGrid } from "./useGrid";
11
12
  function getCellValue(row, column) {
12
13
  if (column.valueGetter)
@@ -126,9 +127,11 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
126
127
  const suppressRowHoverHighlight = options.suppressRowHoverHighlight ?? false;
127
128
  const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null].filter(Boolean).join(" ");
128
129
  const overlayState = state.overlay;
129
- const overlayScope = overlayState.type ? (overlayState.scope ?? "bodyOnly") : undefined;
130
+ const overlayScope = overlayState.type
131
+ ? (overlayState.scope ?? (overlayState.type === "error" ? "full" : "bodyOnly"))
132
+ : undefined;
130
133
  const overlayBlocksHorizontalScroll = overlayState.type
131
- ? (overlayState.blockScroll ?? overlayState.type !== "noMatchingRows")
134
+ ? (overlayState.blockScroll ?? false)
132
135
  : false;
133
136
  const isFullOverlay = overlayScope === "full";
134
137
  /**
@@ -141,6 +144,25 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
141
144
  context: buildRenderContext,
142
145
  };
143
146
  }
147
+ const columnPresentationCacheRef = useRef(new Map());
148
+ const getColumnPresentation = (column) => {
149
+ const revision = grid.getRevision();
150
+ const processedData = grid.getProcessedData();
151
+ const cached = columnPresentationCacheRef.current.get(column.id);
152
+ if (cached && cached.revision === revision && cached.data === processedData) {
153
+ return cached.presentation;
154
+ }
155
+ const values = processedData.map((row) => getCellValue(row, column));
156
+ const params = {
157
+ column,
158
+ values,
159
+ api: grid,
160
+ state: grid.getState(),
161
+ };
162
+ const presentation = resolveColumnPresentation(column, params);
163
+ columnPresentationCacheRef.current.set(column.id, { revision, data: processedData, presentation });
164
+ return presentation;
165
+ };
144
166
  /** Row panel callbacks: close over grid/options, never over DOM. */
145
167
  function buildRowCallbacks(bridgeArg) {
146
168
  const current = () => optionsRef.current;
@@ -178,21 +200,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
178
200
  },
179
201
  resolveCellClasses: (info) => {
180
202
  const cellParams = { id: info.rowId, index: info.rowIndex, data: info.data, column: info.column };
181
- const column = info.column;
182
- const cellClass = typeof column.cellClass === "function" ? column.cellClass(cellParams) : column.cellClass;
183
- const dynamicCellClass = column.getCellClass?.(cellParams);
184
- const ruleClasses = Object.entries(column.cellClassRules ?? {})
185
- .filter(([, predicate]) => predicate(cellParams))
186
- .map(([ruleClass]) => ruleClass);
187
- return [cellClass, ...ruleClasses, dynamicCellClass].filter(Boolean).join(" ");
203
+ const columnPresentation = getColumnPresentation(info.column);
204
+ return resolveCellClasses(info.column, cellParams, columnPresentation.classes);
188
205
  },
189
206
  resolveCellStyle: (info) => {
190
207
  const cellParams = { id: info.rowId, index: info.rowIndex, data: info.data, column: info.column };
191
- const column = info.column;
192
- return {
193
- ...(column.cellStyle ?? {}),
194
- ...(column.getCellStyle?.(cellParams) ?? {}),
195
- };
208
+ const columnPresentation = getColumnPresentation(info.column);
209
+ return resolveCellStyle(info.column, cellParams, columnPresentation.style);
196
210
  },
197
211
  onRowClick: (row, modifiers) => grid.rowClick({
198
212
  id: row.rowId,
@@ -550,48 +564,65 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
550
564
  const deepestDepth = hasGroups ? (viewportData.columnGroupDepth.get(item.index) ?? -1) : -1;
551
565
  const gapRows = headerRowCount - 1 - deepestDepth;
552
566
  const fullHeight = gapRows > 0;
553
- return (_jsx("div", { role: "columnheader", className: `omnigrid-header-cell${fullHeight ? " omnigrid-header-cell-full-height" : ""}`, "data-sort": item.column.sortState, "data-sort-index": item.column.sortIndex, "data-sortable": item.column.sortable === true ? "true" : undefined, "aria-sort": item.column.sortState === "asc" ? "ascending" : item.column.sortState === "desc" ? "descending" : "none", onClick: (event) => item.column.stopHeaderClick
567
+ const headerParams = { column: item.column, index: item.index };
568
+ const className = resolveHeaderClasses(item.column, headerParams, fullHeight);
569
+ const customHeaderStyle = resolveHeaderStyle(item.column, headerParams);
570
+ const headerCellLayout = {
571
+ alignItems: "center",
572
+ display: "flex",
573
+ fontWeight: 600,
574
+ overflow: "hidden",
575
+ padding: "0 12px",
576
+ whiteSpace: "nowrap",
577
+ ...customHeaderStyle,
578
+ position: "absolute",
579
+ left: Math.round(item.offset - originX),
580
+ top: fullHeight ? -(gapRows * rowHeight) : 0,
581
+ bottom: 0,
582
+ touchAction: "none",
583
+ width: item.width,
584
+ };
585
+ return (_jsx("div", { role: "columnheader", className: className, "data-sort": item.column.sortState, "data-sort-index": item.column.sortIndex, "data-sortable": item.column.sortable === true ? "true" : undefined, "aria-sort": item.column.sortState === "asc" ? "ascending" : item.column.sortState === "desc" ? "descending" : "none", onClick: (event) => item.column.stopHeaderClick
554
586
  ? event.stopPropagation()
555
587
  : grid.headerClick(item.column.id, event.shiftKey || event.ctrlKey || event.metaKey), onKeyDown: (event) => {
556
588
  if (event.key === "Enter" || event.key === " ")
557
589
  grid.headerClick(item.column.id);
558
- }, tabIndex: 0, style: {
559
- alignItems: "center",
560
- display: "flex",
561
- fontWeight: 600,
562
- overflow: "hidden",
563
- padding: "0 12px",
564
- position: "absolute",
565
- left: Math.round(item.offset - originX),
566
- top: fullHeight ? -(gapRows * rowHeight) : 0,
567
- bottom: 0,
568
- touchAction: "none",
569
- whiteSpace: "nowrap",
570
- width: item.width,
571
- }, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
590
+ }, tabIndex: 0, style: headerCellLayout, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
572
591
  registry: slotComponentsRef.current,
573
592
  context: buildRenderContext,
574
593
  })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsx("span", { className: "omnigrid-header-tools", children: item.column.sortState && (_jsxs("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: [contentToReactNode(item.column.sortState === "asc"
575
594
  ? grid.icons.get("arrow-up")
576
595
  : grid.icons.get("arrow-down"), { registry: slotComponentsRef.current, context: buildRenderContext }), item.column.sortIndex !== undefined && (_jsx("span", { className: "omnigrid-sort-priority", children: item.column.sortIndex }))] })) })] })) }, item.column.id));
577
596
  });
578
- const renderGroupCells = (depth, columns, originX) => computeGroupSegments(viewportData.columnGroups, columns, depth, originX).map((segment, index) => (_jsx("div", { role: "columnheader", className: "omnigrid-header-cell omnigrid-header-group-cell", "aria-colspan": segment.columnCount, title: segment.group.header ?? segment.group.id, style: {
597
+ const renderGroupCells = (depth, columns, originX) => computeGroupSegments(viewportData.columnGroups, columns, depth, originX).map((segment, index) => {
598
+ const groupParams = {
599
+ group: segment.group,
600
+ column: segment.group,
601
+ depth,
602
+ columnCount: segment.columnCount,
603
+ };
604
+ const className = resolveGroupHeaderClasses(segment.group, groupParams);
605
+ const customGroupStyle = resolveGroupHeaderStyle(segment.group, groupParams);
606
+ const groupCellLayout = {
579
607
  alignItems: "center",
580
608
  display: "flex",
581
609
  fontWeight: 600,
582
610
  justifyContent: "center",
583
- left: Math.round(segment.left),
584
611
  overflow: "hidden",
585
612
  padding: "0 12px",
613
+ whiteSpace: "nowrap",
614
+ ...customGroupStyle,
586
615
  position: "absolute",
616
+ left: Math.round(segment.left),
587
617
  top: 0,
588
618
  bottom: 0,
589
- whiteSpace: "nowrap",
590
619
  width: segment.width,
591
- }, children: segment.group.headerRenderer ? (contentToReactNode(segment.group.headerRenderer(segment.group), {
592
- registry: slotComponentsRef.current,
593
- context: buildRenderContext,
594
- })) : (_jsx("span", { className: "omnigrid-header-label", children: segment.group.header ?? segment.group.id })) }, `${depth}:${index}:${segment.group.id}`)));
620
+ };
621
+ return (_jsx("div", { role: "columnheader", className: className, "aria-colspan": segment.columnCount, title: segment.group.header ?? segment.group.id, style: groupCellLayout, children: segment.group.headerRenderer ? (contentToReactNode(segment.group.headerRenderer(segment.group), {
622
+ registry: slotComponentsRef.current,
623
+ context: buildRenderContext,
624
+ })) : (_jsx("span", { className: "omnigrid-header-label", children: segment.group.header ?? segment.group.id })) }, `${depth}:${index}:${segment.group.id}`));
625
+ });
595
626
  /**
596
627
  * Sticky header stack: `headerRowCount` group rows (one per depth) above the
597
628
  * leaf header row. Each pane renders its own stack with the same geometry;
@@ -633,10 +664,10 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
633
664
  height: autoHeight ? measuredHeight : "100%",
634
665
  minHeight: 0,
635
666
  minWidth: 0,
636
- overflowX: isFullOverlay || (overlayScope === "bodyOnly" && overlayBlocksHorizontalScroll) ? "hidden" : needsHorizontalScroll ? "auto" : "hidden",
637
- overflowY: isFullOverlay || overlayScope === "bodyOnly" || autoHeight ? "hidden" : "auto",
667
+ overflowX: overlayBlocksHorizontalScroll ? "hidden" : needsHorizontalScroll ? "auto" : "hidden",
668
+ overflowY: overlayScope || autoHeight ? "hidden" : "auto",
638
669
  position: "relative",
639
- scrollbarGutter: overlayScope === "bodyOnly" ? "auto" : verticalScrollbarGutter,
670
+ scrollbarGutter: verticalScrollbarGutter,
640
671
  width: "100%",
641
672
  }, children: [_jsxs("div", { style: {
642
673
  display: "flex",
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export { OmniGrid } from "./OmniGrid";
7
7
  export type { GridProps, OverlayComponentProps, SlotRendererRegistry } from "./OmniGrid";
8
8
  export { useGrid } from "./useGrid";
9
9
  export type { UseGridResult } from "./useGrid";
10
+ export { type ResolvedColumnPresentation, resolveCellClasses, resolveCellStyle, resolveColumnPresentation, resolveGroupHeaderClasses, resolveGroupHeaderStyle, resolveHeaderClasses, resolveHeaderStyle, } from "./styling";
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export * from "@omnigrid/core";
4
4
  export { PooledRowPane } from "./pooledRow";
5
5
  export { OmniGrid } from "./OmniGrid";
6
6
  export { useGrid } from "./useGrid";
7
+ export { resolveCellClasses, resolveCellStyle, resolveColumnPresentation, resolveGroupHeaderClasses, resolveGroupHeaderStyle, resolveHeaderClasses, resolveHeaderStyle, } from "./styling";
@@ -0,0 +1,94 @@
1
+ import type { CellRenderParams, ColumnGroupDef, ColumnLeafDef, ColumnStyle, ColumnStyleParams, HeaderGroupRenderParams, HeaderRenderParams, HeaderStyle, RowStyle } from "@omnigrid/core";
2
+ /**
3
+ * Pre-resolved presentation (classes and inline styles) for a column data body.
4
+ * Evaluated once per column across the dataset, then applied to each rendered cell in O(1).
5
+ *
6
+ * @api
7
+ */
8
+ export interface ResolvedColumnPresentation {
9
+ /** Space-separated CSS class names for the column body. */
10
+ classes: string;
11
+ /** Combined inline styles for the column body. */
12
+ style: ColumnStyle;
13
+ }
14
+ /**
15
+ * Resolves column-level presentation once for the entire column across the entire dataset.
16
+ *
17
+ * Evaluates `getColumnStyle`, `getColumnClass`, and `columnClassRules`.
18
+ *
19
+ * @param column - Leaf column definition.
20
+ * @param params - Contextual column presentation parameters with full column values.
21
+ * @returns Pre-resolved classes and styles for the column.
22
+ * @api
23
+ */
24
+ export declare function resolveColumnPresentation<T>(column: ColumnLeafDef<T>, params: ColumnStyleParams<T>): ResolvedColumnPresentation;
25
+ /**
26
+ * Resolves the combined CSS classes for a leaf cell by combining the precomputed
27
+ * column classes with per-cell class definitions.
28
+ *
29
+ * Precedence / concatenation order:
30
+ * 1. Precomputed column classes (`getColumnClass`, `columnClassRules`)
31
+ * 2. `cellClass` (static or function)
32
+ * 3. `cellClassRules`
33
+ * 4. `getCellClass`
34
+ *
35
+ * @param column - Leaf column definition.
36
+ * @param params - Contextual cell render parameters.
37
+ * @param precomputedColumnClasses - Pre-resolved column classes (optional).
38
+ * @returns Space-separated list of CSS class names.
39
+ * @api
40
+ */
41
+ export declare function resolveCellClasses<T>(column: ColumnLeafDef<T>, params: CellRenderParams<T>, precomputedColumnClasses?: string): string;
42
+ /**
43
+ * Resolves the inline styles for a leaf cell by cascading precomputed column styles
44
+ * and cell-level style definitions. Cell-level styles take precedence over column styles.
45
+ *
46
+ * Merge order:
47
+ * 1. Precomputed column style (`getColumnStyle`)
48
+ * 2. `cellStyle`
49
+ * 3. `getCellStyle`
50
+ *
51
+ * @param column - Leaf column definition.
52
+ * @param params - Contextual cell render parameters.
53
+ * @param precomputedColumnStyle - Pre-resolved column style (optional).
54
+ * @returns Combined inline style object.
55
+ * @api
56
+ */
57
+ export declare function resolveCellStyle<T>(column: ColumnLeafDef<T>, params: CellRenderParams<T>, precomputedColumnStyle?: ColumnStyle): RowStyle;
58
+ /**
59
+ * Resolves the CSS classes for a leaf column header cell.
60
+ *
61
+ * @param column - Leaf column definition.
62
+ * @param params - Contextual header render parameters.
63
+ * @param fullHeight - Whether the header cell spans multiple group rows.
64
+ * @returns Space-separated list of CSS class names.
65
+ * @api
66
+ */
67
+ export declare function resolveHeaderClasses<T>(column: ColumnLeafDef<T>, params: HeaderRenderParams<T>, fullHeight?: boolean): string;
68
+ /**
69
+ * Resolves the inline styles for a leaf column header cell.
70
+ *
71
+ * @param column - Leaf column definition.
72
+ * @param params - Contextual header render parameters.
73
+ * @returns Combined header style object.
74
+ * @api
75
+ */
76
+ export declare function resolveHeaderStyle<T>(column: ColumnLeafDef<T>, params: HeaderRenderParams<T>): HeaderStyle;
77
+ /**
78
+ * Resolves the CSS classes for a column group header cell.
79
+ *
80
+ * @param group - Column group definition.
81
+ * @param params - Contextual group header render parameters.
82
+ * @returns Space-separated list of CSS class names.
83
+ * @api
84
+ */
85
+ export declare function resolveGroupHeaderClasses<T>(group: ColumnGroupDef<T>, params: HeaderGroupRenderParams<T>): string;
86
+ /**
87
+ * Resolves the inline styles for a column group header cell.
88
+ *
89
+ * @param group - Column group definition.
90
+ * @param params - Contextual group header render parameters.
91
+ * @returns Combined group header style object.
92
+ * @api
93
+ */
94
+ export declare function resolveGroupHeaderStyle<T>(group: ColumnGroupDef<T>, params: HeaderGroupRenderParams<T>): HeaderStyle;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Resolves column-level presentation once for the entire column across the entire dataset.
3
+ *
4
+ * Evaluates `getColumnStyle`, `getColumnClass`, and `columnClassRules`.
5
+ *
6
+ * @param column - Leaf column definition.
7
+ * @param params - Contextual column presentation parameters with full column values.
8
+ * @returns Pre-resolved classes and styles for the column.
9
+ * @api
10
+ */
11
+ export function resolveColumnPresentation(column, params) {
12
+ const dynamicColumnClass = column.getColumnClass?.(params);
13
+ const ruleClasses = Object.entries(column.columnClassRules ?? {})
14
+ .filter(([, predicate]) => predicate(params))
15
+ .map(([ruleClass]) => ruleClass);
16
+ const classes = [...ruleClasses, dynamicColumnClass].filter(Boolean).join(" ");
17
+ const style = {
18
+ ...(column.getColumnStyle?.(params) ?? {}),
19
+ };
20
+ return { classes, style };
21
+ }
22
+ /**
23
+ * Resolves the combined CSS classes for a leaf cell by combining the precomputed
24
+ * column classes with per-cell class definitions.
25
+ *
26
+ * Precedence / concatenation order:
27
+ * 1. Precomputed column classes (`getColumnClass`, `columnClassRules`)
28
+ * 2. `cellClass` (static or function)
29
+ * 3. `cellClassRules`
30
+ * 4. `getCellClass`
31
+ *
32
+ * @param column - Leaf column definition.
33
+ * @param params - Contextual cell render parameters.
34
+ * @param precomputedColumnClasses - Pre-resolved column classes (optional).
35
+ * @returns Space-separated list of CSS class names.
36
+ * @api
37
+ */
38
+ export function resolveCellClasses(column, params, precomputedColumnClasses) {
39
+ const columnClasses = precomputedColumnClasses;
40
+ const cellClass = typeof column.cellClass === "function" ? column.cellClass(params) : column.cellClass;
41
+ const dynamicCellClass = column.getCellClass?.(params);
42
+ const cellRuleClasses = Object.entries(column.cellClassRules ?? {})
43
+ .filter(([, predicate]) => predicate(params))
44
+ .map(([ruleClass]) => ruleClass);
45
+ return [columnClasses, cellClass, ...cellRuleClasses, dynamicCellClass]
46
+ .filter(Boolean)
47
+ .join(" ");
48
+ }
49
+ /**
50
+ * Resolves the inline styles for a leaf cell by cascading precomputed column styles
51
+ * and cell-level style definitions. Cell-level styles take precedence over column styles.
52
+ *
53
+ * Merge order:
54
+ * 1. Precomputed column style (`getColumnStyle`)
55
+ * 2. `cellStyle`
56
+ * 3. `getCellStyle`
57
+ *
58
+ * @param column - Leaf column definition.
59
+ * @param params - Contextual cell render parameters.
60
+ * @param precomputedColumnStyle - Pre-resolved column style (optional).
61
+ * @returns Combined inline style object.
62
+ * @api
63
+ */
64
+ export function resolveCellStyle(column, params, precomputedColumnStyle) {
65
+ const baseColumnStyle = precomputedColumnStyle;
66
+ return {
67
+ ...(baseColumnStyle ?? {}),
68
+ ...(column.cellStyle ?? {}),
69
+ ...(column.getCellStyle?.(params) ?? {}),
70
+ };
71
+ }
72
+ /**
73
+ * Resolves the CSS classes for a leaf column header cell.
74
+ *
75
+ * @param column - Leaf column definition.
76
+ * @param params - Contextual header render parameters.
77
+ * @param fullHeight - Whether the header cell spans multiple group rows.
78
+ * @returns Space-separated list of CSS class names.
79
+ * @api
80
+ */
81
+ export function resolveHeaderClasses(column, params, fullHeight = false) {
82
+ const headerClass = typeof column.headerClass === "function" ? column.headerClass(params) : column.headerClass;
83
+ const dynamicHeaderClass = column.getHeaderClass?.(params);
84
+ const ruleClasses = Object.entries(column.headerClassRules ?? {})
85
+ .filter(([, predicate]) => predicate(params))
86
+ .map(([ruleClass]) => ruleClass);
87
+ return [
88
+ "omnigrid-header-cell",
89
+ fullHeight ? "omnigrid-header-cell-full-height" : undefined,
90
+ headerClass,
91
+ ...ruleClasses,
92
+ dynamicHeaderClass,
93
+ ]
94
+ .filter(Boolean)
95
+ .join(" ");
96
+ }
97
+ /**
98
+ * Resolves the inline styles for a leaf column header cell.
99
+ *
100
+ * @param column - Leaf column definition.
101
+ * @param params - Contextual header render parameters.
102
+ * @returns Combined header style object.
103
+ * @api
104
+ */
105
+ export function resolveHeaderStyle(column, params) {
106
+ return {
107
+ ...(column.headerStyle ?? {}),
108
+ ...(column.getHeaderStyle?.(params) ?? {}),
109
+ };
110
+ }
111
+ /**
112
+ * Resolves the CSS classes for a column group header cell.
113
+ *
114
+ * @param group - Column group definition.
115
+ * @param params - Contextual group header render parameters.
116
+ * @returns Space-separated list of CSS class names.
117
+ * @api
118
+ */
119
+ export function resolveGroupHeaderClasses(group, params) {
120
+ const groupClass = typeof group.headerClass === "function" ? group.headerClass(params) : group.headerClass;
121
+ const dynamicGroupClass = group.getHeaderClass?.(params);
122
+ const ruleClasses = Object.entries(group.headerClassRules ?? {})
123
+ .filter(([, predicate]) => predicate(params))
124
+ .map(([ruleClass]) => ruleClass);
125
+ return [
126
+ "omnigrid-header-cell",
127
+ "omnigrid-header-group-cell",
128
+ groupClass,
129
+ ...ruleClasses,
130
+ dynamicGroupClass,
131
+ ]
132
+ .filter(Boolean)
133
+ .join(" ");
134
+ }
135
+ /**
136
+ * Resolves the inline styles for a column group header cell.
137
+ *
138
+ * @param group - Column group definition.
139
+ * @param params - Contextual group header render parameters.
140
+ * @returns Combined group header style object.
141
+ * @api
142
+ */
143
+ export function resolveGroupHeaderStyle(group, params) {
144
+ return {
145
+ ...(group.headerStyle ?? {}),
146
+ ...(group.getHeaderStyle?.(params) ?? {}),
147
+ };
148
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/react",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "React adapter and renderer for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",