react-arborist 2.0.0 → 2.1.1
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/README.md +3 -3
- package/dist/components/default-node.d.ts +1 -2
- package/dist/components/default-row.d.ts +1 -2
- package/dist/components/provider.d.ts +2 -3
- package/dist/components/row-container.d.ts +1 -2
- package/dist/components/tree.d.ts +1 -2
- package/dist/context.d.ts +1 -2
- package/dist/data/create-index.d.ts +1 -2
- package/dist/data/create-list.d.ts +1 -2
- package/dist/data/create-root.d.ts +1 -2
- package/dist/data/simple-tree.d.ts +5 -4
- package/dist/dnd/drag-hook.d.ts +1 -2
- package/dist/hooks/use-fresh-node.d.ts +1 -2
- package/dist/hooks/use-simple-tree.d.ts +5 -6
- package/dist/hooks/use-validated-props.d.ts +1 -2
- package/dist/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/node-api.d.ts +2 -3
- package/dist/interfaces/tree-api.d.ts +3 -3
- package/dist/module.js +21 -11
- package/dist/module.js.map +1 -1
- package/dist/types/handlers.d.ts +10 -4
- package/dist/types/renderers.d.ts +2 -3
- package/dist/types/tree-props.d.ts +10 -10
- package/dist/types/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/default-drag-preview.tsx +1 -1
- package/src/components/default-node.tsx +3 -3
- package/src/components/default-row.tsx +1 -1
- package/src/components/provider.tsx +2 -2
- package/src/components/row-container.tsx +1 -1
- package/src/components/tree.tsx +1 -1
- package/src/context.ts +1 -1
- package/src/data/create-index.ts +1 -1
- package/src/data/create-list.ts +3 -3
- package/src/data/create-root.ts +2 -2
- package/src/data/simple-tree.ts +5 -5
- package/src/dnd/drag-hook.ts +5 -4
- package/src/hooks/use-fresh-node.ts +1 -1
- package/src/hooks/use-simple-tree.ts +12 -7
- package/src/hooks/use-validated-props.ts +1 -3
- package/src/interfaces/node-api.ts +2 -2
- package/src/interfaces/tree-api.ts +26 -15
- package/src/types/handlers.ts +12 -4
- package/src/types/renderers.ts +2 -2
- package/src/types/tree-props.ts +10 -10
- package/src/types/utils.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TreeApi } from "./tree-api";
|
|
3
|
-
|
|
4
|
-
declare type Params<T extends IdObj> = {
|
|
3
|
+
declare type Params<T> = {
|
|
5
4
|
id: string;
|
|
6
5
|
data: T;
|
|
7
6
|
level: number;
|
|
@@ -12,7 +11,7 @@ declare type Params<T extends IdObj> = {
|
|
|
12
11
|
rowIndex: number | null;
|
|
13
12
|
tree: TreeApi<T>;
|
|
14
13
|
};
|
|
15
|
-
export declare class NodeApi<T
|
|
14
|
+
export declare class NodeApi<T = any> {
|
|
16
15
|
tree: TreeApi<T>;
|
|
17
16
|
id: string;
|
|
18
17
|
data: T;
|
|
@@ -11,7 +11,7 @@ import { DefaultDragPreview } from "../components/default-drag-preview";
|
|
|
11
11
|
import { DefaultContainer } from "../components/default-container";
|
|
12
12
|
import { Cursor } from "../dnd/compute-drop";
|
|
13
13
|
import { Store } from "redux";
|
|
14
|
-
export declare class TreeApi<T
|
|
14
|
+
export declare class TreeApi<T> {
|
|
15
15
|
store: Store<RootState, Actions>;
|
|
16
16
|
props: TreeProps<T>;
|
|
17
17
|
list: MutableRefObject<FixedSizeList | null>;
|
|
@@ -38,7 +38,7 @@ export declare class TreeApi<T extends IdObj> {
|
|
|
38
38
|
dnd: import("../state/dnd-slice").DndState;
|
|
39
39
|
}>;
|
|
40
40
|
get openState(): import("../state/open-slice").OpenMap;
|
|
41
|
-
get width(): number;
|
|
41
|
+
get width(): string | number;
|
|
42
42
|
get height(): number;
|
|
43
43
|
get indent(): number;
|
|
44
44
|
get rowHeight(): number;
|
|
@@ -66,7 +66,7 @@ export declare class TreeApi<T extends IdObj> {
|
|
|
66
66
|
}): Promise<void>;
|
|
67
67
|
delete(node: string | IdObj | null | string[] | IdObj[]): Promise<void>;
|
|
68
68
|
edit(node: string | IdObj): Promise<EditResult>;
|
|
69
|
-
submit(
|
|
69
|
+
submit(identity: Identity, value: string): Promise<void>;
|
|
70
70
|
reset(): void;
|
|
71
71
|
activate(id: string | IdObj | null): void;
|
|
72
72
|
private resolveEdit;
|
package/dist/module.js
CHANGED
|
@@ -941,10 +941,13 @@ function $907e707a330ef23a$export$715c0d031ede7907(node) {
|
|
|
941
941
|
// If they held down meta, we need to create a copy
|
|
942
942
|
// if (drop.dropEffect === "copy")
|
|
943
943
|
if (drop && drop.parentId) {
|
|
944
|
+
const parentId = drop.parentId === (0, $81080a351c006222$export$ec71a3379b43ae5c) ? null : drop.parentId;
|
|
944
945
|
(0, $0e6083160f4b36ed$export$c6d63370cef03886)(tree.props.onMove, {
|
|
945
946
|
dragIds: item.dragIds,
|
|
946
|
-
parentId:
|
|
947
|
-
index: drop.index
|
|
947
|
+
parentId: parentId,
|
|
948
|
+
index: drop.index,
|
|
949
|
+
dragNodes: item.dragIds.map((id)=>tree.get(id)),
|
|
950
|
+
parentNode: tree.get(drop.parentId)
|
|
948
951
|
});
|
|
949
952
|
tree.open(drop.parentId);
|
|
950
953
|
}
|
|
@@ -1626,10 +1629,14 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1626
1629
|
});
|
|
1627
1630
|
}
|
|
1628
1631
|
async create(opts = {}) {
|
|
1632
|
+
const parentId = opts.parentId === undefined ? $0e6083160f4b36ed$exports.getInsertParentId(this) : opts.parentId;
|
|
1633
|
+
const index = opts.index ?? $0e6083160f4b36ed$exports.getInsertIndex(this);
|
|
1634
|
+
const type = opts.type ?? "leaf";
|
|
1629
1635
|
const data = await $bfece7c4aed4e9c4$var$safeRun(this.props.onCreate, {
|
|
1630
|
-
type:
|
|
1631
|
-
parentId:
|
|
1632
|
-
index:
|
|
1636
|
+
type: type,
|
|
1637
|
+
parentId: parentId,
|
|
1638
|
+
index: index,
|
|
1639
|
+
parentNode: this.get(parentId)
|
|
1633
1640
|
});
|
|
1634
1641
|
if (data) {
|
|
1635
1642
|
this.focus(data);
|
|
@@ -1643,11 +1650,13 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1643
1650
|
}
|
|
1644
1651
|
async delete(node) {
|
|
1645
1652
|
if (!node) return;
|
|
1646
|
-
const
|
|
1653
|
+
const idents = Array.isArray(node) ? node : [
|
|
1647
1654
|
node
|
|
1648
1655
|
];
|
|
1649
|
-
const ids =
|
|
1656
|
+
const ids = idents.map($bfece7c4aed4e9c4$var$identify);
|
|
1657
|
+
const nodes = ids.map((id)=>this.get(id)).filter((n)=>!!n);
|
|
1650
1658
|
await $bfece7c4aed4e9c4$var$safeRun(this.props.onDelete, {
|
|
1659
|
+
nodes: nodes,
|
|
1651
1660
|
ids: ids
|
|
1652
1661
|
});
|
|
1653
1662
|
}
|
|
@@ -1662,12 +1671,13 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1662
1671
|
$bfece7c4aed4e9c4$export$e2da3477247342d1.editPromise = resolve;
|
|
1663
1672
|
});
|
|
1664
1673
|
}
|
|
1665
|
-
async submit(
|
|
1666
|
-
if (!
|
|
1667
|
-
const id = $bfece7c4aed4e9c4$var$identify(
|
|
1674
|
+
async submit(identity, value) {
|
|
1675
|
+
if (!identity) return;
|
|
1676
|
+
const id = $bfece7c4aed4e9c4$var$identify(identity);
|
|
1668
1677
|
await $bfece7c4aed4e9c4$var$safeRun(this.props.onRename, {
|
|
1669
1678
|
id: id,
|
|
1670
|
-
name: value
|
|
1679
|
+
name: value,
|
|
1680
|
+
node: this.get(id)
|
|
1671
1681
|
});
|
|
1672
1682
|
this.dispatch((0, $21783d2b0251be67$export$e1a8e267487c59d1)(null));
|
|
1673
1683
|
this.resolveEdit({
|