@1771technologies/lytenyte-pro 1.0.0-beta.29 → 1.0.0-beta.30
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/cells/cell.js +3 -1
- package/dist/column-manager/branch.d.ts +9 -3
- package/dist/column-manager/branch.js +3 -3
- package/dist/column-manager/column-manager.d.ts +3 -5
- package/dist/column-manager/column-manager.js +6 -8
- package/dist/column-manager/context.d.ts +2 -2
- package/dist/column-manager/label.js +3 -3
- package/dist/column-manager/leaf.d.ts +2 -2
- package/dist/column-manager/leaf.js +3 -3
- package/dist/column-manager/move-handle.d.ts +2 -2
- package/dist/column-manager/move-handle.js +1 -3
- package/dist/column-manager/panel.d.ts +1 -0
- package/dist/column-manager/panel.js +2 -0
- package/dist/column-manager/root.d.ts +6 -7
- package/dist/column-manager/root.js +2 -15
- package/dist/column-manager/use-column-manager.d.ts +7 -21
- package/dist/column-manager/use-column-manager.js +18 -22
- package/dist/column-manager/use-columns-from-context.d.ts +2 -2
- package/dist/column-manager/use-columns-from-context.js +2 -2
- package/dist/filter-tree/branch.js +1 -1
- package/dist/filter-tree/root.js +1 -1
- package/dist/row-data-source-server/use-server-data-source.js +17 -0
- package/dist/tree-view/branch/branch.d.ts +4 -1
- package/dist/tree-view/branch/branch.js +3 -2
- package/dist/tree-view/hooks/use-tree-view-paths.d.ts +1 -1
- package/dist/tree-view/hooks/use-tree-view-paths.js +3 -3
- package/package.json +7 -7
- package/dist/column-manager/passive-scroll.d.ts +0 -2
- package/dist/column-manager/passive-scroll.js +0 -2
package/dist/cells/cell.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { forwardRef, useEffect, useState } from "react";
|
|
3
3
|
import { fastDeepMemo } from "@1771technologies/lytenyte-react-hooks";
|
|
4
4
|
import { useGridRoot } from "../context";
|
|
5
|
-
import { CellReact } from "@1771technologies/lytenyte-shared";
|
|
5
|
+
import { CellReact, GROUP_COLUMN_SINGLE_ID } from "@1771technologies/lytenyte-shared";
|
|
6
6
|
import { CellDefault } from "./cell-default";
|
|
7
7
|
import { CellEditor } from "./cell-editor";
|
|
8
8
|
import { useRowMeta } from "../rows/row/context";
|
|
@@ -33,6 +33,8 @@ const CellImpl = forwardRef(function Cell({ cell, children, ...props }, forwarde
|
|
|
33
33
|
const rowMeta = useRowMeta();
|
|
34
34
|
if (!row)
|
|
35
35
|
return null;
|
|
36
|
+
if (cell.column.id === GROUP_COLUMN_SINGLE_ID)
|
|
37
|
+
console.log(cell.row.get());
|
|
36
38
|
return (_jsxs(CellReact, { ...props, ref: forwarded, cell: cell, isEditing: isEditing, viewportWidth: cx.viewportWidthInner.useValue(), detailHeight: grid.api.rowDetailRenderedHeight(row ?? ""), rtl: cx.rtl.useValue(), xPosition: cx.xPositions.useValue(), yPosition: cx.yPositions.useValue(), children: [isEditing && _jsx(CellEditor, { cell: cell }), !isEditing && (_jsx(_Fragment, { children: typeof Renderer === "function" ? (_jsx(Renderer, { column: cell.column, rowSelected: rowMeta.selected, rowIndeterminate: rowMeta.indeterminate, row: row, grid: grid, rowIndex: cell.rowIndex, colIndex: cell.colIndex, rowPin: cell.rowPin })) : (Renderer) }))] }));
|
|
37
39
|
});
|
|
38
40
|
export const Cell = fastDeepMemo(CellImpl);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
2
|
import type { Column } from "../+types";
|
|
3
3
|
import type { SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
4
|
+
import type { PathBranch } from "@1771technologies/lytenyte-shared";
|
|
4
5
|
export interface ColumnManagerBranchProps {
|
|
5
|
-
readonly item:
|
|
6
|
+
readonly item: PathBranch<Column<any>>;
|
|
6
7
|
readonly label: SlotComponent;
|
|
7
|
-
readonly expander?: SlotComponent
|
|
8
|
+
readonly expander?: SlotComponent<{
|
|
9
|
+
expanded: boolean;
|
|
10
|
+
toggle: () => void;
|
|
11
|
+
}>;
|
|
12
|
+
readonly labelWrapClassName?: string;
|
|
13
|
+
readonly labelWrapStyle?: CSSProperties;
|
|
8
14
|
}
|
|
9
15
|
export declare const Branch: import("react").ForwardRefExoticComponent<Omit<ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
@@ -5,7 +5,7 @@ import { ColumnItemContext } from "./context";
|
|
|
5
5
|
import { dragState, DropWrap } from "@1771technologies/lytenyte-dragon";
|
|
6
6
|
import { useGrid } from "../grid-provider/use-grid";
|
|
7
7
|
import { useColumnsFromContext } from "./use-columns-from-context";
|
|
8
|
-
export const Branch = forwardRef(function Branch({ item, label, ...props }, forwarded) {
|
|
8
|
+
export const Branch = forwardRef(function Branch({ item, label, labelWrapClassName, labelWrapStyle, ...props }, forwarded) {
|
|
9
9
|
const grid = useGrid();
|
|
10
10
|
const id = grid.state.gridId.useValue();
|
|
11
11
|
const accepted = `${id}/columns`;
|
|
@@ -19,13 +19,13 @@ export const Branch = forwardRef(function Branch({ item, label, ...props }, forw
|
|
|
19
19
|
const next = s ?? isVisible;
|
|
20
20
|
grid.api.columnUpdate(Object.fromEntries(columns.map((c) => [c.id, { hide: next }])));
|
|
21
21
|
}, [columns, grid.api, isVisible]);
|
|
22
|
-
return (_jsx(ColumnItemContext, { value: useMemo(() => ({ item }), [item]), children: _jsx(TreeBranch, { ...props, itemId: item.
|
|
22
|
+
return (_jsx(ColumnItemContext, { value: useMemo(() => ({ item }), [item]), children: _jsx(TreeBranch, { ...props, itemId: item.data.idOccurrence, ref: forwarded, onKeyDown: (ev) => {
|
|
23
23
|
props.onKeyDown?.(ev);
|
|
24
24
|
if (ev.key === " ") {
|
|
25
25
|
toggle();
|
|
26
26
|
ev.preventDefault();
|
|
27
27
|
}
|
|
28
|
-
}, labelWrap: _jsx(DropWrap, { "data-ln-column-manager-branch": true, "data-ln-column-id": item.
|
|
28
|
+
}, labelWrap: _jsx(DropWrap, { "data-ln-column-manager-branch": true, "data-ln-column-id": item.data.idOccurrence, accepted: [accepted], className: labelWrapClassName, style: labelWrapStyle, onEnter: (el) => {
|
|
29
29
|
const data = dragState.data
|
|
30
30
|
.get()
|
|
31
31
|
?.siteLocalData?.[accepted]?.at(-1);
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { ForceSyncScrolling } from "../tree-view/virtualized/force-sync-scrolling";
|
|
2
1
|
import { Root } from "./root";
|
|
3
2
|
import { useColumnManager } from "./use-column-manager";
|
|
4
3
|
import { VisibilityCheckbox } from "./visibility-checkbox";
|
|
5
4
|
export declare const ColumnManager: {
|
|
6
5
|
Root: typeof Root;
|
|
7
|
-
Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
8
|
-
PassiveScroll: typeof ForceSyncScrolling;
|
|
9
6
|
Leaf: import("react").ForwardRefExoticComponent<Omit<import("./leaf").ColumnManagerLeafProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
10
|
-
Branch: import("react").ForwardRefExoticComponent<Omit<import("./branch").ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
11
7
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & import("./label").LabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
-
|
|
8
|
+
Branch: import("react").ForwardRefExoticComponent<Omit<import("./branch").ColumnManagerBranchProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
9
|
+
Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
13
10
|
MoveHandle: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & import("./move-handle").MoveHandleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
VisibilityCheckbox: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & VisibilityCheckbox, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
12
|
useColumnManager: typeof useColumnManager;
|
|
15
13
|
};
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { TreePanel } from "../tree-view/panel/panel";
|
|
2
|
-
import { ForceSyncScrolling } from "../tree-view/virtualized/force-sync-scrolling";
|
|
3
1
|
import { Branch } from "./branch";
|
|
4
2
|
import { Label } from "./label";
|
|
5
3
|
import { Leaf } from "./leaf";
|
|
6
4
|
import { MoveHandle } from "./move-handle";
|
|
5
|
+
import { Panel } from "./panel";
|
|
7
6
|
import { Root } from "./root";
|
|
8
7
|
import { useColumnManager } from "./use-column-manager";
|
|
9
8
|
import { VisibilityCheckbox } from "./visibility-checkbox";
|
|
10
9
|
export const ColumnManager = {
|
|
11
|
-
Root
|
|
12
|
-
Panel: TreePanel,
|
|
13
|
-
PassiveScroll: ForceSyncScrolling,
|
|
10
|
+
Root,
|
|
14
11
|
Leaf,
|
|
15
|
-
Branch,
|
|
16
12
|
Label,
|
|
17
|
-
|
|
13
|
+
Branch,
|
|
14
|
+
Panel,
|
|
18
15
|
MoveHandle,
|
|
19
|
-
|
|
16
|
+
VisibilityCheckbox,
|
|
17
|
+
useColumnManager: useColumnManager,
|
|
20
18
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TreeVirtualItem } from "../tree-view/virtualized/make-virtual-tree";
|
|
2
1
|
import type { Column } from "../+types";
|
|
2
|
+
import type { PathBranch, PathLeaf } from "@1771technologies/lytenyte-shared";
|
|
3
3
|
export interface TreeItemContextValue {
|
|
4
|
-
readonly item:
|
|
4
|
+
readonly item: PathBranch<Column<any>> | PathLeaf<Column<any>>;
|
|
5
5
|
}
|
|
6
6
|
export declare const ColumnItemContext: import("react").Context<TreeItemContextValue>;
|
|
7
7
|
export declare const useColumnItemContext: () => TreeItemContextValue;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
|
-
import { useColumnItemContext } from "./context";
|
|
4
3
|
import { forwardRef, useMemo } from "react";
|
|
4
|
+
import { useColumnItemContext } from "./context";
|
|
5
5
|
export const Label = forwardRef(function Label({ as, ...props }, forwarded) {
|
|
6
6
|
const { item } = useColumnItemContext();
|
|
7
7
|
const label = useMemo(() => {
|
|
8
8
|
if (item.kind == "branch")
|
|
9
|
-
return item.
|
|
10
|
-
return item.
|
|
9
|
+
return item.id.split("#").at(-2);
|
|
10
|
+
return item.data.name ?? item.data.id;
|
|
11
11
|
}, [item]);
|
|
12
12
|
const rendered = useSlot({
|
|
13
13
|
props: [{ children: label }, props],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { TreeVirtualLeaf } from "../tree-view/virtualized/make-virtual-tree";
|
|
2
1
|
import type { Column } from "../+types";
|
|
2
|
+
import type { PathLeaf } from "@1771technologies/lytenyte-shared";
|
|
3
3
|
export interface ColumnManagerLeafProps {
|
|
4
|
-
readonly item:
|
|
4
|
+
readonly item: PathLeaf<Column<any>>;
|
|
5
5
|
}
|
|
6
6
|
export declare const Leaf: import("react").ForwardRefExoticComponent<Omit<ColumnManagerLeafProps & import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
@@ -28,7 +28,7 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
|
|
|
28
28
|
?.siteLocalData?.[accepted]?.at(-1);
|
|
29
29
|
if (!data)
|
|
30
30
|
return;
|
|
31
|
-
const columns = [item.
|
|
31
|
+
const columns = [item.data];
|
|
32
32
|
const move = data.id;
|
|
33
33
|
if (columns.some((c) => c.id === move))
|
|
34
34
|
return;
|
|
@@ -48,11 +48,11 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
|
|
|
48
48
|
}, onLeave: (el) => {
|
|
49
49
|
el.removeAttribute("data-ln-is-before");
|
|
50
50
|
el.removeAttribute("data-ln-is-after");
|
|
51
|
-
}, as: _jsx(TreeLeaf, { ...props, itemId: item.
|
|
51
|
+
}, as: _jsx(TreeLeaf, { ...props, itemId: item.data.id, ref: forwarded, onKeyDown: (ev) => {
|
|
52
52
|
props.onKeyDown?.(ev);
|
|
53
53
|
if (ev.key === " ") {
|
|
54
54
|
toggle();
|
|
55
55
|
ev.preventDefault();
|
|
56
56
|
}
|
|
57
|
-
}, "data-ln-column-manager-leaf": true, "data-ln-column-id": item.
|
|
57
|
+
}, "data-ln-column-manager-leaf": true, "data-ln-column-id": item.data.id }) }) }));
|
|
58
58
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { Column } from "../+types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { PathBranch, PathLeaf } from "@1771technologies/lytenyte-shared";
|
|
5
5
|
export interface MoveHandleProps {
|
|
6
6
|
readonly as?: SlotComponent;
|
|
7
7
|
readonly placeholder?: (p: {
|
|
8
8
|
columns: Column<any>[];
|
|
9
|
-
item:
|
|
9
|
+
item: PathBranch<Column<any>> | PathLeaf<Column<any>>;
|
|
10
10
|
}) => ReactNode;
|
|
11
11
|
}
|
|
12
12
|
export declare const MoveHandle: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & MoveHandleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -42,9 +42,7 @@ export const MoveHandle = forwardRef(function MoveHandle({ as, placeholder: Plac
|
|
|
42
42
|
placeholder: () => {
|
|
43
43
|
if (Placeholder)
|
|
44
44
|
return _jsx(Placeholder, { columns: columns, item: item });
|
|
45
|
-
return (_jsx("div", { children: item.kind === "branch"
|
|
46
|
-
? item.branch.data.joinPath.at(-1)
|
|
47
|
-
: (item.leaf.data.name ?? item.leaf.data.id) }));
|
|
45
|
+
return (_jsx("div", { children: item.kind === "branch" ? item.data.joinPath.at(-1) : (item.data.name ?? item.data.id) }));
|
|
48
46
|
},
|
|
49
47
|
});
|
|
50
48
|
const combined = useCombinedRefs(ref, forwarded);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Panel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
2
|
import type { Column, Grid } from "../+types";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export type ColumnManagerRootProps<T> = UseColumnManagerReturn<T>["rootProps"] & {
|
|
3
|
+
import type { PathBranch } from "@1771technologies/lytenyte-shared";
|
|
4
|
+
export interface ColumnManagerRootProps<T> {
|
|
6
5
|
readonly grid: Grid<T>;
|
|
7
|
-
readonly
|
|
8
|
-
}
|
|
9
|
-
export declare function Root<T>({ grid,
|
|
6
|
+
readonly lookup: Record<string, PathBranch<Column<any>>>;
|
|
7
|
+
}
|
|
8
|
+
export declare function Root<T>({ grid, lookup, children }: PropsWithChildren<ColumnManagerRootProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
2
|
import { GridProvider } from "../grid-provider/provider";
|
|
4
3
|
import { TreeRoot } from "../tree-view/root";
|
|
5
4
|
import { branchLookupContext } from "./branch-lookup-context";
|
|
6
|
-
export function Root({ grid,
|
|
7
|
-
|
|
8
|
-
const stack = [...root.children.values()];
|
|
9
|
-
const lookup = {};
|
|
10
|
-
while (stack.length) {
|
|
11
|
-
const item = stack.pop();
|
|
12
|
-
if (item.kind === "leaf")
|
|
13
|
-
continue;
|
|
14
|
-
lookup[item.data.idOccurrence] = item;
|
|
15
|
-
stack.push(...item.children.values());
|
|
16
|
-
}
|
|
17
|
-
return lookup;
|
|
18
|
-
}, [root.children]);
|
|
19
|
-
return (_jsx(branchLookupContext.Provider, { value: branchLookup, children: _jsx(GridProvider, { value: grid, children: _jsx(TreeRoot, { selectMode: "none", transitionEnter: 200, transitionExit: 200, expansionDefault: true, ref: treeRef, ...rootProps, children: children }) }) }));
|
|
5
|
+
export function Root({ grid, lookup, children }) {
|
|
6
|
+
return (_jsx(branchLookupContext.Provider, { value: lookup, children: _jsx(GridProvider, { value: grid, children: _jsx(TreeRoot, { children: children }) }) }));
|
|
20
7
|
}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import type { PathRoot } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
export interface UseColumnManagerReturn<T> {
|
|
6
|
-
readonly rootProps: {
|
|
7
|
-
readonly grid: Grid<T>;
|
|
8
|
-
readonly expansions: Record<string, boolean>;
|
|
9
|
-
readonly onExpansionChange: Dispatch<SetStateAction<Record<string, boolean>>>;
|
|
10
|
-
readonly treeRef: (el: HTMLElement | null) => void;
|
|
11
|
-
readonly getAllIds: () => Set<string>;
|
|
12
|
-
readonly getIdsBetweenNodes: (left: HTMLElement, right: HTMLElement) => string[];
|
|
13
|
-
readonly onFocusChange: (el: HTMLElement | null) => void;
|
|
14
|
-
readonly root: PathRoot<Column<T>>;
|
|
15
|
-
};
|
|
16
|
-
readonly tree: TreeVirtualItem<Column<T>>[];
|
|
17
|
-
readonly spacer: JSX.Element;
|
|
18
|
-
}
|
|
19
|
-
export interface UseColumnManagerArgs<T> {
|
|
1
|
+
import type { Column, Grid } from "../+types";
|
|
2
|
+
import type { PathBranch } from "@1771technologies/lytenyte-shared";
|
|
3
|
+
export interface UseColumnManagerProps<T> {
|
|
20
4
|
readonly grid: Grid<T>;
|
|
21
|
-
readonly itemHeight?: number;
|
|
22
5
|
}
|
|
23
|
-
export declare function useColumnManager<T>({ grid
|
|
6
|
+
export declare function useColumnManager<T>({ grid }: UseColumnManagerProps<T>): {
|
|
7
|
+
items: (PathBranch<Column<T>> | import("@1771technologies/lytenyte-shared").PathLeaf<Column<T>>)[];
|
|
8
|
+
lookup: Record<string, PathBranch<Column<any>>>;
|
|
9
|
+
};
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export function useColumnManager({ grid
|
|
4
|
-
const [expansions, onExpansionChange] = useState({});
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useTreeViewPaths } from "../tree-view/hooks/use-tree-view-paths";
|
|
3
|
+
export function useColumnManager({ grid }) {
|
|
5
4
|
const columns = grid.state.columns.useValue();
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
spacer: virt.spacer,
|
|
22
|
-
tree: virt.virtualTree,
|
|
23
|
-
};
|
|
5
|
+
const items = useTreeViewPaths(columns, true);
|
|
6
|
+
console.log(items);
|
|
7
|
+
const branchLookup = useMemo(() => {
|
|
8
|
+
const stack = [...items];
|
|
9
|
+
const lookup = {};
|
|
10
|
+
while (stack.length) {
|
|
11
|
+
const item = stack.pop();
|
|
12
|
+
if (item.kind === "leaf")
|
|
13
|
+
continue;
|
|
14
|
+
lookup[item.data.idOccurrence] = item;
|
|
15
|
+
stack.push(...item.children.values());
|
|
16
|
+
}
|
|
17
|
+
return lookup;
|
|
18
|
+
}, [items]);
|
|
19
|
+
return { items, lookup: branchLookup };
|
|
24
20
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { TreeVirtualItem } from "../tree-view/virtualized/make-virtual-tree.js";
|
|
2
1
|
import type { Column } from "../+types.js";
|
|
3
|
-
|
|
2
|
+
import type { PathBranch, PathLeaf } from "@1771technologies/lytenyte-shared";
|
|
3
|
+
export declare function useColumnsFromContext<T>(item: PathBranch<Column<T>> | PathLeaf<Column<T>>): Column<any>[] | Column<T>[];
|
|
@@ -5,7 +5,7 @@ export function useColumnsFromContext(item) {
|
|
|
5
5
|
const columns = useMemo(() => {
|
|
6
6
|
if (item.kind === "branch") {
|
|
7
7
|
const allChildren = [];
|
|
8
|
-
const branch = lookup[item.
|
|
8
|
+
const branch = lookup[item.data.idOccurrence];
|
|
9
9
|
const stack = [...branch.children.values()];
|
|
10
10
|
while (stack.length) {
|
|
11
11
|
const p = stack.pop();
|
|
@@ -17,7 +17,7 @@ export function useColumnsFromContext(item) {
|
|
|
17
17
|
}
|
|
18
18
|
return allChildren;
|
|
19
19
|
}
|
|
20
|
-
return [item.
|
|
20
|
+
return [item.data];
|
|
21
21
|
}, [item, lookup]);
|
|
22
22
|
return columns;
|
|
23
23
|
}
|
|
@@ -14,7 +14,7 @@ export const Branch = forwardRef(function Branch({ item, labelWrap, label, ...pr
|
|
|
14
14
|
},
|
|
15
15
|
],
|
|
16
16
|
});
|
|
17
|
-
return (_jsx(FilterTreeItemContext.Provider, { value: value, children: _jsx(TreeBranch, { ...props, itemId: item.branch.data.
|
|
17
|
+
return (_jsx(FilterTreeItemContext.Provider, { value: value, children: _jsx(TreeBranch, { ...props, itemId: item.branch.data.id, ref: forwarded, ...item.attrs, onKeyDown: (ev) => {
|
|
18
18
|
if (ev.key === " ")
|
|
19
19
|
value.onCheckChange();
|
|
20
20
|
}, label: label, labelWrap: labelSlot }) }));
|
package/dist/filter-tree/root.js
CHANGED
|
@@ -26,5 +26,5 @@ export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, e
|
|
|
26
26
|
return loadingSlot;
|
|
27
27
|
if (error)
|
|
28
28
|
return errorSlot;
|
|
29
|
-
return (_jsx(GridProvider, { value: grid, children: _jsx(FilterTreeContext.Provider, { value: value, children: _jsx(TreeRoot, { selectMode: "none", transitionEnter:
|
|
29
|
+
return (_jsx(GridProvider, { value: grid, children: _jsx(FilterTreeContext.Provider, { value: value, children: _jsx(TreeRoot, { selectMode: "none", transitionEnter: 0, transitionExit: 0, expansionDefault: true, ref: treeRef, ...rootProps, children: children }) }) }));
|
|
30
30
|
}
|
|
@@ -453,6 +453,7 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
453
453
|
return { kind: "leaf", data: null, id: `error-${ri}`, loading: false, error };
|
|
454
454
|
if (!node)
|
|
455
455
|
return { kind: "leaf", data: null, id: `loading-${ri}`, loading: true, error: null };
|
|
456
|
+
const isLoading = rdsStore.get(loadingGroups$);
|
|
456
457
|
if (node.kind === "parent") {
|
|
457
458
|
return {
|
|
458
459
|
kind: "branch",
|
|
@@ -461,6 +462,7 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
461
462
|
key: node.path,
|
|
462
463
|
depth: getNodeDepth(node),
|
|
463
464
|
error,
|
|
465
|
+
loading: isLoading.has(node.data.id),
|
|
464
466
|
};
|
|
465
467
|
}
|
|
466
468
|
return {
|
|
@@ -470,13 +472,19 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
470
472
|
error,
|
|
471
473
|
};
|
|
472
474
|
};
|
|
475
|
+
const loadingGroups$ = atom(new Set());
|
|
473
476
|
const rowExpand = (p) => {
|
|
474
477
|
const f = flat.get();
|
|
478
|
+
const loadingRows = new Set(rdsStore.get(loadingGroups$));
|
|
479
|
+
const rowsForThis = new Set();
|
|
475
480
|
const rowIndices = [];
|
|
476
481
|
const requests = Object.entries(p)
|
|
477
482
|
.map(([rowId, state]) => {
|
|
478
483
|
if (!state)
|
|
479
484
|
return null;
|
|
485
|
+
// Mark as loading
|
|
486
|
+
loadingRows.add(rowId);
|
|
487
|
+
rowsForThis.add(rowId);
|
|
480
488
|
const rowIndex = rowToIndex(rowId);
|
|
481
489
|
if (rowIndex == null)
|
|
482
490
|
return null;
|
|
@@ -505,17 +513,26 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
505
513
|
return prev;
|
|
506
514
|
});
|
|
507
515
|
}
|
|
516
|
+
// Mark these groups as loading
|
|
517
|
+
rdsStore.set(loadingGroups$, loadingRows);
|
|
518
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
508
519
|
dataRequestHandler(requests, false, () => {
|
|
509
520
|
if (mode)
|
|
510
521
|
grid?.state.columnPivotColumnGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
511
522
|
else
|
|
512
523
|
grid?.state.rowGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
524
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
525
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
526
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
513
527
|
}, (error) => {
|
|
514
528
|
rdsStore.set(nodesWithError, (prev) => {
|
|
515
529
|
const n = new Map(prev);
|
|
516
530
|
rowIndices.forEach((c) => n.set(c, error));
|
|
517
531
|
return prev;
|
|
518
532
|
});
|
|
533
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
534
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
535
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
519
536
|
});
|
|
520
537
|
};
|
|
521
538
|
const rowToIndex = (rowId) => {
|
|
@@ -3,7 +3,10 @@ export interface TreeBranchProps {
|
|
|
3
3
|
readonly itemId: string;
|
|
4
4
|
readonly labelWrap?: SlotComponent;
|
|
5
5
|
readonly label?: SlotComponent;
|
|
6
|
-
readonly expander?: SlotComponent
|
|
6
|
+
readonly expander?: SlotComponent<{
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}>;
|
|
7
10
|
readonly transitionEnterMs?: number;
|
|
8
11
|
readonly transitionExitMs?: number;
|
|
9
12
|
readonly gridWrapped?: boolean;
|
|
@@ -31,7 +31,8 @@ export const TreeBranch = forwardRef(function TreeBranch({ itemId, label, expand
|
|
|
31
31
|
slot: label ?? _jsx("div", {}),
|
|
32
32
|
});
|
|
33
33
|
const expandedProps = {
|
|
34
|
-
onClick: () => {
|
|
34
|
+
onClick: (e) => {
|
|
35
|
+
e.stopPropagation();
|
|
35
36
|
onExpansionChange(!expanded);
|
|
36
37
|
},
|
|
37
38
|
};
|
|
@@ -51,7 +52,7 @@ export const TreeBranch = forwardRef(function TreeBranch({ itemId, label, expand
|
|
|
51
52
|
});
|
|
52
53
|
return (_jsx(depthContext.Provider, { value: depth + 1, children: _jsxs("li", { ...props, onKeyDown: useBranchKeys(itemId, root.expansionDefault ?? false, props.onKeyDown), tabIndex: -1, ref: forwarded, role: "treeitem", "aria-expanded": open, "aria-selected": root.selection.has(itemId), "aria-level": depth + 1, "data-ln-selected": root.selection.has(itemId), "data-ln-tree-node": true, "data-ln-tree-branch": true, "data-ln-tree-id": itemId, style: {
|
|
53
54
|
...props.style,
|
|
54
|
-
"--tree-depth": depth,
|
|
55
|
+
"--ln-tree-depth": depth,
|
|
55
56
|
}, children: [labelWrapSlot, _jsx("div", { children: _jsx(Wrapped, { wrapped: wrapped, expanded: open, children: shouldMount && (_jsx("ul", { "data-tree-branch-children": true, "data-expanded": open, "data-open-state": state, role: "group", children: props.children })) }) })] }) }));
|
|
56
57
|
});
|
|
57
58
|
function Wrapped(props) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type PathProvidedItem } from "@1771technologies/lytenyte-shared";
|
|
2
|
-
export declare function useTreeViewPaths<T extends PathProvidedItem>(paths: T[]): (import("@1771technologies/lytenyte-shared").PathBranch<T> | import("@1771technologies/lytenyte-shared").PathLeaf<T>)[];
|
|
2
|
+
export declare function useTreeViewPaths<T extends PathProvidedItem>(paths: T[], nonAdjacentAreDistinct?: boolean): (import("@1771technologies/lytenyte-shared").PathBranch<T> | import("@1771technologies/lytenyte-shared").PathLeaf<T>)[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { computePathTree } from "@1771technologies/lytenyte-shared";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
export function useTreeViewPaths(paths) {
|
|
3
|
+
export function useTreeViewPaths(paths, nonAdjacentAreDistinct) {
|
|
4
4
|
const tree = useMemo(() => {
|
|
5
|
-
const result = computePathTree(paths);
|
|
5
|
+
const result = computePathTree(paths, {}, nonAdjacentAreDistinct);
|
|
6
6
|
return [...result.children.values()];
|
|
7
|
-
}, [paths]);
|
|
7
|
+
}, [nonAdjacentAreDistinct, paths]);
|
|
8
8
|
return tree;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1771technologies/lytenyte-pro",
|
|
3
3
|
"description": "Blazingly fast headless React data grid with 100s of features.",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.30",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "COMMERCIAL",
|
|
7
7
|
"files": [
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@1771technologies/atom": "^1.0.2",
|
|
52
|
-
"@1771technologies/lytenyte-dom-utils": "1.0.0-beta.
|
|
53
|
-
"@1771technologies/lytenyte-
|
|
54
|
-
"@1771technologies/lytenyte-dragon": "1.0.0-beta.
|
|
55
|
-
"@1771technologies/lytenyte-
|
|
56
|
-
"@1771technologies/lytenyte-
|
|
57
|
-
"@1771technologies/lytenyte-
|
|
52
|
+
"@1771technologies/lytenyte-dom-utils": "1.0.0-beta.30",
|
|
53
|
+
"@1771technologies/lytenyte-js-utils": "1.0.0-beta.30",
|
|
54
|
+
"@1771technologies/lytenyte-dragon": "1.0.0-beta.30",
|
|
55
|
+
"@1771technologies/lytenyte-shared": "1.0.0-beta.30",
|
|
56
|
+
"@1771technologies/lytenyte-react-hooks": "1.0.0-beta.30",
|
|
57
|
+
"@1771technologies/lytenyte-core": "1.0.0-beta.30"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.0.0 || ^19.0.0",
|