@omnigrid/react 0.1.25 → 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.
- package/dist/OmniGrid.d.ts +1 -28
- package/dist/OmniGrid.js +79 -33
- package/dist/content.d.ts +3 -11
- package/dist/controls.d.ts +3 -4
- package/dist/groupCell.d.ts +53 -0
- package/dist/groupCell.js +201 -0
- package/dist/index.d.ts +5 -4
- package/dist/pooledRow.d.ts +2 -48
- package/dist/pooledRow.js +6 -2
- package/dist/popup.d.ts +1 -4
- package/dist/reactColumnDef.d.ts +39 -0
- package/dist/reactColumnDef.js +1 -0
- package/dist/styling.d.ts +2 -12
- package/dist/types.d.ts +108 -0
- package/dist/types.js +1 -0
- package/dist/useGrid.d.ts +3 -8
- package/package.json +54 -54
package/dist/OmniGrid.d.ts
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
/**
|
|
16
|
-
* Minimum grid height in rows when `style.height` is not set (auto-height
|
|
17
|
-
* mode). The viewport will be at least `headerHeight + minHeight *
|
|
18
|
-
* rowHeight` tall so the grid does not collapse when it has few or no
|
|
19
|
-
* rows. Set to `0` to disable.
|
|
20
|
-
*
|
|
21
|
-
* @api
|
|
22
|
-
* @default 3
|
|
23
|
-
*/
|
|
24
|
-
minHeight?: number;
|
|
25
|
-
slotComponents?: SlotRendererRegistry<T>;
|
|
26
|
-
overlayComponents?: Record<string, OverlayComponent<T>>;
|
|
27
|
-
}
|
|
1
|
+
import type { GridProps } from "./types";
|
|
28
2
|
/**
|
|
29
3
|
* React adapter over the headless core.
|
|
30
4
|
*
|
|
@@ -51,4 +25,3 @@ export interface GridProps<T> extends Omit<GridOptions<T>, "overlayComponents">
|
|
|
51
25
|
* `slotComponents`.
|
|
52
26
|
*/
|
|
53
27
|
export declare function OmniGrid<T>({ className, style, slotComponents, ...options }: GridProps<T>): import("react").JSX.Element;
|
|
54
|
-
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({
|
|
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);
|
|
@@ -231,9 +242,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
231
242
|
const overlayScope = overlayState.type
|
|
232
243
|
? (overlayState.scope ?? (overlayState.type === "error" ? "full" : "bodyOnly"))
|
|
233
244
|
: undefined;
|
|
234
|
-
const overlayBlocksHorizontalScroll = overlayState.type
|
|
235
|
-
? (overlayState.blockScroll ?? false)
|
|
236
|
-
: false;
|
|
245
|
+
const overlayBlocksHorizontalScroll = overlayState.type ? (overlayState.blockScroll ?? false) : false;
|
|
237
246
|
const isFullOverlay = overlayScope === "full";
|
|
238
247
|
/**
|
|
239
248
|
* Bridge between the core's headless content and React: a factory for the
|
|
@@ -524,29 +533,48 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
524
533
|
scheduleHeightFlush();
|
|
525
534
|
},
|
|
526
535
|
renderCellContent: (info) => {
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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));
|
|
531
555
|
}
|
|
532
|
-
return
|
|
556
|
+
return content;
|
|
533
557
|
},
|
|
534
558
|
renderCellPlaceholder: (info) => {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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);
|
|
544
570
|
const valueType = typeof value;
|
|
545
571
|
if (valueType === "string" || valueType === "number" || valueType === "boolean")
|
|
546
572
|
return String(value);
|
|
547
573
|
return null;
|
|
548
574
|
},
|
|
549
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";
|
|
550
578
|
const rowParams = { id: row.rowId, index: row.index, data: row.data };
|
|
551
579
|
const currentOptions = current();
|
|
552
580
|
const rowClass = typeof currentOptions.rowClass === "function" ? currentOptions.rowClass(rowParams) : currentOptions.rowClass;
|
|
@@ -557,7 +585,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
557
585
|
const pluginClasses = (currentOptions.plugins ?? [])
|
|
558
586
|
.map((plugin) => plugin.getRowClass?.(rowParams))
|
|
559
587
|
.filter((rowClass) => Boolean(rowClass));
|
|
560
|
-
return [
|
|
588
|
+
return [base, rowClass, ...ruleClasses, dynamicRowClass, ...pluginClasses].filter(Boolean).join(" ");
|
|
561
589
|
},
|
|
562
590
|
resolveRowStyle: (row) => {
|
|
563
591
|
const rowParams = { id: row.rowId, index: row.index, data: row.data };
|
|
@@ -602,13 +630,21 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
602
630
|
const columnPresentation = getColumnPresentation(info.column);
|
|
603
631
|
return resolveCellStyle(info.column, cellParams, columnPresentation.style);
|
|
604
632
|
},
|
|
605
|
-
onRowClick: (row, modifiers) =>
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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
|
+
},
|
|
612
648
|
onRowHover: (row, hovered) => {
|
|
613
649
|
const rowElements = viewportRef.current?.querySelectorAll(`[data-row-index="${row.index}"]`);
|
|
614
650
|
rowElements?.forEach((element) => element.classList.toggle("omnigrid-row-hover", hovered));
|
|
@@ -617,6 +653,12 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
617
653
|
onCellClick: (row, column, modifiers) => {
|
|
618
654
|
if (column.stopRowClick)
|
|
619
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
|
+
}
|
|
620
662
|
grid.rowClick({
|
|
621
663
|
id: row.rowId,
|
|
622
664
|
index: row.index,
|
|
@@ -645,7 +687,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
645
687
|
const { paneMap, panes } = layer;
|
|
646
688
|
layer.pool = new DomPool({
|
|
647
689
|
rowHeight,
|
|
648
|
-
getRowId: (row, index) => grid
|
|
690
|
+
getRowId: (row, index) => poolGetRowId(grid, row, index),
|
|
649
691
|
bindings: {
|
|
650
692
|
createRow: () => {
|
|
651
693
|
const element = document.createElement("div");
|
|
@@ -714,7 +756,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
714
756
|
if (!pool || grid.isDestroyed())
|
|
715
757
|
return;
|
|
716
758
|
const state = grid.getState();
|
|
717
|
-
const processed = grid
|
|
759
|
+
const processed = getPoolData(grid);
|
|
718
760
|
const changed = layer.revision !== grid.getRevision() || layer.totalWidth !== viewportData.totalWidth || layer.processed !== processed;
|
|
719
761
|
if (changed) {
|
|
720
762
|
layer.revision = grid.getRevision();
|
|
@@ -1067,7 +1109,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
1067
1109
|
if (groups.every((group) => group === null))
|
|
1068
1110
|
return null;
|
|
1069
1111
|
const slotClass = slot === "down" ? "omnigrid-slot omnigrid-slot-bottom omnigrid-slot-down" : `omnigrid-slot omnigrid-slot-${slot}`;
|
|
1070
|
-
return
|
|
1112
|
+
return _jsx("div", { className: slotClass, children: groups });
|
|
1071
1113
|
};
|
|
1072
1114
|
/** Renders slots that overlay the table body (absolute positioning, no layout shift). */
|
|
1073
1115
|
const renderBodySlot = (slot) => {
|
|
@@ -1172,9 +1214,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
1172
1214
|
}, tabIndex: 0, style: headerCellLayout, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
|
|
1173
1215
|
registry: slotComponentsRef.current,
|
|
1174
1216
|
context: buildRenderContext,
|
|
1175
|
-
})) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column
|
|
1176
|
-
|
|
1177
|
-
|
|
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) => {
|
|
1178
1224
|
event.stopPropagation();
|
|
1179
1225
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
1180
1226
|
const layoutRect = layoutRef.current?.getBoundingClientRect() ?? { left: 0, top: 0, width: 0, height: 0 };
|
package/dist/content.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { CheckboxControl, SlotNodeContent
|
|
3
|
-
|
|
4
|
-
|
|
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";
|
package/dist/controls.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { UIControlDescriptor
|
|
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 "./
|
|
6
|
+
export type { ContentBridge, PooledCellRenderInfo, PooledColumn, PooledRowCallbacks, PooledRowModifiers } from "./types";
|
|
6
7
|
export { OmniGrid } from "./OmniGrid";
|
|
7
|
-
export type { GridProps, OverlayComponentProps, SlotRendererRegistry } from "./
|
|
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 "./
|
|
13
|
-
export type { UseGridResult } from "./
|
|
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";
|
package/dist/pooledRow.d.ts
CHANGED
|
@@ -1,52 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PooledRow, RowSpanLayout } from "@omnigrid/core";
|
|
2
2
|
import { type ContentBridge } from "./content";
|
|
3
|
-
import type {
|
|
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
|
@@ -342,6 +342,7 @@ export class PooledRowPane {
|
|
|
342
342
|
for (const key of cell.appliedStyleKeys)
|
|
343
343
|
cell.element.style.removeProperty(cssPropertyName(key));
|
|
344
344
|
cell.appliedStyleKeys.length = 0;
|
|
345
|
+
cell.element.style.padding = "";
|
|
345
346
|
const style = this.callbacks.resolveCellStyle(cellInfo);
|
|
346
347
|
if (style) {
|
|
347
348
|
for (const [key, value] of Object.entries(style)) {
|
|
@@ -351,6 +352,9 @@ export class PooledRowPane {
|
|
|
351
352
|
cell.appliedStyleKeys.push(key);
|
|
352
353
|
}
|
|
353
354
|
}
|
|
355
|
+
const flushLayout = cellInfo.column.cellLayout === "flush";
|
|
356
|
+
if (flushLayout)
|
|
357
|
+
cell.element.style.padding = "0";
|
|
354
358
|
if (cell.column?.wrapText) {
|
|
355
359
|
// Wrapping cell: the text breaks into several lines and the cell
|
|
356
360
|
// grows with it. The theme owns the horizontal padding and the
|
|
@@ -360,7 +364,7 @@ export class PooledRowPane {
|
|
|
360
364
|
cell.element.style.wordBreak = "break-word";
|
|
361
365
|
cell.element.style.overflow = "visible";
|
|
362
366
|
cell.element.style.textOverflow = "clip";
|
|
363
|
-
cell.element.style.paddingBlock = "4px";
|
|
367
|
+
cell.element.style.paddingBlock = flushLayout ? "0" : "4px";
|
|
364
368
|
cell.element.style.alignItems = "flex-start";
|
|
365
369
|
}
|
|
366
370
|
else {
|
|
@@ -369,7 +373,7 @@ export class PooledRowPane {
|
|
|
369
373
|
cell.element.style.whiteSpace = "nowrap";
|
|
370
374
|
cell.element.style.overflow = "hidden";
|
|
371
375
|
cell.element.style.textOverflow = "ellipsis";
|
|
372
|
-
cell.element.style.paddingBlock = "";
|
|
376
|
+
cell.element.style.paddingBlock = flushLayout ? "0" : "";
|
|
373
377
|
cell.element.style.alignItems = "";
|
|
374
378
|
}
|
|
375
379
|
}
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type {
|
|
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
|
-
|
|
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
|
*
|
package/dist/types.d.ts
ADDED
|
@@ -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 {
|
|
2
|
-
import {
|
|
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:
|
|
21
|
+
export declare function useGrid<T>(options: ReactGridOptions<T>): UseGridResult<T>;
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
}
|