@omnigrid/react 0.1.30 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -62
- package/dist/OmniGrid.js +275 -182
- package/dist/cellTooltip.d.ts +6 -2
- package/dist/cellTooltip.js +38 -8
- package/dist/controls.js +36 -8
- package/dist/index.d.ts +2 -2
- package/dist/pooledRow.d.ts +8 -0
- package/dist/pooledRow.js +36 -1
- package/dist/popup.d.ts +1 -0
- package/dist/popup.js +18 -9
- package/dist/reactColumnDef.d.ts +30 -0
- package/dist/types.d.ts +8 -7
- package/package.json +1 -1
package/dist/cellTooltip.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, type RefObject } from "react";
|
|
2
|
-
import type { CellTooltipRenderer } from "./
|
|
2
|
+
import type { CellTooltipRenderer } from "./reactColumnDef";
|
|
3
|
+
import type { CellTooltipOptions } from "./types";
|
|
4
|
+
export declare function isTextOverflowed(textWidth: number, containerWidth: number): boolean;
|
|
3
5
|
/** Props for the delegated tooltip layer mounted by the grid. */
|
|
4
6
|
export interface CellTooltipLayerProps {
|
|
5
7
|
/** Viewport whose cell and header descendants are checked on pointer entry. */
|
|
@@ -8,6 +10,8 @@ export interface CellTooltipLayerProps {
|
|
|
8
10
|
renderer?: CellTooltipRenderer;
|
|
9
11
|
/** Additional CSS class applied to the tooltip element. */
|
|
10
12
|
className?: string;
|
|
13
|
+
/** Resolves per-column tooltip overrides for hovered data cells. */
|
|
14
|
+
resolveCellTooltip?: (columnId: string) => CellTooltipOptions | undefined;
|
|
11
15
|
}
|
|
12
16
|
/** Displays a tooltip only when hovered cell or header content exceeds its visible bounds. */
|
|
13
|
-
export declare function CellTooltipLayer({ viewportRef, renderer, className }: CellTooltipLayerProps): ReactNode;
|
|
17
|
+
export declare function CellTooltipLayer({ viewportRef, renderer, className, resolveCellTooltip }: CellTooltipLayerProps): ReactNode;
|
package/dist/cellTooltip.js
CHANGED
|
@@ -8,16 +8,21 @@ function isOverflowed(element) {
|
|
|
8
8
|
return false;
|
|
9
9
|
const range = document.createRange();
|
|
10
10
|
range.selectNodeContents(element);
|
|
11
|
-
return range.getBoundingClientRect().width
|
|
11
|
+
return isTextOverflowed(range.getBoundingClientRect().width, element.getBoundingClientRect().width);
|
|
12
|
+
}
|
|
13
|
+
export function isTextOverflowed(textWidth, containerWidth) {
|
|
14
|
+
return textWidth - containerWidth > 1;
|
|
12
15
|
}
|
|
13
16
|
/** Displays a tooltip only when hovered cell or header content exceeds its visible bounds. */
|
|
14
|
-
export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
17
|
+
export function CellTooltipLayer({ viewportRef, renderer, className, resolveCellTooltip }) {
|
|
15
18
|
const [tooltip, setTooltip] = useState(null);
|
|
16
19
|
const tooltipRef = useRef(null);
|
|
17
20
|
const rendererRef = useRef(renderer);
|
|
18
21
|
const classNameRef = useRef(className);
|
|
22
|
+
const resolveCellTooltipRef = useRef(resolveCellTooltip);
|
|
19
23
|
rendererRef.current = renderer;
|
|
20
24
|
classNameRef.current = className;
|
|
25
|
+
resolveCellTooltipRef.current = resolveCellTooltip;
|
|
21
26
|
useEffect(() => {
|
|
22
27
|
const viewport = viewportRef.current;
|
|
23
28
|
if (!viewport)
|
|
@@ -68,7 +73,17 @@ export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
|
68
73
|
const rect = overflowTarget.getBoundingClientRect();
|
|
69
74
|
activeContainer = container;
|
|
70
75
|
activeHoverTarget = overflowTarget;
|
|
71
|
-
|
|
76
|
+
const columnTooltip = isCell && container.dataset.columnId ? resolveCellTooltipRef.current?.(container.dataset.columnId) : undefined;
|
|
77
|
+
setTooltip({
|
|
78
|
+
text,
|
|
79
|
+
anchorRect: rect,
|
|
80
|
+
pointer: { clientX: event.clientX, clientY: event.clientY },
|
|
81
|
+
source: isCell ? "cell" : "header",
|
|
82
|
+
columnId: isCell ? container.dataset.columnId : undefined,
|
|
83
|
+
placement: "bottom",
|
|
84
|
+
renderer: columnTooltip?.renderer ?? rendererRef.current,
|
|
85
|
+
className: columnTooltip?.className ?? classNameRef.current,
|
|
86
|
+
});
|
|
72
87
|
};
|
|
73
88
|
const handlePointerOut = (event) => {
|
|
74
89
|
if (!activeContainer || !(event.target instanceof Node) || !activeContainer.contains(event.target))
|
|
@@ -95,15 +110,30 @@ export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
|
95
110
|
if (!element || !tooltip)
|
|
96
111
|
return;
|
|
97
112
|
const rect = element.getBoundingClientRect();
|
|
98
|
-
const left = Math.max(8, Math.min(tooltip.left, window.innerWidth - rect.width - 8));
|
|
99
|
-
const belowTop = tooltip.
|
|
100
|
-
const
|
|
113
|
+
const left = Math.max(8, Math.min(tooltip.anchorRect.left, window.innerWidth - rect.width - 8));
|
|
114
|
+
const belowTop = tooltip.anchorRect.bottom + 6;
|
|
115
|
+
const placement = belowTop + rect.height <= window.innerHeight - 8 ? "bottom" : "top";
|
|
116
|
+
const top = placement === "bottom" ? belowTop : Math.max(8, tooltip.anchorRect.top - rect.height - 6);
|
|
101
117
|
element.style.left = `${left}px`;
|
|
102
118
|
element.style.top = `${top}px`;
|
|
119
|
+
element.dataset.placement = placement;
|
|
120
|
+
const arrowX = tooltip.pointer?.clientX ?? tooltip.anchorRect.left + tooltip.anchorRect.width / 2;
|
|
121
|
+
element.style.setProperty("--omnigrid-tooltip-arrow-x", `${Math.max(8, Math.min(arrowX - left, rect.width - 8))}px`);
|
|
122
|
+
element.style.setProperty("--omnigrid-tooltip-arrow-y", placement === "bottom" ? "0px" : `${rect.height}px`);
|
|
123
|
+
if (tooltip.placement !== placement) {
|
|
124
|
+
setTooltip((current) => (current === tooltip ? { ...current, placement } : current));
|
|
125
|
+
}
|
|
103
126
|
}, [tooltip]);
|
|
104
127
|
if (!tooltip)
|
|
105
128
|
return null;
|
|
106
|
-
const
|
|
107
|
-
|
|
129
|
+
const renderContext = {
|
|
130
|
+
anchorRect: tooltip.anchorRect,
|
|
131
|
+
pointer: tooltip.pointer,
|
|
132
|
+
source: tooltip.source,
|
|
133
|
+
columnId: tooltip.columnId,
|
|
134
|
+
placement: tooltip.placement,
|
|
135
|
+
};
|
|
136
|
+
const content = tooltip.renderer ? tooltip.renderer(tooltip.text, renderContext) : tooltip.text;
|
|
137
|
+
const tooltipClassName = ["omnigrid-cell-tooltip", tooltip.className].filter(Boolean).join(" ");
|
|
108
138
|
return createPortal(_jsx("div", { ref: tooltipRef, className: tooltipClassName, role: "tooltip", style: { left: 0, top: 0 }, children: content }), document.body);
|
|
109
139
|
}
|
package/dist/controls.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
|
-
const CONTROL_TYPES = new Set([
|
|
3
|
+
const CONTROL_TYPES = new Set([
|
|
4
|
+
"text",
|
|
5
|
+
"number",
|
|
6
|
+
"date",
|
|
7
|
+
"select",
|
|
8
|
+
"checkbox",
|
|
9
|
+
"button",
|
|
10
|
+
"label",
|
|
11
|
+
"multi-select",
|
|
12
|
+
"group",
|
|
13
|
+
]);
|
|
4
14
|
/** Type guard for core `UIControlDescriptor` objects. */
|
|
5
15
|
export function isUIControlDescriptor(value) {
|
|
6
16
|
if (typeof value !== "object" || value === null)
|
|
@@ -57,6 +67,7 @@ export function DebouncedInput({ descriptor }) {
|
|
|
57
67
|
flush();
|
|
58
68
|
};
|
|
59
69
|
return createElement("div", { className: "omnigrid-control-input-wrapper" }, createElement("input", {
|
|
70
|
+
id: descriptor.id,
|
|
60
71
|
className: ["omnigrid-control-input", descriptor.className].filter(Boolean).join(" "),
|
|
61
72
|
type: descriptor.type === "number" ? "number" : descriptor.type === "date" ? "date" : "text",
|
|
62
73
|
value: local,
|
|
@@ -81,7 +92,9 @@ function withLabel(descriptor, field, inline = false, resolveIcon) {
|
|
|
81
92
|
if (!descriptor.label)
|
|
82
93
|
return createElement("div", { key: descriptor.id, className }, body);
|
|
83
94
|
const label = createElement("span", { className: "omnigrid-control-label" }, descriptor.label);
|
|
84
|
-
return inline
|
|
95
|
+
return inline
|
|
96
|
+
? createElement("label", { key: descriptor.id, className }, body, label)
|
|
97
|
+
: createElement("label", { key: descriptor.id, className }, label, body);
|
|
85
98
|
}
|
|
86
99
|
/**
|
|
87
100
|
* Custom-styled, keyboard-navigable drop-down select. Replaces the native
|
|
@@ -199,7 +212,10 @@ function SelectControl({ descriptor }) {
|
|
|
199
212
|
let node = buttonRef.current;
|
|
200
213
|
while (node && node !== document.body) {
|
|
201
214
|
const style = window.getComputedStyle(node);
|
|
202
|
-
if (style.overflowY === "auto" ||
|
|
215
|
+
if (style.overflowY === "auto" ||
|
|
216
|
+
style.overflowY === "scroll" ||
|
|
217
|
+
style.overflow === "auto" ||
|
|
218
|
+
style.overflow === "scroll") {
|
|
203
219
|
targets.push(node);
|
|
204
220
|
}
|
|
205
221
|
node = node.parentElement;
|
|
@@ -217,7 +233,7 @@ function SelectControl({ descriptor }) {
|
|
|
217
233
|
}, [isOpen, anchorRect]);
|
|
218
234
|
const currentOption = descriptor.options[selectedIndex === -1 ? 0 : selectedIndex];
|
|
219
235
|
const label = currentOption ? currentOption.label : descriptor.value;
|
|
220
|
-
const listbox =
|
|
236
|
+
const listbox = anchorRect &&
|
|
221
237
|
isOpen &&
|
|
222
238
|
createPortal(createElement("div", {
|
|
223
239
|
ref: listboxRef,
|
|
@@ -255,7 +271,7 @@ function SelectControl({ descriptor }) {
|
|
|
255
271
|
onClick: () => selectOption(index),
|
|
256
272
|
onKeyDown: (event) => handleListboxKeyDown(event),
|
|
257
273
|
}, option.label);
|
|
258
|
-
})), document.body)
|
|
274
|
+
})), document.body);
|
|
259
275
|
return createElement("div", {
|
|
260
276
|
className: ["omnigrid-select-wrapper", descriptor.className].filter(Boolean).join(" "),
|
|
261
277
|
}, createElement("button", {
|
|
@@ -372,18 +388,30 @@ export function renderControl(descriptor, resolveIcon) {
|
|
|
372
388
|
return createElement("button", {
|
|
373
389
|
key: descriptor.id,
|
|
374
390
|
type: "button",
|
|
375
|
-
className: [
|
|
391
|
+
className: [
|
|
392
|
+
"omnigrid-control-button",
|
|
393
|
+
descriptor.variant === "primary" ? "omnigrid-control-button-primary" : null,
|
|
394
|
+
descriptor.className,
|
|
395
|
+
]
|
|
376
396
|
.filter(Boolean)
|
|
377
397
|
.join(" "),
|
|
378
398
|
disabled: descriptor.disabled,
|
|
379
399
|
onClick: () => descriptor.onClick(),
|
|
380
400
|
}, descriptor.text);
|
|
381
401
|
case "label":
|
|
382
|
-
return createElement("div", {
|
|
402
|
+
return createElement("div", {
|
|
403
|
+
key: descriptor.id,
|
|
404
|
+
className: ["omnigrid-control-label", descriptor.className].filter(Boolean).join(" "),
|
|
405
|
+
}, descriptor.text);
|
|
383
406
|
case "group":
|
|
384
407
|
return createElement("div", {
|
|
385
408
|
key: descriptor.id,
|
|
386
|
-
className: [
|
|
409
|
+
className: [
|
|
410
|
+
"omnigrid-control",
|
|
411
|
+
"omnigrid-control-group",
|
|
412
|
+
descriptor.direction === "row" ? "omnigrid-control-group-row" : null,
|
|
413
|
+
descriptor.className,
|
|
414
|
+
]
|
|
387
415
|
.filter(Boolean)
|
|
388
416
|
.join(" "),
|
|
389
417
|
}, descriptor.children.map((child) => renderControl(child, resolveIcon)));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
+
export type { CellTooltipRenderer, CellTooltipRenderContext, ReactCellRenderer, ReactColumnDef, ReactColumnDef as ColumnDef, ReactColumnGroupDef, ReactColumnGroupDef as ColumnGroupDef, ReactColumnLeafDef, ReactColumnLeafDef as ColumnLeafDef, ReactGridOptions, ReactGridOptions as GridOptions, } from "./reactColumnDef";
|
|
5
5
|
export { PooledRowPane } from "./pooledRow";
|
|
6
6
|
export type { ContentBridge, PooledCellRenderInfo, PooledColumn, PooledRowCallbacks, PooledRowModifiers } from "./types";
|
|
7
7
|
export { OmniGrid } from "./OmniGrid";
|
|
8
|
-
export type {
|
|
8
|
+
export type { GridProps, OverlayComponent, OverlayComponentProps, SlotRendererRegistry } from "./types";
|
|
9
9
|
export { useGrid } from "./useGrid";
|
|
10
10
|
export { DebouncedInput, isUIControlDescriptor, renderControl } from "./controls";
|
|
11
11
|
export type { DebouncedInputProps } from "./controls";
|
package/dist/pooledRow.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class PooledRowPane<T> {
|
|
|
29
29
|
private variableHeight;
|
|
30
30
|
private heightMeasureId;
|
|
31
31
|
private rowHasWrapText;
|
|
32
|
+
private offsetY;
|
|
33
|
+
private rowAnimation;
|
|
32
34
|
constructor(host: HTMLDivElement, callbacks: PooledRowCallbacks<T>, bridge: ContentBridge<T>);
|
|
33
35
|
/** Binds a row to the panel and fully rebuilds content. */
|
|
34
36
|
bind(row: PooledRow<T>, columns: PooledColumn<T>[], originX?: number, spans?: RowSpanLayout | null): void;
|
|
@@ -38,6 +40,12 @@ export declare class PooledRowPane<T> {
|
|
|
38
40
|
updateColumns(columns: PooledColumn<T>[], originX?: number, spans?: RowSpanLayout | null): void;
|
|
39
41
|
/** Single row positioning operation — transform only (no reflow). */
|
|
40
42
|
setOffsetY(offsetY: number): void;
|
|
43
|
+
/** Returns the current virtualized row position in grid coordinates. */
|
|
44
|
+
getOffsetY(): number;
|
|
45
|
+
/** Animates a row from its previous grid position without changing its scroll transform. */
|
|
46
|
+
animateFrom(previousOffsetY: number): void;
|
|
47
|
+
/** Cancels any active row-position animation. */
|
|
48
|
+
cancelAnimation(): void;
|
|
41
49
|
/**
|
|
42
50
|
* Updates the row index the node stands for without touching its content.
|
|
43
51
|
*
|
package/dist/pooledRow.js
CHANGED
|
@@ -44,6 +44,8 @@ export class PooledRowPane {
|
|
|
44
44
|
this.variableHeight = false;
|
|
45
45
|
this.heightMeasureId = 0;
|
|
46
46
|
this.rowHasWrapText = false;
|
|
47
|
+
this.offsetY = 0;
|
|
48
|
+
this.rowAnimation = null;
|
|
47
49
|
host.classList.add("omnigrid-row");
|
|
48
50
|
host.setAttribute("role", "row");
|
|
49
51
|
host.style.position = "absolute";
|
|
@@ -93,6 +95,7 @@ export class PooledRowPane {
|
|
|
93
95
|
}
|
|
94
96
|
/** Binds a row to the panel and fully rebuilds content. */
|
|
95
97
|
bind(row, columns, originX = 0, spans) {
|
|
98
|
+
this.cancelAnimation();
|
|
96
99
|
const hovered = this.host.matches(":hover");
|
|
97
100
|
if (hovered && this.row)
|
|
98
101
|
this.callbacks.onRowHover(this.row, false);
|
|
@@ -127,7 +130,38 @@ export class PooledRowPane {
|
|
|
127
130
|
}
|
|
128
131
|
/** Single row positioning operation — transform only (no reflow). */
|
|
129
132
|
setOffsetY(offsetY) {
|
|
130
|
-
|
|
133
|
+
const roundedOffsetY = Math.round(offsetY);
|
|
134
|
+
if (this.offsetY !== roundedOffsetY)
|
|
135
|
+
this.cancelAnimation();
|
|
136
|
+
this.offsetY = roundedOffsetY;
|
|
137
|
+
this.host.style.transform = `translate3d(0, ${roundedOffsetY}px, 0)`;
|
|
138
|
+
}
|
|
139
|
+
/** Returns the current virtualized row position in grid coordinates. */
|
|
140
|
+
getOffsetY() {
|
|
141
|
+
return this.offsetY;
|
|
142
|
+
}
|
|
143
|
+
/** Animates a row from its previous grid position without changing its scroll transform. */
|
|
144
|
+
animateFrom(previousOffsetY) {
|
|
145
|
+
this.cancelAnimation();
|
|
146
|
+
const deltaY = previousOffsetY - this.offsetY;
|
|
147
|
+
if (deltaY === 0)
|
|
148
|
+
return;
|
|
149
|
+
const animation = this.host.animate([{ translate: `0px ${deltaY}px` }, { translate: "0px 0px" }], { duration: 180, easing: "ease-out" });
|
|
150
|
+
this.rowAnimation = animation;
|
|
151
|
+
animation.onfinish = () => {
|
|
152
|
+
if (this.rowAnimation === animation)
|
|
153
|
+
this.rowAnimation = null;
|
|
154
|
+
};
|
|
155
|
+
animation.oncancel = () => {
|
|
156
|
+
if (this.rowAnimation === animation)
|
|
157
|
+
this.rowAnimation = null;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** Cancels any active row-position animation. */
|
|
161
|
+
cancelAnimation() {
|
|
162
|
+
const animation = this.rowAnimation;
|
|
163
|
+
this.rowAnimation = null;
|
|
164
|
+
animation?.cancel();
|
|
131
165
|
}
|
|
132
166
|
/**
|
|
133
167
|
* Updates the row index the node stands for without touching its content.
|
|
@@ -358,6 +392,7 @@ export class PooledRowPane {
|
|
|
358
392
|
cell.appliedStyleKeys.push(key);
|
|
359
393
|
}
|
|
360
394
|
}
|
|
395
|
+
cell.element.dataset.columnId = cellInfo.column.id;
|
|
361
396
|
const flushLayout = cellInfo.column.cellLayout === "flush";
|
|
362
397
|
if (flushLayout)
|
|
363
398
|
cell.element.style.padding = "0";
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { PopupHostProps } from "./types";
|
|
3
|
+
export declare function clampPopupLeft(desiredLeft: number, popupWidth: number, minLeft: number, maxRight: number): number;
|
|
3
4
|
/**
|
|
4
5
|
* Renders the grid's active `UIPopupDescriptor`. Popup state lives here, so
|
|
5
6
|
* opening or updating a popup never re-renders the grid body. The popup is
|
package/dist/popup.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createElement, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import { contentToReactNode } from "./content";
|
|
3
3
|
const VIEWPORT_MARGIN = 8;
|
|
4
|
+
export function clampPopupLeft(desiredLeft, popupWidth, minLeft, maxRight) {
|
|
5
|
+
const maxLeft = Math.max(minLeft, maxRight - popupWidth);
|
|
6
|
+
return Math.min(Math.max(desiredLeft, minLeft), maxLeft);
|
|
7
|
+
}
|
|
4
8
|
function anchorStyle(popup) {
|
|
5
9
|
const base = { position: "absolute", zIndex: 1000 };
|
|
6
10
|
const anchor = popup.anchor;
|
|
@@ -49,20 +53,25 @@ export function PopupHost({ grid }) {
|
|
|
49
53
|
document.removeEventListener("keydown", handleKeyDown);
|
|
50
54
|
};
|
|
51
55
|
}, [grid, isOpen, closeOnOutside, closeOnEscape]);
|
|
52
|
-
// Keep an anchored popup inside the
|
|
56
|
+
// Keep an anchored popup inside both the grid and the visible window.
|
|
53
57
|
useLayoutEffect(() => {
|
|
54
58
|
const element = elementRef.current;
|
|
55
59
|
if (!element || !popup?.anchor)
|
|
56
60
|
return;
|
|
57
|
-
const rect = element.getBoundingClientRect();
|
|
58
61
|
const parent = element.parentElement;
|
|
59
|
-
const parentRect = parent
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
62
|
+
const parentRect = parent?.getBoundingClientRect() ?? null;
|
|
63
|
+
const parentLeft = parentRect?.left ?? 0;
|
|
64
|
+
const minLeft = Math.max(VIEWPORT_MARGIN, parentLeft + VIEWPORT_MARGIN);
|
|
65
|
+
const maxRight = Math.min(window.innerWidth - VIEWPORT_MARGIN, (parentRect?.right ?? window.innerWidth) - VIEWPORT_MARGIN);
|
|
66
|
+
const availableWidth = Math.max(0, maxRight - minLeft);
|
|
67
|
+
element.style.maxWidth = `${availableWidth}px`;
|
|
68
|
+
element.style.minWidth = `${Math.min(200, availableWidth)}px`;
|
|
69
|
+
const rect = element.getBoundingClientRect();
|
|
70
|
+
const anchorLeft = parentLeft + popup.anchor.x;
|
|
71
|
+
const desiredLeft = popup.placement === "bottom-end" ? anchorLeft + (popup.anchor.width ?? 0) - rect.width : anchorLeft;
|
|
72
|
+
const left = clampPopupLeft(desiredLeft, rect.width, minLeft, maxRight);
|
|
73
|
+
element.style.transform = "none";
|
|
74
|
+
element.style.left = `${left - parentLeft}px`;
|
|
66
75
|
}, [popup]);
|
|
67
76
|
if (!popup)
|
|
68
77
|
return null;
|
package/dist/reactColumnDef.d.ts
CHANGED
|
@@ -6,6 +6,32 @@ import type { CellRenderParams, ColumnGroupDef, ColumnLeafDef, GridOptions } fro
|
|
|
6
6
|
* @api
|
|
7
7
|
*/
|
|
8
8
|
export type ReactCellRenderer<T> = (params: CellRenderParams<T>) => ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Context supplied to a custom cell or header tooltip renderer.
|
|
11
|
+
*
|
|
12
|
+
* @api
|
|
13
|
+
*/
|
|
14
|
+
export interface CellTooltipRenderContext {
|
|
15
|
+
/** Bounds of the truncated text or header label in viewport coordinates. */
|
|
16
|
+
anchorRect: DOMRectReadOnly;
|
|
17
|
+
/** Pointer position in viewport coordinates, or `null` when unavailable. */
|
|
18
|
+
pointer: {
|
|
19
|
+
clientX: number;
|
|
20
|
+
clientY: number;
|
|
21
|
+
} | null;
|
|
22
|
+
/** Whether the truncated content belongs to a data cell or a header. */
|
|
23
|
+
source: "cell" | "header";
|
|
24
|
+
/** Column identifier for data cells; group headers may not have one. */
|
|
25
|
+
columnId?: string;
|
|
26
|
+
/** Side of the anchor where the tooltip is displayed after viewport collision handling. */
|
|
27
|
+
placement: "top" | "bottom";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Renders the full text of a truncated cell or header in its hover tooltip.
|
|
31
|
+
*
|
|
32
|
+
* @api
|
|
33
|
+
*/
|
|
34
|
+
export type CellTooltipRenderer = (text: string, context?: CellTooltipRenderContext) => ReactNode;
|
|
9
35
|
/**
|
|
10
36
|
* Leaf column definition with a renderer typed for React content.
|
|
11
37
|
*
|
|
@@ -14,6 +40,10 @@ export type ReactCellRenderer<T> = (params: CellRenderParams<T>) => ReactNode;
|
|
|
14
40
|
export type ReactColumnLeafDef<T> = Omit<ColumnLeafDef<T>, "cellRenderer"> & {
|
|
15
41
|
/** Replaces the default cell content with a React node. */
|
|
16
42
|
cellRenderer?: ReactCellRenderer<T>;
|
|
43
|
+
/** Overrides the grid-level renderer for this column's truncated cell content. */
|
|
44
|
+
cellTooltipRenderer?: CellTooltipRenderer;
|
|
45
|
+
/** Overrides the grid-level class for this column's truncated cell tooltip. */
|
|
46
|
+
cellTooltipClassName?: string;
|
|
17
47
|
};
|
|
18
48
|
/**
|
|
19
49
|
* Column group definition whose children use React-specific column types.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { SlotRenderContext, UIInputControl } from "@omnigrid/core";
|
|
3
3
|
import type { CellRoot } from "./reactRoot";
|
|
4
|
-
import type { ReactGridOptions } from "./reactColumnDef";
|
|
4
|
+
import type { CellTooltipRenderer, ReactGridOptions } from "./reactColumnDef";
|
|
5
|
+
/** Tooltip overrides resolved for a particular data column. */
|
|
6
|
+
export interface CellTooltipOptions {
|
|
7
|
+
/** Custom renderer for the truncated cell's full text. */
|
|
8
|
+
renderer?: CellTooltipRenderer;
|
|
9
|
+
/** Additional class applied to the tooltip element. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Bridge between the core's headless content and native adapter values.
|
|
7
14
|
* `registry` — registry of React components for `SlotComponentContent`;
|
|
@@ -78,12 +85,6 @@ export interface SlotRendererRegistry<T> {
|
|
|
78
85
|
}
|
|
79
86
|
export type OverlayComponentProps<T> = import("@omnigrid/core").OverlayComponentProps<T>;
|
|
80
87
|
export type OverlayComponent<T> = import("react").ComponentType<import("@omnigrid/core").OverlayComponentProps<T>> | import("@omnigrid/core").OverlayComponent<T>;
|
|
81
|
-
/**
|
|
82
|
-
* Renders the full text of a truncated cell or header in its hover tooltip.
|
|
83
|
-
*
|
|
84
|
-
* @api
|
|
85
|
-
*/
|
|
86
|
-
export type CellTooltipRenderer = (text: string) => ReactNode;
|
|
87
88
|
export interface GridProps<T> extends Omit<ReactGridOptions<T>, "overlayComponents"> {
|
|
88
89
|
className?: string;
|
|
89
90
|
style?: import("react").CSSProperties;
|