@1771technologies/lytenyte-pro 1.0.0-beta.3 → 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/+types.d.ts +88 -14
- package/dist/cell-selection/cell-selection-driver.js +9 -1
- package/dist/cell-selection/update-additive-cell-selection.js +0 -2
- package/dist/cells/cell-editor.js +11 -4
- package/dist/cells/cell.js +6 -3
- package/dist/column-manager/branch.d.ts +9 -3
- package/dist/column-manager/branch.js +20 -4
- 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.d.ts +1 -1
- package/dist/column-manager/label.js +5 -5
- package/dist/column-manager/leaf.d.ts +2 -2
- package/dist/column-manager/leaf.js +22 -4
- package/dist/column-manager/move-handle.d.ts +3 -3
- package/dist/column-manager/move-handle.js +3 -5
- 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 +8 -18
- 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/column-manager/visibility-checkbox.d.ts +1 -1
- package/dist/column-manager/visibility-checkbox.js +2 -2
- package/dist/filter-tree/branch.js +1 -1
- 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 +4 -4
- package/dist/grid-box/+types.d.ts +4 -2
- 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.js +3 -1
- package/dist/grid-box/use-column-box-items.d.ts +6 -2
- package/dist/grid-box/use-column-box-items.js +11 -14
- package/dist/grid-box/use-row-group-box-items.d.ts +2 -2
- package/dist/grid-box/use-row-group-box-items.js +14 -15
- package/dist/grid.d.ts +0 -12
- package/dist/grid.js +0 -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.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 +7 -0
- package/dist/index.js +7 -0
- package/dist/listbox/item.js +1 -1
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +3 -3
- package/dist/row-data-source-client/use-client-data-source-paginated.js +66 -24
- package/dist/row-data-source-client/use-client-data-source.js +50 -20
- package/dist/row-data-source-client/use-client-tree-data-source.js +49 -20
- package/dist/row-data-source-server/use-server-data-source.js +20 -0
- 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/state/+types.d.ts +2 -1
- package/dist/state/api/column-autosize.js +1 -1
- package/dist/state/api/column-from-index.d.ts +1 -1
- package/dist/state/api/column-from-index.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/edit-end.js +1 -1
- package/dist/state/api/export-data-rect.js +1 -1
- 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/edit-on-change.js +1 -0
- 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 +16 -4
- 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/dist/tree-view/leaf.js +1 -0
- package/dist/viewport/begin-editing.js +1 -1
- package/main.css +4 -0
- package/package.json +12 -6
- package/dist/column-manager/passive-scroll.d.ts +0 -2
- package/dist/column-manager/passive-scroll.js +0 -2
|
@@ -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: "multiple", 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,19 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
1
|
+
import type { Column, Grid } from "../+types";
|
|
2
|
+
import type { PathBranch } from "@1771technologies/lytenyte-shared";
|
|
3
|
+
export interface UseColumnManagerProps<T> {
|
|
4
|
+
readonly grid: Grid<T>;
|
|
18
5
|
}
|
|
19
|
-
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
|
}
|
|
@@ -4,7 +4,7 @@ import { useColumnItemContext } from "./context";
|
|
|
4
4
|
import { forwardRef, useCallback, useMemo } from "react";
|
|
5
5
|
import { useGrid } from "../grid-provider/use-grid";
|
|
6
6
|
import { useColumnsFromContext } from "./use-columns-from-context";
|
|
7
|
-
export const VisibilityCheckbox = forwardRef(function VisibilityCheckbox({
|
|
7
|
+
export const VisibilityCheckbox = forwardRef(function VisibilityCheckbox({ as, ...props }, forwarded) {
|
|
8
8
|
const { item } = useColumnItemContext();
|
|
9
9
|
const grid = useGrid();
|
|
10
10
|
const base = grid.state.columnBase.useValue();
|
|
@@ -21,7 +21,7 @@ export const VisibilityCheckbox = forwardRef(function VisibilityCheckbox({ slot,
|
|
|
21
21
|
const rendered = useSlot({
|
|
22
22
|
props: [props],
|
|
23
23
|
ref: forwarded,
|
|
24
|
-
slot:
|
|
24
|
+
slot: as ?? (_jsx("input", { type: "checkbox", checked: isVisible, "aria-label": "visibility toggle", onChange: () => {
|
|
25
25
|
toggle();
|
|
26
26
|
} })),
|
|
27
27
|
state: { visible: isVisible, indeterminate: isIndeterminate, toggle },
|
|
@@ -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 }) }));
|
|
@@ -2,13 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useTreeItemContext } from "./context";
|
|
5
|
-
export const InclusionCheckbox = forwardRef(function InclusionCheckbox({
|
|
5
|
+
export const InclusionCheckbox = forwardRef(function InclusionCheckbox({ as, ...props }, forwarded) {
|
|
6
6
|
const { isChecked, onCheckChange, isIndeterminate } = useTreeItemContext();
|
|
7
7
|
const rendered = useSlot({
|
|
8
8
|
props: [props],
|
|
9
9
|
ref: forwarded,
|
|
10
10
|
state: { checked: isChecked, toggle: onCheckChange, indeterminate: isIndeterminate },
|
|
11
|
-
slot:
|
|
11
|
+
slot: as ?? (_jsx("input", { type: "checkbox", checked: isChecked, "aria-label": "visibility toggle", onChange: () => onCheckChange() })),
|
|
12
12
|
});
|
|
13
13
|
return rendered;
|
|
14
14
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
export interface LabelProps {
|
|
3
|
-
readonly
|
|
3
|
+
readonly as?: SlotComponent;
|
|
4
4
|
}
|
|
5
5
|
export declare const Label: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & LabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef, useMemo } from "react";
|
|
4
4
|
import { useTreeItemContext } from "./context";
|
|
5
|
-
export const Label = forwardRef(function Label({
|
|
5
|
+
export const Label = forwardRef(function Label({ as, ...props }, forwarded) {
|
|
6
6
|
const { item } = useTreeItemContext();
|
|
7
7
|
const label = useMemo(() => {
|
|
8
8
|
if (item.kind == "branch")
|
|
@@ -12,7 +12,7 @@ export const Label = forwardRef(function Label({ slot, ...props }, forwarded) {
|
|
|
12
12
|
const rendered = useSlot({
|
|
13
13
|
props: [{ children: label }, props],
|
|
14
14
|
ref: forwarded,
|
|
15
|
-
slot:
|
|
15
|
+
slot: as ?? _jsx("div", {}),
|
|
16
16
|
});
|
|
17
17
|
return rendered;
|
|
18
18
|
});
|
|
@@ -4,10 +4,10 @@ import type { UseTreeFilterReturn } from "./hooks/use-filter-tree";
|
|
|
4
4
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
5
5
|
export type FilterTreeRootProps<T> = UseTreeFilterReturn<T>["rootProps"] & {
|
|
6
6
|
readonly grid: Grid<T>;
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
7
|
+
readonly loadingAs?: SlotComponent;
|
|
8
|
+
readonly errorAs?: SlotComponent<{
|
|
9
9
|
error: any;
|
|
10
10
|
refetch: () => void;
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
|
-
export declare function Root<T>({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading,
|
|
13
|
+
export declare function Root<T>({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading, errorAs, loadingAs, fetchItems, items, applyChangesImmediately, filterInChange, ...rootProps }: PropsWithChildren<FilterTreeRootProps<T>>): import("react/jsx-runtime").JSX.Element;
|
package/dist/filter-tree/root.js
CHANGED
|
@@ -4,7 +4,7 @@ import { GridProvider } from "../grid-provider/provider";
|
|
|
4
4
|
import { TreeRoot } from "../tree-view/root";
|
|
5
5
|
import { FilterTreeContext } from "./context";
|
|
6
6
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
7
|
-
export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading,
|
|
7
|
+
export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading, errorAs, loadingAs, fetchItems, items, applyChangesImmediately, filterInChange, ...rootProps }) {
|
|
8
8
|
const value = useMemo(() => {
|
|
9
9
|
return {
|
|
10
10
|
filter: filterIn,
|
|
@@ -16,15 +16,15 @@ export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, e
|
|
|
16
16
|
};
|
|
17
17
|
}, [applyChangesImmediately, columnId, filterIn, filterInChange, items, pivotMode]);
|
|
18
18
|
const loadingSlot = useSlot({
|
|
19
|
-
slot:
|
|
19
|
+
slot: loadingAs ?? _jsx("div", { children: "Loading..." }),
|
|
20
20
|
});
|
|
21
21
|
const errorSlot = useSlot({
|
|
22
|
-
slot:
|
|
22
|
+
slot: errorAs ?? _jsx("div", { children: "Error Occurred Fetching" }),
|
|
23
23
|
state: { error, refetch: fetchItems },
|
|
24
24
|
});
|
|
25
25
|
if (loading)
|
|
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
|
}
|
|
@@ -8,6 +8,8 @@ export interface GridBoxItem<T = any> {
|
|
|
8
8
|
readonly draggable: boolean;
|
|
9
9
|
readonly dragPlaceholder?: () => ReactNode;
|
|
10
10
|
readonly onDrop: (p: DropEventParams) => void;
|
|
11
|
-
readonly onAction: () => void;
|
|
12
|
-
readonly onDelete: () => void;
|
|
11
|
+
readonly onAction: (el: HTMLElement) => void;
|
|
12
|
+
readonly onDelete: (el: HTMLElement) => void;
|
|
13
|
+
readonly index: number;
|
|
14
|
+
readonly source: string;
|
|
13
15
|
}
|
package/dist/grid-box/item.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
1
2
|
import type { GridBoxItem } from "./+types";
|
|
2
3
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
3
4
|
export interface GridBoxItemProps {
|
|
4
5
|
readonly item: GridBoxItem;
|
|
5
|
-
readonly
|
|
6
|
+
readonly itemAs?: SlotComponent;
|
|
7
|
+
readonly itemClassName?: string;
|
|
8
|
+
readonly itemStyle?: CSSProperties;
|
|
6
9
|
}
|
|
7
10
|
export declare const BoxItem: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & GridBoxItemProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/grid-box/item.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Item } from "../listbox/item";
|
|
4
|
-
import { DropWrap, useDraggable } from "@1771technologies/lytenyte-dragon";
|
|
4
|
+
import { dragState, DropWrap, useDraggable } from "@1771technologies/lytenyte-dragon";
|
|
5
5
|
import { useCombinedRefs, useSlot, } from "@1771technologies/lytenyte-react-hooks";
|
|
6
6
|
import { useGridBoxContext } from "./context";
|
|
7
|
-
export const BoxItem = forwardRef(function BoxItem({ item,
|
|
7
|
+
export const BoxItem = forwardRef(function BoxItem({ item, itemAs, itemClassName, itemStyle, children, ...props }, forwarded) {
|
|
8
8
|
const { accepted } = useGridBoxContext();
|
|
9
9
|
const { dragProps } = useDraggable({
|
|
10
10
|
getItems: () => {
|
|
@@ -19,15 +19,45 @@ export const BoxItem = forwardRef(function BoxItem({ item, itemWrap, ...props },
|
|
|
19
19
|
const renderer = useSlot({
|
|
20
20
|
props: [
|
|
21
21
|
{
|
|
22
|
-
children: (_jsx(Item, { ...
|
|
23
|
-
if (ev.key === " ")
|
|
24
|
-
item.onAction?.();
|
|
22
|
+
children: (_jsx(Item, { ...extraProps, onKeyDown: (ev) => {
|
|
23
|
+
if (ev.key === " ") {
|
|
24
|
+
item.onAction?.(ev.currentTarget);
|
|
25
|
+
ev.preventDefault();
|
|
26
|
+
}
|
|
25
27
|
if (ev.key === "Backspace" || ev.key === "Delete")
|
|
26
|
-
item.onDelete?.();
|
|
27
|
-
}, onClick: () => item.onAction() })),
|
|
28
|
+
item.onDelete?.(ev.currentTarget);
|
|
29
|
+
}, onClick: (ev) => item.onAction(ev.currentTarget), className: itemClassName, style: itemStyle, "data-ln-source": item.source, "data-ln-index": item.index, children: children })),
|
|
28
30
|
},
|
|
29
31
|
],
|
|
30
|
-
slot:
|
|
32
|
+
slot: itemAs ?? _jsx("div", {}),
|
|
31
33
|
});
|
|
32
|
-
return _jsx(DropWrap, {
|
|
34
|
+
return (_jsx(DropWrap, { ...props, onEnter: (e) => {
|
|
35
|
+
const data = dragState.active.get();
|
|
36
|
+
const thisSource = e.getAttribute("data-ln-source");
|
|
37
|
+
const dragSource = data?.getAttribute("data-ln-source");
|
|
38
|
+
if (!data)
|
|
39
|
+
return;
|
|
40
|
+
if (thisSource !== dragSource) {
|
|
41
|
+
e.setAttribute("data-ln-is-after", "true");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const overIndex = Number.parseInt(e.getAttribute("data-ln-index"));
|
|
45
|
+
const dragIndex = Number.parseInt(data.getAttribute("data-ln-index"));
|
|
46
|
+
if (Number.isNaN(dragIndex) || Number.isNaN(overIndex) || overIndex === dragIndex)
|
|
47
|
+
return;
|
|
48
|
+
if (overIndex < dragIndex) {
|
|
49
|
+
e.setAttribute("data-ln-is-before", "true");
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
e.setAttribute("data-ln-is-after", "true");
|
|
53
|
+
}
|
|
54
|
+
}, onLeave: (el) => {
|
|
55
|
+
el.removeAttribute("data-ln-is-before");
|
|
56
|
+
el.removeAttribute("data-ln-is-after");
|
|
57
|
+
}, "data-ln-source": item.source, "data-ln-index": item.index, accepted: accepted, onDrop: (e) => {
|
|
58
|
+
const el = e.dropElement;
|
|
59
|
+
el.removeAttribute("data-ln-is-before");
|
|
60
|
+
el.removeAttribute("data-ln-is-after");
|
|
61
|
+
item.onDrop(e);
|
|
62
|
+
}, as: renderer }));
|
|
33
63
|
});
|
|
@@ -4,13 +4,15 @@ export function useAggregationBoxItems({ grid, orientation }) {
|
|
|
4
4
|
const model = grid.state.aggModel.useValue();
|
|
5
5
|
const gridId = grid.state.gridId.useValue();
|
|
6
6
|
const items = useMemo(() => {
|
|
7
|
-
const items = Object.entries(model).map(([id, agg]) => {
|
|
7
|
+
const items = Object.entries(model).map(([id, agg], i) => {
|
|
8
8
|
const column = grid.api.columnById(id);
|
|
9
9
|
const name = column?.name ?? column?.id ?? id;
|
|
10
10
|
const fn = typeof agg.fn === "string" ? agg.fn : "Fn(x)";
|
|
11
11
|
return {
|
|
12
12
|
draggable: false,
|
|
13
13
|
id,
|
|
14
|
+
index: i,
|
|
15
|
+
source: "aggregation",
|
|
14
16
|
data: { id, agg },
|
|
15
17
|
dragData: {},
|
|
16
18
|
label: `${name} ${fn}`,
|
|
@@ -9,6 +9,10 @@ export interface OnDropParams<T> {
|
|
|
9
9
|
export interface OnRootDropParams<T> {
|
|
10
10
|
readonly column: Column<T>;
|
|
11
11
|
}
|
|
12
|
+
export interface OnActionParams<T> {
|
|
13
|
+
readonly column: Column<T>;
|
|
14
|
+
readonly el: HTMLElement;
|
|
15
|
+
}
|
|
12
16
|
export interface UseColumnBoxItemArgs<T> {
|
|
13
17
|
readonly grid: Grid<T>;
|
|
14
18
|
readonly orientation?: "horizontal" | "vertical";
|
|
@@ -16,8 +20,8 @@ export interface UseColumnBoxItemArgs<T> {
|
|
|
16
20
|
readonly itemFilter?: (c: Column<T>) => boolean;
|
|
17
21
|
readonly onRootDrop?: (p: OnRootDropParams<T>) => void;
|
|
18
22
|
readonly onDrop?: (p: OnDropParams<T>) => void;
|
|
19
|
-
readonly onAction?: (c:
|
|
20
|
-
readonly onDelete?: (c:
|
|
23
|
+
readonly onAction?: (c: OnActionParams<T>) => void;
|
|
24
|
+
readonly onDelete?: (c: OnActionParams<T>) => void;
|
|
21
25
|
readonly dragPlaceholder?: (c: Column<T>) => ReactNode;
|
|
22
26
|
}
|
|
23
27
|
export declare function useColumnBoxItems<T>({ grid, onRootDrop, onDrop, onDelete, onAction, orientation, draggable, dragPlaceholder, itemFilter, }: UseColumnBoxItemArgs<T>): {
|
|
@@ -12,7 +12,7 @@ export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction
|
|
|
12
12
|
.filter((c) => {
|
|
13
13
|
return itemFilter ? itemFilter(c) : true;
|
|
14
14
|
})
|
|
15
|
-
.map((c) => {
|
|
15
|
+
.map((c, i) => {
|
|
16
16
|
const canGroup = c.uiHints?.rowGroupable ?? base.uiHints?.rowGroupable ?? false;
|
|
17
17
|
const canAgg = Boolean(c.uiHints?.aggDefault ??
|
|
18
18
|
c.uiHints?.aggDefault?.length ??
|
|
@@ -28,23 +28,22 @@ export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction
|
|
|
28
28
|
return {
|
|
29
29
|
label: c.name ?? c.id,
|
|
30
30
|
id: c.id,
|
|
31
|
+
index: i,
|
|
32
|
+
source: "columns",
|
|
31
33
|
draggable,
|
|
32
34
|
data: c,
|
|
33
35
|
dragData: data,
|
|
34
36
|
dragPlaceholder: dragPlaceholder ? () => dragPlaceholder?.(c) : undefined,
|
|
35
|
-
onAction: () => onAction?.(c),
|
|
36
|
-
onDelete: () => onDelete?.(c),
|
|
37
|
+
onAction: (el) => onAction?.({ column: c, el }),
|
|
38
|
+
onDelete: (el) => onDelete?.({ column: c, el }),
|
|
37
39
|
onDrop: (p) => {
|
|
38
|
-
const target = c;
|
|
39
40
|
const src = p.state.siteLocalData?.[columnId];
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
isBefore = p.moveState.topHalf;
|
|
47
|
-
}
|
|
41
|
+
const target = c;
|
|
42
|
+
const dragIndex = columns.findIndex((x) => x.id === src.id);
|
|
43
|
+
const overIndex = columns.findIndex((x) => x.id === c.id);
|
|
44
|
+
const isBefore = overIndex < dragIndex;
|
|
45
|
+
if (overIndex === dragIndex)
|
|
46
|
+
return;
|
|
48
47
|
onDrop?.({ src, target, isBefore });
|
|
49
48
|
},
|
|
50
49
|
};
|
|
@@ -56,13 +55,11 @@ export function useColumnBoxItems({ grid, onRootDrop, onDrop, onDelete, onAction
|
|
|
56
55
|
columns,
|
|
57
56
|
dragPlaceholder,
|
|
58
57
|
draggable,
|
|
59
|
-
grid.state.rtl,
|
|
60
58
|
gridId,
|
|
61
59
|
itemFilter,
|
|
62
60
|
onAction,
|
|
63
61
|
onDelete,
|
|
64
62
|
onDrop,
|
|
65
|
-
orientation,
|
|
66
63
|
]);
|
|
67
64
|
const onRootDropEv = useEvent((p) => {
|
|
68
65
|
const columnId = `${gridId}-column`;
|
|
@@ -4,10 +4,10 @@ import type { GridBoxItem } from "./+types.js";
|
|
|
4
4
|
export interface UseRowGroupBoxItems<T> {
|
|
5
5
|
readonly grid: Grid<T>;
|
|
6
6
|
readonly orientation?: "horizontal" | "vertical";
|
|
7
|
-
readonly
|
|
7
|
+
readonly dragPlaceholder?: (c: RowGroupModelItem<T>) => ReactNode;
|
|
8
8
|
readonly hideColumnOnGroup?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare function useRowGroupBoxItems<T>({ grid, orientation,
|
|
10
|
+
export declare function useRowGroupBoxItems<T>({ grid, orientation, dragPlaceholder, hideColumnOnGroup, }: UseRowGroupBoxItems<T>): {
|
|
11
11
|
rootProps: {
|
|
12
12
|
accepted: string[];
|
|
13
13
|
onRootDrop: (p: DropEventParams) => void;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useEvent } from "@1771technologies/lytenyte-react-hooks";
|
|
3
|
-
export function useRowGroupBoxItems({ grid, orientation,
|
|
3
|
+
export function useRowGroupBoxItems({ grid, orientation, dragPlaceholder, hideColumnOnGroup = true, }) {
|
|
4
4
|
const rowGroupModel = grid.state.rowGroupModel.useValue();
|
|
5
5
|
const gridId = grid.state.gridId.useValue();
|
|
6
6
|
const items = useMemo(() => {
|
|
7
7
|
const groupId = `${gridId}-group`;
|
|
8
8
|
return rowGroupModel
|
|
9
|
-
.map((c) => {
|
|
9
|
+
.map((c, i) => {
|
|
10
10
|
const onDelete = () => {
|
|
11
11
|
grid.state.rowGroupModel.set((prev) => prev.filter((x) => x !== c));
|
|
12
12
|
};
|
|
13
13
|
const onDrop = (p) => {
|
|
14
14
|
const target = c;
|
|
15
15
|
const src = p.state.siteLocalData?.[groupId];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
else {
|
|
22
|
-
isBefore = p.moveState.topHalf;
|
|
23
|
-
}
|
|
16
|
+
const overIndex = rowGroupModel.findIndex((x) => x === c);
|
|
17
|
+
const dragIndex = rowGroupModel.findIndex((x) => x === src);
|
|
18
|
+
const isBefore = overIndex < dragIndex;
|
|
19
|
+
if (overIndex === dragIndex)
|
|
20
|
+
return;
|
|
24
21
|
const srcIndex = rowGroupModel.findIndex((x) => {
|
|
25
22
|
if (typeof src !== typeof x)
|
|
26
23
|
return;
|
|
@@ -58,12 +55,14 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
58
55
|
dragData: { [groupId]: c },
|
|
59
56
|
data: c,
|
|
60
57
|
draggable: true,
|
|
58
|
+
source: "groups",
|
|
61
59
|
id: c,
|
|
60
|
+
index: i,
|
|
62
61
|
label: column.name ?? column.id,
|
|
63
62
|
onAction: () => { },
|
|
64
63
|
onDelete: onDelete,
|
|
65
64
|
onDrop: onDrop,
|
|
66
|
-
dragPlaceholder:
|
|
65
|
+
dragPlaceholder: dragPlaceholder ? () => dragPlaceholder(c) : undefined,
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
else {
|
|
@@ -72,11 +71,13 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
72
71
|
data: c,
|
|
73
72
|
draggable: true,
|
|
74
73
|
id: c.id,
|
|
74
|
+
source: "groups",
|
|
75
|
+
index: i,
|
|
75
76
|
label: c.name ?? c.id,
|
|
76
77
|
onAction: () => { },
|
|
77
78
|
onDelete: onDelete,
|
|
78
79
|
onDrop,
|
|
79
|
-
dragPlaceholder:
|
|
80
|
+
dragPlaceholder: dragPlaceholder ? () => dragPlaceholder(c) : undefined,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
})
|
|
@@ -84,11 +85,9 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
84
85
|
}, [
|
|
85
86
|
grid.api,
|
|
86
87
|
grid.state.rowGroupModel,
|
|
87
|
-
grid.state.rtl,
|
|
88
88
|
gridId,
|
|
89
89
|
hideColumnOnGroup,
|
|
90
|
-
|
|
91
|
-
placeholder,
|
|
90
|
+
dragPlaceholder,
|
|
92
91
|
rowGroupModel,
|
|
93
92
|
]);
|
|
94
93
|
const onRootDrop = useEvent((p) => {
|
package/dist/grid.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Root } from "./root/root";
|
|
2
|
-
import { makeClientDataSource, useClientRowDataSource } from "./row-data-source-client/use-client-data-source";
|
|
3
|
-
import { makeClientDataSourcePaginated, useClientRowDataSourcePaginated } from "./row-data-source-client/use-client-data-source-paginated";
|
|
4
|
-
import { makeClientTreeDataSource, useClientTreeDataSource } from "./row-data-source-client/use-client-tree-data-source";
|
|
5
|
-
import { makeServerDataSource, useServerDataSource } from "./row-data-source-server/use-server-data-source";
|
|
6
2
|
import { useLyteNyte } from "./state/use-lytenyte";
|
|
7
3
|
export declare const Grid: {
|
|
8
4
|
Root: typeof Root;
|
|
@@ -19,12 +15,4 @@ export declare const Grid: {
|
|
|
19
15
|
RowsCenter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
16
|
Viewport: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
17
|
useLyteNyte: typeof useLyteNyte;
|
|
22
|
-
useClientRowDataSource: typeof useClientRowDataSource;
|
|
23
|
-
makeClientDataSource: typeof makeClientDataSource;
|
|
24
|
-
makeClientDataSourcePaginated: typeof makeClientDataSourcePaginated;
|
|
25
|
-
useClientRowDataSourcePaginated: typeof useClientRowDataSourcePaginated;
|
|
26
|
-
useClientTreeDataSource: typeof useClientTreeDataSource;
|
|
27
|
-
makeClientTreeDataSource: typeof makeClientTreeDataSource;
|
|
28
|
-
makeServerDataSource: typeof makeServerDataSource;
|
|
29
|
-
useServerDataSource: typeof useServerDataSource;
|
|
30
18
|
};
|
package/dist/grid.js
CHANGED
|
@@ -4,10 +4,6 @@ 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";
|
|
12
8
|
import { Row } from "./rows/row/row";
|
|
13
9
|
import { RowsContainer } from "./rows/rows-container";
|
|
@@ -29,12 +25,4 @@ export const Grid = {
|
|
|
29
25
|
RowsCenter,
|
|
30
26
|
Viewport,
|
|
31
27
|
useLyteNyte,
|
|
32
|
-
useClientRowDataSource,
|
|
33
|
-
makeClientDataSource,
|
|
34
|
-
makeClientDataSourcePaginated,
|
|
35
|
-
useClientRowDataSourcePaginated,
|
|
36
|
-
useClientTreeDataSource,
|
|
37
|
-
makeClientTreeDataSource,
|
|
38
|
-
makeServerDataSource,
|
|
39
|
-
useServerDataSource,
|
|
40
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
|
}
|