react-arborist 3.2.0 → 3.3.1-0
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/main/components/cursor.d.ts +1 -0
- package/dist/main/components/cursor.js +20 -0
- package/dist/{components → main/components}/default-container.d.ts +1 -2
- package/dist/main/components/default-container.js +238 -0
- package/dist/main/components/default-cursor.js +35 -0
- package/dist/{components → main/components}/default-drag-preview.d.ts +1 -2
- package/dist/main/components/default-drag-preview.js +57 -0
- package/dist/{components → main/components}/default-node.d.ts +1 -2
- package/dist/main/components/default-node.js +32 -0
- package/dist/{components → main/components}/default-row.d.ts +1 -2
- package/dist/main/components/default-row.js +8 -0
- package/dist/main/components/drag-preview-container.d.ts +1 -0
- package/dist/main/components/drag-preview-container.js +21 -0
- package/dist/{components → main/components}/list-inner-element.d.ts +1 -1
- package/dist/main/components/list-inner-element.js +25 -0
- package/dist/main/components/list-outer-element.d.ts +2 -0
- package/dist/main/components/list-outer-element.js +38 -0
- package/dist/main/components/outer-drop.js +9 -0
- package/dist/{components → main/components}/provider.d.ts +2 -2
- package/dist/main/components/provider.js +52 -0
- package/dist/{components → main/components}/row-container.d.ts +2 -2
- package/dist/main/components/row-container.js +84 -0
- package/dist/main/components/tree-container.d.ts +1 -0
- package/dist/main/components/tree-container.js +12 -0
- package/dist/{components → main/components}/tree.d.ts +1 -1
- package/dist/main/components/tree.js +15 -0
- package/dist/{context.d.ts → main/context.d.ts} +4 -4
- package/dist/main/context.js +33 -0
- package/dist/main/data/create-index.js +10 -0
- package/dist/main/data/create-list.js +62 -0
- package/dist/main/data/create-root.js +43 -0
- package/dist/main/data/make-tree.d.ts +5 -0
- package/dist/main/data/make-tree.js +40 -0
- package/dist/{data → main/data}/simple-tree.d.ts +1 -1
- package/dist/main/data/simple-tree.js +100 -0
- package/dist/{dnd → main/dnd}/compute-drop.d.ts +6 -6
- package/dist/main/dnd/compute-drop.js +129 -0
- package/dist/main/dnd/drag-hook.js +46 -0
- package/dist/{dnd → main/dnd}/drop-hook.d.ts +2 -2
- package/dist/main/dnd/drop-hook.js +42 -0
- package/dist/main/dnd/measure-hover.d.ts +8 -0
- package/dist/main/dnd/measure-hover.js +21 -0
- package/dist/main/dnd/outer-drop-hook.js +45 -0
- package/dist/main/hooks/use-fresh-node.js +18 -0
- package/dist/{hooks → main/hooks}/use-simple-tree.d.ts +1 -1
- package/dist/main/hooks/use-simple-tree.js +35 -0
- package/dist/main/hooks/use-validated-props.js +29 -0
- package/dist/main/index.js +27 -0
- package/dist/{interfaces → main/interfaces}/node-api.d.ts +2 -1
- package/dist/main/interfaces/node-api.js +164 -0
- package/dist/{interfaces → main/interfaces}/tree-api.d.ts +90 -7
- package/dist/main/interfaces/tree-api.js +649 -0
- package/dist/main/interfaces/tree-api.test.d.ts +1 -0
- package/dist/main/interfaces/tree-api.test.js +14 -0
- package/dist/{state → main/state}/dnd-slice.d.ts +4 -4
- package/dist/main/state/dnd-slice.js +35 -0
- package/dist/{state → main/state}/drag-slice.d.ts +4 -2
- package/dist/main/state/drag-slice.js +24 -0
- package/dist/{state → main/state}/edit-slice.d.ts +1 -1
- package/dist/main/state/edit-slice.js +18 -0
- package/dist/{state → main/state}/focus-slice.d.ts +1 -1
- package/dist/main/state/focus-slice.js +26 -0
- package/dist/main/state/initial.js +29 -0
- package/dist/{state → main/state}/open-slice.d.ts +2 -2
- package/dist/main/state/open-slice.js +48 -0
- package/dist/main/state/root-reducer.d.ts +96 -0
- package/dist/main/state/root-reducer.js +20 -0
- package/dist/{state → main/state}/selection-slice.d.ts +1 -1
- package/dist/main/state/selection-slice.js +59 -0
- package/dist/{types → main/types}/dnd.d.ts +2 -2
- package/dist/main/types/dnd.js +2 -0
- package/dist/{types → main/types}/handlers.d.ts +5 -5
- package/dist/main/types/handlers.js +2 -0
- package/dist/{types → main/types}/renderers.d.ts +4 -4
- package/dist/main/types/renderers.js +2 -0
- package/dist/main/types/state.d.ts +2 -0
- package/dist/main/types/state.js +2 -0
- package/dist/main/types/tree-props.js +2 -0
- package/dist/{types → main/types}/utils.d.ts +5 -5
- package/dist/main/types/utils.js +2 -0
- package/dist/{utils.d.ts → main/utils.d.ts} +2 -2
- package/dist/main/utils.js +183 -0
- package/dist/module/components/cursor.d.ts +1 -0
- package/dist/module/components/cursor.js +16 -0
- package/dist/module/components/default-container.d.ts +6 -0
- package/dist/module/components/default-container.js +234 -0
- package/dist/module/components/default-cursor.d.ts +3 -0
- package/dist/module/components/default-cursor.js +29 -0
- package/dist/module/components/default-drag-preview.d.ts +2 -0
- package/dist/module/components/default-drag-preview.js +53 -0
- package/dist/module/components/default-node.d.ts +2 -0
- package/dist/module/components/default-node.js +28 -0
- package/dist/module/components/default-row.d.ts +2 -0
- package/dist/module/components/default-row.js +4 -0
- package/dist/module/components/drag-preview-container.d.ts +1 -0
- package/dist/module/components/drag-preview-container.js +17 -0
- package/dist/module/components/list-inner-element.d.ts +2 -0
- package/dist/module/components/list-inner-element.js +22 -0
- package/dist/module/components/list-outer-element.d.ts +2 -0
- package/dist/module/components/list-outer-element.js +35 -0
- package/dist/module/components/outer-drop.d.ts +4 -0
- package/dist/module/components/outer-drop.js +5 -0
- package/dist/module/components/provider.d.ts +10 -0
- package/dist/module/components/provider.js +48 -0
- package/dist/module/components/row-container.d.ts +7 -0
- package/dist/module/components/row-container.js +58 -0
- package/dist/module/components/tree-container.d.ts +1 -0
- package/dist/module/components/tree-container.js +8 -0
- package/dist/module/components/tree.d.ts +8 -0
- package/dist/module/components/tree.js +12 -0
- package/dist/module/context.d.ts +22 -0
- package/dist/module/context.js +26 -0
- package/dist/module/data/create-index.d.ts +4 -0
- package/dist/module/data/create-index.js +6 -0
- package/dist/module/data/create-list.d.ts +3 -0
- package/dist/module/data/create-list.js +58 -0
- package/dist/module/data/create-root.d.ts +4 -0
- package/dist/module/data/create-root.js +39 -0
- package/dist/module/data/make-tree.d.ts +5 -0
- package/dist/module/data/make-tree.js +36 -0
- package/dist/module/data/simple-tree.d.ts +44 -0
- package/dist/module/data/simple-tree.js +96 -0
- package/dist/module/dnd/compute-drop.d.ts +37 -0
- package/dist/module/dnd/compute-drop.js +125 -0
- package/dist/module/dnd/drag-hook.d.ts +3 -0
- package/dist/module/dnd/drag-hook.js +42 -0
- package/dist/module/dnd/drop-hook.d.ts +8 -0
- package/dist/module/dnd/drop-hook.js +38 -0
- package/dist/module/dnd/measure-hover.d.ts +8 -0
- package/dist/module/dnd/measure-hover.js +17 -0
- package/dist/module/dnd/outer-drop-hook.d.ts +1 -0
- package/dist/module/dnd/outer-drop-hook.js +41 -0
- package/dist/module/hooks/use-fresh-node.d.ts +1 -0
- package/dist/module/hooks/use-fresh-node.js +14 -0
- package/dist/module/hooks/use-simple-tree.d.ts +12 -0
- package/dist/module/hooks/use-simple-tree.js +31 -0
- package/dist/module/hooks/use-validated-props.d.ts +2 -0
- package/dist/module/hooks/use-validated-props.js +25 -0
- package/dist/module/index.d.ts +8 -0
- package/dist/module/index.js +9 -0
- package/dist/module/interfaces/node-api.d.ts +71 -0
- package/dist/module/interfaces/node-api.js +160 -0
- package/dist/module/interfaces/tree-api.d.ts +214 -0
- package/dist/module/interfaces/tree-api.js +622 -0
- package/dist/module/interfaces/tree-api.test.d.ts +1 -0
- package/dist/module/interfaces/tree-api.test.js +12 -0
- package/dist/module/state/dnd-slice.d.ts +29 -0
- package/dist/module/state/dnd-slice.js +31 -0
- package/dist/module/state/drag-slice.d.ts +9 -0
- package/dist/module/state/drag-slice.js +20 -0
- package/dist/module/state/edit-slice.d.ts +8 -0
- package/dist/module/state/edit-slice.js +13 -0
- package/dist/module/state/focus-slice.d.ts +12 -0
- package/dist/module/state/focus-slice.js +20 -0
- package/dist/module/state/initial.d.ts +3 -0
- package/dist/module/state/initial.js +25 -0
- package/dist/module/state/open-slice.d.ts +30 -0
- package/dist/module/state/open-slice.js +44 -0
- package/dist/module/state/root-reducer.d.ts +96 -0
- package/dist/module/state/root-reducer.js +17 -0
- package/dist/module/state/selection-slice.d.ts +42 -0
- package/dist/module/state/selection-slice.js +55 -0
- package/dist/module/types/dnd.d.ts +8 -0
- package/dist/module/types/dnd.js +1 -0
- package/dist/module/types/handlers.d.ts +30 -0
- package/dist/module/types/handlers.js +1 -0
- package/dist/module/types/renderers.d.ts +29 -0
- package/dist/module/types/renderers.js +1 -0
- package/dist/module/types/state.d.ts +2 -0
- package/dist/module/types/state.js +1 -0
- package/dist/module/types/tree-props.d.ts +56 -0
- package/dist/module/types/tree-props.js +1 -0
- package/dist/module/types/utils.d.ts +17 -0
- package/dist/module/types/utils.js +1 -0
- package/dist/module/utils.d.ts +24 -0
- package/dist/module/utils.js +162 -0
- package/package.json +26 -25
- package/src/components/default-container.tsx +2 -0
- package/src/components/provider.tsx +3 -2
- package/src/components/row-container.tsx +1 -1
- package/src/dnd/compute-drop.ts +6 -3
- package/src/dnd/drag-hook.ts +1 -1
- package/src/dnd/drop-hook.ts +1 -1
- package/src/interfaces/node-api.ts +10 -0
- package/src/interfaces/tree-api.ts +16 -3
- package/src/state/dnd-slice.ts +2 -2
- package/src/state/drag-slice.ts +27 -11
- package/src/state/initial.ts +6 -1
- package/src/utils.ts +2 -2
- package/dist/components/cursor.d.ts +0 -2
- package/dist/components/drag-preview-container.d.ts +0 -2
- package/dist/components/list-outer-element.d.ts +0 -2
- package/dist/components/tree-container.d.ts +0 -2
- package/dist/index.js +0 -2414
- package/dist/index.js.map +0 -1
- package/dist/module.js +0 -2387
- package/dist/module.js.map +0 -1
- package/dist/state/root-reducer.d.ts +0 -13
- package/dist/types/state.d.ts +0 -2
- package/jest.config.js +0 -5
- package/tsconfig.json +0 -4
- /package/dist/{components → main/components}/default-cursor.d.ts +0 -0
- /package/dist/{components → main/components}/outer-drop.d.ts +0 -0
- /package/dist/{data → main/data}/create-index.d.ts +0 -0
- /package/dist/{data → main/data}/create-list.d.ts +0 -0
- /package/dist/{data → main/data}/create-root.d.ts +0 -0
- /package/dist/{dnd → main/dnd}/drag-hook.d.ts +0 -0
- /package/dist/{dnd → main/dnd}/outer-drop-hook.d.ts +0 -0
- /package/dist/{hooks → main/hooks}/use-fresh-node.d.ts +0 -0
- /package/dist/{hooks → main/hooks}/use-validated-props.d.ts +0 -0
- /package/dist/{index.d.ts → main/index.d.ts} +0 -0
- /package/dist/{state → main/state}/initial.d.ts +0 -0
- /package/dist/{types → main/types}/tree-props.d.ts +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RowContainer = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const context_1 = require("../context");
|
|
30
|
+
const drag_hook_1 = require("../dnd/drag-hook");
|
|
31
|
+
const drop_hook_1 = require("../dnd/drop-hook");
|
|
32
|
+
const use_fresh_node_1 = require("../hooks/use-fresh-node");
|
|
33
|
+
exports.RowContainer = react_1.default.memo(function RowContainer({ index, style, }) {
|
|
34
|
+
/* When will the <Row> will re-render.
|
|
35
|
+
*
|
|
36
|
+
* The row component is memo'd so it will only render
|
|
37
|
+
* when a new instance of the NodeApi class is passed
|
|
38
|
+
* to it.
|
|
39
|
+
*
|
|
40
|
+
* The TreeApi instance is stable. It does not
|
|
41
|
+
* change when the internal state changes.
|
|
42
|
+
*
|
|
43
|
+
* The TreeApi has all the references to the nodes.
|
|
44
|
+
* We need to clone the nodes when their state
|
|
45
|
+
* changes. The node class contains no state itself,
|
|
46
|
+
* It always checks the tree for state. The tree's
|
|
47
|
+
* state will always be up to date.
|
|
48
|
+
*/
|
|
49
|
+
(0, context_1.useDataUpdates)(); // Re-render when tree props or visability changes
|
|
50
|
+
const _ = (0, context_1.useNodesContext)(); // So that we re-render appropriately
|
|
51
|
+
const tree = (0, context_1.useTreeApi)(); // Tree already has the fresh state
|
|
52
|
+
const node = (0, use_fresh_node_1.useFreshNode)(index);
|
|
53
|
+
const el = (0, react_1.useRef)(null);
|
|
54
|
+
const dragRef = (0, drag_hook_1.useDragHook)(node);
|
|
55
|
+
const dropRef = (0, drop_hook_1.useDropHook)(el, node);
|
|
56
|
+
const innerRef = (0, react_1.useCallback)((n) => {
|
|
57
|
+
el.current = n;
|
|
58
|
+
dropRef(n);
|
|
59
|
+
}, [dropRef]);
|
|
60
|
+
const indent = tree.indent * node.level;
|
|
61
|
+
const nodeStyle = (0, react_1.useMemo)(() => ({ paddingLeft: indent }), [indent]);
|
|
62
|
+
const rowStyle = (0, react_1.useMemo)(() => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
return (Object.assign(Object.assign({}, style), { top: parseFloat(style.top) +
|
|
65
|
+
((_b = (_a = tree.props.padding) !== null && _a !== void 0 ? _a : tree.props.paddingTop) !== null && _b !== void 0 ? _b : 0) }));
|
|
66
|
+
}, [style, tree.props.padding, tree.props.paddingTop]);
|
|
67
|
+
const rowAttrs = {
|
|
68
|
+
role: "treeitem",
|
|
69
|
+
"aria-level": node.level + 1,
|
|
70
|
+
"aria-selected": node.isSelected,
|
|
71
|
+
style: rowStyle,
|
|
72
|
+
tabIndex: -1,
|
|
73
|
+
className: tree.props.rowClassName,
|
|
74
|
+
};
|
|
75
|
+
(0, react_1.useEffect)(() => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (!node.isEditing && node.isFocused) {
|
|
78
|
+
(_a = el.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
79
|
+
}
|
|
80
|
+
}, [node.isEditing, node.isFocused, el.current]);
|
|
81
|
+
const Node = tree.renderNode;
|
|
82
|
+
const Row = tree.renderRow;
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(Row, { node: node, innerRef: innerRef, attrs: rowAttrs, children: (0, jsx_runtime_1.jsx)(Node, { node: node, tree: tree, style: nodeStyle, dragHandle: dragRef }) }));
|
|
84
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TreeContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TreeContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
const default_container_1 = require("./default-container");
|
|
7
|
+
function TreeContainer() {
|
|
8
|
+
const tree = (0, context_1.useTreeApi)();
|
|
9
|
+
const Container = tree.props.renderContainer || default_container_1.DefaultContainer;
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Container, {}) }));
|
|
11
|
+
}
|
|
12
|
+
exports.TreeContainer = TreeContainer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TreeApi } from "../interfaces/tree-api";
|
|
3
3
|
import { TreeProps } from "../types/tree-props";
|
|
4
|
-
declare function TreeComponent<T>(props: TreeProps<T>, ref: React.Ref<TreeApi<T> | undefined>): JSX.Element;
|
|
4
|
+
declare function TreeComponent<T>(props: TreeProps<T>, ref: React.Ref<TreeApi<T> | undefined>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare const Tree: <T>(props: TreeProps<T> & {
|
|
6
6
|
ref?: import("react").ForwardedRef<TreeApi<T> | undefined> | undefined;
|
|
7
7
|
}) => ReturnType<typeof TreeComponent>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tree = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("./provider");
|
|
7
|
+
const outer_drop_1 = require("./outer-drop");
|
|
8
|
+
const tree_container_1 = require("./tree-container");
|
|
9
|
+
const drag_preview_container_1 = require("./drag-preview-container");
|
|
10
|
+
const use_validated_props_1 = require("../hooks/use-validated-props");
|
|
11
|
+
function TreeComponent(props, ref) {
|
|
12
|
+
const treeProps = (0, use_validated_props_1.useValidatedProps)(props);
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(provider_1.TreeProvider, { treeProps: treeProps, imperativeHandle: ref, children: [(0, jsx_runtime_1.jsx)(outer_drop_1.OuterDrop, { children: (0, jsx_runtime_1.jsx)(tree_container_1.TreeContainer, {}) }), (0, jsx_runtime_1.jsx)(drag_preview_container_1.DragPreviewContainer, {})] }));
|
|
14
|
+
}
|
|
15
|
+
exports.Tree = (0, react_1.forwardRef)(TreeComponent);
|
|
@@ -2,20 +2,20 @@ import React from "react";
|
|
|
2
2
|
import { TreeApi } from "./interfaces/tree-api";
|
|
3
3
|
export declare const TreeApiContext: React.Context<TreeApi<any> | null>;
|
|
4
4
|
export declare function useTreeApi<T>(): TreeApi<T>;
|
|
5
|
-
export declare const NodesContext: React.Context<
|
|
5
|
+
export declare const NodesContext: React.Context<{
|
|
6
6
|
focus: import("./state/focus-slice").FocusState;
|
|
7
7
|
edit: import("./state/edit-slice").EditState;
|
|
8
8
|
open: import("./state/open-slice").OpenSlice;
|
|
9
9
|
selection: import("./state/selection-slice").SelectionState;
|
|
10
10
|
drag: import("./state/drag-slice").DragSlice;
|
|
11
|
-
}
|
|
12
|
-
export declare function useNodesContext():
|
|
11
|
+
} | null>;
|
|
12
|
+
export declare function useNodesContext(): {
|
|
13
13
|
focus: import("./state/focus-slice").FocusState;
|
|
14
14
|
edit: import("./state/edit-slice").EditState;
|
|
15
15
|
open: import("./state/open-slice").OpenSlice;
|
|
16
16
|
selection: import("./state/selection-slice").SelectionState;
|
|
17
17
|
drag: import("./state/drag-slice").DragSlice;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
export declare const DndContext: React.Context<import("./state/dnd-slice").DndState | null>;
|
|
20
20
|
export declare function useDndContext(): import("./state/dnd-slice").DndState;
|
|
21
21
|
export declare const DataUpdatesContext: React.Context<number>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDataUpdates = exports.DataUpdatesContext = exports.useDndContext = exports.DndContext = exports.useNodesContext = exports.NodesContext = exports.useTreeApi = exports.TreeApiContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.TreeApiContext = (0, react_1.createContext)(null);
|
|
6
|
+
function useTreeApi() {
|
|
7
|
+
const value = (0, react_1.useContext)(exports.TreeApiContext);
|
|
8
|
+
if (value === null)
|
|
9
|
+
throw new Error("No Tree Api Provided");
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
exports.useTreeApi = useTreeApi;
|
|
13
|
+
exports.NodesContext = (0, react_1.createContext)(null);
|
|
14
|
+
function useNodesContext() {
|
|
15
|
+
const value = (0, react_1.useContext)(exports.NodesContext);
|
|
16
|
+
if (value === null)
|
|
17
|
+
throw new Error("Provide a NodesContext");
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
exports.useNodesContext = useNodesContext;
|
|
21
|
+
exports.DndContext = (0, react_1.createContext)(null);
|
|
22
|
+
function useDndContext() {
|
|
23
|
+
const value = (0, react_1.useContext)(exports.DndContext);
|
|
24
|
+
if (value === null)
|
|
25
|
+
throw new Error("Provide a DnDContext");
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
exports.useDndContext = useDndContext;
|
|
29
|
+
exports.DataUpdatesContext = (0, react_1.createContext)(0);
|
|
30
|
+
function useDataUpdates() {
|
|
31
|
+
(0, react_1.useContext)(exports.DataUpdatesContext);
|
|
32
|
+
}
|
|
33
|
+
exports.useDataUpdates = useDataUpdates;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIndex = void 0;
|
|
4
|
+
const createIndex = (nodes) => {
|
|
5
|
+
return nodes.reduce((map, node, index) => {
|
|
6
|
+
map[node.id] = index;
|
|
7
|
+
return map;
|
|
8
|
+
}, {});
|
|
9
|
+
};
|
|
10
|
+
exports.createIndex = createIndex;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createList = void 0;
|
|
4
|
+
function createList(tree) {
|
|
5
|
+
if (tree.isFiltered) {
|
|
6
|
+
return flattenAndFilterTree(tree.root, tree.isMatch.bind(tree));
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return flattenTree(tree.root);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.createList = createList;
|
|
13
|
+
function flattenTree(root) {
|
|
14
|
+
const list = [];
|
|
15
|
+
function collect(node) {
|
|
16
|
+
var _a;
|
|
17
|
+
if (node.level >= 0) {
|
|
18
|
+
list.push(node);
|
|
19
|
+
}
|
|
20
|
+
if (node.isOpen) {
|
|
21
|
+
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(collect);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
collect(root);
|
|
25
|
+
list.forEach(assignRowIndex);
|
|
26
|
+
return list;
|
|
27
|
+
}
|
|
28
|
+
function flattenAndFilterTree(root, isMatch) {
|
|
29
|
+
const matches = {};
|
|
30
|
+
const list = [];
|
|
31
|
+
function markMatch(node) {
|
|
32
|
+
const yes = !node.isRoot && isMatch(node);
|
|
33
|
+
if (yes) {
|
|
34
|
+
matches[node.id] = true;
|
|
35
|
+
let parent = node.parent;
|
|
36
|
+
while (parent) {
|
|
37
|
+
matches[parent.id] = true;
|
|
38
|
+
parent = parent.parent;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (node.children) {
|
|
42
|
+
for (let child of node.children)
|
|
43
|
+
markMatch(child);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function collect(node) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (node.level >= 0 && matches[node.id]) {
|
|
49
|
+
list.push(node);
|
|
50
|
+
}
|
|
51
|
+
if (node.isOpen) {
|
|
52
|
+
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(collect);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
markMatch(root);
|
|
56
|
+
collect(root);
|
|
57
|
+
list.forEach(assignRowIndex);
|
|
58
|
+
return list;
|
|
59
|
+
}
|
|
60
|
+
function assignRowIndex(node, index) {
|
|
61
|
+
node.rowIndex = index;
|
|
62
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRoot = exports.ROOT_ID = void 0;
|
|
4
|
+
const node_api_1 = require("../interfaces/node-api");
|
|
5
|
+
exports.ROOT_ID = "__REACT_ARBORIST_INTERNAL_ROOT__";
|
|
6
|
+
function createRoot(tree) {
|
|
7
|
+
var _a;
|
|
8
|
+
function visitSelfAndChildren(data, level, parent) {
|
|
9
|
+
const id = tree.accessId(data);
|
|
10
|
+
const node = new node_api_1.NodeApi({
|
|
11
|
+
tree,
|
|
12
|
+
data,
|
|
13
|
+
level,
|
|
14
|
+
parent,
|
|
15
|
+
id,
|
|
16
|
+
children: null,
|
|
17
|
+
isDraggable: tree.isDraggable(data),
|
|
18
|
+
rowIndex: null,
|
|
19
|
+
});
|
|
20
|
+
const children = tree.accessChildren(data);
|
|
21
|
+
if (children) {
|
|
22
|
+
node.children = children.map((child) => visitSelfAndChildren(child, level + 1, node));
|
|
23
|
+
}
|
|
24
|
+
return node;
|
|
25
|
+
}
|
|
26
|
+
const root = new node_api_1.NodeApi({
|
|
27
|
+
tree,
|
|
28
|
+
id: exports.ROOT_ID,
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
data: { id: exports.ROOT_ID },
|
|
31
|
+
level: -1,
|
|
32
|
+
parent: null,
|
|
33
|
+
children: null,
|
|
34
|
+
isDraggable: true,
|
|
35
|
+
rowIndex: null,
|
|
36
|
+
});
|
|
37
|
+
const data = (_a = tree.props.data) !== null && _a !== void 0 ? _a : [];
|
|
38
|
+
root.children = data.map((child) => {
|
|
39
|
+
return visitSelfAndChildren(child, 0, root);
|
|
40
|
+
});
|
|
41
|
+
return root;
|
|
42
|
+
}
|
|
43
|
+
exports.createRoot = createRoot;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A function that turns a string of text into a tree
|
|
3
|
+
// Each line is a node
|
|
4
|
+
// The number of spaces at the beginning indicate the level
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeTree = void 0;
|
|
7
|
+
function makeTree(string) {
|
|
8
|
+
const root = { id: "ROOT", name: "ROOT", isOpen: true };
|
|
9
|
+
let prevNode = root;
|
|
10
|
+
let prevLevel = -1;
|
|
11
|
+
let id = 1;
|
|
12
|
+
string.split("\n").forEach((line) => {
|
|
13
|
+
const name = line.trimStart();
|
|
14
|
+
const level = line.length - name.length;
|
|
15
|
+
const diff = level - prevLevel;
|
|
16
|
+
const node = { id: (id++).toString(), name, isOpen: false };
|
|
17
|
+
if (diff === 1) {
|
|
18
|
+
// First child
|
|
19
|
+
//@ts-ignore
|
|
20
|
+
node.parent = prevNode;
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
prevNode.children = [node];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// Find the parent and go up
|
|
26
|
+
//@ts-ignore
|
|
27
|
+
let parent = prevNode.parent;
|
|
28
|
+
for (let i = diff; i < 0; i++) {
|
|
29
|
+
parent = parent.parent;
|
|
30
|
+
}
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
node.parent = parent;
|
|
33
|
+
parent.children.push(node);
|
|
34
|
+
}
|
|
35
|
+
prevNode = node;
|
|
36
|
+
prevLevel = level;
|
|
37
|
+
});
|
|
38
|
+
return root;
|
|
39
|
+
}
|
|
40
|
+
exports.makeTree = makeTree;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleTree = void 0;
|
|
4
|
+
class SimpleTree {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
this.root = createRoot(data);
|
|
7
|
+
}
|
|
8
|
+
get data() {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
return (_b = (_a = this.root.children) === null || _a === void 0 ? void 0 : _a.map((node) => node.data)) !== null && _b !== void 0 ? _b : [];
|
|
11
|
+
}
|
|
12
|
+
create(args) {
|
|
13
|
+
const parent = args.parentId ? this.find(args.parentId) : this.root;
|
|
14
|
+
if (!parent)
|
|
15
|
+
return null;
|
|
16
|
+
parent.addChild(args.data, args.index);
|
|
17
|
+
}
|
|
18
|
+
move(args) {
|
|
19
|
+
const src = this.find(args.id);
|
|
20
|
+
const parent = args.parentId ? this.find(args.parentId) : this.root;
|
|
21
|
+
if (!src || !parent)
|
|
22
|
+
return;
|
|
23
|
+
parent.addChild(src.data, args.index);
|
|
24
|
+
src.drop();
|
|
25
|
+
}
|
|
26
|
+
update(args) {
|
|
27
|
+
const node = this.find(args.id);
|
|
28
|
+
if (node)
|
|
29
|
+
node.update(args.changes);
|
|
30
|
+
}
|
|
31
|
+
drop(args) {
|
|
32
|
+
const node = this.find(args.id);
|
|
33
|
+
if (node)
|
|
34
|
+
node.drop();
|
|
35
|
+
}
|
|
36
|
+
find(id, node = this.root) {
|
|
37
|
+
if (!node)
|
|
38
|
+
return null;
|
|
39
|
+
if (node.id === id)
|
|
40
|
+
return node;
|
|
41
|
+
if (node.children) {
|
|
42
|
+
for (let child of node.children) {
|
|
43
|
+
const found = this.find(id, child);
|
|
44
|
+
if (found)
|
|
45
|
+
return found;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SimpleTree = SimpleTree;
|
|
53
|
+
function createRoot(data) {
|
|
54
|
+
const root = new SimpleNode({ id: "ROOT" }, null);
|
|
55
|
+
root.children = data.map((d) => createNode(d, root));
|
|
56
|
+
return root;
|
|
57
|
+
}
|
|
58
|
+
function createNode(data, parent) {
|
|
59
|
+
const node = new SimpleNode(data, parent);
|
|
60
|
+
if (data.children)
|
|
61
|
+
node.children = data.children.map((d) => createNode(d, node));
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
class SimpleNode {
|
|
65
|
+
constructor(data, parent) {
|
|
66
|
+
this.data = data;
|
|
67
|
+
this.parent = parent;
|
|
68
|
+
this.id = data.id;
|
|
69
|
+
}
|
|
70
|
+
hasParent() {
|
|
71
|
+
return !!this.parent;
|
|
72
|
+
}
|
|
73
|
+
get childIndex() {
|
|
74
|
+
return this.hasParent() ? this.parent.children.indexOf(this) : -1;
|
|
75
|
+
}
|
|
76
|
+
addChild(data, index) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const node = createNode(data, this);
|
|
79
|
+
this.children = (_a = this.children) !== null && _a !== void 0 ? _a : [];
|
|
80
|
+
this.children.splice(index, 0, node);
|
|
81
|
+
this.data.children = (_b = this.data.children) !== null && _b !== void 0 ? _b : [];
|
|
82
|
+
this.data.children.splice(index, 0, data);
|
|
83
|
+
}
|
|
84
|
+
removeChild(index) {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.splice(index, 1);
|
|
87
|
+
(_b = this.data.children) === null || _b === void 0 ? void 0 : _b.splice(index, 1);
|
|
88
|
+
}
|
|
89
|
+
update(changes) {
|
|
90
|
+
if (this.hasParent()) {
|
|
91
|
+
const i = this.childIndex;
|
|
92
|
+
this.parent.addChild(Object.assign(Object.assign({}, this.data), changes), i);
|
|
93
|
+
this.drop();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
drop() {
|
|
97
|
+
if (this.hasParent())
|
|
98
|
+
this.parent.removeChild(this.childIndex);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XYCoord } from "react-dnd";
|
|
2
2
|
import { NodeApi } from "../interfaces/node-api";
|
|
3
3
|
import { DropResult } from "./drop-hook";
|
|
4
|
-
|
|
4
|
+
type Args = {
|
|
5
5
|
element: HTMLElement;
|
|
6
6
|
offset: XYCoord;
|
|
7
7
|
indent: number;
|
|
@@ -9,7 +9,7 @@ declare type Args = {
|
|
|
9
9
|
prevNode: NodeApi | null;
|
|
10
10
|
nextNode: NodeApi | null;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type ComputedDrop = {
|
|
13
13
|
drop: DropResult | null;
|
|
14
14
|
cursor: Cursor | null;
|
|
15
15
|
};
|
|
@@ -25,10 +25,10 @@ declare function highlightCursor(id: string): {
|
|
|
25
25
|
type: "highlight";
|
|
26
26
|
id: string;
|
|
27
27
|
};
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
28
|
+
export type LineCursor = ReturnType<typeof lineCursor>;
|
|
29
|
+
export type NoCursor = ReturnType<typeof noCursor>;
|
|
30
|
+
export type HighlightCursor = ReturnType<typeof highlightCursor>;
|
|
31
|
+
export type Cursor = LineCursor | NoCursor | HighlightCursor;
|
|
32
32
|
/**
|
|
33
33
|
* This is the most complex, tricky function in the whole repo.
|
|
34
34
|
* It could be simplified and made more understandable.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeDrop = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function measureHover(el, offset) {
|
|
6
|
+
const rect = el.getBoundingClientRect();
|
|
7
|
+
const x = offset.x - Math.round(rect.x);
|
|
8
|
+
const y = offset.y - Math.round(rect.y);
|
|
9
|
+
const height = rect.height;
|
|
10
|
+
const inTopHalf = y < height / 2;
|
|
11
|
+
const inBottomHalf = !inTopHalf;
|
|
12
|
+
const pad = height / 4;
|
|
13
|
+
const inMiddle = y > pad && y < height - pad;
|
|
14
|
+
const atTop = !inMiddle && inTopHalf;
|
|
15
|
+
const atBottom = !inMiddle && inBottomHalf;
|
|
16
|
+
return { x, inTopHalf, inBottomHalf, inMiddle, atTop, atBottom };
|
|
17
|
+
}
|
|
18
|
+
function getNodesAroundCursor(node, prev, next, hover) {
|
|
19
|
+
if (!node) {
|
|
20
|
+
// We're hovering over the empty part of the list, not over an item,
|
|
21
|
+
// Put the cursor below the last item which is "prev"
|
|
22
|
+
return [prev, null];
|
|
23
|
+
}
|
|
24
|
+
if (node.isInternal) {
|
|
25
|
+
if (hover.atTop) {
|
|
26
|
+
return [prev, node];
|
|
27
|
+
}
|
|
28
|
+
else if (hover.inMiddle) {
|
|
29
|
+
return [node, node];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return [node, next];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (hover.inTopHalf) {
|
|
37
|
+
return [prev, node];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return [node, next];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getDropLevel(hovering, aboveCursor, belowCursor, indent) {
|
|
45
|
+
const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
|
|
46
|
+
let min, max;
|
|
47
|
+
if (!aboveCursor) {
|
|
48
|
+
max = 0;
|
|
49
|
+
min = 0;
|
|
50
|
+
}
|
|
51
|
+
else if (!belowCursor) {
|
|
52
|
+
max = aboveCursor.level;
|
|
53
|
+
min = 0;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
max = aboveCursor.level;
|
|
57
|
+
min = belowCursor.level;
|
|
58
|
+
}
|
|
59
|
+
return (0, utils_1.bound)(hoverLevel, min, max);
|
|
60
|
+
}
|
|
61
|
+
function dropAt(parentId, index) {
|
|
62
|
+
return { parentId: parentId || null, index };
|
|
63
|
+
}
|
|
64
|
+
function lineCursor(index, level) {
|
|
65
|
+
return {
|
|
66
|
+
type: "line",
|
|
67
|
+
index,
|
|
68
|
+
level,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function noCursor() {
|
|
72
|
+
return {
|
|
73
|
+
type: "none",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function highlightCursor(id) {
|
|
77
|
+
return {
|
|
78
|
+
type: "highlight",
|
|
79
|
+
id,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function walkUpFrom(node, level) {
|
|
83
|
+
var _a;
|
|
84
|
+
let drop = node;
|
|
85
|
+
while (drop.parent && drop.level > level) {
|
|
86
|
+
drop = drop.parent;
|
|
87
|
+
}
|
|
88
|
+
const parentId = ((_a = drop.parent) === null || _a === void 0 ? void 0 : _a.id) || null;
|
|
89
|
+
const index = (0, utils_1.indexOf)(drop) + 1;
|
|
90
|
+
return { parentId, index };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* This is the most complex, tricky function in the whole repo.
|
|
94
|
+
* It could be simplified and made more understandable.
|
|
95
|
+
*/
|
|
96
|
+
function computeDrop(args) {
|
|
97
|
+
var _a;
|
|
98
|
+
const hover = measureHover(args.element, args.offset);
|
|
99
|
+
const { node, nextNode, prevNode } = args;
|
|
100
|
+
const [above, below] = getNodesAroundCursor(node, prevNode, nextNode, hover);
|
|
101
|
+
/* Hovering over the middle of a folder */
|
|
102
|
+
if (node && node.isInternal && hover.inMiddle) {
|
|
103
|
+
return {
|
|
104
|
+
drop: dropAt(node.id, null),
|
|
105
|
+
cursor: highlightCursor(node.id),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/* At the top of the list */
|
|
109
|
+
if (!above) {
|
|
110
|
+
return {
|
|
111
|
+
drop: dropAt((_a = below === null || below === void 0 ? void 0 : below.parent) === null || _a === void 0 ? void 0 : _a.id, 0),
|
|
112
|
+
cursor: lineCursor(0, 0),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/* The above node is an item or a closed folder */
|
|
116
|
+
if ((0, utils_1.isItem)(above) || (0, utils_1.isClosed)(above)) {
|
|
117
|
+
const level = getDropLevel(hover, above, below, args.indent);
|
|
118
|
+
return {
|
|
119
|
+
drop: walkUpFrom(above, level),
|
|
120
|
+
cursor: lineCursor(above.rowIndex + 1, level),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/* The above node is an open folder */
|
|
124
|
+
return {
|
|
125
|
+
drop: dropAt(above === null || above === void 0 ? void 0 : above.id, 0),
|
|
126
|
+
cursor: lineCursor(above.rowIndex + 1, above.level + 1),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
exports.computeDrop = computeDrop;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDragHook = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_dnd_1 = require("react-dnd");
|
|
6
|
+
const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
7
|
+
const context_1 = require("../context");
|
|
8
|
+
const dnd_slice_1 = require("../state/dnd-slice");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const create_root_1 = require("../data/create-root");
|
|
11
|
+
function useDragHook(node) {
|
|
12
|
+
const tree = (0, context_1.useTreeApi)();
|
|
13
|
+
const ids = tree.selectedIds;
|
|
14
|
+
const [_, ref, preview] = (0, react_dnd_1.useDrag)(() => ({
|
|
15
|
+
canDrag: () => node.isDraggable,
|
|
16
|
+
type: "NODE",
|
|
17
|
+
item: () => {
|
|
18
|
+
// This is fired once at the begging of a drag operation
|
|
19
|
+
const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [node.id];
|
|
20
|
+
tree.dispatch(dnd_slice_1.actions.dragStart(node.id, dragIds));
|
|
21
|
+
return { id: node.id };
|
|
22
|
+
},
|
|
23
|
+
end: () => {
|
|
24
|
+
tree.hideCursor();
|
|
25
|
+
let { parentId, index, dragIds } = tree.state.dnd;
|
|
26
|
+
// If they held down meta, we need to create a copy
|
|
27
|
+
// if (drop.dropEffect === "copy")
|
|
28
|
+
if (tree.canDrop()) {
|
|
29
|
+
(0, utils_1.safeRun)(tree.props.onMove, {
|
|
30
|
+
dragIds,
|
|
31
|
+
parentId: parentId === create_root_1.ROOT_ID ? null : parentId,
|
|
32
|
+
index: index === null ? 0 : index, // When it's null it was dropped over a folder
|
|
33
|
+
dragNodes: tree.dragNodes,
|
|
34
|
+
parentNode: tree.get(parentId),
|
|
35
|
+
});
|
|
36
|
+
tree.open(parentId);
|
|
37
|
+
}
|
|
38
|
+
tree.dispatch(dnd_slice_1.actions.dragEnd());
|
|
39
|
+
},
|
|
40
|
+
}), [ids, node]);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
preview((0, react_dnd_html5_backend_1.getEmptyImage)());
|
|
43
|
+
}, [preview]);
|
|
44
|
+
return ref;
|
|
45
|
+
}
|
|
46
|
+
exports.useDragHook = useDragHook;
|