@1771technologies/lytenyte-pro 1.0.14 → 1.0.15
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/__play__/cell-selections/cell-selection.play.d.ts +5 -0
- package/dist/__play__/{grid-navigation/normal-layout.play.js → cell-selections/cell-selection.play.js} +32 -24
- package/dist/__play__/test-utils/row-handler.js +3 -3
- package/dist/cell-selection/cell-selection-driver.js +5 -2
- package/dist/context.d.ts +2 -1
- package/dist/context.js +5 -4
- package/dist/grid/cell.d.ts +6 -0
- package/dist/grid/cell.js +3 -0
- package/dist/{header → grid}/header-cell.d.ts +2 -2
- package/dist/grid/header-cell.js +4 -0
- package/dist/grid/header-group-cell.d.ts +6 -0
- package/dist/grid/header-group-cell.js +3 -0
- package/dist/grid/header-row.d.ts +5 -0
- package/dist/grid/header-row.js +2 -0
- package/dist/grid/header.js +2 -0
- package/dist/{root → grid}/root.d.ts +1 -1
- package/dist/grid/root.js +37 -0
- package/dist/{rows → grid}/row-full-width.d.ts +2 -1
- package/dist/grid/row-full-width.js +4 -0
- package/dist/grid/row.d.ts +8 -0
- package/dist/grid/row.js +4 -0
- package/dist/grid/rows-container.js +2 -0
- package/dist/grid/rows-sections.js +13 -0
- package/dist/grid/viewport.js +9 -0
- package/dist/grid.d.ts +7 -7
- package/dist/grid.js +11 -11
- package/dist/types/types.d.ts +6 -6
- package/package.json +7 -7
- package/dist/__play__/grid-navigation/cell-spans-large.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/cell-spans-large.play.js +0 -26
- package/dist/__play__/grid-navigation/cell-spans-with-pins.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/cell-spans-with-pins.play.js +0 -27
- package/dist/__play__/grid-navigation/cell-spans.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/cell-spans.play.js +0 -52
- package/dist/__play__/grid-navigation/cell-with-tabbables.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/cell-with-tabbables.play.js +0 -47
- package/dist/__play__/grid-navigation/column-groups.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/column-groups.play.js +0 -24
- package/dist/__play__/grid-navigation/full-width-rows.play.d.ts +0 -6
- package/dist/__play__/grid-navigation/full-width-rows.play.js +0 -67
- package/dist/__play__/grid-navigation/horizontal-navigation.pt.d.ts +0 -1
- package/dist/__play__/grid-navigation/horizontal-navigation.pt.js +0 -877
- package/dist/__play__/grid-navigation/normal-layout.play.d.ts +0 -10
- package/dist/__play__/grid-navigation/pinned-gap-layout.play.d.ts +0 -3
- package/dist/__play__/grid-navigation/pinned-gap-layout.play.js +0 -11
- package/dist/__play__/grid-navigation/row-detail-with-spans.play.d.ts +0 -6
- package/dist/__play__/grid-navigation/row-detail-with-spans.play.js +0 -79
- package/dist/__play__/grid-navigation/row-detail.play.d.ts +0 -6
- package/dist/__play__/grid-navigation/row-detail.play.js +0 -78
- package/dist/__play__/grid-navigation/row-detail.pt.d.ts +0 -1
- package/dist/__play__/grid-navigation/row-detail.pt.js +0 -68
- package/dist/__play__/grid-navigation/vertical-navigation.pt.d.ts +0 -1
- package/dist/__play__/grid-navigation/vertical-navigation.pt.js +0 -176
- package/dist/cells/+types.cell.d.ts +0 -13
- package/dist/cells/+types.cell.js +0 -1
- package/dist/cells/cell-default.d.ts +0 -2
- package/dist/cells/cell-default.js +0 -8
- package/dist/cells/cell-editor.d.ts +0 -6
- package/dist/cells/cell-editor.js +0 -110
- package/dist/cells/cell-spacer.d.ts +0 -9
- package/dist/cells/cell-spacer.js +0 -39
- package/dist/cells/cell.d.ts +0 -5
- package/dist/cells/cell.js +0 -44
- package/dist/cells/use-cell-style.d.ts +0 -3
- package/dist/cells/use-cell-style.js +0 -51
- package/dist/header/header-cell.js +0 -22
- package/dist/header/header-group-cell.d.ts +0 -5
- package/dist/header/header-group-cell.js +0 -16
- package/dist/header/header-row.d.ts +0 -4
- package/dist/header/header-row.js +0 -10
- package/dist/header/header.js +0 -12
- package/dist/header/resize-handler.d.ts +0 -12
- package/dist/header/resize-handler.js +0 -136
- package/dist/header/use-drag-move.d.ts +0 -14
- package/dist/header/use-drag-move.js +0 -97
- package/dist/header/use-header-cell-renderer.d.ts +0 -4
- package/dist/header/use-header-cell-renderer.js +0 -37
- package/dist/root/root.js +0 -108
- package/dist/rows/row/context.d.ts +0 -15
- package/dist/rows/row/context.js +0 -14
- package/dist/rows/row/row.d.ts +0 -7
- package/dist/rows/row/row.js +0 -25
- package/dist/rows/row/use-row-context-value.d.ts +0 -6
- package/dist/rows/row/use-row-context-value.js +0 -45
- package/dist/rows/row-detail-row.d.ts +0 -4
- package/dist/rows/row-detail-row.js +0 -47
- package/dist/rows/row-full-width.js +0 -19
- package/dist/rows/rows-container.js +0 -9
- package/dist/rows/rows-sections.js +0 -27
- package/dist/rows/scrollers/native-scroller.d.ts +0 -2
- package/dist/rows/scrollers/native-scroller.js +0 -4
- package/dist/utils/cycle-sorts.d.ts +0 -2
- package/dist/utils/cycle-sorts.js +0 -16
- package/dist/viewport/begin-editing.d.ts +0 -5
- package/dist/viewport/begin-editing.js +0 -15
- package/dist/viewport/viewport.js +0 -85
- /package/dist/{root → grid}/dialog-driver.d.ts +0 -0
- /package/dist/{root → grid}/dialog-driver.js +0 -0
- /package/dist/{header → grid}/header.d.ts +0 -0
- /package/dist/{root → grid}/popover-driver.d.ts +0 -0
- /package/dist/{root → grid}/popover-driver.js +0 -0
- /package/dist/{rows → grid}/rows-container.d.ts +0 -0
- /package/dist/{rows → grid}/rows-sections.d.ts +0 -0
- /package/dist/{viewport → grid}/viewport.d.ts +0 -0
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useGridRoot } from "../context.js";
|
|
3
|
-
import { useRowMeta } from "../rows/row/context.js";
|
|
4
|
-
export function CellSpacePinStart({ xPositions: x }) {
|
|
5
|
-
const { layout, colBounds } = useRowMeta();
|
|
6
|
-
const ctx = useGridRoot().grid;
|
|
7
|
-
const bounds = ctx.state.viewBounds.useValue();
|
|
8
|
-
const meta = ctx.state.columnMeta.useValue();
|
|
9
|
-
if (meta.columnVisibleStartCount === 0 || layout.kind === "full-width")
|
|
10
|
-
return null;
|
|
11
|
-
const colOffset = layout.cells.findIndex((c) => !c.colPin && c.colIndex + c.colSpan - 1 >= colBounds[0] && !c.isDeadCol);
|
|
12
|
-
const offset = x[colOffset] - x[bounds.colStartEnd];
|
|
13
|
-
return _jsx("div", { style: { display: "inline-block", width: offset, height: 0 } });
|
|
14
|
-
}
|
|
15
|
-
export function CellSpacerPinEnd({ xPositions: x }) {
|
|
16
|
-
const ctx = useGridRoot().grid;
|
|
17
|
-
const bounds = ctx.state.viewBounds.useValue();
|
|
18
|
-
const startOffset = x[bounds.colCenterEnd];
|
|
19
|
-
let offset = x[bounds.colEndStart] - startOffset;
|
|
20
|
-
const viewWidth = ctx.state.viewportWidthInner.useValue();
|
|
21
|
-
if (x.at(-1) < viewWidth) {
|
|
22
|
-
offset = viewWidth - x.at(-1);
|
|
23
|
-
}
|
|
24
|
-
const meta = ctx.state.columnMeta.useValue();
|
|
25
|
-
if (meta.columnVisibleEndCount === 0)
|
|
26
|
-
return null;
|
|
27
|
-
return _jsx("div", { style: { display: "inline-block", width: offset, height: 0 } });
|
|
28
|
-
}
|
|
29
|
-
export function CellSpacerNoPin({ xPositions: x }) {
|
|
30
|
-
const { layout, colBounds } = useRowMeta();
|
|
31
|
-
const ctx = useGridRoot().grid;
|
|
32
|
-
const bounds = ctx.state.viewBounds.useValue();
|
|
33
|
-
const meta = ctx.state.columnMeta.useValue();
|
|
34
|
-
if (meta.columnVisibleStartCount > 0 || layout.kind === "full-width")
|
|
35
|
-
return null;
|
|
36
|
-
const colOffset = layout.cells.findIndex((c) => c.colIndex + c.colSpan - 1 >= colBounds[0] && !c.isDeadCol);
|
|
37
|
-
const offset = x[colOffset - bounds.colStartEnd];
|
|
38
|
-
return _jsx("div", { style: { display: "inline-block", width: offset, height: 0 } });
|
|
39
|
-
}
|
package/dist/cells/cell.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { RowCellLayout } from "../+types";
|
|
2
|
-
export interface CellProps {
|
|
3
|
-
readonly cell: RowCellLayout<any>;
|
|
4
|
-
}
|
|
5
|
-
export declare const Cell: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & CellProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/cells/cell.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, memo, useEffect, useState } from "react";
|
|
3
|
-
import { useGridRoot } from "../context.js";
|
|
4
|
-
import { sizeFromCoord } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
import { CellDefault } from "./cell-default.js";
|
|
6
|
-
import { CellEditor } from "./cell-editor.js";
|
|
7
|
-
import { useRowMeta } from "../rows/row/context.js";
|
|
8
|
-
import { CellSpacePinStart, CellSpacerPinEnd } from "./cell-spacer.js";
|
|
9
|
-
import { useCellStyle } from "./use-cell-style.js";
|
|
10
|
-
export const Cell = forwardRef(function Cell(props, forwarded) {
|
|
11
|
-
const { colBounds: [start, end], ...rowMeta } = useRowMeta();
|
|
12
|
-
// This enforces our column virtualization.
|
|
13
|
-
if (props.cell.colPin == null &&
|
|
14
|
-
(props.cell.colIndex >= end || props.cell.colIndex + props.cell.colSpan - 1 < start)) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return _jsx(CellImpl, { ...props, ref: forwarded, ...rowMeta });
|
|
18
|
-
});
|
|
19
|
-
const CellImpl = memo(forwardRef(function Cell({ cell, row, selected, indeterminate, xPositions, yPositions, base, renderers, rtl, layout: _, ...props }, forwarded) {
|
|
20
|
-
const grid = useGridRoot().grid;
|
|
21
|
-
const providedRenderer = cell.column.cellRenderer ?? base.cellRenderer;
|
|
22
|
-
const Renderer = providedRenderer
|
|
23
|
-
? typeof providedRenderer === "string"
|
|
24
|
-
? (renderers[providedRenderer] ?? CellDefault)
|
|
25
|
-
: providedRenderer
|
|
26
|
-
: CellDefault;
|
|
27
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
return grid.internal.editActivePos.watch(() => {
|
|
30
|
-
const pos = grid.internal.editActivePos.get();
|
|
31
|
-
if (!pos)
|
|
32
|
-
return setIsEditing(false);
|
|
33
|
-
setIsEditing(pos.column === cell.column &&
|
|
34
|
-
pos.rowIndex >= cell.rowIndex &&
|
|
35
|
-
pos.rowIndex < cell.rowIndex + cell.rowSpan);
|
|
36
|
-
});
|
|
37
|
-
}, [cell.column, cell.rowIndex, cell.rowSpan, grid.internal.editActivePos]);
|
|
38
|
-
const style = useCellStyle(xPositions, yPositions, cell, rtl, grid.api.rowDetailRenderedHeight(row ?? ""), undefined);
|
|
39
|
-
if (cell.isDeadRow)
|
|
40
|
-
return _jsx("div", { style: { width: sizeFromCoord(cell.colIndex, xPositions) } });
|
|
41
|
-
if (!row || cell.isDeadCol)
|
|
42
|
-
return null;
|
|
43
|
-
return (_jsxs(_Fragment, { children: [cell.colFirstEndPin && _jsx(CellSpacerPinEnd, { xPositions: xPositions }), _jsxs("div", { ...props, ref: forwarded, role: "gridcell", "data-ln-rowindex": cell.rowIndex, "data-ln-colindex": cell.colIndex, "data-ln-colspan": cell.colSpan, "data-ln-rowspan": cell.rowSpan, "data-ln-pin": cell.colPin ?? "center", "data-ln-cell": true, "data-ln-last-top-pin": cell.rowLastPinTop, "data-ln-first-bottom-pin": cell.rowFirstPinBottom, "data-ln-last-start-pin": cell.colLastStartPin, "data-ln-first-end-pin": cell.colFirstEndPin, tabIndex: isEditing ? -1 : 0, style: { ...style, ...props.style }, children: [isEditing && _jsx(CellEditor, { cell: cell }), !isEditing && (_jsx(Renderer, { column: cell.column, rowSelected: selected, rowIndeterminate: indeterminate, row: row, grid: grid, rowIndex: cell.rowIndex, colIndex: cell.colIndex, rowPin: cell.rowPin }))] }), cell.colLastStartPin && _jsx(CellSpacePinStart, { xPositions: xPositions })] }));
|
|
44
|
-
}));
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties } from "react";
|
|
2
|
-
import type { Cell } from "./+types.cell";
|
|
3
|
-
export declare function useCellStyle(xPositions: Uint32Array, yPositions: Uint32Array, cell: Cell, rtl: boolean, detailHeight: number, additional: CSSProperties | undefined): CSSProperties;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { sizeFromCoord } from "@1771technologies/lytenyte-shared";
|
|
3
|
-
export function useCellStyle(xPositions, yPositions, cell, rtl, detailHeight, additional) {
|
|
4
|
-
const width = sizeFromCoord(cell.colIndex, xPositions, cell.colSpan);
|
|
5
|
-
const height = sizeFromCoord(cell.rowIndex, yPositions, cell.rowSpan) - detailHeight;
|
|
6
|
-
const isSticky = !!cell.colPin;
|
|
7
|
-
const isRowPinned = !!cell.rowPin;
|
|
8
|
-
const styles = useMemo(() => {
|
|
9
|
-
const styles = {
|
|
10
|
-
height,
|
|
11
|
-
width,
|
|
12
|
-
minWidth: width,
|
|
13
|
-
maxWidth: width,
|
|
14
|
-
boxSizing: "border-box",
|
|
15
|
-
pointerEvents: "all",
|
|
16
|
-
display: "inline-block",
|
|
17
|
-
overflow: "hidden",
|
|
18
|
-
};
|
|
19
|
-
if (cell.colPin === "end") {
|
|
20
|
-
styles.position = "sticky";
|
|
21
|
-
const x = xPositions.at(-1) - xPositions[cell.colIndex + cell.colSpan];
|
|
22
|
-
if (rtl)
|
|
23
|
-
styles.left = x;
|
|
24
|
-
else
|
|
25
|
-
styles.right = x;
|
|
26
|
-
styles.zIndex = isRowPinned ? 5 : 2;
|
|
27
|
-
}
|
|
28
|
-
else if (isSticky) {
|
|
29
|
-
styles.position = "sticky";
|
|
30
|
-
const x = xPositions[cell.colIndex];
|
|
31
|
-
if (rtl)
|
|
32
|
-
styles.right = x;
|
|
33
|
-
else
|
|
34
|
-
styles.left = x;
|
|
35
|
-
styles.zIndex = isRowPinned ? 5 : 2;
|
|
36
|
-
}
|
|
37
|
-
return { ...additional, ...styles };
|
|
38
|
-
}, [
|
|
39
|
-
additional,
|
|
40
|
-
cell.colIndex,
|
|
41
|
-
cell.colPin,
|
|
42
|
-
cell.colSpan,
|
|
43
|
-
height,
|
|
44
|
-
isRowPinned,
|
|
45
|
-
isSticky,
|
|
46
|
-
rtl,
|
|
47
|
-
width,
|
|
48
|
-
xPositions,
|
|
49
|
-
]);
|
|
50
|
-
return styles;
|
|
51
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { useGridRoot } from "../context.js";
|
|
4
|
-
import { COLUMN_MARKER_ID, HeaderCellReact } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
import { fastDeepMemo, useCombinedRefs, } from "@1771technologies/lytenyte-react-hooks";
|
|
6
|
-
import { useHeaderCellRenderer } from "./use-header-cell-renderer.js";
|
|
7
|
-
import { ResizeHandler } from "./resize-handler.js";
|
|
8
|
-
import { useDragMove } from "./use-drag-move.js";
|
|
9
|
-
const HeaderCellImpl = forwardRef(function HeaderCell({ cell, resizerAs, resizerStyle, resizerClassName, children, ...props }, forwarded) {
|
|
10
|
-
const grid = useGridRoot().grid;
|
|
11
|
-
const ctx = grid.state;
|
|
12
|
-
const xPositions = ctx.xPositions.useValue();
|
|
13
|
-
const base = ctx.columnBase.useValue();
|
|
14
|
-
const Renderer = useHeaderCellRenderer(cell);
|
|
15
|
-
const resizable = cell.id === COLUMN_MARKER_ID
|
|
16
|
-
? false
|
|
17
|
-
: (cell.column.uiHints?.resizable ?? base.uiHints?.resizable ?? false);
|
|
18
|
-
const { ref, ...dragProps } = useDragMove(grid, cell, props.onDragStart);
|
|
19
|
-
const combined = useCombinedRefs(forwarded, ref);
|
|
20
|
-
return (_jsxs(HeaderCellReact, { ...props, ...dragProps, ref: combined, cell: cell, columnId: cell.column.id, isFloating: cell.kind === "floating", xPositions: xPositions, children: [children == undefined ? _jsx(Renderer, { column: cell.column, grid: grid }) : children, resizable && cell.kind === "cell" && (_jsx(ResizeHandler, { cell: cell, xPositions: xPositions, as: resizerAs, className: resizerClassName, style: resizerStyle }))] }));
|
|
21
|
-
});
|
|
22
|
-
export const HeaderCell = fastDeepMemo(HeaderCellImpl);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { HeaderGroupCellLayout } from "../+types";
|
|
2
|
-
export interface HeaderGroupCellProps {
|
|
3
|
-
readonly cell: HeaderGroupCellLayout;
|
|
4
|
-
}
|
|
5
|
-
export declare const HeaderGroupCell: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & HeaderGroupCellProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { useGridRoot } from "../context.js";
|
|
4
|
-
import { HeaderGroupCellReact } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
import { fastDeepMemo, useCombinedRefs } from "@1771technologies/lytenyte-react-hooks";
|
|
6
|
-
import { useDragMove } from "./use-drag-move.js";
|
|
7
|
-
const HeaderGroupCellImpl = forwardRef(function HeaderCell({ cell, children, ...props }, forwarded) {
|
|
8
|
-
const grid = useGridRoot().grid;
|
|
9
|
-
const ctx = grid.state;
|
|
10
|
-
const { ref, ...dragProps } = useDragMove(grid, cell, props.onDragStart);
|
|
11
|
-
const combined = useCombinedRefs(ref, forwarded);
|
|
12
|
-
const isExpanded = grid.state.columnGroupExpansions.useValue()[cell.id] ??
|
|
13
|
-
grid.state.columnGroupDefaultExpansion.get();
|
|
14
|
-
return (_jsx(HeaderGroupCellReact, { ...props, ...dragProps, ref: combined, cell: cell, cellId: cell.id, height: ctx.headerGroupHeight.useValue(), xPositions: ctx.xPositions.useValue(), isHiddenMove: cell.isHiddenMove ?? false, "data-ln-collapsible": cell.isCollapsible, "data-ln-collapsed": !isExpanded, children: children == undefined ? cell.id : children }));
|
|
15
|
-
});
|
|
16
|
-
export const HeaderGroupCell = fastDeepMemo(HeaderGroupCellImpl);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export interface HeaderRowProps {
|
|
2
|
-
readonly headerRowIndex: number;
|
|
3
|
-
}
|
|
4
|
-
export declare const HeaderRow: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & HeaderRowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { fastDeepMemo } from "@1771technologies/lytenyte-react-hooks";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
import { useGridRoot } from "../context.js";
|
|
5
|
-
import { HeaderRowReact } from "@1771technologies/lytenyte-shared";
|
|
6
|
-
const HeaderRowImpl = forwardRef(function HeaderRow(props, forwarded) {
|
|
7
|
-
const maxRow = useGridRoot().grid.view.get().header.maxRow;
|
|
8
|
-
return _jsx(HeaderRowReact, { ...props, ref: forwarded, maxRow: maxRow });
|
|
9
|
-
});
|
|
10
|
-
export const HeaderRow = fastDeepMemo(HeaderRowImpl);
|
package/dist/header/header.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { useGridRoot } from "../context.js";
|
|
4
|
-
import { fastDeepMemo } from "@1771technologies/lytenyte-react-hooks";
|
|
5
|
-
import { HeaderReact } from "@1771technologies/lytenyte-shared";
|
|
6
|
-
const HeaderImpl = forwardRef(function Header(props, forwarded) {
|
|
7
|
-
const grid = useGridRoot().grid;
|
|
8
|
-
const xPositions = grid.state.xPositions.useValue();
|
|
9
|
-
const columnVisible = grid.state.columnMeta.useValue();
|
|
10
|
-
return (_jsx(HeaderReact, { ...props, ref: forwarded, floatingRowEnabled: grid.state.floatingRowEnabled.useValue(), floatingRowHeight: grid.state.floatingRowHeight.useValue(), headerGroupHeight: grid.state.headerGroupHeight.useValue(), headerHeight: grid.state.headerHeight.useValue(), rows: grid.internal.headerRows.useValue(), xPositions: xPositions, countBeforeEnd: columnVisible.columnVisibleCenterCount + columnVisible.columnVisibleStartCount, width: grid.state.widthTotal.useValue() }));
|
|
11
|
-
});
|
|
12
|
-
export const Header = fastDeepMemo(HeaderImpl);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
|
-
import type { HeaderCellLayout } from "../+types";
|
|
3
|
-
import { type CSSProperties } from "react";
|
|
4
|
-
interface ResizeHandlerProps<T> {
|
|
5
|
-
readonly as?: SlotComponent;
|
|
6
|
-
readonly cell: HeaderCellLayout<T>;
|
|
7
|
-
readonly xPositions: Uint32Array;
|
|
8
|
-
readonly className?: string;
|
|
9
|
-
readonly style?: CSSProperties;
|
|
10
|
-
}
|
|
11
|
-
export declare function ResizeHandler<T>({ as, cell, xPositions, style, className, }: ResizeHandlerProps<T>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
-
export {};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
|
-
import {} from "react";
|
|
4
|
-
import { DEFAULT_COLUMN_WIDTH_MAX, DEFAULT_COLUMN_WIDTH_MIN, sizeFromCoord, } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
import { useGridRoot } from "../context.js";
|
|
6
|
-
import { getComputedStyle } from "@1771technologies/lytenyte-dom-utils";
|
|
7
|
-
import { clamp, getClientX } from "@1771technologies/lytenyte-js-utils";
|
|
8
|
-
export function ResizeHandler({ as, cell, xPositions, style, className, }) {
|
|
9
|
-
const width = sizeFromCoord(cell.colStart, xPositions, cell.colSpan);
|
|
10
|
-
const sx = useGridRoot().grid;
|
|
11
|
-
const double = sx.state.columnDoubleClickToAutosize.useValue();
|
|
12
|
-
const defaultProps = {
|
|
13
|
-
role: "button",
|
|
14
|
-
"data-ln-header-resizer": "true",
|
|
15
|
-
"aria-label": `Resize ${cell.column.name ?? cell.column.id}`,
|
|
16
|
-
tabIndex: -1,
|
|
17
|
-
onDoubleClick: () => {
|
|
18
|
-
if (!double)
|
|
19
|
-
return;
|
|
20
|
-
sx.api.columnAutosize({
|
|
21
|
-
columns: [cell.column],
|
|
22
|
-
includeHeader: true,
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
onPointerDown: (ev) => {
|
|
26
|
-
const vp = sx.state.viewport.get();
|
|
27
|
-
if (!vp)
|
|
28
|
-
return;
|
|
29
|
-
if (ev.pointerType === "mouse" && ev.button !== 0)
|
|
30
|
-
return;
|
|
31
|
-
ev.preventDefault();
|
|
32
|
-
ev.stopPropagation();
|
|
33
|
-
const isRtl = sx.state.rtl.get();
|
|
34
|
-
let startX = null;
|
|
35
|
-
let anim = null;
|
|
36
|
-
const style = getComputedStyle(vp);
|
|
37
|
-
const overflow = style.overflowX;
|
|
38
|
-
vp.style.overflowX = "hidden";
|
|
39
|
-
const base = sx.state.columnBase.get();
|
|
40
|
-
const minWidth = cell.column.widthMin ?? base.widthMin ?? DEFAULT_COLUMN_WIDTH_MIN;
|
|
41
|
-
const maxWidth = cell.column.widthMax ?? base.widthMax ?? DEFAULT_COLUMN_WIDTH_MAX;
|
|
42
|
-
const maxDelta = maxWidth - width;
|
|
43
|
-
const minDelta = minWidth - width;
|
|
44
|
-
const deltaRef = { current: 0 };
|
|
45
|
-
const controller = new AbortController();
|
|
46
|
-
document.addEventListener("pointermove", (ev) => {
|
|
47
|
-
if (startX === null) {
|
|
48
|
-
startX = getClientX(ev);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const endAdjust = cell.colPin === "end" ? -1 : 1;
|
|
52
|
-
const rtlAdjust = isRtl ? -1 : 1;
|
|
53
|
-
deltaRef.current = clamp(minDelta, (getClientX(ev) - startX) * endAdjust * rtlAdjust, maxDelta);
|
|
54
|
-
if (anim)
|
|
55
|
-
return;
|
|
56
|
-
anim = requestAnimationFrame(() => {
|
|
57
|
-
const newWidth = width + deltaRef.current;
|
|
58
|
-
sx.api.columnResize({ [cell.id]: newWidth });
|
|
59
|
-
// TODO @Mike: the below method is a much faster, but potentially much tricky way to get resizing done. We should investigate
|
|
60
|
-
// the best approach to lever this. The main issues are around resizing group headers and ensuring column cells pinned to the
|
|
61
|
-
// end of the grid do not get shifted.
|
|
62
|
-
// const id = sx.state.gridId.get();
|
|
63
|
-
// const query = `[data-ln-row][data-ln-gridid="${id}"] [data-ln-cell="true"][data-ln-colindex="${cell.colStart}"]`;
|
|
64
|
-
// const headerQuery = `[data-ln-header-row] [data-ln-header-cell="true"][data-ln-header-id="${cell.id}"]`;
|
|
65
|
-
// const floatingQuery = `[data-ln-header-row] [data-ln-header-cell="true"][data-ln-header-id="${cell.id}"][data-ln-header-floating="true"]`;
|
|
66
|
-
// const header = vp.querySelector(headerQuery) as HTMLElement;
|
|
67
|
-
// const floating = vp.querySelector(floatingQuery) as HTMLElement | undefined;
|
|
68
|
-
// if (!header) return;
|
|
69
|
-
// const pin = header.getAttribute("data-ln-pin");
|
|
70
|
-
// const cells = Array.from(vp.querySelectorAll(query)) as HTMLElement[];
|
|
71
|
-
// const headers = [header];
|
|
72
|
-
// if (floating) headers.push(floating);
|
|
73
|
-
// headers.forEach((c) => {
|
|
74
|
-
// if (!isHTMLElement(c)) return;
|
|
75
|
-
// c.style.removeProperty("min-width");
|
|
76
|
-
// c.style.removeProperty("max-width");
|
|
77
|
-
// c.style.width = `${width + deltaRef.current}px`;
|
|
78
|
-
// if (pin === "end") {
|
|
79
|
-
// const viewportWidth = sx.state.viewportWidthInner.get();
|
|
80
|
-
// const spaceLeft = xPositions.at(-1)! - xPositions[cell.colStart];
|
|
81
|
-
// const x = viewportWidth - spaceLeft - deltaRef.current;
|
|
82
|
-
// c.style.transform = getTranslate(isRtl ? -x : x, 0);
|
|
83
|
-
// }
|
|
84
|
-
// });
|
|
85
|
-
// const widthPx = `${width + deltaRef.current}px`;
|
|
86
|
-
// cells.forEach((c) => {
|
|
87
|
-
// if (!isHTMLElement(c)) return;
|
|
88
|
-
// c.style.minWidth = widthPx;
|
|
89
|
-
// c.style.maxWidth = widthPx;
|
|
90
|
-
// c.style.width = widthPx;
|
|
91
|
-
// });
|
|
92
|
-
// const headerAfterQuery = `${headerQuery} ~ [data-ln-header-cell="true"]`;
|
|
93
|
-
// let after: HTMLElement[];
|
|
94
|
-
// if (pin !== "end") {
|
|
95
|
-
// after = Array.from(vp.querySelectorAll(headerAfterQuery)) as HTMLElement[];
|
|
96
|
-
// } else {
|
|
97
|
-
// after = [];
|
|
98
|
-
// }
|
|
99
|
-
// after.forEach((c) => {
|
|
100
|
-
// if (!isHTMLElement(c)) return;
|
|
101
|
-
// const thisPin = c.getAttribute("data-ln-pin");
|
|
102
|
-
// if (pin === "end" && thisPin === "end") return;
|
|
103
|
-
// if (pin !== "end" && thisPin === "end") return;
|
|
104
|
-
// const colindex = getColIndexFromEl(c);
|
|
105
|
-
// const transform = xPositions[colindex] + deltaRef.current;
|
|
106
|
-
// c.style.transform = getTranslate(transform * (isRtl ? -1 : 1), 0);
|
|
107
|
-
// });
|
|
108
|
-
anim = null;
|
|
109
|
-
});
|
|
110
|
-
}, { signal: controller.signal });
|
|
111
|
-
window.addEventListener("pointerup", () => {
|
|
112
|
-
if (anim)
|
|
113
|
-
cancelAnimationFrame(anim);
|
|
114
|
-
controller.abort();
|
|
115
|
-
vp.style.overflowX = overflow;
|
|
116
|
-
const newWidth = width + deltaRef.current;
|
|
117
|
-
sx.api.columnResize({ [cell.id]: newWidth });
|
|
118
|
-
}, { signal: controller.signal });
|
|
119
|
-
},
|
|
120
|
-
className,
|
|
121
|
-
style: {
|
|
122
|
-
height: "100%",
|
|
123
|
-
width: "6px",
|
|
124
|
-
...style,
|
|
125
|
-
top: "0px",
|
|
126
|
-
insetInlineEnd: cell.colPin !== "end" ? "0px" : undefined,
|
|
127
|
-
insetInlineStart: cell.colPin === "end" ? "0px" : undefined,
|
|
128
|
-
position: "absolute",
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
const edge = useSlot({
|
|
132
|
-
props: [defaultProps],
|
|
133
|
-
slot: as ?? _jsx("div", {}),
|
|
134
|
-
});
|
|
135
|
-
return edge;
|
|
136
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Grid, HeaderCellFloating, HeaderCellLayout, HeaderGroupCellLayout } from "../+types.js";
|
|
2
|
-
import { type JSX } from "react";
|
|
3
|
-
import type { InternalAtoms } from "../state/+types.js";
|
|
4
|
-
export declare function useDragMove<T>(grid: Grid<T> & {
|
|
5
|
-
internal: InternalAtoms;
|
|
6
|
-
}, cell: HeaderGroupCellLayout | HeaderCellLayout<T> | HeaderCellFloating<T>, onDragStart?: JSX.IntrinsicElements["div"]["onDragStart"]): {
|
|
7
|
-
draggable?: undefined;
|
|
8
|
-
onDragStart?: undefined;
|
|
9
|
-
ref?: undefined;
|
|
10
|
-
} | {
|
|
11
|
-
draggable: true;
|
|
12
|
-
onDragStart: (e: import("react").DragEvent<Element>) => void;
|
|
13
|
-
ref: any;
|
|
14
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { COLUMN_MARKER_ID, getHoveredColumnIndex, getNearestFocusable, GROUP_COLUMN_PREFIX, useDraggable, } from "@1771technologies/lytenyte-shared";
|
|
2
|
-
import { useMemo, useRef } from "react";
|
|
3
|
-
export function useDragMove(grid, cell, onDragStart) {
|
|
4
|
-
const ctx = grid.state;
|
|
5
|
-
const meta = ctx.columnMeta.useValue();
|
|
6
|
-
const base = ctx.columnBase.useValue();
|
|
7
|
-
const columns = useMemo(() => {
|
|
8
|
-
const columns = [];
|
|
9
|
-
for (let i = cell.colStart; i < cell.colEnd; i++) {
|
|
10
|
-
columns.push(meta.columnsVisible[i]);
|
|
11
|
-
}
|
|
12
|
-
return columns;
|
|
13
|
-
}, [cell.colEnd, cell.colStart, meta.columnsVisible]);
|
|
14
|
-
const isMovable = useMemo(() => {
|
|
15
|
-
return columns.every((c) => !c.id.startsWith(GROUP_COLUMN_PREFIX) &&
|
|
16
|
-
c.id !== COLUMN_MARKER_ID &&
|
|
17
|
-
(c.uiHints?.movable ?? base.uiHints?.movable ?? false));
|
|
18
|
-
}, [base.uiHints?.movable, columns]);
|
|
19
|
-
const swapDirection = useRef(null);
|
|
20
|
-
const swapIndex = useRef(-1);
|
|
21
|
-
const swapPrevIndex = useRef(-1);
|
|
22
|
-
const isForward = useRef(false);
|
|
23
|
-
const prevPos = useRef(-1);
|
|
24
|
-
const { dragProps } = useDraggable({
|
|
25
|
-
getItems: () => ({}),
|
|
26
|
-
onDragStart: () => {
|
|
27
|
-
if (cell.kind === "group")
|
|
28
|
-
grid.internal.draggingHeader.set(cell);
|
|
29
|
-
},
|
|
30
|
-
onDragEnd: () => {
|
|
31
|
-
grid.internal.draggingHeader.set(null);
|
|
32
|
-
},
|
|
33
|
-
onDragMove: (p) => {
|
|
34
|
-
const element = document.elementFromPoint(p.position.x, p.position.y);
|
|
35
|
-
const vp = grid.state.viewport.get();
|
|
36
|
-
if (!vp?.contains(element))
|
|
37
|
-
return;
|
|
38
|
-
const nearest = getNearestFocusable(element);
|
|
39
|
-
if (!nearest)
|
|
40
|
-
return;
|
|
41
|
-
if (prevPos.current < p.position.x)
|
|
42
|
-
isForward.current = true;
|
|
43
|
-
if (prevPos.current > p.position.x)
|
|
44
|
-
isForward.current = false;
|
|
45
|
-
prevPos.current = p.position.x;
|
|
46
|
-
const meta = grid.state.columnMeta.get();
|
|
47
|
-
const index = getHoveredColumnIndex({
|
|
48
|
-
viewport: vp,
|
|
49
|
-
centerCount: meta.columnVisibleCenterCount,
|
|
50
|
-
startCount: meta.columnVisibleStartCount,
|
|
51
|
-
endCount: meta.columnVisibleEndCount,
|
|
52
|
-
clientX: p.position.x,
|
|
53
|
-
rtl: grid.state.rtl.get(),
|
|
54
|
-
xPositions: grid.state.xPositions.get(),
|
|
55
|
-
});
|
|
56
|
-
if (index == null)
|
|
57
|
-
return;
|
|
58
|
-
const columnTarget = grid.api.columnByIndex(index);
|
|
59
|
-
if (columnTarget) {
|
|
60
|
-
if (columnTarget.id === COLUMN_MARKER_ID || columnTarget.id.startsWith(GROUP_COLUMN_PREFIX))
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const first = columns[0];
|
|
64
|
-
const currentIndex = grid.api.columnIndex(first);
|
|
65
|
-
const columnIndices = columns.map((c) => grid.api.columnIndex(c));
|
|
66
|
-
if (columnIndices.includes(index))
|
|
67
|
-
return;
|
|
68
|
-
const ignoreMove = swapDirection.current === isForward.current &&
|
|
69
|
-
swapIndex.current === currentIndex &&
|
|
70
|
-
index === swapPrevIndex.current;
|
|
71
|
-
if (currentIndex === index || ignoreMove)
|
|
72
|
-
return;
|
|
73
|
-
swapDirection.current = isForward.current;
|
|
74
|
-
swapIndex.current = index;
|
|
75
|
-
swapPrevIndex.current = currentIndex;
|
|
76
|
-
grid.api.columnMove({
|
|
77
|
-
moveColumns: columns,
|
|
78
|
-
moveTarget: index,
|
|
79
|
-
before: currentIndex > index,
|
|
80
|
-
updatePinState: true,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
const finalProps = useMemo(() => {
|
|
85
|
-
if (cell.kind === "floating" || !isMovable)
|
|
86
|
-
return {};
|
|
87
|
-
return {
|
|
88
|
-
draggable: true,
|
|
89
|
-
onDragStart: (e) => {
|
|
90
|
-
onDragStart?.(e);
|
|
91
|
-
dragProps.onDragStart(e);
|
|
92
|
-
},
|
|
93
|
-
ref: dragProps.ref,
|
|
94
|
-
};
|
|
95
|
-
}, [cell.kind, dragProps, isMovable, onDragStart]);
|
|
96
|
-
return finalProps;
|
|
97
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HeaderCellFloating, HeaderCellLayout, HeaderCellRendererParams } from "../+types";
|
|
2
|
-
declare function DefaultRenderer(p: HeaderCellRendererParams<any>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare function useHeaderCellRenderer<T>(cell: HeaderCellLayout<T> | HeaderCellFloating<T>): import("../+types").HeaderFloatingCellRendererFn<any> | import("../+types").HeaderCellRendererFn<T> | typeof DefaultRenderer;
|
|
4
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useGridRoot } from "../context.js";
|
|
4
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
5
|
-
function DefaultRenderer(p) {
|
|
6
|
-
return _jsx(_Fragment, { children: p.column.name ?? p.column.id });
|
|
7
|
-
}
|
|
8
|
-
export function useHeaderCellRenderer(cell) {
|
|
9
|
-
const ctx = useGridRoot().grid;
|
|
10
|
-
const base = ctx.state.columnBase.useValue();
|
|
11
|
-
const floatingRenderers = ctx.state.floatingCellRenderers.useValue();
|
|
12
|
-
const headerRenderers = ctx.state.headerCellRenderers.useValue();
|
|
13
|
-
return useMemo(() => {
|
|
14
|
-
if (cell.kind === "cell") {
|
|
15
|
-
const renderer = cell.column.headerRenderer ?? base.headerRenderer ?? DefaultRenderer;
|
|
16
|
-
if (typeof renderer === "string")
|
|
17
|
-
return headerRenderers[renderer] ?? DefaultRenderer;
|
|
18
|
-
else
|
|
19
|
-
return renderer;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
const renderer = cell.column.floatingCellRenderer ?? base.floatingCellRenderer ?? DefaultRenderer;
|
|
23
|
-
if (typeof renderer === "string")
|
|
24
|
-
return floatingRenderers[renderer] ?? DefaultRenderer;
|
|
25
|
-
else
|
|
26
|
-
return renderer;
|
|
27
|
-
}
|
|
28
|
-
}, [
|
|
29
|
-
base.floatingCellRenderer,
|
|
30
|
-
base.headerRenderer,
|
|
31
|
-
cell.column.floatingCellRenderer,
|
|
32
|
-
cell.column.headerRenderer,
|
|
33
|
-
cell.kind,
|
|
34
|
-
floatingRenderers,
|
|
35
|
-
headerRenderers,
|
|
36
|
-
]);
|
|
37
|
-
}
|
package/dist/root/root.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { RootProvider } from "../context.js";
|
|
4
|
-
import { DialogDriver } from "./dialog-driver.js";
|
|
5
|
-
import { PopoverDriver } from "./popover-driver.js";
|
|
6
|
-
import { CellSelectionDriver } from "../cell-selection/cell-selection-driver.js";
|
|
7
|
-
import { hasAValidLicense, licenseState } from "../license.js";
|
|
8
|
-
export function Root({ grid, children, ...events }) {
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (hasAValidLicense)
|
|
11
|
-
return;
|
|
12
|
-
const existing = document.getElementById("lng1771-watermark");
|
|
13
|
-
if (existing)
|
|
14
|
-
return;
|
|
15
|
-
const invalidLicenseWatermark = document.createElement("div");
|
|
16
|
-
invalidLicenseWatermark.style.position = "fixed";
|
|
17
|
-
invalidLicenseWatermark.style.bottom = "0px";
|
|
18
|
-
invalidLicenseWatermark.style.insetInlineEnd = "0px";
|
|
19
|
-
invalidLicenseWatermark.style.background = "rgb(255, 167, 167)";
|
|
20
|
-
invalidLicenseWatermark.style.color = "black";
|
|
21
|
-
invalidLicenseWatermark.style.fontSize = "1.2rem";
|
|
22
|
-
invalidLicenseWatermark.style.fontWeight = "bold";
|
|
23
|
-
invalidLicenseWatermark.style.border = "1px solid black";
|
|
24
|
-
invalidLicenseWatermark.style.padding = "16px";
|
|
25
|
-
if (licenseState === "expired")
|
|
26
|
-
invalidLicenseWatermark.innerHTML = `LyteNyte Grid: License key expired. Your license covers earlier versions only.`;
|
|
27
|
-
else if (licenseState === "invalid")
|
|
28
|
-
invalidLicenseWatermark.innerHTML = `LyteNyte Grid: Invalid license key. Please verify the key and try again.`;
|
|
29
|
-
else
|
|
30
|
-
invalidLicenseWatermark.innerHTML = `LyteNyte Grid PRO is being used for evaluation.
|
|
31
|
-
<a href="https://1771Technologies.com/pricing">Click here</a> to secure your license.`;
|
|
32
|
-
document.body.appendChild(invalidLicenseWatermark);
|
|
33
|
-
return () => invalidLicenseWatermark.remove();
|
|
34
|
-
}, []);
|
|
35
|
-
// Add event listeners in the standard react way
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const ev = Object.entries(events).map(([onName, fn]) => {
|
|
38
|
-
if (!onName.startsWith("on"))
|
|
39
|
-
return;
|
|
40
|
-
const name = onName[2].toLowerCase() + onName.slice(3);
|
|
41
|
-
return grid.api.eventAddListener(name, fn);
|
|
42
|
-
});
|
|
43
|
-
return () => ev.forEach((c) => c?.());
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
}, [Object.values(events)]);
|
|
46
|
-
const internal = grid.internal;
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
return internal.focusActive.watch(() => {
|
|
49
|
-
const editActive = internal.editActivePos.get();
|
|
50
|
-
if (!editActive)
|
|
51
|
-
return;
|
|
52
|
-
const focus = internal.focusActive.get();
|
|
53
|
-
if (focus?.kind !== "cell") {
|
|
54
|
-
grid.api.editEnd();
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if (grid.api.editIsCellActive({ rowIndex: focus.rowIndex, column: focus.colIndex }))
|
|
58
|
-
return;
|
|
59
|
-
grid.api.editEnd();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}, [grid.api, internal.editActivePos, internal.focusActive]);
|
|
63
|
-
const [vp, ref] = useState(null);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!vp)
|
|
66
|
-
return;
|
|
67
|
-
const controller = new AbortController();
|
|
68
|
-
vp.addEventListener("scroll", () => {
|
|
69
|
-
internal.xScroll.set(Math.abs(vp.scrollLeft));
|
|
70
|
-
internal.yScroll.set(vp.scrollTop);
|
|
71
|
-
}, { signal: controller.signal });
|
|
72
|
-
return () => controller.abort();
|
|
73
|
-
}, [internal.xScroll, internal.yScroll, vp]);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
grid.state.viewport.set(vp);
|
|
76
|
-
if (!vp)
|
|
77
|
-
return;
|
|
78
|
-
const obs = new ResizeObserver(() => {
|
|
79
|
-
grid.state.viewportHeightOuter.set(vp.offsetHeight);
|
|
80
|
-
grid.state.viewportWidthOuter.set(vp.offsetWidth);
|
|
81
|
-
grid.state.viewportWidthInner.set(vp.clientWidth);
|
|
82
|
-
grid.state.viewportHeightInner.set(vp.clientHeight);
|
|
83
|
-
});
|
|
84
|
-
grid.state.viewportHeightOuter.set(vp.offsetHeight);
|
|
85
|
-
grid.state.viewportWidthOuter.set(vp.offsetWidth);
|
|
86
|
-
grid.state.viewportWidthInner.set(vp.clientWidth);
|
|
87
|
-
grid.state.viewportHeightInner.set(vp.clientHeight);
|
|
88
|
-
obs.observe(vp);
|
|
89
|
-
return () => {
|
|
90
|
-
obs.disconnect();
|
|
91
|
-
};
|
|
92
|
-
}, [
|
|
93
|
-
grid.state.viewport,
|
|
94
|
-
grid.state.viewportHeightInner,
|
|
95
|
-
grid.state.viewportHeightOuter,
|
|
96
|
-
grid.state.viewportWidthInner,
|
|
97
|
-
grid.state.viewportWidthOuter,
|
|
98
|
-
vp,
|
|
99
|
-
]);
|
|
100
|
-
const value = useMemo(() => {
|
|
101
|
-
return {
|
|
102
|
-
ref,
|
|
103
|
-
grid: grid,
|
|
104
|
-
};
|
|
105
|
-
}, [grid]);
|
|
106
|
-
const cellSelectionMode = grid.state.cellSelectionMode.useValue();
|
|
107
|
-
return (_jsxs(RootProvider, { value: value, children: [_jsx(DialogDriver, {}), _jsx(PopoverDriver, {}), cellSelectionMode !== "none" && _jsx(CellSelectionDriver, {}), children] }));
|
|
108
|
-
}
|