@1771technologies/lytenyte-pro 1.0.0-beta.2 → 1.0.0-beta.21
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/+types.d.ts +80 -11
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.d.ts +1 -1
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +1 -1
- package/dist/cell-selection/are-rects-equal.d.ts +1 -1
- package/dist/cell-selection/bound-selection-rect.d.ts +1 -1
- package/dist/cell-selection/cell-selection-driver.js +9 -1
- package/dist/cell-selection/deselect-rect-range.d.ts +1 -1
- package/dist/cell-selection/deselect-rect-range.js +1 -1
- package/dist/cell-selection/expand-cell-selection-down.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-down.js +1 -1
- package/dist/cell-selection/expand-cell-selection-end.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-end.js +1 -1
- package/dist/cell-selection/expand-cell-selection-start.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-start.js +1 -1
- package/dist/cell-selection/expand-cell-selection-up.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-up.js +1 -1
- package/dist/cell-selection/full-width-start-end-index.d.ts +1 -1
- package/dist/cell-selection/get-root-cell.d.ts +1 -1
- package/dist/cell-selection/get-root-cell.js +2 -2
- package/dist/cell-selection/is-bottom-rect.d.ts +1 -1
- package/dist/cell-selection/is-center-col-rect.d.ts +1 -1
- package/dist/cell-selection/is-center-rect.d.ts +1 -1
- package/dist/cell-selection/is-end-rect.d.ts +1 -1
- package/dist/cell-selection/is-overlapping-rect.d.ts +1 -1
- package/dist/cell-selection/is-start-rect.d.ts +1 -1
- package/dist/cell-selection/is-top-rect.d.ts +1 -1
- package/dist/cell-selection/is-within-selection-rect.d.ts +1 -1
- package/dist/cell-selection/split-cell-selection-rect.d.ts +1 -1
- package/dist/cell-selection/update-additive-cell-selection.d.ts +2 -2
- package/dist/cell-selection/update-additive-cell-selection.js +4 -6
- package/dist/cell-selection/use-edge-scroll.d.ts +2 -2
- package/dist/cells/cell.js +3 -2
- package/dist/column-manager/branch.js +19 -3
- package/dist/column-manager/label.d.ts +1 -1
- package/dist/column-manager/label.js +2 -2
- package/dist/column-manager/leaf.js +21 -3
- package/dist/column-manager/move-handle.d.ts +1 -1
- package/dist/column-manager/move-handle.js +2 -2
- package/dist/column-manager/root.js +1 -1
- package/dist/column-manager/use-column-manager.d.ts +7 -3
- package/dist/column-manager/use-column-manager.js +3 -3
- package/dist/column-manager/use-columns-from-context.d.ts +2 -2
- package/dist/column-manager/use-columns-from-context.js +1 -1
- package/dist/column-manager/visibility-checkbox.d.ts +1 -1
- package/dist/column-manager/visibility-checkbox.js +2 -2
- package/dist/filter-tree/filter-tree.d.ts +7 -7
- package/dist/filter-tree/filter-tree.js +8 -8
- package/dist/filter-tree/hooks/use-tree-item.d.ts +2 -2
- package/dist/filter-tree/hooks/use-tree-item.js +2 -2
- package/dist/filter-tree/inclusion-checkbox.d.ts +1 -1
- package/dist/filter-tree/inclusion-checkbox.js +2 -2
- package/dist/filter-tree/label.d.ts +1 -1
- package/dist/filter-tree/label.js +2 -2
- package/dist/filter-tree/root.d.ts +3 -3
- package/dist/filter-tree/root.js +3 -3
- package/dist/grid-box/+types.d.ts +5 -3
- package/dist/grid-box/context.d.ts +1 -1
- package/dist/grid-box/item.d.ts +4 -1
- package/dist/grid-box/item.js +39 -9
- package/dist/grid-box/use-aggregation-box-items.d.ts +2 -2
- package/dist/grid-box/use-aggregation-box-items.js +3 -1
- package/dist/grid-box/use-column-box-items.d.ts +8 -4
- package/dist/grid-box/use-column-box-items.js +11 -14
- package/dist/grid-box/use-row-group-box-items.d.ts +4 -4
- package/dist/grid-box/use-row-group-box-items.js +14 -15
- package/dist/grid-provider/context.d.ts +2 -2
- package/dist/grid-provider/provider.d.ts +2 -2
- package/dist/grid-provider/provider.js +1 -1
- package/dist/grid-provider/use-grid.d.ts +2 -2
- package/dist/grid-provider/use-grid.js +1 -1
- package/dist/grid.d.ts +1 -12
- package/dist/grid.js +2 -12
- package/dist/header/header-cell.d.ts +1 -1
- package/dist/header/header-cell.js +2 -2
- package/dist/header/header-group-cell.js +3 -1
- package/dist/header/resize-handler.d.ts +2 -2
- package/dist/header/resize-handler.js +8 -3
- package/dist/header/use-drag-move.d.ts +2 -2
- package/dist/header/use-drag-move.js +9 -2
- package/dist/header/use-header-cell-renderer.js +4 -4
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/listbox/item.js +1 -1
- package/dist/row-data-source-client/built-ins/built-ins.d.ts +1 -1
- package/dist/row-data-source-client/built-ins/built-ins.js +1 -1
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
- package/dist/row-data-source-client/pivots/create-pivot-columns.js +2 -2
- package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +1 -1
- package/dist/row-data-source-client/tree/evaluator-group.d.ts +1 -1
- package/dist/row-data-source-client/tree/traverse.d.ts +1 -1
- package/dist/row-data-source-client/tree/traverse.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +4 -4
- package/dist/row-data-source-client/use-client-data-source-paginated.js +55 -26
- package/dist/row-data-source-client/use-client-data-source.d.ts +2 -2
- package/dist/row-data-source-client/use-client-data-source.js +56 -27
- package/dist/row-data-source-client/use-client-tree-data-source.d.ts +1 -1
- package/dist/row-data-source-client/use-client-tree-data-source.js +54 -25
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +1 -1
- package/dist/row-data-source-server/async-tree/make-async-tree.js +3 -3
- package/dist/row-data-source-server/use-server-data-source.d.ts +1 -1
- package/dist/row-data-source-server/use-server-data-source.js +8 -5
- package/dist/sort-manager/context.d.ts +3 -3
- package/dist/sort-manager/hooks/use-sort-manager.d.ts +2 -2
- package/dist/sort-manager/hooks/use-sort-manager.js +2 -2
- package/dist/sort-manager/hooks/use-sort-row-item.d.ts +1 -1
- package/dist/sort-manager/hooks/use-sort-row-item.js +1 -1
- package/dist/sort-manager/sort-add.d.ts +1 -1
- package/dist/sort-manager/sort-add.js +3 -3
- package/dist/sort-manager/sort-apply.d.ts +1 -1
- package/dist/sort-manager/sort-apply.js +3 -3
- package/dist/sort-manager/sort-cancel.d.ts +1 -1
- package/dist/sort-manager/sort-cancel.js +3 -3
- package/dist/sort-manager/sort-clear.d.ts +1 -1
- package/dist/sort-manager/sort-clear.js +3 -3
- package/dist/sort-manager/sort-column-select.d.ts +1 -1
- package/dist/sort-manager/sort-column-select.js +2 -2
- package/dist/sort-manager/sort-direction-select.d.ts +1 -1
- package/dist/sort-manager/sort-direction-select.js +2 -2
- package/dist/sort-manager/sort-remove.d.ts +1 -1
- package/dist/sort-manager/sort-remove.js +3 -3
- package/dist/sort-manager/sort-value-select.d.ts +1 -1
- package/dist/sort-manager/sort-value-select.js +2 -2
- package/dist/sort-manager/utils/sort-item-to-sort-model.d.ts +1 -1
- package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +1 -1
- package/dist/state/+types.d.ts +2 -1
- package/dist/state/api/column-autosize.d.ts +1 -1
- package/dist/state/api/column-autosize.js +2 -2
- package/dist/state/api/column-move.js +1 -1
- package/dist/state/api/column-update.d.ts +4 -1
- package/dist/state/api/column-update.js +13 -0
- package/dist/state/api/dialog-frame.d.ts +1 -1
- package/dist/state/api/edit-begin.d.ts +1 -1
- package/dist/state/api/edit-begin.js +1 -1
- package/dist/state/api/edit-end.d.ts +1 -1
- package/dist/state/api/edit-is-cell-active.d.ts +1 -1
- package/dist/state/api/edit-update.d.ts +1 -1
- package/dist/state/api/edit-update.js +1 -1
- package/dist/state/api/export-csv.js +1 -1
- package/dist/state/api/export-data-rect.js +1 -1
- package/dist/state/api/focus-cell.d.ts +1 -1
- package/dist/state/api/popover-frame.d.ts +2 -2
- package/dist/state/api/row-detail-rendered-height.d.ts +2 -2
- package/dist/state/helpers/column-add-row-group.d.ts +2 -1
- package/dist/state/helpers/column-add-row-group.js +9 -1
- package/dist/state/helpers/column-marker.js +1 -1
- package/dist/state/helpers/empty-row-data-source.js +1 -0
- package/dist/state/helpers/resolve-column.d.ts +1 -1
- package/dist/state/helpers/resolve-column.js +7 -0
- package/dist/state/use-lytenyte.js +5 -0
- package/dist/tree-view/leaf.js +1 -0
- package/package.json +12 -6
package/dist/grid.js
CHANGED
|
@@ -4,11 +4,8 @@ import { HeaderCell } from "./header/header-cell";
|
|
|
4
4
|
import { HeaderGroupCell } from "./header/header-group-cell";
|
|
5
5
|
import { HeaderRow } from "./header/header-row";
|
|
6
6
|
import { Root } from "./root/root";
|
|
7
|
-
import { makeClientDataSource, useClientRowDataSource, } from "./row-data-source-client/use-client-data-source";
|
|
8
|
-
import { makeClientDataSourcePaginated, useClientRowDataSourcePaginated, } from "./row-data-source-client/use-client-data-source-paginated";
|
|
9
|
-
import { makeClientTreeDataSource, useClientTreeDataSource, } from "./row-data-source-client/use-client-tree-data-source";
|
|
10
|
-
import { makeServerDataSource, useServerDataSource, } from "./row-data-source-server/use-server-data-source";
|
|
11
7
|
import { RowFullWidth } from "./rows/row-full-width";
|
|
8
|
+
import { Row } from "./rows/row/row";
|
|
12
9
|
import { RowsContainer } from "./rows/rows-container";
|
|
13
10
|
import { RowsBottom, RowsCenter, RowsTop } from "./rows/rows-sections";
|
|
14
11
|
import { useLyteNyte } from "./state/use-lytenyte";
|
|
@@ -24,15 +21,8 @@ export const Grid = {
|
|
|
24
21
|
RowsContainer,
|
|
25
22
|
RowsBottom,
|
|
26
23
|
RowsTop,
|
|
24
|
+
Row,
|
|
27
25
|
RowsCenter,
|
|
28
26
|
Viewport,
|
|
29
27
|
useLyteNyte,
|
|
30
|
-
useClientRowDataSource,
|
|
31
|
-
makeClientDataSource,
|
|
32
|
-
makeClientDataSourcePaginated,
|
|
33
|
-
useClientRowDataSourcePaginated,
|
|
34
|
-
useClientTreeDataSource,
|
|
35
|
-
makeClientTreeDataSource,
|
|
36
|
-
makeServerDataSource,
|
|
37
|
-
useServerDataSource,
|
|
38
28
|
};
|
|
@@ -3,7 +3,7 @@ import type { HeaderCellFloating, HeaderCellLayout } from "../+types";
|
|
|
3
3
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
4
4
|
export interface HeaderCellProps<T> {
|
|
5
5
|
readonly cell: HeaderCellLayout<T> | HeaderCellFloating<T>;
|
|
6
|
-
readonly
|
|
6
|
+
readonly resizerAs?: SlotComponent;
|
|
7
7
|
readonly resizerClassName?: string;
|
|
8
8
|
readonly resizerStyle?: CSSProperties;
|
|
9
9
|
}
|
|
@@ -6,7 +6,7 @@ import { fastDeepMemo, useCombinedRefs, } from "@1771technologies/lytenyte-react
|
|
|
6
6
|
import { useHeaderCellRenderer } from "./use-header-cell-renderer";
|
|
7
7
|
import { ResizeHandler } from "./resize-handler";
|
|
8
8
|
import { useDragMove } from "./use-drag-move";
|
|
9
|
-
const HeaderCellImpl = forwardRef(function HeaderCell({ cell,
|
|
9
|
+
const HeaderCellImpl = forwardRef(function HeaderCell({ cell, resizerAs, resizerStyle, resizerClassName, children, ...props }, forwarded) {
|
|
10
10
|
const grid = useGridRoot().grid;
|
|
11
11
|
const ctx = grid.state;
|
|
12
12
|
const xPositions = ctx.xPositions.useValue();
|
|
@@ -19,6 +19,6 @@ const HeaderCellImpl = forwardRef(function HeaderCell({ cell, resizerSlot, resiz
|
|
|
19
19
|
: (cell.column.uiHints?.resizable ?? base.uiHints?.resizable ?? false);
|
|
20
20
|
const { ref, ...dragProps } = useDragMove(grid, cell, props.onDragStart);
|
|
21
21
|
const combined = useCombinedRefs(forwarded, ref);
|
|
22
|
-
return (_jsxs(HeaderCellReact, { ...props, ...dragProps, ref: combined, cell: cell, columnId: cell.column.id, viewportWidth: viewport, isFloating: cell.kind === "floating", rtl: rtl, xPositions: xPositions, children: [children == undefined ? _jsx(Renderer, { column: cell.column, grid: grid }) : children, resizable && cell.kind === "cell" && (_jsx(ResizeHandler, { cell: cell, xPositions: xPositions,
|
|
22
|
+
return (_jsxs(HeaderCellReact, { ...props, ...dragProps, ref: combined, cell: cell, columnId: cell.column.id, viewportWidth: viewport, isFloating: cell.kind === "floating", rtl: rtl, 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 }))] }));
|
|
23
23
|
});
|
|
24
24
|
export const HeaderCell = fastDeepMemo(HeaderCellImpl);
|
|
@@ -9,6 +9,8 @@ const HeaderGroupCellImpl = forwardRef(function HeaderCell({ cell, children, ...
|
|
|
9
9
|
const ctx = grid.state;
|
|
10
10
|
const { ref, ...dragProps } = useDragMove(grid, cell, props.onDragStart);
|
|
11
11
|
const combined = useCombinedRefs(ref, forwarded);
|
|
12
|
-
|
|
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(), rtl: ctx.rtl.useValue(), viewportWidth: ctx.viewportWidthInner.useValue(), xPositions: ctx.xPositions.useValue(), isHiddenMove: cell.isHiddenMove ?? false, "data-ln-collapsible": cell.isCollapsible, "data-ln-collapsed": !isExpanded, children: children == undefined ? cell.id : children }));
|
|
13
15
|
});
|
|
14
16
|
export const HeaderGroupCell = fastDeepMemo(HeaderGroupCellImpl);
|
|
@@ -2,11 +2,11 @@ import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
|
2
2
|
import type { HeaderCellLayout } from "../+types";
|
|
3
3
|
import { type CSSProperties } from "react";
|
|
4
4
|
interface ResizeHandlerProps<T> {
|
|
5
|
-
readonly
|
|
5
|
+
readonly as?: SlotComponent;
|
|
6
6
|
readonly cell: HeaderCellLayout<T>;
|
|
7
7
|
readonly xPositions: Uint32Array;
|
|
8
8
|
readonly className?: string;
|
|
9
9
|
readonly style?: CSSProperties;
|
|
10
10
|
}
|
|
11
|
-
export declare function ResizeHandler<T>({
|
|
11
|
+
export declare function ResizeHandler<T>({ as, cell, xPositions, style, className, }: ResizeHandlerProps<T>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
12
|
export {};
|
|
@@ -5,12 +5,13 @@ import { DEFAULT_COLUMN_WIDTH_MAX, DEFAULT_COLUMN_WIDTH_MIN, getColIndexFromEl,
|
|
|
5
5
|
import { useGridRoot } from "../context";
|
|
6
6
|
import { getComputedStyle, isHTMLElement } from "@1771technologies/lytenyte-dom-utils";
|
|
7
7
|
import { clamp, getClientX } from "@1771technologies/lytenyte-js-utils";
|
|
8
|
-
export function ResizeHandler({
|
|
8
|
+
export function ResizeHandler({ as, cell, xPositions, style, className, }) {
|
|
9
9
|
const width = sizeFromCoord(cell.colStart, xPositions, cell.colSpan);
|
|
10
10
|
const sx = useGridRoot().grid;
|
|
11
11
|
const double = sx.state.columnDoubleClickToAutosize.useValue();
|
|
12
12
|
const defaultProps = {
|
|
13
13
|
role: "button",
|
|
14
|
+
"data-ln-header-resizer": "true",
|
|
14
15
|
"aria-label": `Resize ${cell.column.name ?? cell.column.id}`,
|
|
15
16
|
tabIndex: -1,
|
|
16
17
|
onDoubleClick: () => {
|
|
@@ -56,7 +57,9 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
56
57
|
const id = sx.state.gridId.get();
|
|
57
58
|
const query = `[data-ln-row][data-ln-gridid="${id}"] [data-ln-cell="true"][data-ln-colindex="${cell.colStart}"]`;
|
|
58
59
|
const headerQuery = `[data-ln-header-row] [data-ln-header-cell="true"][data-ln-header-id="${cell.id}"]`;
|
|
60
|
+
const floatingQuery = `[data-ln-header-row] [data-ln-header-cell="true"][data-ln-header-id="${cell.id}"][data-ln-header-floating="true"]`;
|
|
59
61
|
const header = vp.querySelector(headerQuery);
|
|
62
|
+
const floating = vp.querySelector(floatingQuery);
|
|
60
63
|
if (!header)
|
|
61
64
|
return;
|
|
62
65
|
const pin = header.getAttribute("data-ln-pin");
|
|
@@ -71,6 +74,8 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
71
74
|
}
|
|
72
75
|
const q = Array.from(vp.querySelectorAll(query));
|
|
73
76
|
q.push(header);
|
|
77
|
+
if (floating)
|
|
78
|
+
q.push(floating);
|
|
74
79
|
q.forEach((c) => {
|
|
75
80
|
if (!isHTMLElement(c))
|
|
76
81
|
return;
|
|
@@ -112,7 +117,7 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
112
117
|
className,
|
|
113
118
|
style: {
|
|
114
119
|
height: "100%",
|
|
115
|
-
width: "
|
|
120
|
+
width: "6px",
|
|
116
121
|
...style,
|
|
117
122
|
top: "0px",
|
|
118
123
|
insetInlineEnd: cell.colPin !== "end" ? "0px" : undefined,
|
|
@@ -122,7 +127,7 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
122
127
|
};
|
|
123
128
|
const edge = useSlot({
|
|
124
129
|
props: [defaultProps],
|
|
125
|
-
slot:
|
|
130
|
+
slot: as ?? _jsx("div", {}),
|
|
126
131
|
});
|
|
127
132
|
return edge;
|
|
128
133
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Grid, HeaderCellFloating, HeaderCellLayout, HeaderGroupCellLayout } from "../+types";
|
|
1
|
+
import type { Grid, HeaderCellFloating, HeaderCellLayout, HeaderGroupCellLayout } from "../+types.js";
|
|
2
2
|
import { type JSX } from "react";
|
|
3
|
-
import type { InternalAtoms } from "../state/+types";
|
|
3
|
+
import type { InternalAtoms } from "../state/+types.js";
|
|
4
4
|
export declare function useDragMove<T>(grid: Grid<T> & {
|
|
5
5
|
internal: InternalAtoms;
|
|
6
6
|
}, cell: HeaderGroupCellLayout | HeaderCellLayout<T> | HeaderCellFloating<T>, onDragStart?: JSX.IntrinsicElements["div"]["onDragStart"]): {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getHoveredColumnIndex, getNearestFocusable, useDraggable, } from "@1771technologies/lytenyte-shared";
|
|
1
|
+
import { COLUMN_MARKER_ID, getHoveredColumnIndex, getNearestFocusable, GROUP_COLUMN_PREFIX, useDraggable, } from "@1771technologies/lytenyte-shared";
|
|
2
2
|
import { useMemo, useRef } from "react";
|
|
3
3
|
export function useDragMove(grid, cell, onDragStart) {
|
|
4
4
|
const ctx = grid.state;
|
|
@@ -12,7 +12,9 @@ export function useDragMove(grid, cell, onDragStart) {
|
|
|
12
12
|
return columns;
|
|
13
13
|
}, [cell.colEnd, cell.colStart, meta.columnsVisible]);
|
|
14
14
|
const isMovable = useMemo(() => {
|
|
15
|
-
return columns.every((c) => c.
|
|
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));
|
|
16
18
|
}, [base.uiHints?.movable, columns]);
|
|
17
19
|
const swapDirection = useRef(null);
|
|
18
20
|
const swapIndex = useRef(-1);
|
|
@@ -53,6 +55,11 @@ export function useDragMove(grid, cell, onDragStart) {
|
|
|
53
55
|
});
|
|
54
56
|
if (index == null)
|
|
55
57
|
return;
|
|
58
|
+
const columnTarget = grid.api.columnFromIndex(index);
|
|
59
|
+
if (columnTarget) {
|
|
60
|
+
if (columnTarget.id === COLUMN_MARKER_ID || columnTarget.id.startsWith(GROUP_COLUMN_PREFIX))
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
56
63
|
const first = columns[0];
|
|
57
64
|
const currentIndex = grid.api.columnIndex(first);
|
|
58
65
|
const columnIndices = columns.map((c) => grid.api.columnIndex(c));
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { useGridRoot } from "../context";
|
|
4
4
|
function DefaultRenderer(p) {
|
|
5
|
-
return _jsx(_Fragment, { children: p.column.id });
|
|
5
|
+
return _jsx(_Fragment, { children: p.column.name ?? p.column.id });
|
|
6
6
|
}
|
|
7
7
|
export function useHeaderCellRenderer(cell) {
|
|
8
8
|
const ctx = useGridRoot().grid;
|
|
@@ -18,16 +18,16 @@ export function useHeaderCellRenderer(cell) {
|
|
|
18
18
|
return renderer;
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
const renderer = cell.column.
|
|
21
|
+
const renderer = cell.column.floatingCellRenderer ?? base.floatingCellRenderer ?? DefaultRenderer;
|
|
22
22
|
if (typeof renderer === "string")
|
|
23
23
|
return floatingRenderers[renderer] ?? DefaultRenderer;
|
|
24
24
|
else
|
|
25
25
|
return renderer;
|
|
26
26
|
}
|
|
27
27
|
}, [
|
|
28
|
-
base.
|
|
28
|
+
base.floatingCellRenderer,
|
|
29
29
|
base.headerRenderer,
|
|
30
|
-
cell.column.
|
|
30
|
+
cell.column.floatingCellRenderer,
|
|
31
31
|
cell.column.headerRenderer,
|
|
32
32
|
cell.kind,
|
|
33
33
|
floatingRenderers,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AddIcon, AddSmallIcon, AggregateIcon, AggregationIcon, ArchiveIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightCurvedIcon, ArrowRightIcon, ArrowUpIcon, AutosizeIcon, BackIcon, BookmarkIcon, BooleanIcon, CalendarIcon, ChartIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, Close2Icon, CloseIcon, CollapseGroupIcon, Columns2Icon, ColumnsIcon, CopyIcon, CornerRadiusIcon, CustomizeThemeIcon, CutIcon, CsvIcon, DeleteIcon, DocsIcon, DownloadIcon, Drag2Icon, DragDotsIcon, DragDotsSmallIcon, DragIcon, DuplicateIcon, EditIcon, EmailIcon, ExcelIcon, ExpandGroupIcon, ExpandIcon, Expression2Icon, ExpressionIcon, ExternalLinkIcon, File2Icon, FileIcon, FilterIcon, FolderIcon, GlobeIcon, GridViewIcon, GroupByColIcon, HamburgerIcon, HelpIcon, HiddenIcon, HistoryIcon, ImportIcon, LinkIcon, ListViewIcon, LoadingIcon, LocationIcon, ModalIcon, MoreIcon, MoreVerticalIcon, MultilineIcon, NumberIcon, PasteIcon, PieIcon, PinColumnIcon, RefreshIcon, SearchIcon, SettingsIcon, ShareIcon, SingleLineIcon, Sort2Icon, SortIcon, SpacingHIcon, SpacingIcon, StickColumnIcon, SwapIcon, TagIcon, TaskIcon, TextIcon, ThemesIcon, Tickmark2Icon, TickmarkIcon, TimeIcon, UploadIcon, UserIcon, ViewIcon, } from "@1771technologies/lytenyte-core/icons";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AddIcon, AddSmallIcon, AggregateIcon, AggregationIcon, ArchiveIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightCurvedIcon, ArrowRightIcon, ArrowUpIcon, AutosizeIcon, BackIcon, BookmarkIcon, BooleanIcon, CalendarIcon, ChartIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, Close2Icon, CloseIcon, CollapseGroupIcon, Columns2Icon, ColumnsIcon, CopyIcon, CornerRadiusIcon, CustomizeThemeIcon, CutIcon, CsvIcon, DeleteIcon, DocsIcon, DownloadIcon, Drag2Icon, DragDotsIcon, DragDotsSmallIcon, DragIcon, DuplicateIcon, EditIcon, EmailIcon, ExcelIcon, ExpandGroupIcon, ExpandIcon, Expression2Icon, ExpressionIcon, ExternalLinkIcon, File2Icon, FileIcon, FilterIcon, FolderIcon, GlobeIcon, GridViewIcon, GroupByColIcon, HamburgerIcon, HelpIcon, HiddenIcon, HistoryIcon, ImportIcon, LinkIcon, ListViewIcon, LoadingIcon, LocationIcon, ModalIcon, MoreIcon, MoreVerticalIcon, MultilineIcon, NumberIcon, PasteIcon, PieIcon, PinColumnIcon, RefreshIcon, SearchIcon, SettingsIcon, ShareIcon, SingleLineIcon, Sort2Icon, SortIcon, SpacingHIcon, SpacingIcon, StickColumnIcon, SwapIcon, TagIcon, TaskIcon, TextIcon, ThemesIcon, Tickmark2Icon, TickmarkIcon, TimeIcon, UploadIcon, UserIcon, ViewIcon, } from "@1771technologies/lytenyte-core/icons";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,8 @@ export { FilterTree } from "./filter-tree/filter-tree.js";
|
|
|
4
4
|
export { ColumnManager } from "./column-manager/column-manager.js";
|
|
5
5
|
export { GridBox } from "./grid-box/grid-box.js";
|
|
6
6
|
export { activateLicense } from "./license.js";
|
|
7
|
+
export { measureText } from "@1771technologies/lytenyte-shared";
|
|
8
|
+
export { makeClientDataSource, useClientRowDataSource, } from "./row-data-source-client/use-client-data-source";
|
|
9
|
+
export { makeClientDataSourcePaginated, useClientRowDataSourcePaginated, } from "./row-data-source-client/use-client-data-source-paginated";
|
|
10
|
+
export { makeClientTreeDataSource, useClientTreeDataSource, } from "./row-data-source-client/use-client-tree-data-source";
|
|
11
|
+
export { makeServerDataSource, useServerDataSource, } from "./row-data-source-server/use-server-data-source";
|
package/dist/index.js
CHANGED
|
@@ -4,3 +4,8 @@ export { FilterTree } from "./filter-tree/filter-tree.js";
|
|
|
4
4
|
export { ColumnManager } from "./column-manager/column-manager.js";
|
|
5
5
|
export { GridBox } from "./grid-box/grid-box.js";
|
|
6
6
|
export { activateLicense } from "./license.js";
|
|
7
|
+
export { measureText } from "@1771technologies/lytenyte-shared";
|
|
8
|
+
export { makeClientDataSource, useClientRowDataSource, } from "./row-data-source-client/use-client-data-source";
|
|
9
|
+
export { makeClientDataSourcePaginated, useClientRowDataSourcePaginated, } from "./row-data-source-client/use-client-data-source-paginated";
|
|
10
|
+
export { makeClientTreeDataSource, useClientTreeDataSource, } from "./row-data-source-client/use-client-tree-data-source";
|
|
11
|
+
export { makeServerDataSource, useServerDataSource, } from "./row-data-source-server/use-server-data-source";
|
package/dist/listbox/item.js
CHANGED
|
@@ -9,6 +9,7 @@ export const Item = forwardRef(function Item(props, forwarded) {
|
|
|
9
9
|
const prev = ctx.rtl ? "ArrowRight" : "ArrowLeft";
|
|
10
10
|
if (ev.key !== next && ev.key !== prev)
|
|
11
11
|
return;
|
|
12
|
+
ev.preventDefault();
|
|
12
13
|
const items = getTabbables(ev.currentTarget);
|
|
13
14
|
if (!items.length)
|
|
14
15
|
return;
|
|
@@ -18,7 +19,6 @@ export const Item = forwardRef(function Item(props, forwarded) {
|
|
|
18
19
|
const itemToFocus = items[nextIndex];
|
|
19
20
|
if (!itemToFocus)
|
|
20
21
|
return;
|
|
21
|
-
ev.preventDefault();
|
|
22
22
|
ev.stopPropagation();
|
|
23
23
|
itemToFocus.focus();
|
|
24
24
|
}, ref: forwarded, tabIndex: 0, "data-ln-listbox-item": true }));
|
|
@@ -10,7 +10,7 @@ import { sum } from "./sum.js";
|
|
|
10
10
|
* Collection of built-in array utility functions for numerical and statistical operations.
|
|
11
11
|
* Each function handles null and undefined values gracefully.
|
|
12
12
|
* @example
|
|
13
|
-
* import { builtIns } from './builtIns';
|
|
13
|
+
* import { builtIns } from './builtIns.js';
|
|
14
14
|
*
|
|
15
15
|
* const data = [1, null, 3, 2];
|
|
16
16
|
* builtIns.sum(data); // Returns 6
|
|
@@ -10,7 +10,7 @@ import { sum } from "./sum.js";
|
|
|
10
10
|
* Collection of built-in array utility functions for numerical and statistical operations.
|
|
11
11
|
* Each function handles null and undefined values gracefully.
|
|
12
12
|
* @example
|
|
13
|
-
* import { builtIns } from './builtIns';
|
|
13
|
+
* import { builtIns } from './builtIns.js';
|
|
14
14
|
*
|
|
15
15
|
* const data = [1, null, 3, 2];
|
|
16
16
|
* builtIns.sum(data); // Returns 6
|
|
@@ -22,7 +22,7 @@ export function computeFilteredRows(rows, grid, filterModel, filterInModel, quic
|
|
|
22
22
|
const pass = nonIgnored.some((c) => {
|
|
23
23
|
const field = `${grid.api.columnField(c, { data: row.data, kind: "leaf" })}`;
|
|
24
24
|
if (sensitivity === "case-insensitive")
|
|
25
|
-
field.toLowerCase().includes(quickSearch.toLowerCase());
|
|
25
|
+
return field.toLowerCase().includes(quickSearch.toLowerCase());
|
|
26
26
|
return field.includes(quickSearch);
|
|
27
27
|
});
|
|
28
28
|
if (!pass)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createColumnPivotsFromPaths } from "./create-pivot-columns-from-paths";
|
|
2
|
-
import { createPivotTree } from "./create-pivot-tree";
|
|
1
|
+
import { createColumnPivotsFromPaths } from "./create-pivot-columns-from-paths.js";
|
|
2
|
+
import { createPivotTree } from "./create-pivot-tree.js";
|
|
3
3
|
export function createPivotColumns(model, lookup, grid, leafRows) {
|
|
4
4
|
const activeColumns = model.columns.filter((c) => lookup.has(c.field) && (c.active ?? true));
|
|
5
5
|
const activeValues = model.values.filter((c) => lookup.has(c.field) && (c.active ?? true));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AggregationItem } from "../+types";
|
|
1
|
+
import type { AggregationItem } from "../+types.js";
|
|
2
2
|
export declare function aggregationEvaluator<Data>(agg: AggregationItem<Data>[], data: Data[]): Record<string, unknown>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { GroupItem } from "../+types";
|
|
1
|
+
import type { GroupItem } from "../+types.js";
|
|
2
2
|
export declare function groupEvaluator<Data>(g: GroupItem<Data>[] | ((d: Data) => (string | null | undefined)[]), d: Data): (string | null | undefined)[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BranchNode, Root, TreeNode } from "../+types";
|
|
1
|
+
import type { BranchNode, Root, TreeNode } from "../+types.js";
|
|
2
2
|
export declare function traverse<Data>(root: Root<Data> | BranchNode<Data>, fn: (node: TreeNode<Data>, lookupKey: string | null) => boolean | void, comparator?: (l: TreeNode<Data>, r: TreeNode<Data>) => number): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { GridAtom, RowDataSourceClientPaginated } from "../+types";
|
|
2
|
-
import { type
|
|
1
|
+
import type { GridAtom, RowDataSourceClientPaginated } from "../+types.js";
|
|
2
|
+
import { type ClientRowDataSourcePaginatedParams } from "../+types.js";
|
|
3
3
|
interface DataAtoms<T> {
|
|
4
4
|
readonly top: GridAtom<T[]>;
|
|
5
5
|
readonly center: GridAtom<T[]>;
|
|
6
6
|
readonly bottom: GridAtom<T[]>;
|
|
7
7
|
}
|
|
8
|
-
export declare function makeClientDataSourcePaginated<T>(p:
|
|
9
|
-
export declare function useClientRowDataSourcePaginated<T>(p:
|
|
8
|
+
export declare function makeClientDataSourcePaginated<T>(p: ClientRowDataSourcePaginatedParams<T>): [RowDataSourceClientPaginated<T>, DataAtoms<T>];
|
|
9
|
+
export declare function useClientRowDataSourcePaginated<T>(p: ClientRowDataSourcePaginatedParams<T>): RowDataSourceClientPaginated<T>;
|
|
10
10
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {} from "../+types";
|
|
1
|
+
import {} from "../+types.js";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { atom, createStore } from "@1771technologies/atom";
|
|
4
|
-
import { traverse } from "./tree/traverse";
|
|
4
|
+
import { traverse } from "./tree/traverse.js";
|
|
5
5
|
import { dateComparator, makeGridAtom, numberComparator, stringComparator, } from "@1771technologies/lytenyte-shared";
|
|
6
6
|
import { clamp, equal, get } from "@1771technologies/lytenyte-js-utils";
|
|
7
|
-
import { makeClientTree } from "./tree/client-tree";
|
|
8
|
-
import { computeFilteredRows } from "./filter/compute-filtered-rows";
|
|
9
|
-
import { builtIns } from "./built-ins/built-ins";
|
|
7
|
+
import { makeClientTree } from "./tree/client-tree.js";
|
|
8
|
+
import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
|
|
9
|
+
import { builtIns } from "./built-ins/built-ins.js";
|
|
10
10
|
export function makeClientDataSourcePaginated(p) {
|
|
11
11
|
const rdsStore = createStore();
|
|
12
12
|
const pageInternal = atom(0);
|
|
13
|
-
const rowsPerPage = atom(50);
|
|
13
|
+
const rowsPerPage = atom(p.rowsPerPage ?? 50);
|
|
14
14
|
const pageCount = atom((g) => Math.max(Math.ceil(g(flatLength) / g(rowsPerPage)), 1));
|
|
15
15
|
const page = atom((g) => clamp(0, g(pageInternal), g(pageCount) - 1), (g, s, n) => {
|
|
16
16
|
const res = typeof n === "function" ? n(g(pageInternal)) : n;
|
|
@@ -19,6 +19,9 @@ export function makeClientDataSourcePaginated(p) {
|
|
|
19
19
|
const data = atom(p.data);
|
|
20
20
|
const topData = atom(p.topData ?? []);
|
|
21
21
|
const bottomData = atom(p.bottomData ?? []);
|
|
22
|
+
const dataToSrc$ = atom((g) => {
|
|
23
|
+
return new Map(g(data).map((c, i) => [c, i]));
|
|
24
|
+
});
|
|
22
25
|
const cache = new Map();
|
|
23
26
|
const centerNodes = atom((g) => {
|
|
24
27
|
const nodes = [];
|
|
@@ -149,6 +152,13 @@ export function makeClientDataSourcePaginated(p) {
|
|
|
149
152
|
};
|
|
150
153
|
return comparator;
|
|
151
154
|
});
|
|
155
|
+
const idToNode = atom((g) => {
|
|
156
|
+
const map = new Map();
|
|
157
|
+
traverse(g(tree).root, (node) => {
|
|
158
|
+
map.set(node.id, node);
|
|
159
|
+
});
|
|
160
|
+
return map;
|
|
161
|
+
});
|
|
152
162
|
const initialized = atom(false);
|
|
153
163
|
const flat = atom((g) => {
|
|
154
164
|
if (!g(initialized))
|
|
@@ -299,30 +309,32 @@ export function makeClientDataSourcePaginated(p) {
|
|
|
299
309
|
};
|
|
300
310
|
const rowUpdate = (updates) => {
|
|
301
311
|
const grid = rdsStore.get(grid$);
|
|
302
|
-
const t = rdsStore.get(tree);
|
|
303
312
|
const d = rdsStore.get(data);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
313
|
+
const idMap = rdsStore.get(idToNode);
|
|
314
|
+
const dataToSrc = rdsStore.get(dataToSrc$);
|
|
315
|
+
for (const [key, next] of updates.entries()) {
|
|
316
|
+
const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
|
|
317
|
+
const treeNode = typeof key === "string" ? idMap.get(key) : null;
|
|
318
|
+
if ((!row && !treeNode) || !grid) {
|
|
319
|
+
console.error(`Failed to find the row with identifier ${key} which is being updated.`);
|
|
309
320
|
continue;
|
|
310
321
|
}
|
|
311
|
-
if (row
|
|
312
|
-
row.data =
|
|
322
|
+
if (row?.kind === "branch") {
|
|
323
|
+
row.data = next;
|
|
313
324
|
}
|
|
314
325
|
else {
|
|
315
|
-
const
|
|
326
|
+
const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
|
|
327
|
+
const source = dataToSrc.get(data);
|
|
316
328
|
if (source == null) {
|
|
317
|
-
console.error(`Failed to find the row
|
|
329
|
+
console.error(`Failed to find the row with identifier ${key} which is being updated.`);
|
|
318
330
|
continue;
|
|
319
331
|
}
|
|
320
|
-
d[source] =
|
|
332
|
+
d[source] = next;
|
|
321
333
|
}
|
|
322
|
-
grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
|
|
323
334
|
}
|
|
324
335
|
rdsStore.set(data, [...d]);
|
|
325
336
|
rdsStore.set(snapshot, (prev) => prev + 1);
|
|
337
|
+
grid.state.rowDataStore.rowClearCache();
|
|
326
338
|
};
|
|
327
339
|
const rowToIndex = (rowId) => {
|
|
328
340
|
const f = rdsStore.get(flat);
|
|
@@ -375,11 +387,10 @@ export function makeClientDataSourcePaginated(p) {
|
|
|
375
387
|
const field = grid.api.columnField(c, row);
|
|
376
388
|
return field;
|
|
377
389
|
}));
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
});
|
|
390
|
+
if (p.transformInFilterItem) {
|
|
391
|
+
return p.transformInFilterItem({ column: c, values: [...values] });
|
|
392
|
+
}
|
|
393
|
+
return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
|
|
383
394
|
},
|
|
384
395
|
rowAreAllSelected: (rowId) => {
|
|
385
396
|
const g = rdsStore.get(grid$);
|
|
@@ -436,11 +447,29 @@ export function makeClientDataSourcePaginated(p) {
|
|
|
436
447
|
const grid = rdsStore.get(grid$);
|
|
437
448
|
grid?.state.rowDataStore.rowClearCache();
|
|
438
449
|
},
|
|
450
|
+
rowSetCenterData: (d) => {
|
|
451
|
+
rdsStore.set(data, d);
|
|
452
|
+
const grid = rdsStore.get(grid$);
|
|
453
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
454
|
+
},
|
|
439
455
|
rowSetTopData: (data) => {
|
|
440
456
|
rdsStore.set(topData, data);
|
|
441
457
|
const grid = rdsStore.get(grid$);
|
|
442
458
|
grid?.state.rowDataStore.rowClearCache();
|
|
443
459
|
},
|
|
460
|
+
rowData: (section) => {
|
|
461
|
+
const d = [];
|
|
462
|
+
if (section === "top" || section === "flat") {
|
|
463
|
+
d.push(...rdsStore.get(topData));
|
|
464
|
+
}
|
|
465
|
+
if (section === "center" || section === "flat") {
|
|
466
|
+
d.push(...rdsStore.get(data));
|
|
467
|
+
}
|
|
468
|
+
if (section === "bottom" || section === "flat") {
|
|
469
|
+
d.push(...rdsStore.get(bottomData));
|
|
470
|
+
}
|
|
471
|
+
return d;
|
|
472
|
+
},
|
|
444
473
|
rowExpand: (expansions) => {
|
|
445
474
|
const grid = rdsStore.get(grid$);
|
|
446
475
|
if (!grid)
|
|
@@ -527,12 +556,12 @@ export function useClientRowDataSourcePaginated(p) {
|
|
|
527
556
|
if (p.reflectData) {
|
|
528
557
|
// Need to queue the microtask since it we cannot update state during render.
|
|
529
558
|
if (p.data !== da.center.get())
|
|
530
|
-
queueMicrotask(() =>
|
|
559
|
+
queueMicrotask(() => ds.current.rowSetCenterData(p.data));
|
|
531
560
|
if (!equal(p.topData ?? [], da.top.get())) {
|
|
532
|
-
queueMicrotask(() =>
|
|
561
|
+
queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
|
|
533
562
|
}
|
|
534
563
|
if (!equal(p.bottomData ?? [], da.bottom.get()))
|
|
535
|
-
queueMicrotask(() =>
|
|
564
|
+
queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
|
|
536
565
|
}
|
|
537
566
|
return ds.current;
|
|
538
567
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridAtom, RowDataSourceClient } from "../+types";
|
|
2
|
-
import { type ClientRowDataSourceParams } from "../+types";
|
|
1
|
+
import type { GridAtom, RowDataSourceClient } from "../+types.js";
|
|
2
|
+
import { type ClientRowDataSourceParams } from "../+types.js";
|
|
3
3
|
interface DataAtoms<T> {
|
|
4
4
|
readonly top: GridAtom<T[]>;
|
|
5
5
|
readonly center: GridAtom<T[]>;
|