@omnigrid/react 0.1.24 → 0.1.26

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.
@@ -1,20 +1,4 @@
1
- import { type ComponentType, type CSSProperties, type ReactNode } from "react";
2
- import type { GridOptions, OverlayComponent as CoreOverlayComponent, OverlayComponentProps as CoreOverlayComponentProps, SlotRenderContext } from "@omnigrid/core";
3
- /**
4
- * Registry of native adapter components for `SlotComponentContent`:
5
- * slotComponents={{ ["my-widget"]: (payload, context) => <MyWidget .../> }}
6
- */
7
- export interface SlotRendererRegistry<T> {
8
- [kind: string]: (payload: unknown, context: SlotRenderContext<T>) => ReactNode;
9
- }
10
- export type OverlayComponentProps<T> = CoreOverlayComponentProps<T>;
11
- type OverlayComponent<T> = ComponentType<CoreOverlayComponentProps<T>> | CoreOverlayComponent<T>;
12
- export interface GridProps<T> extends Omit<GridOptions<T>, "overlayComponents"> {
13
- className?: string;
14
- style?: CSSProperties;
15
- slotComponents?: SlotRendererRegistry<T>;
16
- overlayComponents?: Record<string, OverlayComponent<T>>;
17
- }
1
+ import type { GridProps } from "./types";
18
2
  /**
19
3
  * React adapter over the headless core.
20
4
  *
@@ -41,4 +25,3 @@ export interface GridProps<T> extends Omit<GridOptions<T>, "overlayComponents">
41
25
  * `slotComponents`.
42
26
  */
43
27
  export declare function OmniGrid<T>({ className, style, slotComponents, ...options }: GridProps<T>): import("react").JSX.Element;
44
- export {};
package/dist/OmniGrid.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { createElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
+ import { createElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
3
3
  import { flushSync } from "react-dom";
4
4
  import { DomPool, isActiveCondition } from "@omnigrid/core";
5
5
  import { contentToReactNode, hasRenderableContent } from "./content";
6
6
  import { computeGroupSegments } from "./groupHeader";
7
+ import { getCollapsedGroupDisplay, getGroupColumnRole, poolGetRowId, renderGroupCellContent, renderGroupCellPlaceholder } from "./groupCell";
7
8
  import { PooledRowPane } from "./pooledRow";
8
9
  import { createCellRoot } from "./reactRoot";
9
10
  import { renderDefaultOverlay } from "./overlays";
@@ -18,6 +19,10 @@ function getCellValue(row, column) {
18
19
  return row[column.field];
19
20
  return undefined;
20
21
  }
22
+ /** Returns the flat row array the virtualizer pools against: grouped rows when grouping, else raw data. */
23
+ function getPoolData(grid) {
24
+ return grid.getRows();
25
+ }
21
26
  const SLOT_POSITIONS = ["start", "center", "end"];
22
27
  /**
23
28
  * Scroll velocity (px/ms) above which a scroll is treated as "fast".
@@ -83,7 +88,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
83
88
  const pinnedRightRowsLayerRef = useRef(null);
84
89
  /** Space taken by the viewport's native scrollbars; body slots stay clear of it. */
85
90
  const [scrollbarInsets, setScrollbarInsets] = useState({ right: 0, bottom: 0 });
86
- const scrollFrameRef = useRef({ id: 0, top: 0, left: 0, lastTop: 0, lastTime: 0 });
91
+ const scrollFrameRef = useRef({
92
+ id: 0,
93
+ top: 0,
94
+ left: 0,
95
+ lastTop: 0,
96
+ lastTime: 0,
97
+ });
87
98
  const scrollVelocityRef = useRef(0);
88
99
  /** Timestamp of the last processed scroll frame — used to age out the velocity. */
89
100
  const lastScrollTimeRef = useRef(0);
@@ -97,6 +108,8 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
97
108
  const pendingHeightCorrectionRef = useRef(0);
98
109
  /** rAF handle of the scheduled row-height flush. */
99
110
  const heightFlushRef = useRef(null);
111
+ /** Latest `syncPool` — read imperatively from `measureViewport`/ResizeObserver so the callback stays stable. */
112
+ const syncPoolRef = useRef(null);
100
113
  /**
101
114
  * Scrollable content height frozen at the start of a user scroll gesture.
102
115
  *
@@ -131,6 +144,10 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
131
144
  // of the header — row DOM nodes remain managed by the DomPool and are
132
145
  // never touched by React's reconciliation.
133
146
  const [, setColumnWindowVersion] = useState(0);
147
+ /** Set to `true` once the viewport dimensions have been measured against
148
+ * the real DOM element. Before that the grid content is hidden so the
149
+ * user never sees flex columns collapsed to minWidth at width === 0. */
150
+ const [isViewportMeasured, setIsViewportMeasured] = useState(false);
134
151
  optionsRef.current = options;
135
152
  slotComponentsRef.current = slotComponents ?? {};
136
153
  // Memoized render context for header cells, group cells, and slot content.
@@ -152,6 +169,8 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
152
169
  const headerRowCount = viewportData.headerRowCount;
153
170
  const hasGroups = headerRowCount > 0;
154
171
  const headerHeight = (headerRowCount + 1) * rowHeight;
172
+ const minHeightRows = options.minHeight ?? 3;
173
+ const minViewportHeight = autoHeight ? headerHeight + minHeightRows * rowHeight : 0;
155
174
  /**
156
175
  * Writes the scrollable content height (and the height of the row
157
176
  * layers) into the DOM.
@@ -199,9 +218,20 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
199
218
  */
200
219
  const measuredHeight = viewportData.totalHeight + headerHeight;
201
220
  const hasVerticalOverflow = !autoHeight && measuredHeight > state.viewport.height;
202
- const verticalScrollbarGutter = hasVerticalOverflow ? "stable" : "auto";
203
- const viewportStyle = { ...style, height: autoHeight ? measuredHeight : style?.height };
221
+ // Use "auto" instead of "stable" so the viewport does not reserve space for
222
+ // a vertical scrollbar before it actually appears. With "stable" the header
223
+ // container is drawn narrower than full width on first render, then jumps
224
+ // when the scrollbar materializes. "auto" keeps the header full width and
225
+ // only cedes space to the scrollbar once it is really needed.
226
+ const verticalScrollbarGutter = "auto";
204
227
  const suppressRowHoverHighlight = options.suppressRowHoverHighlight ?? false;
228
+ const cellFlashRaw = options.cellFlash;
229
+ const cellFlashDurationMs = cellFlashRaw === true ? 1000 : typeof cellFlashRaw === "number" && cellFlashRaw > 0 ? cellFlashRaw : false;
230
+ const viewportStyle = {
231
+ ...style,
232
+ height: autoHeight ? measuredHeight : style?.height,
233
+ ...(cellFlashDurationMs !== false ? { "--omnigrid-flash-duration": `${cellFlashDurationMs}ms` } : {}),
234
+ };
205
235
  const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null].filter(Boolean).join(" ");
206
236
  const overlayState = state.overlay;
207
237
  const filterModelSnapshot = grid.getFilterModel();
@@ -212,9 +242,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
212
242
  const overlayScope = overlayState.type
213
243
  ? (overlayState.scope ?? (overlayState.type === "error" ? "full" : "bodyOnly"))
214
244
  : undefined;
215
- const overlayBlocksHorizontalScroll = overlayState.type
216
- ? (overlayState.blockScroll ?? false)
217
- : false;
245
+ const overlayBlocksHorizontalScroll = overlayState.type ? (overlayState.blockScroll ?? false) : false;
218
246
  const isFullOverlay = overlayScope === "full";
219
247
  /**
220
248
  * Bridge between the core's headless content and React: a factory for the
@@ -505,29 +533,48 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
505
533
  scheduleHeightFlush();
506
534
  },
507
535
  renderCellContent: (info) => {
508
- const column = info.column;
509
- const value = getCellValue(info.data, column);
510
- if (column.cellRenderer) {
511
- return column.cellRenderer({ value, data: info.data, column, id: info.rowId, index: info.rowIndex });
536
+ const groupContent = renderGroupCellContent(info, bridgeArg, grid);
537
+ if (groupContent !== undefined) {
538
+ return groupContent;
539
+ }
540
+ const rawData = (info.data && typeof info.data === "object" && "data" in info.data
541
+ ? info.data.data
542
+ : info.data);
543
+ // When a leaf row is displayed as a collapsed single-child group,
544
+ // show the grouping field's value in the group column instead of
545
+ // the row's own field value.
546
+ const collapsedGroupDisplay = getCollapsedGroupDisplay(info.data, info.column, grid.getState().groupBy ?? [], grid.getState().groupColumnMode ?? "single");
547
+ const value = collapsedGroupDisplay !== undefined ? collapsedGroupDisplay.value : getCellValue(rawData, info.column);
548
+ const content = info.column.cellRenderer
549
+ ? info.column.cellRenderer({ value, data: rawData, column: info.column, id: info.rowId, index: info.rowIndex })
550
+ : info.column.valueFormatter
551
+ ? info.column.valueFormatter(value)
552
+ : String(value ?? "");
553
+ if (collapsedGroupDisplay && grid.getState().groupColumnMode === "single") {
554
+ return createElement("span", { style: { paddingLeft: collapsedGroupDisplay.level * 20 } }, contentToReactNode(content, bridgeArg));
512
555
  }
513
- return column.valueFormatter ? column.valueFormatter(value) : String(value ?? "");
556
+ return content;
514
557
  },
515
558
  renderCellPlaceholder: (info) => {
516
- // Cheap scalar preview mirroring the renderCellContent pipeline
517
- // minus the (possibly expensive) cellRenderer: same value source,
518
- // same formatter. Skipped when the raw value is not scalar and no
519
- // formatter exists (e.g. CheckboxControl sources) — the cell
520
- // stays empty for the one commit rather than showing garbage.
521
- const column = info.column;
522
- const value = getCellValue(info.data, column);
523
- if (column.valueFormatter)
524
- return column.valueFormatter(value);
559
+ const groupPlaceholder = renderGroupCellPlaceholder(info, grid);
560
+ if (groupPlaceholder !== undefined) {
561
+ return groupPlaceholder;
562
+ }
563
+ const rawData = (info.data && typeof info.data === "object" && "data" in info.data
564
+ ? info.data.data
565
+ : info.data);
566
+ const collapsedGroupDisplay = getCollapsedGroupDisplay(info.data, info.column, grid.getState().groupBy ?? [], grid.getState().groupColumnMode ?? "single");
567
+ const value = collapsedGroupDisplay !== undefined ? collapsedGroupDisplay.value : getCellValue(rawData, info.column);
568
+ if (info.column.valueFormatter)
569
+ return info.column.valueFormatter(value);
525
570
  const valueType = typeof value;
526
571
  if (valueType === "string" || valueType === "number" || valueType === "boolean")
527
572
  return String(value);
528
573
  return null;
529
574
  },
530
575
  resolveRowClasses: (row) => {
576
+ const isGroup = Boolean(row.data && typeof row.data === "object" && "type" in row.data && row.data.type === "group");
577
+ const base = isGroup ? "omnigrid-row omnigrid-row-group" : "omnigrid-row";
531
578
  const rowParams = { id: row.rowId, index: row.index, data: row.data };
532
579
  const currentOptions = current();
533
580
  const rowClass = typeof currentOptions.rowClass === "function" ? currentOptions.rowClass(rowParams) : currentOptions.rowClass;
@@ -538,7 +585,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
538
585
  const pluginClasses = (currentOptions.plugins ?? [])
539
586
  .map((plugin) => plugin.getRowClass?.(rowParams))
540
587
  .filter((rowClass) => Boolean(rowClass));
541
- return ["omnigrid-row", rowClass, ...ruleClasses, dynamicRowClass, ...pluginClasses].filter(Boolean).join(" ");
588
+ return [base, rowClass, ...ruleClasses, dynamicRowClass, ...pluginClasses].filter(Boolean).join(" ");
542
589
  },
543
590
  resolveRowStyle: (row) => {
544
591
  const rowParams = { id: row.rowId, index: row.index, data: row.data };
@@ -550,22 +597,54 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
550
597
  return (currentOptions.plugins ?? []).reduce((styleAcc, plugin) => ({ ...styleAcc, ...(plugin.getRowStyle?.(rowParams) ?? {}) }), baseRowStyle);
551
598
  },
552
599
  resolveCellClasses: (info) => {
553
- const cellParams = { id: info.rowId, index: info.rowIndex, data: info.data, column: info.column };
600
+ const flashedCells = grid.getState().flashedCells;
601
+ const flashTimestamp = flashedCells.get(`${info.rowId}:${info.column.id}`);
602
+ const isFlashed = cellFlashDurationMs !== false && flashTimestamp !== undefined && Date.now() - flashTimestamp <= cellFlashDurationMs;
603
+ const cellParams = {
604
+ id: info.rowId,
605
+ index: info.rowIndex,
606
+ data: info.data,
607
+ column: info.column,
608
+ isFlashed,
609
+ flashTimestamp,
610
+ };
554
611
  const columnPresentation = getColumnPresentation(info.column);
555
- return resolveCellClasses(info.column, cellParams, columnPresentation.classes);
612
+ let classes = resolveCellClasses(info.column, cellParams, columnPresentation.classes);
613
+ if (isFlashed) {
614
+ classes = classes ? `${classes} omnigrid-cell-flashed` : "omnigrid-cell-flashed";
615
+ }
616
+ return classes;
556
617
  },
557
618
  resolveCellStyle: (info) => {
558
- const cellParams = { id: info.rowId, index: info.rowIndex, data: info.data, column: info.column };
619
+ const flashedCells = grid.getState().flashedCells;
620
+ const flashTimestamp = flashedCells.get(`${info.rowId}:${info.column.id}`);
621
+ const isFlashed = cellFlashDurationMs !== false && flashTimestamp !== undefined && Date.now() - flashTimestamp <= cellFlashDurationMs;
622
+ const cellParams = {
623
+ id: info.rowId,
624
+ index: info.rowIndex,
625
+ data: info.data,
626
+ column: info.column,
627
+ isFlashed,
628
+ flashTimestamp,
629
+ };
559
630
  const columnPresentation = getColumnPresentation(info.column);
560
631
  return resolveCellStyle(info.column, cellParams, columnPresentation.style);
561
632
  },
562
- onRowClick: (row, modifiers) => grid.rowClick({
563
- id: row.rowId,
564
- index: row.index,
565
- data: row.data,
566
- ctrlKey: modifiers.ctrlKey,
567
- shiftKey: modifiers.shiftKey,
568
- }),
633
+ onRowClick: (row, modifiers) => {
634
+ if (row.data && typeof row.data === "object" && "type" in row.data && row.data.type === "group") {
635
+ if (typeof grid.toggleGroup === "function") {
636
+ grid.toggleGroup(row.data.id);
637
+ }
638
+ return;
639
+ }
640
+ grid.rowClick({
641
+ id: row.rowId,
642
+ index: row.index,
643
+ data: row.data,
644
+ ctrlKey: modifiers.ctrlKey,
645
+ shiftKey: modifiers.shiftKey,
646
+ });
647
+ },
569
648
  onRowHover: (row, hovered) => {
570
649
  const rowElements = viewportRef.current?.querySelectorAll(`[data-row-index="${row.index}"]`);
571
650
  rowElements?.forEach((element) => element.classList.toggle("omnigrid-row-hover", hovered));
@@ -574,6 +653,12 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
574
653
  onCellClick: (row, column, modifiers) => {
575
654
  if (column.stopRowClick)
576
655
  return;
656
+ if (row.data && typeof row.data === "object" && "type" in row.data && row.data.type === "group") {
657
+ if (typeof grid.toggleGroup === "function") {
658
+ grid.toggleGroup(row.data.id);
659
+ }
660
+ return;
661
+ }
577
662
  grid.rowClick({
578
663
  id: row.rowId,
579
664
  index: row.index,
@@ -602,7 +687,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
602
687
  const { paneMap, panes } = layer;
603
688
  layer.pool = new DomPool({
604
689
  rowHeight,
605
- getRowId: (row, index) => grid.getRowId(row, index),
690
+ getRowId: (row, index) => poolGetRowId(grid, row, index),
606
691
  bindings: {
607
692
  createRow: () => {
608
693
  const element = document.createElement("div");
@@ -671,7 +756,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
671
756
  if (!pool || grid.isDestroyed())
672
757
  return;
673
758
  const state = grid.getState();
674
- const processed = grid.getProcessedData();
759
+ const processed = getPoolData(grid);
675
760
  const changed = layer.revision !== grid.getRevision() || layer.totalWidth !== viewportData.totalWidth || layer.processed !== processed;
676
761
  if (changed) {
677
762
  layer.revision = grid.getRevision();
@@ -809,6 +894,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
809
894
  }
810
895
  }
811
896
  };
897
+ syncPoolRef.current = syncPool;
812
898
  /**
813
899
  * Measures viewport dimensions from the DOM and syncs them to the core.
814
900
  * Called on mount and on ResizeObserver events.
@@ -833,10 +919,22 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
833
919
  scrollbarWidthRef.current = scrollbarWidth;
834
920
  const width = element.clientWidth;
835
921
  const height = element.clientHeight;
836
- if (width === 0 || height === 0)
922
+ if (width === 0) {
923
+ // Layout may not be computed yet on the first paint. Retry on the
924
+ // next animation frame so flex columns are sized against the real
925
+ // client width instead of collapsing to minWidth at width === 0.
926
+ requestAnimationFrame(() => {
927
+ measureViewport();
928
+ });
837
929
  return;
838
- grid.setViewport({ width, height });
839
- }, [grid, syncScrollbarInsets]);
930
+ }
931
+ grid.setViewport({
932
+ width,
933
+ ...(height > 0 ? { height } : {}),
934
+ });
935
+ syncPoolRef.current?.(false, false);
936
+ setIsViewportMeasured(true);
937
+ }, [grid, syncScrollbarInsets, setIsViewportMeasured]);
840
938
  useEffect(() => {
841
939
  const element = viewportRef.current;
842
940
  if (!element)
@@ -853,11 +951,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
853
951
  if (width === 0 || height === 0)
854
952
  return;
855
953
  grid.setViewport({ width, height });
954
+ syncPoolRef.current?.(false, false);
955
+ setIsViewportMeasured(true);
856
956
  });
857
957
  observer.observe(element, { box: "content-box" });
858
958
  measureViewport();
859
959
  return () => observer.disconnect();
860
- }, [grid, measureViewport, syncScrollbarInsets]);
960
+ }, [grid, measureViewport, syncScrollbarInsets, setIsViewportMeasured]);
861
961
  // Scrollbars can appear or disappear when the CONTENT size changes (the
862
962
  // rows are measured, a column is resized). Measuring the insets after
863
963
  // EVERY render forces a synchronous layout of the whole page — during a
@@ -872,10 +972,11 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
872
972
  syncScrollbarInsets(viewportRef.current);
873
973
  }, [contentSizeKey]);
874
974
  useLayoutEffect(() => {
875
- if (autoHeight)
876
- return;
877
- // Scrollbar and gutter changes alter clientWidth; sync it before paint
878
- // so columns remain aligned when an overlay locks vertical scrolling.
975
+ // Measure the viewport on mount so flex column widths are computed
976
+ // against the real client width before the first paint. Without this
977
+ // the header cells render with viewport.width === 0 (flex columns fall
978
+ // back to minWidth) and only snap to the correct size after the
979
+ // ResizeObserver-driven useEffect runs — a visible flash on first load.
879
980
  measureViewport();
880
981
  }, [autoHeight, hasVerticalOverflow, measureViewport, overlayScope]);
881
982
  useEffect(() => {
@@ -1008,7 +1109,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1008
1109
  if (groups.every((group) => group === null))
1009
1110
  return null;
1010
1111
  const slotClass = slot === "down" ? "omnigrid-slot omnigrid-slot-bottom omnigrid-slot-down" : `omnigrid-slot omnigrid-slot-${slot}`;
1011
- return (_jsx("div", { className: slotClass, children: groups }));
1112
+ return _jsx("div", { className: slotClass, children: groups });
1012
1113
  };
1013
1114
  /** Renders slots that overlay the table body (absolute positioning, no layout shift). */
1014
1115
  const renderBodySlot = (slot) => {
@@ -1102,6 +1203,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1102
1203
  top: fullHeight ? -(gapRows * rowHeight) : 0,
1103
1204
  bottom: 0,
1104
1205
  touchAction: "none",
1206
+ visibility: isViewportMeasured ? undefined : "hidden",
1105
1207
  width: item.width,
1106
1208
  };
1107
1209
  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
@@ -1112,9 +1214,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1112
1214
  }, tabIndex: 0, style: headerCellLayout, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
1113
1215
  registry: slotComponentsRef.current,
1114
1216
  context: buildRenderContext,
1115
- })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsxs("span", { className: "omnigrid-header-tools", children: [item.column.sortState && (_jsxs("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: [contentToReactNode(item.column.sortState === "asc"
1116
- ? grid.icons.get("arrow-up")
1117
- : grid.icons.get("arrow-down"), { registry: slotComponentsRef.current, context: buildRenderContext }), item.column.sortIndex !== undefined && (_jsx("span", { className: "omnigrid-sort-priority", children: item.column.sortIndex }))] })), grid.hasFilterMenu() && item.column.filterable !== false && (_jsx("button", { type: "button", className: "omnigrid-filter-trigger", "data-omnigrid-filter-trigger": "", "data-active": isColumnFiltered(item.column) ? "true" : undefined, "aria-label": `Filter ${item.column.header ?? item.column.id}`, "aria-haspopup": "dialog", tabIndex: -1, onClick: (event) => {
1217
+ })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: getGroupColumnRole(item.column, grid.getState().groupBy, grid.getState().groupColumnMode).isGroupColumn &&
1218
+ grid.getState().groupColumnMode === "single"
1219
+ ? grid.getState().groupColumnHeader
1220
+ : (item.column.header ?? item.column.id) }), _jsxs("span", { className: "omnigrid-header-tools", children: [item.column.sortState && (_jsxs("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: [contentToReactNode(item.column.sortState === "asc" ? grid.icons.get("arrow-up") : grid.icons.get("arrow-down"), {
1221
+ registry: slotComponentsRef.current,
1222
+ context: buildRenderContext,
1223
+ }), item.column.sortIndex !== undefined && _jsx("span", { className: "omnigrid-sort-priority", children: item.column.sortIndex })] })), grid.hasFilterMenu() && item.column.filterable !== false && (_jsx("button", { type: "button", className: "omnigrid-filter-trigger", "data-omnigrid-filter-trigger": "", "data-active": isColumnFiltered(item.column) ? "true" : undefined, "aria-label": `Filter ${item.column.header ?? item.column.id}`, "aria-haspopup": "dialog", tabIndex: -1, onClick: (event) => {
1118
1224
  event.stopPropagation();
1119
1225
  const rect = event.currentTarget.getBoundingClientRect();
1120
1226
  const layoutRect = layoutRef.current?.getBoundingClientRect() ?? { left: 0, top: 0, width: 0, height: 0 };
@@ -1148,6 +1254,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1148
1254
  left: Math.round(segment.left),
1149
1255
  top: 0,
1150
1256
  bottom: 0,
1257
+ visibility: isViewportMeasured ? undefined : "hidden",
1151
1258
  width: segment.width,
1152
1259
  };
1153
1260
  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), {
@@ -1191,6 +1298,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1191
1298
  overflow: "hidden",
1192
1299
  position: "absolute",
1193
1300
  top: headerHeight,
1301
+ visibility: isViewportMeasured ? undefined : "hidden",
1194
1302
  width,
1195
1303
  } }));
1196
1304
  return (_jsxs("div", { className: "omnigrid-layout", ref: layoutRef, style: { ...style, position: "relative", ...(isFullOverlay ? { overflow: "hidden" } : {}) }, children: [renderSlot("top"), _jsxs("div", { className: "omnigrid-layout-body", children: [renderSlot("left"), _jsxs("div", { className: "omnigrid-viewport-container", style: {
@@ -1203,7 +1311,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1203
1311
  ...viewportStyle,
1204
1312
  flex: "1 1 0",
1205
1313
  height: autoHeight ? measuredHeight : "100%",
1206
- minHeight: 0,
1314
+ minHeight: minViewportHeight,
1207
1315
  minWidth: 0,
1208
1316
  overflowX: overlayBlocksHorizontalScroll ? "hidden" : needsHorizontalScroll ? "auto" : "hidden",
1209
1317
  overflowY: overlayScope || autoHeight ? "hidden" : "auto",
package/dist/content.d.ts CHANGED
@@ -1,15 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
- import type { CheckboxControl, SlotNodeContent, SlotRenderContext } from "@omnigrid/core";
3
- /**
4
- * Bridge between the core's headless content and native adapter values.
5
- * `registry` — registry of React components for `SlotComponentContent`;
6
- * `context()` — factory for the current render context so providers see
7
- * up-to-date grid state at render time.
8
- */
9
- export interface ContentBridge<T> {
10
- registry: Record<string, (payload: unknown, context: SlotRenderContext<T>) => ReactNode>;
11
- context: () => SlotRenderContext<T>;
12
- }
2
+ import type { CheckboxControl, SlotNodeContent } from "@omnigrid/core";
3
+ import type { ContentBridge } from "./types";
4
+ export type { ContentBridge };
13
5
  export declare function isCheckboxControl(value: unknown): value is CheckboxControl;
14
6
  export declare function isSlotHtmlContent(value: unknown): value is {
15
7
  type: "html";
@@ -1,10 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- import type { UIControlDescriptor, UIInputControl } from "@omnigrid/core";
2
+ import type { UIControlDescriptor } from "@omnigrid/core";
3
+ import type { DebouncedInputProps } from "./types";
4
+ export type { DebouncedInputProps };
3
5
  /** Type guard for core `UIControlDescriptor` objects. */
4
6
  export declare function isUIControlDescriptor(value: unknown): value is UIControlDescriptor;
5
- export interface DebouncedInputProps {
6
- descriptor: UIInputControl;
7
- }
8
7
  /**
9
8
  * Text/number input that keeps typing in local state and forwards the value to
10
9
  * the descriptor callback after `debounceMs` of inactivity. Pending input is
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ColumnLeafDef, GridApi, GroupRowNode, RowId } from "@omnigrid/core";
3
+ import { type ContentBridge } from "./content";
4
+ /**
5
+ * Checks whether an arbitrary row node represents a grouping tree node.
6
+ *
7
+ * @api
8
+ */
9
+ export declare function isGroupRowNode<T>(row: unknown): row is GroupRowNode<T>;
10
+ /**
11
+ * Stable row id resolver for pooled rows: tree nodes expose their stable `id` path,
12
+ * whereas regular data rows resolve via `grid.getRowId`.
13
+ *
14
+ * @api
15
+ */
16
+ export declare function poolGetRowId<T>(grid: GridApi<T>, row: unknown, index: number): RowId;
17
+ /**
18
+ * Determines whether a column functions as the group column for a row level.
19
+ */
20
+ export declare function getGroupColumnRole<T>(column: ColumnLeafDef<T>, groupBy: string[], mode: "single" | "perLevel"): {
21
+ isGroupColumn: boolean;
22
+ level: number | null;
23
+ };
24
+ /**
25
+ * Returns the grouping value for a leaf row collapsed from a single-child group
26
+ * when the current column is the appropriate display column for the mode.
27
+ *
28
+ * @api
29
+ */
30
+ export declare function getCollapsedGroupDisplay<T>(row: unknown, column: ColumnLeafDef<T>, groupBy: string[], mode: "single" | "perLevel"): {
31
+ value: string;
32
+ level: number;
33
+ } | undefined;
34
+ export interface CellRenderInfo<T> {
35
+ rowId: RowId;
36
+ rowIndex: number;
37
+ column: ColumnLeafDef<T>;
38
+ data: unknown;
39
+ }
40
+ /**
41
+ * Renders cell content when grouping is active (either group header row or indented leaf).
42
+ * Returns undefined when cell does not require grouping-specific rendering.
43
+ *
44
+ * @api
45
+ */
46
+ export declare function renderGroupCellContent<T>(info: CellRenderInfo<T>, bridgeArg: ContentBridge<T>, grid: GridApi<T>): ReactNode | undefined;
47
+ /**
48
+ * Generates placeholder text for group rows during fast scrolling.
49
+ * Returns undefined when standard placeholder should be used.
50
+ *
51
+ * @api
52
+ */
53
+ export declare function renderGroupCellPlaceholder<T>(info: CellRenderInfo<T>, grid: GridApi<T>): string | undefined;
@@ -0,0 +1,201 @@
1
+ import { createElement } from "react";
2
+ import { contentToReactNode } from "./content";
3
+ /**
4
+ * Checks whether an arbitrary row node represents a grouping tree node.
5
+ *
6
+ * @api
7
+ */
8
+ export function isGroupRowNode(row) {
9
+ return Boolean(row && typeof row === "object" && "type" in row && row.type === "group");
10
+ }
11
+ /**
12
+ * Stable row id resolver for pooled rows: tree nodes expose their stable `id` path,
13
+ * whereas regular data rows resolve via `grid.getRowId`.
14
+ *
15
+ * @api
16
+ */
17
+ export function poolGetRowId(grid, row, index) {
18
+ if (row && typeof row === "object" && "id" in row && "type" in row) {
19
+ return row.id;
20
+ }
21
+ return grid.getRowId(row, index);
22
+ }
23
+ /**
24
+ * Determines whether a column functions as the group column for a row level.
25
+ */
26
+ export function getGroupColumnRole(column, groupBy, mode) {
27
+ if (!groupBy || groupBy.length === 0)
28
+ return { isGroupColumn: false, level: null };
29
+ const match = (field) => column.id === field || column.field === field;
30
+ if (mode === "single") {
31
+ return match(groupBy[0]) ? { isGroupColumn: true, level: null } : { isGroupColumn: false, level: null };
32
+ }
33
+ for (let level = 0; level < groupBy.length; level += 1) {
34
+ if (match(groupBy[level]))
35
+ return { isGroupColumn: true, level };
36
+ }
37
+ return { isGroupColumn: false, level: null };
38
+ }
39
+ /**
40
+ * Returns the grouping value for a leaf row collapsed from a single-child group
41
+ * when the current column is the appropriate display column for the mode.
42
+ *
43
+ * @api
44
+ */
45
+ export function getCollapsedGroupDisplay(row, column, groupBy, mode) {
46
+ if (!row || typeof row !== "object" || !("collapsedGroup" in row))
47
+ return undefined;
48
+ const collapsedGroup = row.collapsedGroup;
49
+ if (!collapsedGroup)
50
+ return undefined;
51
+ const displayValue = mode === "single"
52
+ ? getGroupColumnRole(column, groupBy, mode).isGroupColumn
53
+ : column.id === collapsedGroup.field || column.field === collapsedGroup.field;
54
+ return displayValue ? { value: collapsedGroup.key, level: collapsedGroup.level } : undefined;
55
+ }
56
+ /**
57
+ * Renders cell content when grouping is active (either group header row or indented leaf).
58
+ * Returns undefined when cell does not require grouping-specific rendering.
59
+ *
60
+ * @api
61
+ */
62
+ export function renderGroupCellContent(info, bridgeArg, grid) {
63
+ const column = info.column;
64
+ const node = info.data;
65
+ const state = grid.getState();
66
+ const groupBy = state.groupBy ?? [];
67
+ const mode = state.groupColumnMode ?? "single";
68
+ const showGroupValues = false;
69
+ const showChildCount = state.showChildCount ?? true;
70
+ const groupRowRenderer = state.groupRowRenderer;
71
+ if (isGroupRowNode(node)) {
72
+ const role = getGroupColumnRole(column, groupBy, mode);
73
+ if (role.isGroupColumn) {
74
+ const level = node.level;
75
+ if (mode !== "single" && role.level !== node.level)
76
+ return null;
77
+ const chevronName = node.expanded ? "chevron-down" : "chevron-right";
78
+ const icon = contentToReactNode(bridgeArg.context().api.icons.get(chevronName), bridgeArg);
79
+ if (groupRowRenderer) {
80
+ const rendered = groupRowRenderer({
81
+ node: node,
82
+ column,
83
+ id: info.rowId,
84
+ index: info.rowIndex,
85
+ api: grid,
86
+ state,
87
+ });
88
+ return contentToReactNode(rendered, bridgeArg);
89
+ }
90
+ if (showChildCount) {
91
+ return createElement("span", {
92
+ style: { paddingLeft: mode === "single" ? level * 20 : 0, display: "flex", alignItems: "center", gap: 6 },
93
+ title: String(node.key),
94
+ }, icon, " ", node.key, " (", node.childrenCount, ")");
95
+ }
96
+ return createElement("span", {
97
+ style: { paddingLeft: mode === "single" ? level * 20 : 0, display: "flex", alignItems: "center", gap: 6 },
98
+ title: String(node.key),
99
+ }, icon, " ", node.key);
100
+ }
101
+ if (column.cellRenderer) {
102
+ const value = node.aggregations[column.id];
103
+ const rendered = column.cellRenderer({
104
+ value,
105
+ data: undefined,
106
+ column,
107
+ id: info.rowId,
108
+ index: info.rowIndex,
109
+ });
110
+ const content = contentToReactNode(rendered, bridgeArg);
111
+ if (column.valueFormatter && typeof value === "number") {
112
+ const formatted = column.valueFormatter(value);
113
+ // For numeric aggregations, prefer formatted output if renderer returns simple value
114
+ }
115
+ return content;
116
+ }
117
+ // Non-group column within a group row: show pre-computed aggregate.
118
+ const value = node.aggregations[column.id];
119
+ return column.valueFormatter ? column.valueFormatter(value) : String(value ?? "");
120
+ }
121
+ if (getCollapsedGroupDisplay(node, column, groupBy, mode) !== undefined)
122
+ return undefined;
123
+ if (groupBy.length > 0 && mode === "single") {
124
+ const role = getGroupColumnRole(column, groupBy, mode);
125
+ if (role.isGroupColumn) {
126
+ return createElement("span", { style: { paddingLeft: node.level * 20 } });
127
+ }
128
+ const isGroupField = groupBy.some((g) => column.id === g || column.field === g);
129
+ if (isGroupField) {
130
+ return createElement("span");
131
+ }
132
+ }
133
+ if (groupBy.length > 0 && mode === "perLevel") {
134
+ const role = getGroupColumnRole(column, groupBy, mode);
135
+ if (role.isGroupColumn && !showGroupValues) {
136
+ return createElement("span");
137
+ }
138
+ }
139
+ return undefined;
140
+ }
141
+ /**
142
+ * Generates placeholder text for group rows during fast scrolling.
143
+ * Returns undefined when standard placeholder should be used.
144
+ *
145
+ * @api
146
+ */
147
+ export function renderGroupCellPlaceholder(info, grid) {
148
+ const column = info.column;
149
+ const node = info.data;
150
+ const state = grid.getState();
151
+ const groupBy = state.groupBy ?? [];
152
+ const mode = state.groupColumnMode ?? "single";
153
+ const showGroupValues = false;
154
+ const showChildCount = state.showChildCount ?? true;
155
+ const groupRowRenderer = state.groupRowRenderer;
156
+ if (isGroupRowNode(node)) {
157
+ const role = getGroupColumnRole(column, groupBy, mode);
158
+ if (role.isGroupColumn) {
159
+ const level = node.level;
160
+ if (mode !== "single" && role.level !== node.level)
161
+ return "";
162
+ if (groupRowRenderer) {
163
+ const rendered = groupRowRenderer({
164
+ node: node,
165
+ column,
166
+ id: info.rowId,
167
+ index: info.rowIndex,
168
+ api: grid,
169
+ state,
170
+ });
171
+ if (typeof rendered === "string" || typeof rendered === "number" || typeof rendered === "boolean") {
172
+ return String(rendered);
173
+ }
174
+ }
175
+ if (showChildCount) {
176
+ return `${node.expanded ? "▼" : "▶"} ${node.key} (${node.childrenCount})`;
177
+ }
178
+ return `${node.expanded ? "▼" : "▶"} ${node.key}`;
179
+ }
180
+ if (column.cellRenderer)
181
+ return undefined;
182
+ const value = node.aggregations[column.id];
183
+ return column.valueFormatter ? column.valueFormatter(value) : String(value ?? "");
184
+ }
185
+ if (getCollapsedGroupDisplay(node, column, groupBy, mode) !== undefined)
186
+ return undefined;
187
+ if (groupBy.length > 0 && mode === "single") {
188
+ const role = getGroupColumnRole(column, groupBy, mode);
189
+ if (role.isGroupColumn)
190
+ return "";
191
+ const isGroupField = groupBy.some((g) => column.id === g || column.field === g);
192
+ if (isGroupField)
193
+ return "";
194
+ }
195
+ if (groupBy.length > 0 && mode === "perLevel") {
196
+ const role = getGroupColumnRole(column, groupBy, mode);
197
+ if (role.isGroupColumn && !showGroupValues)
198
+ return "";
199
+ }
200
+ return undefined;
201
+ }
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import "@omnigrid/style";
2
2
  import "@omnigrid/default-theme";
3
3
  export * from "@omnigrid/core";
4
+ export type { ReactCellRenderer, ReactColumnDef, ReactColumnDef as ColumnDef, ReactColumnGroupDef, ReactColumnGroupDef as ColumnGroupDef, ReactColumnLeafDef, ReactColumnLeafDef as ColumnLeafDef, ReactGridOptions, ReactGridOptions as GridOptions, } from "./reactColumnDef";
4
5
  export { PooledRowPane } from "./pooledRow";
5
- export type { PooledCellRenderInfo, PooledColumn, PooledRowCallbacks, PooledRowModifiers } from "./pooledRow";
6
+ export type { ContentBridge, PooledCellRenderInfo, PooledColumn, PooledRowCallbacks, PooledRowModifiers } from "./types";
6
7
  export { OmniGrid } from "./OmniGrid";
7
- export type { GridProps, OverlayComponentProps, SlotRendererRegistry } from "./OmniGrid";
8
+ export type { GridProps, OverlayComponent, OverlayComponentProps, SlotRendererRegistry } from "./types";
8
9
  export { useGrid } from "./useGrid";
9
10
  export { DebouncedInput, isUIControlDescriptor, renderControl } from "./controls";
10
11
  export type { DebouncedInputProps } from "./controls";
11
12
  export { PopupHost } from "./popup";
12
- export type { PopupHostProps } from "./popup";
13
- export type { UseGridResult } from "./useGrid";
13
+ export type { PopupHostProps } from "./types";
14
+ export type { UseGridResult } from "./types";
14
15
  export { type ResolvedColumnPresentation, resolveCellClasses, resolveCellStyle, resolveColumnPresentation, resolveGroupHeaderClasses, resolveGroupHeaderStyle, resolveHeaderClasses, resolveHeaderStyle, } from "./styling";
@@ -1,52 +1,6 @@
1
- import type { ColumnLeafDef, PooledRow, RowId, RowSpanLayout, RowStyle, ViewportData } from "@omnigrid/core";
1
+ import type { PooledRow, RowSpanLayout } from "@omnigrid/core";
2
2
  import { type ContentBridge } from "./content";
3
- import type { CellRoot } from "./reactRoot";
4
- /** Column within the pool: definition + geometry from the virtual window. */
5
- export type PooledColumn<T> = ViewportData<T>["columns"][number];
6
- export interface PooledCellRenderInfo<T> {
7
- data: T;
8
- column: ColumnLeafDef<T>;
9
- columnIndex: number;
10
- rowId: RowId;
11
- rowIndex: number;
12
- /**
13
- * Normalized horizontal span of this cell (`1` = plain cell).
14
- * Span origins render the merged width; covered cells are skipped.
15
- */
16
- colSpan: number;
17
- }
18
- export interface PooledRowModifiers {
19
- ctrlKey: boolean;
20
- shiftKey: boolean;
21
- }
22
- /**
23
- * Injected back-channel: the row panel does NOT know about grid/adapter —
24
- * it only fires these callbacks. This allows the panel to be reused across
25
- * any adapter with a DOM environment.
26
- */
27
- export interface PooledRowCallbacks<T> {
28
- rowHeight: number;
29
- renderCellContent(info: PooledCellRenderInfo<T>): unknown;
30
- resolveRowClasses(row: PooledRow<T>): string | undefined;
31
- resolveRowStyle(row: PooledRow<T>): RowStyle | undefined;
32
- resolveCellClasses(cellInfo: PooledCellRenderInfo<T>): string | undefined;
33
- resolveCellStyle(cellInfo: PooledCellRenderInfo<T>): RowStyle | undefined;
34
- onRowClick(row: PooledRow<T>, modifiers: PooledRowModifiers): void;
35
- onRowHover(row: PooledRow<T>, hovered: boolean): void;
36
- onCellClick(row: PooledRow<T>, column: ColumnLeafDef<T>, modifiers: PooledRowModifiers): void;
37
- createRoot(container: HTMLDivElement): CellRoot;
38
- onRowHeightChange?(rowIndex: number, height: number): void;
39
- /**
40
- * Returns a cheap scalar preview of the cell value, painted synchronously
41
- * into a blank cell while its first React commit (complex content) is
42
- * pending — keeps the grid from showing empty cells during fast scroll
43
- * ("staging" placeholder; React's first commit replaces it entirely).
44
- * Return `null` to skip staging for this cell.
45
- *
46
- * @api
47
- */
48
- renderCellPlaceholder?(info: PooledCellRenderInfo<T>): string | null;
49
- }
3
+ import type { PooledColumn, PooledRowCallbacks } from "./types";
50
4
  /**
51
5
  * Reusable row panel: holds a fixed set of cells, lays them out for the
52
6
  * horizontal column window via `translateX`, and updates content in-place
package/dist/pooledRow.js CHANGED
@@ -328,10 +328,21 @@ export class PooledRowPane {
328
328
  }
329
329
  applyCellPresentation(cell, cellInfo) {
330
330
  const cellClasses = this.callbacks.resolveCellClasses(cellInfo);
331
+ // When a cell is re-flashed, the CSS class is the same
332
+ // (omnigrid-cell-flashed) so the selector matches continuously and
333
+ // the browser does not restart the animation. Reset it imperatively:
334
+ // remove the flash class, force a reflow, then apply the new one.
335
+ const hasFlashClass = cell.element.classList.contains("omnigrid-cell-flashed");
336
+ const nextHasFlashClass = /omnigrid-cell-flashed/.test(cellClasses ?? "");
337
+ if (hasFlashClass && nextHasFlashClass) {
338
+ cell.element.classList.remove("omnigrid-cell-flashed");
339
+ cell.element.offsetHeight; // force reflow
340
+ }
331
341
  cell.element.className = cellClasses ?? "";
332
342
  for (const key of cell.appliedStyleKeys)
333
343
  cell.element.style.removeProperty(cssPropertyName(key));
334
344
  cell.appliedStyleKeys.length = 0;
345
+ cell.element.style.padding = "";
335
346
  const style = this.callbacks.resolveCellStyle(cellInfo);
336
347
  if (style) {
337
348
  for (const [key, value] of Object.entries(style)) {
@@ -341,6 +352,9 @@ export class PooledRowPane {
341
352
  cell.appliedStyleKeys.push(key);
342
353
  }
343
354
  }
355
+ const flushLayout = cellInfo.column.cellLayout === "flush";
356
+ if (flushLayout)
357
+ cell.element.style.padding = "0";
344
358
  if (cell.column?.wrapText) {
345
359
  // Wrapping cell: the text breaks into several lines and the cell
346
360
  // grows with it. The theme owns the horizontal padding and the
@@ -350,7 +364,7 @@ export class PooledRowPane {
350
364
  cell.element.style.wordBreak = "break-word";
351
365
  cell.element.style.overflow = "visible";
352
366
  cell.element.style.textOverflow = "clip";
353
- cell.element.style.paddingBlock = "4px";
367
+ cell.element.style.paddingBlock = flushLayout ? "0" : "4px";
354
368
  cell.element.style.alignItems = "flex-start";
355
369
  }
356
370
  else {
@@ -359,7 +373,7 @@ export class PooledRowPane {
359
373
  cell.element.style.whiteSpace = "nowrap";
360
374
  cell.element.style.overflow = "hidden";
361
375
  cell.element.style.textOverflow = "ellipsis";
362
- cell.element.style.paddingBlock = "";
376
+ cell.element.style.paddingBlock = flushLayout ? "0" : "";
363
377
  cell.element.style.alignItems = "";
364
378
  }
365
379
  }
package/dist/popup.d.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { GridApi } from "@omnigrid/core";
3
- export interface PopupHostProps<T> {
4
- grid: GridApi<T>;
5
- }
2
+ import type { PopupHostProps } from "./types";
6
3
  /**
7
4
  * Renders the grid's active `UIPopupDescriptor`. Popup state lives here, so
8
5
  * opening or updating a popup never re-renders the grid body. The popup is
@@ -0,0 +1,39 @@
1
+ import type { ReactNode } from "react";
2
+ import type { CellRenderParams, ColumnGroupDef, ColumnLeafDef, GridOptions } from "@omnigrid/core";
3
+ /**
4
+ * React cell renderer accepted by the React adapter.
5
+ *
6
+ * @api
7
+ */
8
+ export type ReactCellRenderer<T> = (params: CellRenderParams<T>) => ReactNode;
9
+ /**
10
+ * Leaf column definition with a renderer typed for React content.
11
+ *
12
+ * @api
13
+ */
14
+ export type ReactColumnLeafDef<T> = Omit<ColumnLeafDef<T>, "cellRenderer"> & {
15
+ /** Replaces the default cell content with a React node. */
16
+ cellRenderer?: ReactCellRenderer<T>;
17
+ };
18
+ /**
19
+ * Column group definition whose children use React-specific column types.
20
+ *
21
+ * @api
22
+ */
23
+ export type ReactColumnGroupDef<T> = Omit<ColumnGroupDef<T>, "children"> & {
24
+ children: ReactColumnDef<T>[];
25
+ };
26
+ /**
27
+ * Leaf or grouped column definition accepted by the React adapter.
28
+ *
29
+ * @api
30
+ */
31
+ export type ReactColumnDef<T> = ReactColumnLeafDef<T> | ReactColumnGroupDef<T>;
32
+ /**
33
+ * Core grid options with React-specific column definitions.
34
+ *
35
+ * @api
36
+ */
37
+ export type ReactGridOptions<T> = Omit<GridOptions<T>, "columns"> & {
38
+ columns: ReactColumnDef<T>[];
39
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/styling.d.ts CHANGED
@@ -1,16 +1,6 @@
1
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
- }
2
+ import type { ResolvedColumnPresentation } from "./types";
3
+ export type { ResolvedColumnPresentation };
14
4
  /**
15
5
  * Resolves column-level presentation once for the entire column across the entire dataset.
16
6
  *
@@ -0,0 +1,108 @@
1
+ import type { ReactNode } from "react";
2
+ import type { SlotRenderContext, UIInputControl } from "@omnigrid/core";
3
+ import type { CellRoot } from "./reactRoot";
4
+ import type { ReactGridOptions } from "./reactColumnDef";
5
+ /**
6
+ * Bridge between the core's headless content and native adapter values.
7
+ * `registry` — registry of React components for `SlotComponentContent`;
8
+ * `context()` — factory for the current render context so providers see
9
+ * up-to-date grid state at render time.
10
+ */
11
+ export interface ContentBridge<T> {
12
+ registry: Record<string, (payload: unknown, context: SlotRenderContext<T>) => ReactNode>;
13
+ context: () => SlotRenderContext<T>;
14
+ }
15
+ /** Column within the pool: definition + geometry from the virtual window. */
16
+ export type PooledColumn<T> = import("@omnigrid/core").ViewportData<T>["columns"][number];
17
+ export interface PooledCellRenderInfo<T> {
18
+ data: T;
19
+ column: import("@omnigrid/core").ColumnLeafDef<T>;
20
+ columnIndex: number;
21
+ rowId: import("@omnigrid/core").RowId;
22
+ rowIndex: number;
23
+ /**
24
+ * Normalized horizontal span of this cell (`1` = plain cell).
25
+ * Span origins render the merged width; covered cells are skipped.
26
+ */
27
+ colSpan: number;
28
+ }
29
+ export interface PooledRowModifiers {
30
+ ctrlKey: boolean;
31
+ shiftKey: boolean;
32
+ }
33
+ /**
34
+ * Injected back-channel: the row panel does NOT know about grid/adapter —
35
+ * it only fires these callbacks. This allows the panel to be reused across
36
+ * any adapter with a DOM environment.
37
+ */
38
+ export interface PooledRowCallbacks<T> {
39
+ rowHeight: number;
40
+ renderCellContent(info: PooledCellRenderInfo<T>): unknown;
41
+ resolveRowClasses(row: import("@omnigrid/core").PooledRow<T>): string | undefined;
42
+ resolveRowStyle(row: import("@omnigrid/core").PooledRow<T>): import("@omnigrid/core").RowStyle | undefined;
43
+ resolveCellClasses(cellInfo: PooledCellRenderInfo<T>): string | undefined;
44
+ resolveCellStyle(cellInfo: PooledCellRenderInfo<T>): import("@omnigrid/core").RowStyle | undefined;
45
+ onRowClick(row: import("@omnigrid/core").PooledRow<T>, modifiers: PooledRowModifiers): void;
46
+ onRowHover(row: import("@omnigrid/core").PooledRow<T>, hovered: boolean): void;
47
+ onCellClick(row: import("@omnigrid/core").PooledRow<T>, column: import("@omnigrid/core").ColumnLeafDef<T>, modifiers: PooledRowModifiers): void;
48
+ createRoot(container: HTMLDivElement): CellRoot;
49
+ onRowHeightChange?(rowIndex: number, height: number): void;
50
+ /**
51
+ * Returns a cheap scalar preview of the cell value, painted synchronously
52
+ * into a blank cell while its first React commit (complex content) is
53
+ * pending — keeps the grid from showing empty cells during fast scroll
54
+ * ("staging" placeholder; React's first commit replaces it entirely).
55
+ * Return `null` to skip staging for this cell.
56
+ *
57
+ * @api
58
+ */
59
+ renderCellPlaceholder?(info: PooledCellRenderInfo<T>): string | null;
60
+ }
61
+ export interface DebouncedInputProps {
62
+ descriptor: UIInputControl;
63
+ }
64
+ export interface PopupHostProps<T> {
65
+ grid: import("@omnigrid/core").GridApi<T>;
66
+ }
67
+ export interface UseGridResult<T> {
68
+ grid: import("@omnigrid/core").Grid<T>;
69
+ state: import("@omnigrid/core").GridState<T>;
70
+ viewportData: import("@omnigrid/core").ViewportData<T>;
71
+ }
72
+ /**
73
+ * Registry of native adapter components for `SlotComponentContent`:
74
+ * slotComponents={{ ["my-widget"]: (payload, context) => <MyWidget .../> }}
75
+ */
76
+ export interface SlotRendererRegistry<T> {
77
+ [kind: string]: (payload: unknown, context: SlotRenderContext<T>) => ReactNode;
78
+ }
79
+ export type OverlayComponentProps<T> = import("@omnigrid/core").OverlayComponentProps<T>;
80
+ export type OverlayComponent<T> = import("react").ComponentType<import("@omnigrid/core").OverlayComponentProps<T>> | import("@omnigrid/core").OverlayComponent<T>;
81
+ export interface GridProps<T> extends Omit<ReactGridOptions<T>, "overlayComponents"> {
82
+ className?: string;
83
+ style?: import("react").CSSProperties;
84
+ /**
85
+ * Minimum grid height in rows when `style.height` is not set (auto-height
86
+ * mode). The viewport will be at least `headerHeight + minHeight *
87
+ * rowHeight` tall so the grid does not collapse when it has few or no
88
+ * rows. Set to `0` to disable.
89
+ *
90
+ * @api
91
+ * @default 3
92
+ */
93
+ minHeight?: number;
94
+ slotComponents?: SlotRendererRegistry<T>;
95
+ overlayComponents?: Record<string, import("@omnigrid/core").OverlayComponent<T>>;
96
+ }
97
+ /**
98
+ * Pre-resolved presentation (classes and inline styles) for a column data body.
99
+ * Evaluated once per column across the dataset, then applied to each rendered cell in O(1).
100
+ *
101
+ * @api
102
+ */
103
+ export interface ResolvedColumnPresentation {
104
+ /** Space-separated CSS class names for the column body. */
105
+ classes: string;
106
+ /** Combined inline styles for the column body. */
107
+ style: import("@omnigrid/core").ColumnStyle;
108
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/useGrid.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- import type { GridOptions, GridState, ViewportData } from '@omnigrid/core';
2
- import { Grid } from '@omnigrid/core';
3
- export interface UseGridResult<T> {
4
- grid: Grid<T>;
5
- state: GridState<T>;
6
- viewportData: ViewportData<T>;
7
- }
1
+ import type { UseGridResult } from "./types";
2
+ import type { ReactGridOptions } from "./reactColumnDef";
8
3
  /**
9
4
  * Binds the Grid instance from @omnigrid/core to the React lifecycle.
10
5
  *
@@ -23,4 +18,4 @@ export interface UseGridResult<T> {
23
18
  * entirely, so useSyncExternalStore does NOT trigger a React re-render on
24
19
  * every scroll frame. The DOM Pool handles scroll imperatively.
25
20
  */
26
- export declare function useGrid<T>(options: GridOptions<T>): UseGridResult<T>;
21
+ export declare function useGrid<T>(options: ReactGridOptions<T>): UseGridResult<T>;
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
1
  {
2
- "name": "@omnigrid/react",
3
- "version": "0.1.24",
4
- "description": "React adapter and renderer for OmniGrid",
5
- "keywords": [
6
- "omnigrid",
7
- "grid",
8
- "table",
9
- "react",
10
- "react-component"
11
- ],
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/KRZK-Apps/omnigrid.git",
15
- "directory": "react"
16
- },
17
- "homepage": "https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react#readme",
18
- "bugs": {
19
- "url": "https://github.com/KRZK-Apps/omnigrid/issues"
20
- },
21
- "license": "MIT",
22
- "type": "module",
23
- "main": "dist/index.js",
24
- "types": "dist/index.d.ts",
25
- "exports": {
26
- ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.js"
2
+ "name": "@omnigrid/react",
3
+ "version": "0.1.26",
4
+ "description": "React adapter and renderer for OmniGrid",
5
+ "keywords": [
6
+ "omnigrid",
7
+ "grid",
8
+ "table",
9
+ "react",
10
+ "react-component"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/KRZK-Apps/omnigrid.git",
15
+ "directory": "react"
16
+ },
17
+ "homepage": "https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/KRZK-Apps/omnigrid/issues"
20
+ },
21
+ "license": "MIT",
22
+ "type": "module",
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
36
+ "lint": "npx tsc --noEmit -p tsconfig.json",
37
+ "test": "vitest run",
38
+ "prebuild": "npm --workspace @omnigrid/core run build && npm --workspace @omnigrid/style run build && npm --workspace @omnigrid/default-theme run build && npm run clean",
39
+ "build": "npx tsc -p tsconfig.json",
40
+ "prepublishOnly": "npm run build"
41
+ },
42
+ "dependencies": {
43
+ "@omnigrid/core": "^0.1.0",
44
+ "@omnigrid/style": "^0.1.0",
45
+ "@omnigrid/default-theme": "^0.1.0"
46
+ },
47
+ "devDependencies": {
48
+ "@omnigrid/column-filter-plugin": "*",
49
+ "@omnigrid/quick-filter-plugin": "*",
50
+ "@types/react": "^19.0.0",
51
+ "@types/react-dom": "^19.0.0"
52
+ },
53
+ "peerDependencies": {
54
+ "react": ">=18",
55
+ "react-dom": ">=18"
29
56
  }
30
- },
31
- "files": [
32
- "dist"
33
- ],
34
- "scripts": {
35
- "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
36
- "lint": "npx tsc --noEmit -p tsconfig.json",
37
- "test": "vitest run",
38
- "prebuild": "npm --workspace @omnigrid/core run build && npm --workspace @omnigrid/style run build && npm --workspace @omnigrid/default-theme run build && npm run clean",
39
- "build": "npx tsc -p tsconfig.json",
40
- "prepublishOnly": "npm run build"
41
- },
42
- "dependencies": {
43
- "@omnigrid/core": "^0.1.0",
44
- "@omnigrid/style": "^0.1.0",
45
- "@omnigrid/default-theme": "^0.1.0"
46
- },
47
- "devDependencies": {
48
- "@omnigrid/column-filter-plugin": "*",
49
- "@omnigrid/quick-filter-plugin": "*",
50
- "@types/react": "^19.0.0",
51
- "@types/react-dom": "^19.0.0"
52
- },
53
- "peerDependencies": {
54
- "react": ">=18",
55
- "react-dom": ">=18"
56
- }
57
57
  }