@1771technologies/lytenyte-pro 1.0.0-beta.13 → 1.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +5 -1
- package/dist/column-manager/use-column-manager.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/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 +4 -2
- package/dist/grid-box/item.d.ts +4 -1
- package/dist/grid-box/item.js +34 -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 +5 -3
- package/dist/grid-box/use-row-group-box-items.d.ts +2 -2
- package/dist/grid-box/use-row-group-box-items.js +9 -5
- package/dist/header/header-cell.d.ts +1 -1
- package/dist/header/header-cell.js +2 -2
- package/dist/header/resize-handler.d.ts +2 -2
- package/dist/header/resize-handler.js +7 -3
- package/dist/listbox/item.js +1 -1
- package/dist/row-data-source-client/filter/compute-filtered-rows.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/state/+types.d.ts +2 -1
- package/dist/state/api/column-update.d.ts +4 -1
- package/dist/state/api/column-update.js +13 -0
- package/dist/state/helpers/column-add-row-group.d.ts +2 -1
- package/dist/state/helpers/column-add-row-group.js +8 -1
- package/dist/state/use-lytenyte.js +5 -0
- package/dist/tree-view/leaf.js +1 -0
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useMemo } from "react";
|
|
3
3
|
import { TreeBranch } from "../tree-view/branch/branch";
|
|
4
4
|
import { ColumnItemContext } from "./context";
|
|
5
5
|
import { dragState, DropWrap } from "@1771technologies/lytenyte-dragon";
|
|
@@ -9,8 +9,23 @@ export const Branch = forwardRef(function Branch({ item, label, ...props }, forw
|
|
|
9
9
|
const grid = useGrid();
|
|
10
10
|
const id = grid.state.gridId.useValue();
|
|
11
11
|
const accepted = `${id}/columns`;
|
|
12
|
+
const base = grid.state.columnBase.useValue();
|
|
12
13
|
const columns = useColumnsFromContext(item);
|
|
13
|
-
|
|
14
|
+
const isVisible = useMemo(() => {
|
|
15
|
+
const allVisible = columns.every((c) => !(c.hide ?? base.hide));
|
|
16
|
+
return allVisible;
|
|
17
|
+
}, [base.hide, columns]);
|
|
18
|
+
const toggle = useCallback((s) => {
|
|
19
|
+
const next = s ?? isVisible;
|
|
20
|
+
grid.api.columnUpdate(Object.fromEntries(columns.map((c) => [c.id, { hide: next }])));
|
|
21
|
+
}, [columns, grid.api, isVisible]);
|
|
22
|
+
return (_jsx(ColumnItemContext, { value: useMemo(() => ({ item }), [item]), children: _jsx(TreeBranch, { ...props, itemId: item.branch.data.idOccurrence, ref: forwarded, ...item.attrs, onKeyDown: (ev) => {
|
|
23
|
+
props.onKeyDown?.(ev);
|
|
24
|
+
if (ev.key === " ") {
|
|
25
|
+
toggle();
|
|
26
|
+
ev.preventDefault();
|
|
27
|
+
}
|
|
28
|
+
}, labelWrap: _jsx(DropWrap, { "data-ln-column-manager-branch": true, "data-ln-column-id": item.branch.data.idOccurrence, accepted: [accepted], onEnter: (el) => {
|
|
14
29
|
const data = dragState.data
|
|
15
30
|
.get()
|
|
16
31
|
?.siteLocalData?.[accepted]?.at(-1);
|
|
@@ -25,7 +40,8 @@ export const Branch = forwardRef(function Branch({ item, label, ...props }, forw
|
|
|
25
40
|
return;
|
|
26
41
|
const thisIndex = allColumns.findIndex((c) => c.id === columns[0].id);
|
|
27
42
|
const isBefore = thisIndex > moveIndex;
|
|
28
|
-
|
|
43
|
+
// Flipped since our source is the one moving
|
|
44
|
+
if (!isBefore) {
|
|
29
45
|
el.setAttribute("data-ln-is-before", "true");
|
|
30
46
|
}
|
|
31
47
|
else {
|
|
@@ -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 { useColumnItemContext } from "./context";
|
|
4
4
|
import { forwardRef, useMemo } from "react";
|
|
5
|
-
export const Label = forwardRef(function Label({
|
|
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")
|
|
@@ -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
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useMemo } from "react";
|
|
3
3
|
import { ColumnItemContext } from "./context";
|
|
4
4
|
import { TreeLeaf } from "../tree-view/leaf";
|
|
5
5
|
import { dragState, DropWrap } from "@1771technologies/lytenyte-dragon";
|
|
6
6
|
import { useGrid } from "../grid-provider/use-grid";
|
|
7
|
+
import { useColumnsFromContext } from "./use-columns-from-context";
|
|
7
8
|
export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, forwarded) {
|
|
8
9
|
const context = useMemo(() => {
|
|
9
10
|
return { item: item };
|
|
@@ -11,6 +12,16 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
|
|
|
11
12
|
const grid = useGrid();
|
|
12
13
|
const id = grid.state.gridId.useValue();
|
|
13
14
|
const accepted = `${id}/columns`;
|
|
15
|
+
const base = grid.state.columnBase.useValue();
|
|
16
|
+
const columns = useColumnsFromContext(item);
|
|
17
|
+
const isVisible = useMemo(() => {
|
|
18
|
+
const allVisible = columns.every((c) => !(c.hide ?? base.hide));
|
|
19
|
+
return allVisible;
|
|
20
|
+
}, [base.hide, columns]);
|
|
21
|
+
const toggle = useCallback((s) => {
|
|
22
|
+
const next = s ?? isVisible;
|
|
23
|
+
grid.api.columnUpdate(Object.fromEntries(columns.map((c) => [c.id, { hide: next }])));
|
|
24
|
+
}, [columns, grid.api, isVisible]);
|
|
14
25
|
return (_jsx(ColumnItemContext.Provider, { value: context, children: _jsx(DropWrap, { accepted: [accepted], onEnter: (el) => {
|
|
15
26
|
const data = dragState.data
|
|
16
27
|
.get()
|
|
@@ -27,7 +38,8 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
|
|
|
27
38
|
return;
|
|
28
39
|
const thisIndex = allColumns.findIndex((c) => c.id === columns[0].id);
|
|
29
40
|
const isBefore = thisIndex > moveIndex;
|
|
30
|
-
|
|
41
|
+
// Flipped since our source is the one moving
|
|
42
|
+
if (!isBefore) {
|
|
31
43
|
el.setAttribute("data-ln-is-before", "true");
|
|
32
44
|
}
|
|
33
45
|
else {
|
|
@@ -36,5 +48,11 @@ export const Leaf = forwardRef(function ColumnManagerLeaf({ item, ...props }, fo
|
|
|
36
48
|
}, onLeave: (el) => {
|
|
37
49
|
el.removeAttribute("data-ln-is-before");
|
|
38
50
|
el.removeAttribute("data-ln-is-after");
|
|
39
|
-
}, as: _jsx(TreeLeaf, { ...props, itemId: item.leaf.data.id, ref: forwarded, ...item.attrs, style: { ...props.style, ...item.attrs.style },
|
|
51
|
+
}, as: _jsx(TreeLeaf, { ...props, itemId: item.leaf.data.id, ref: forwarded, ...item.attrs, style: { ...props.style, ...item.attrs.style }, onKeyDown: (ev) => {
|
|
52
|
+
props.onKeyDown?.(ev);
|
|
53
|
+
if (ev.key === " ") {
|
|
54
|
+
toggle();
|
|
55
|
+
ev.preventDefault();
|
|
56
|
+
}
|
|
57
|
+
}, "data-ln-column-manager-leaf": true, "data-ln-column-id": item.leaf.data.id }) }) }));
|
|
40
58
|
});
|
|
@@ -3,7 +3,7 @@ import { type ReactNode } from "react";
|
|
|
3
3
|
import type { Column } from "../+types";
|
|
4
4
|
import type { TreeVirtualItem } from "../tree-view/virtualized/make-virtual-tree";
|
|
5
5
|
export interface MoveHandleProps {
|
|
6
|
-
readonly
|
|
6
|
+
readonly as?: SlotComponent;
|
|
7
7
|
readonly placeholder?: (p: {
|
|
8
8
|
columns: Column<any>[];
|
|
9
9
|
item: TreeVirtualItem<Column<any>>;
|
|
@@ -5,7 +5,7 @@ import { forwardRef, useMemo } from "react";
|
|
|
5
5
|
import { useColumnItemContext } from "./context";
|
|
6
6
|
import { useColumnsFromContext } from "./use-columns-from-context";
|
|
7
7
|
import { useGrid } from "../grid-provider/use-grid";
|
|
8
|
-
export const MoveHandle = forwardRef(function MoveHandle({
|
|
8
|
+
export const MoveHandle = forwardRef(function MoveHandle({ as, placeholder: Placeholder, ...props }, forwarded) {
|
|
9
9
|
const item = useColumnItemContext().item;
|
|
10
10
|
const grid = useGrid();
|
|
11
11
|
const columns = useColumnsFromContext(item);
|
|
@@ -52,7 +52,7 @@ export const MoveHandle = forwardRef(function MoveHandle({ slot, placeholder: Pl
|
|
|
52
52
|
const renderer = useSlot({
|
|
53
53
|
props: [{ "aria-label": "Drag to move column" }, additionalProps, props],
|
|
54
54
|
ref: isMovable ? combined : forwarded,
|
|
55
|
-
slot:
|
|
55
|
+
slot: as ?? _jsx("div", {}),
|
|
56
56
|
});
|
|
57
57
|
return renderer;
|
|
58
58
|
});
|
|
@@ -16,5 +16,5 @@ export function Root({ grid, children, treeRef, root, ...rootProps }) {
|
|
|
16
16
|
}
|
|
17
17
|
return lookup;
|
|
18
18
|
}, [root.children]);
|
|
19
|
-
return (_jsx(branchLookupContext.Provider, { value: branchLookup, children: _jsx(GridProvider, { value: grid, children: _jsx(TreeRoot, { selectMode: "
|
|
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 }) }) }));
|
|
20
20
|
}
|
|
@@ -16,4 +16,8 @@ export interface UseColumnManagerReturn<T> {
|
|
|
16
16
|
readonly tree: TreeVirtualItem<Column<T>>[];
|
|
17
17
|
readonly spacer: JSX.Element;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export interface UseColumnManagerArgs<T> {
|
|
20
|
+
readonly grid: Grid<T>;
|
|
21
|
+
readonly itemHeight?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function useColumnManager<T>({ grid, itemHeight, }: UseColumnManagerArgs<T>): UseColumnManagerReturn<T>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { useVirtualizedTree } from "../tree-view/virtualized/use-virtualized-tree.js";
|
|
3
|
-
export function useColumnManager(grid) {
|
|
3
|
+
export function useColumnManager({ grid, itemHeight = 24, }) {
|
|
4
4
|
const [expansions, onExpansionChange] = useState({});
|
|
5
5
|
const columns = grid.state.columns.useValue();
|
|
6
6
|
const virt = useVirtualizedTree({
|
|
7
7
|
paths: columns,
|
|
8
8
|
expansions,
|
|
9
|
-
itemHeight
|
|
9
|
+
itemHeight,
|
|
10
10
|
expansionDefault: true,
|
|
11
11
|
nonAdjacentPathTrees: true,
|
|
12
12
|
});
|
|
@@ -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 },
|
|
@@ -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,10 +16,10 @@ 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)
|
|
@@ -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, ...props }, forwarded) {
|
|
8
8
|
const { accepted } = useGridBoxContext();
|
|
9
9
|
const { dragProps } = useDraggable({
|
|
10
10
|
getItems: () => {
|
|
@@ -19,15 +19,40 @@ 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 })),
|
|
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 thisIndex = Number.parseInt(e.getAttribute("data-ln-index"));
|
|
45
|
+
const dragIndex = Number.parseInt(e.getAttribute("data-ln-index"));
|
|
46
|
+
if (Number.isNaN(dragIndex) || Number.isNaN(thisIndex))
|
|
47
|
+
return;
|
|
48
|
+
if (thisIndex < 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: item.onDrop, as: renderer }));
|
|
33
58
|
});
|
|
@@ -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,12 +28,14 @@ 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
40
|
const target = c;
|
|
39
41
|
const src = p.state.siteLocalData?.[columnId];
|
|
@@ -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,12 +1,12 @@
|
|
|
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
|
};
|
|
@@ -58,12 +58,14 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
58
58
|
dragData: { [groupId]: c },
|
|
59
59
|
data: c,
|
|
60
60
|
draggable: true,
|
|
61
|
+
source: "groups",
|
|
61
62
|
id: c,
|
|
63
|
+
index: i,
|
|
62
64
|
label: column.name ?? column.id,
|
|
63
65
|
onAction: () => { },
|
|
64
66
|
onDelete: onDelete,
|
|
65
67
|
onDrop: onDrop,
|
|
66
|
-
dragPlaceholder:
|
|
68
|
+
dragPlaceholder: dragPlaceholder ? () => dragPlaceholder(c) : undefined,
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
else {
|
|
@@ -72,11 +74,13 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
72
74
|
data: c,
|
|
73
75
|
draggable: true,
|
|
74
76
|
id: c.id,
|
|
77
|
+
source: "groups",
|
|
78
|
+
index: i,
|
|
75
79
|
label: c.name ?? c.id,
|
|
76
80
|
onAction: () => { },
|
|
77
81
|
onDelete: onDelete,
|
|
78
82
|
onDrop,
|
|
79
|
-
dragPlaceholder:
|
|
83
|
+
dragPlaceholder: dragPlaceholder ? () => dragPlaceholder(c) : undefined,
|
|
80
84
|
};
|
|
81
85
|
}
|
|
82
86
|
})
|
|
@@ -88,7 +92,7 @@ export function useRowGroupBoxItems({ grid, orientation, placeholder, hideColumn
|
|
|
88
92
|
gridId,
|
|
89
93
|
hideColumnOnGroup,
|
|
90
94
|
orientation,
|
|
91
|
-
|
|
95
|
+
dragPlaceholder,
|
|
92
96
|
rowGroupModel,
|
|
93
97
|
]);
|
|
94
98
|
const onRootDrop = useEvent((p) => {
|
|
@@ -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);
|
|
@@ -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,7 +5,7 @@ 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();
|
|
@@ -57,7 +57,9 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
57
57
|
const id = sx.state.gridId.get();
|
|
58
58
|
const query = `[data-ln-row][data-ln-gridid="${id}"] [data-ln-cell="true"][data-ln-colindex="${cell.colStart}"]`;
|
|
59
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"]`;
|
|
60
61
|
const header = vp.querySelector(headerQuery);
|
|
62
|
+
const floating = vp.querySelector(floatingQuery);
|
|
61
63
|
if (!header)
|
|
62
64
|
return;
|
|
63
65
|
const pin = header.getAttribute("data-ln-pin");
|
|
@@ -72,6 +74,8 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
72
74
|
}
|
|
73
75
|
const q = Array.from(vp.querySelectorAll(query));
|
|
74
76
|
q.push(header);
|
|
77
|
+
if (floating)
|
|
78
|
+
q.push(floating);
|
|
75
79
|
q.forEach((c) => {
|
|
76
80
|
if (!isHTMLElement(c))
|
|
77
81
|
return;
|
|
@@ -113,7 +117,7 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
113
117
|
className,
|
|
114
118
|
style: {
|
|
115
119
|
height: "100%",
|
|
116
|
-
width: "
|
|
120
|
+
width: "6px",
|
|
117
121
|
...style,
|
|
118
122
|
top: "0px",
|
|
119
123
|
insetInlineEnd: cell.colPin !== "end" ? "0px" : undefined,
|
|
@@ -123,7 +127,7 @@ export function ResizeHandler({ slot, cell, xPositions, style, className, }) {
|
|
|
123
127
|
};
|
|
124
128
|
const edge = useSlot({
|
|
125
129
|
props: [defaultProps],
|
|
126
|
-
slot:
|
|
130
|
+
slot: as ?? _jsx("div", {}),
|
|
127
131
|
});
|
|
128
132
|
return edge;
|
|
129
133
|
}
|
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 }));
|
|
@@ -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)
|
|
@@ -2,12 +2,12 @@ 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 { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortAdd = forwardRef(function SortAdd({
|
|
5
|
+
export const SortAdd = forwardRef(function SortAdd({ as: as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const renderer = useSlot({
|
|
8
|
-
props: [props],
|
|
8
|
+
props: [typeof as !== "function" ? { onClick: row.onAdd, disabled: !row.canAdd } : {}, props],
|
|
9
9
|
ref: forwarded,
|
|
10
|
-
slot:
|
|
10
|
+
slot: as ?? _jsx("button", { children: "+" }),
|
|
11
11
|
state: { onAdd: row.onAdd, disabled: !row.canAdd },
|
|
12
12
|
});
|
|
13
13
|
return renderer;
|
|
@@ -4,7 +4,7 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
5
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
6
6
|
import { sortItemsToSortModel } from "./utils/sort-item-to-sort-model";
|
|
7
|
-
export const SortApply = forwardRef(function SortApply({
|
|
7
|
+
export const SortApply = forwardRef(function SortApply({ as, ...props }, forwarded) {
|
|
8
8
|
const ctx = useSortManagerCtx();
|
|
9
9
|
const onApply = useEvent(() => {
|
|
10
10
|
const lookup = itemsWithIdToMap(ctx.mode ? ctx.grid.state.columnPivotColumns.get() : ctx.grid.state.columns.get());
|
|
@@ -15,9 +15,9 @@ export const SortApply = forwardRef(function SortApply({ slot, ...props }, forwa
|
|
|
15
15
|
ctx.grid.state.sortModel.set(model);
|
|
16
16
|
});
|
|
17
17
|
const renderer = useSlot({
|
|
18
|
-
props: [props],
|
|
18
|
+
props: [typeof as !== "function" ? { onClick: onApply } : {}, props],
|
|
19
19
|
ref: forwarded,
|
|
20
|
-
slot:
|
|
20
|
+
slot: as ?? _jsx("button", {}),
|
|
21
21
|
state: { onApply },
|
|
22
22
|
});
|
|
23
23
|
return renderer;
|
|
@@ -4,7 +4,7 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
5
|
import { sortModelToSortItems } from "./utils/sort-model-to-sort-items";
|
|
6
6
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
7
|
-
export const SortCancel = forwardRef(function SortCancel({
|
|
7
|
+
export const SortCancel = forwardRef(function SortCancel({ as, ...props }, forwarded) {
|
|
8
8
|
const ctx = useSortManagerCtx();
|
|
9
9
|
const onCancel = useEvent(() => {
|
|
10
10
|
const model = ctx.mode
|
|
@@ -18,9 +18,9 @@ export const SortCancel = forwardRef(function SortCancel({ slot, ...props }, for
|
|
|
18
18
|
ctx.setSortItems(state);
|
|
19
19
|
});
|
|
20
20
|
const renderer = useSlot({
|
|
21
|
-
props: [props],
|
|
21
|
+
props: [typeof as !== "function" ? { onClick: onCancel } : {}, props],
|
|
22
22
|
ref: forwarded,
|
|
23
|
-
slot:
|
|
23
|
+
slot: as ?? _jsx("button", {}),
|
|
24
24
|
state: { onCancel },
|
|
25
25
|
});
|
|
26
26
|
return renderer;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEvent, useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
|
-
export const SortClear = forwardRef(function SortClear({
|
|
5
|
+
export const SortClear = forwardRef(function SortClear({ as, ...props }, forwarded) {
|
|
6
6
|
const ctx = useSortManagerCtx();
|
|
7
7
|
const onClear = useEvent(() => {
|
|
8
8
|
if (ctx.mode) {
|
|
@@ -13,9 +13,9 @@ export const SortClear = forwardRef(function SortClear({ slot, ...props }, forwa
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
const renderer = useSlot({
|
|
16
|
-
props: [props],
|
|
16
|
+
props: [typeof as !== "function" ? { onClick: onClear } : {}, props],
|
|
17
17
|
ref: forwarded,
|
|
18
|
-
slot:
|
|
18
|
+
slot: as ?? _jsx("button", {}),
|
|
19
19
|
state: { onClear },
|
|
20
20
|
});
|
|
21
21
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortColumnSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortColumnSelect = forwardRef(function SortColumnSelect({
|
|
5
|
+
export const SortColumnSelect = forwardRef(function SortColumnSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsxs("select", { "aria-label": "Select column to sort", value: row.columnItem?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.columnOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortColumnSelect = forwardRef(function SortColumnSelect({ slot, ...
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: { options: row.columnOptions, onSelect: row.columnOnSelect, value: row.columnSelected },
|
|
18
18
|
});
|
|
19
19
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortDirectionSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -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 } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortDirectionSelect = forwardRef(function SortDirectionSelect({
|
|
5
|
+
export const SortDirectionSelect = forwardRef(function SortDirectionSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsx("select", { "aria-label": "Select sort direction", value: row.sortDirectionSelected?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.sortDirectionOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortDirectionSelect = forwardRef(function SortDirectionSelect({ slo
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: {
|
|
18
18
|
options: row.sortDirectionOptions,
|
|
19
19
|
onSelect: row.sortDirectionOnSelect,
|
|
@@ -2,12 +2,12 @@ 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 { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortRemove = forwardRef(function SortRemove({
|
|
5
|
+
export const SortRemove = forwardRef(function SortRemove({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const renderer = useSlot({
|
|
8
|
-
props: [props],
|
|
8
|
+
props: [typeof as !== "function" ? { onClick: row.onDelete } : {}, props],
|
|
9
9
|
ref: forwarded,
|
|
10
|
-
slot:
|
|
10
|
+
slot: as ?? _jsx("button", { children: "x" }),
|
|
11
11
|
state: { onAdd: row.onDelete },
|
|
12
12
|
});
|
|
13
13
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortValueSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortValueSelect = forwardRef(function SortValueSelect({
|
|
5
|
+
export const SortValueSelect = forwardRef(function SortValueSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsxs("select", { "aria-label": "Select sort value", value: row.sortSelected?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.sortOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortValueSelect = forwardRef(function SortValueSelect({ slot, ...pr
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: {
|
|
18
18
|
options: row.sortOptions,
|
|
19
19
|
value: row.sortSelected,
|
package/dist/state/+types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutMap } from "@1771technologies/lytenyte-shared";
|
|
2
|
-
import type { DataRect, EditActivePosition, GridAtom, GridAtomReadonly, HeaderGroupCellLayout, PositionUnion, VirtualTarget } from "../+types";
|
|
2
|
+
import type { Column, DataRect, EditActivePosition, GridAtom, GridAtomReadonly, HeaderGroupCellLayout, PositionUnion, VirtualTarget } from "../+types";
|
|
3
3
|
import type { Atom, createStore } from "@1771technologies/atom";
|
|
4
4
|
export interface InternalAtoms {
|
|
5
5
|
readonly headerRows: GridAtomReadonly<number>;
|
|
@@ -20,6 +20,7 @@ export interface InternalAtoms {
|
|
|
20
20
|
readonly rowSelectedIds: Atom<Set<string>>;
|
|
21
21
|
readonly rowSelectionPivot: GridAtom<string | null>;
|
|
22
22
|
readonly rowSelectionLastWasDeselect: GridAtom<boolean>;
|
|
23
|
+
readonly rowGroupColumnState: GridAtom<Record<string, Partial<Column<any>>>>;
|
|
23
24
|
readonly draggingHeader: GridAtom<HeaderGroupCellLayout | null>;
|
|
24
25
|
readonly dialogFrames: GridAtom<Record<string, any>>;
|
|
25
26
|
readonly popoverFrames: GridAtom<Record<string, {
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Grid, GridApi } from "../../+types";
|
|
2
|
-
|
|
2
|
+
import type { InternalAtoms } from "../+types";
|
|
3
|
+
export declare const makeColumnUpdate: (grid: Grid<any> & {
|
|
4
|
+
internal: InternalAtoms;
|
|
5
|
+
}) => GridApi<any>["columnUpdate"];
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { GROUP_COLUMN_PREFIX } from "@1771technologies/lytenyte-shared";
|
|
1
2
|
export const makeColumnUpdate = (grid) => {
|
|
2
3
|
return (updates) => {
|
|
3
4
|
const columns = [...grid.state.columns.get()];
|
|
5
|
+
const groupColumns = grid.state.columnMeta
|
|
6
|
+
.get()
|
|
7
|
+
.columnsVisible.filter((c) => c.id.startsWith(GROUP_COLUMN_PREFIX));
|
|
8
|
+
const groupState = { ...grid.internal.rowGroupColumnState.get() };
|
|
9
|
+
for (let i = 0; i < groupColumns.length; i++) {
|
|
10
|
+
const column = groupColumns[i];
|
|
11
|
+
if (updates[column.id]) {
|
|
12
|
+
const next = { ...groupState[column.id], ...updates[column.id] };
|
|
13
|
+
groupState[column.id] = next;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
grid.internal.rowGroupColumnState.set(groupState);
|
|
4
17
|
for (let i = 0; i < columns.length; i++) {
|
|
5
18
|
const column = columns[i];
|
|
6
19
|
if (updates[column.id]) {
|
|
@@ -4,6 +4,7 @@ interface ColumnHandleGroupColumnArgs<T> {
|
|
|
4
4
|
readonly rowGroupTemplate: RowGroupColumn<T>;
|
|
5
5
|
readonly rowGroupModel: RowGroupModelItem<T>[];
|
|
6
6
|
readonly rowGroupDisplayMode: RowGroupDisplayMode;
|
|
7
|
+
readonly rowGroupColumnState: Record<string, Partial<Column<T>>>;
|
|
7
8
|
}
|
|
8
|
-
export declare function columnAddRowGroup<T>({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, }: ColumnHandleGroupColumnArgs<T>): Column<T>[];
|
|
9
|
+
export declare function columnAddRowGroup<T>({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, rowGroupColumnState, }: ColumnHandleGroupColumnArgs<T>): Column<T>[];
|
|
9
10
|
export {};
|
|
@@ -10,7 +10,7 @@ const baseGroup = {
|
|
|
10
10
|
return d.data.key;
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, }) {
|
|
13
|
+
export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, rowGroupColumnState, }) {
|
|
14
14
|
const lookup = itemsWithIdToMap(columns);
|
|
15
15
|
rowGroupModel.forEach((c) => {
|
|
16
16
|
if (typeof c === "string")
|
|
@@ -62,5 +62,12 @@ export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode,
|
|
|
62
62
|
}
|
|
63
63
|
if (!hasGroupColumn)
|
|
64
64
|
columns = columns.filter((c) => !c.id.startsWith(GROUP_COLUMN_PREFIX));
|
|
65
|
+
const keys = Object.keys(rowGroupColumnState);
|
|
66
|
+
for (let i = 0; i < keys.length; i++) {
|
|
67
|
+
if (!lookup.has(keys[i]))
|
|
68
|
+
continue;
|
|
69
|
+
const column = lookup.get(keys[i]);
|
|
70
|
+
Object.assign(column, rowGroupColumnState[keys[i]]);
|
|
71
|
+
}
|
|
65
72
|
return columns;
|
|
66
73
|
}
|
|
@@ -132,6 +132,7 @@ export function makeLyteNyte(p) {
|
|
|
132
132
|
const columnPivotRowGroupExpansions = atom({});
|
|
133
133
|
const cellSelections = atom(p.cellSelections ?? []);
|
|
134
134
|
const cellSelectionMode = atom(p.cellSelectionMode ?? "none");
|
|
135
|
+
const internal__rowGroupColumnState = atom({});
|
|
135
136
|
const internal_cellSelectionPivot = atom(null);
|
|
136
137
|
const internal_cellSelectionAdditive = atom(null);
|
|
137
138
|
const internal_cellSelectionSplits = atom((g) => {
|
|
@@ -220,6 +221,7 @@ export function makeLyteNyte(p) {
|
|
|
220
221
|
* is impacted by the column definitions, the group expansions, the row group display mode.
|
|
221
222
|
*/
|
|
222
223
|
const columnView = atom((g) => {
|
|
224
|
+
const groupState = g(internal__rowGroupColumnState);
|
|
223
225
|
const pivotMode = g(columnPivotMode);
|
|
224
226
|
let cols;
|
|
225
227
|
if (pivotMode) {
|
|
@@ -229,6 +231,7 @@ export function makeLyteNyte(p) {
|
|
|
229
231
|
rowGroupDisplayMode: "single-column",
|
|
230
232
|
rowGroupModel: model.rows.filter((c) => c.active ?? true).map((c) => c.field),
|
|
231
233
|
rowGroupTemplate: g(rowGroupColumn),
|
|
234
|
+
rowGroupColumnState: groupState,
|
|
232
235
|
});
|
|
233
236
|
}
|
|
234
237
|
else {
|
|
@@ -237,6 +240,7 @@ export function makeLyteNyte(p) {
|
|
|
237
240
|
rowGroupDisplayMode: g(rowGroupDisplayMode),
|
|
238
241
|
rowGroupModel: g(rowGroupModel),
|
|
239
242
|
rowGroupTemplate: g(rowGroupColumn),
|
|
243
|
+
rowGroupColumnState: groupState,
|
|
240
244
|
});
|
|
241
245
|
}
|
|
242
246
|
const colsWithMarker = columnHandleMarker({
|
|
@@ -543,6 +547,7 @@ export function makeLyteNyte(p) {
|
|
|
543
547
|
cellSelectionAdditiveRects: makeGridAtom(internal_cellSelectionAdditive, store),
|
|
544
548
|
cellSelectionIsDeselect: makeGridAtom(atom(false), store),
|
|
545
549
|
cellSelectionSplits: makeGridAtom(internal_cellSelectionSplits, store),
|
|
550
|
+
rowGroupColumnState: makeGridAtom(internal__rowGroupColumnState, store),
|
|
546
551
|
store: store,
|
|
547
552
|
},
|
|
548
553
|
});
|
package/dist/tree-view/leaf.js
CHANGED
|
@@ -13,6 +13,7 @@ export const TreeLeaf = forwardRef(function TreeLeaf({ itemId, ...props }, forwa
|
|
|
13
13
|
e.ctrlKey ||
|
|
14
14
|
e.shiftKey)
|
|
15
15
|
return;
|
|
16
|
+
e.preventDefault();
|
|
16
17
|
const nodes = getFocusables(e.currentTarget);
|
|
17
18
|
const index = nodes.indexOf(document.activeElement);
|
|
18
19
|
if (index === -1) {
|
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.15",
|
|
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-core": "1.0.0-beta.
|
|
53
|
-
"@1771technologies/lytenyte-
|
|
54
|
-
"@1771technologies/lytenyte-dom-utils": "1.0.0-beta.
|
|
55
|
-
"@1771technologies/lytenyte-
|
|
56
|
-
"@1771technologies/lytenyte-
|
|
57
|
-
"@1771technologies/lytenyte-react-hooks": "1.0.0-beta.
|
|
52
|
+
"@1771technologies/lytenyte-core": "1.0.0-beta.15",
|
|
53
|
+
"@1771technologies/lytenyte-dragon": "1.0.0-beta.15",
|
|
54
|
+
"@1771technologies/lytenyte-dom-utils": "1.0.0-beta.15",
|
|
55
|
+
"@1771technologies/lytenyte-js-utils": "1.0.0-beta.15",
|
|
56
|
+
"@1771technologies/lytenyte-shared": "1.0.0-beta.15",
|
|
57
|
+
"@1771technologies/lytenyte-react-hooks": "1.0.0-beta.15"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.0.0 || ^19.0.0",
|