react-arborist 3.3.0-rc.1 → 3.3.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/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 +1 -1
- 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 +1 -1
- package/dist/main/interfaces/node-api.js +164 -0
- package/dist/{interfaces → main/interfaces}/tree-api.d.ts +88 -8
- 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 +1 -1
- package/dist/main/state/dnd-slice.js +35 -0
- package/dist/{state → main/state}/drag-slice.d.ts +1 -1
- 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/{types → main/types}/tree-props.d.ts +1 -1
- 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/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 +24 -24
- 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/interfaces/tree-api.ts +1 -1
- package/src/types/tree-props.ts +1 -1
- 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 -2433
- package/dist/index.js.map +0 -1
- package/dist/module.js +0 -2406
- 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/{utils.d.ts → main/utils.d.ts} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reducer = exports.actions = void 0;
|
|
4
|
+
const initial_1 = require("./initial");
|
|
5
|
+
/* Actions */
|
|
6
|
+
exports.actions = {
|
|
7
|
+
cursor(cursor) {
|
|
8
|
+
return { type: "DND_CURSOR", cursor };
|
|
9
|
+
},
|
|
10
|
+
dragStart(id, dragIds) {
|
|
11
|
+
return { type: "DND_DRAG_START", id, dragIds };
|
|
12
|
+
},
|
|
13
|
+
dragEnd() {
|
|
14
|
+
return { type: "DND_DRAG_END" };
|
|
15
|
+
},
|
|
16
|
+
hovering(parentId, index) {
|
|
17
|
+
return { type: "DND_HOVERING", parentId, index };
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/* Reducer */
|
|
21
|
+
function reducer(state = (0, initial_1.initialState)()["dnd"], action) {
|
|
22
|
+
switch (action.type) {
|
|
23
|
+
case "DND_CURSOR":
|
|
24
|
+
return Object.assign(Object.assign({}, state), { cursor: action.cursor });
|
|
25
|
+
case "DND_DRAG_START":
|
|
26
|
+
return Object.assign(Object.assign({}, state), { dragId: action.id, dragIds: action.dragIds });
|
|
27
|
+
case "DND_DRAG_END":
|
|
28
|
+
return (0, initial_1.initialState)()["dnd"];
|
|
29
|
+
case "DND_HOVERING":
|
|
30
|
+
return Object.assign(Object.assign({}, state), { parentId: action.parentId, index: action.index });
|
|
31
|
+
default:
|
|
32
|
+
return state;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.reducer = reducer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reducer = void 0;
|
|
4
|
+
const initial_1 = require("./initial");
|
|
5
|
+
/* Reducer */
|
|
6
|
+
function reducer(state = (0, initial_1.initialState)().nodes.drag, action) {
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case "DND_DRAG_START":
|
|
9
|
+
return Object.assign(Object.assign({}, state), { id: action.id, selectedIds: action.dragIds });
|
|
10
|
+
case "DND_DRAG_END":
|
|
11
|
+
return Object.assign(Object.assign({}, state), { id: null, destinationParentId: null, destinationIndex: null, selectedIds: [] });
|
|
12
|
+
case "DND_HOVERING":
|
|
13
|
+
if (action.parentId !== state.destinationParentId ||
|
|
14
|
+
action.index != state.destinationIndex) {
|
|
15
|
+
return Object.assign(Object.assign({}, state), { destinationParentId: action.parentId, destinationIndex: action.index });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
20
|
+
default:
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.reducer = reducer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reducer = exports.edit = void 0;
|
|
4
|
+
/* Actions */
|
|
5
|
+
function edit(id) {
|
|
6
|
+
return { type: "EDIT", id };
|
|
7
|
+
}
|
|
8
|
+
exports.edit = edit;
|
|
9
|
+
/* Reducer */
|
|
10
|
+
function reducer(state = { id: null }, action) {
|
|
11
|
+
if (action.type === "EDIT") {
|
|
12
|
+
return Object.assign(Object.assign({}, state), { id: action.id });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.reducer = reducer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Types */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.reducer = exports.treeBlur = exports.focus = void 0;
|
|
5
|
+
/* Actions */
|
|
6
|
+
function focus(id) {
|
|
7
|
+
return { type: "FOCUS", id };
|
|
8
|
+
}
|
|
9
|
+
exports.focus = focus;
|
|
10
|
+
function treeBlur() {
|
|
11
|
+
return { type: "TREE_BLUR" };
|
|
12
|
+
}
|
|
13
|
+
exports.treeBlur = treeBlur;
|
|
14
|
+
/* Reducer */
|
|
15
|
+
function reducer(state = { id: null, treeFocused: false }, action) {
|
|
16
|
+
if (action.type === "FOCUS") {
|
|
17
|
+
return Object.assign(Object.assign({}, state), { id: action.id, treeFocused: true });
|
|
18
|
+
}
|
|
19
|
+
else if (action.type === "TREE_BLUR") {
|
|
20
|
+
return Object.assign(Object.assign({}, state), { treeFocused: false });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.reducer = reducer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialState = void 0;
|
|
4
|
+
const initialState = (props) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return ({
|
|
7
|
+
nodes: {
|
|
8
|
+
// Changes together
|
|
9
|
+
open: { filtered: {}, unfiltered: (_a = props === null || props === void 0 ? void 0 : props.initialOpenState) !== null && _a !== void 0 ? _a : {} },
|
|
10
|
+
focus: { id: null, treeFocused: false },
|
|
11
|
+
edit: { id: null },
|
|
12
|
+
drag: {
|
|
13
|
+
id: null,
|
|
14
|
+
selectedIds: [],
|
|
15
|
+
destinationParentId: null,
|
|
16
|
+
destinationIndex: null,
|
|
17
|
+
},
|
|
18
|
+
selection: { ids: new Set(), anchor: null, mostRecent: null },
|
|
19
|
+
},
|
|
20
|
+
dnd: {
|
|
21
|
+
cursor: { type: "none" },
|
|
22
|
+
dragId: null,
|
|
23
|
+
dragIds: [],
|
|
24
|
+
parentId: null,
|
|
25
|
+
index: -1,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.initialState = initialState;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reducer = exports.actions = void 0;
|
|
4
|
+
/* Actions */
|
|
5
|
+
exports.actions = {
|
|
6
|
+
open(id, filtered) {
|
|
7
|
+
return { type: "VISIBILITY_OPEN", id, filtered };
|
|
8
|
+
},
|
|
9
|
+
close(id, filtered) {
|
|
10
|
+
return { type: "VISIBILITY_CLOSE", id, filtered };
|
|
11
|
+
},
|
|
12
|
+
toggle(id, filtered) {
|
|
13
|
+
return { type: "VISIBILITY_TOGGLE", id, filtered };
|
|
14
|
+
},
|
|
15
|
+
clear(filtered) {
|
|
16
|
+
return { type: "VISIBILITY_CLEAR", filtered };
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
/* Reducer */
|
|
20
|
+
function openMapReducer(state = {}, action) {
|
|
21
|
+
if (action.type === "VISIBILITY_OPEN") {
|
|
22
|
+
return Object.assign(Object.assign({}, state), { [action.id]: true });
|
|
23
|
+
}
|
|
24
|
+
else if (action.type === "VISIBILITY_CLOSE") {
|
|
25
|
+
return Object.assign(Object.assign({}, state), { [action.id]: false });
|
|
26
|
+
}
|
|
27
|
+
else if (action.type === "VISIBILITY_TOGGLE") {
|
|
28
|
+
const prev = state[action.id];
|
|
29
|
+
return Object.assign(Object.assign({}, state), { [action.id]: !prev });
|
|
30
|
+
}
|
|
31
|
+
else if (action.type === "VISIBILITY_CLEAR") {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return state;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function reducer(state = { filtered: {}, unfiltered: {} }, action) {
|
|
39
|
+
if (!action.type.startsWith("VISIBILITY"))
|
|
40
|
+
return state;
|
|
41
|
+
if (action.filtered) {
|
|
42
|
+
return Object.assign(Object.assign({}, state), { filtered: openMapReducer(state.filtered, action) });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return Object.assign(Object.assign({}, state), { unfiltered: openMapReducer(state.unfiltered, action) });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.reducer = reducer;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ActionFromReducer } from "redux";
|
|
2
|
+
export declare const rootReducer: import("redux").Reducer<{
|
|
3
|
+
nodes: {
|
|
4
|
+
focus: import("./focus-slice").FocusState;
|
|
5
|
+
edit: import("./edit-slice").EditState;
|
|
6
|
+
open: import("./open-slice").OpenSlice;
|
|
7
|
+
selection: import("./selection-slice").SelectionState;
|
|
8
|
+
drag: import("./drag-slice").DragSlice;
|
|
9
|
+
};
|
|
10
|
+
dnd: import("./dnd-slice").DndState;
|
|
11
|
+
}, {
|
|
12
|
+
type: "FOCUS";
|
|
13
|
+
id: string | null;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "TREE_BLUR";
|
|
16
|
+
} | {
|
|
17
|
+
type: "EDIT";
|
|
18
|
+
id: string | null;
|
|
19
|
+
} | import("../types/utils").ActionTypes<{
|
|
20
|
+
open(id: string, filtered: boolean): {
|
|
21
|
+
type: "VISIBILITY_OPEN";
|
|
22
|
+
id: string;
|
|
23
|
+
filtered: boolean;
|
|
24
|
+
};
|
|
25
|
+
close(id: string, filtered: boolean): {
|
|
26
|
+
type: "VISIBILITY_CLOSE";
|
|
27
|
+
id: string;
|
|
28
|
+
filtered: boolean;
|
|
29
|
+
};
|
|
30
|
+
toggle(id: string, filtered: boolean): {
|
|
31
|
+
type: "VISIBILITY_TOGGLE";
|
|
32
|
+
id: string;
|
|
33
|
+
filtered: boolean;
|
|
34
|
+
};
|
|
35
|
+
clear(filtered: boolean): {
|
|
36
|
+
type: "VISIBILITY_CLEAR";
|
|
37
|
+
filtered: boolean;
|
|
38
|
+
};
|
|
39
|
+
}> | import("../types/utils").ActionTypes<{
|
|
40
|
+
clear: () => {
|
|
41
|
+
type: "SELECTION_CLEAR";
|
|
42
|
+
};
|
|
43
|
+
only: (id: string | import("../types/utils").IdObj) => {
|
|
44
|
+
type: "SELECTION_ONLY";
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
add: (id: string | import("../types/utils").IdObj | string[] | import("../types/utils").IdObj[]) => {
|
|
48
|
+
type: "SELECTION_ADD";
|
|
49
|
+
ids: string[];
|
|
50
|
+
};
|
|
51
|
+
remove: (id: string | import("../types/utils").IdObj | string[] | import("../types/utils").IdObj[]) => {
|
|
52
|
+
type: "SELECTION_REMOVE";
|
|
53
|
+
ids: string[];
|
|
54
|
+
};
|
|
55
|
+
set: (args: {
|
|
56
|
+
ids: Set<string>;
|
|
57
|
+
anchor: string | null;
|
|
58
|
+
mostRecent: string | null;
|
|
59
|
+
}) => {
|
|
60
|
+
ids: Set<string>;
|
|
61
|
+
anchor: string | null;
|
|
62
|
+
mostRecent: string | null;
|
|
63
|
+
type: "SELECTION_SET";
|
|
64
|
+
};
|
|
65
|
+
mostRecent: (id: string | import("../types/utils").IdObj | null) => {
|
|
66
|
+
type: "SELECTION_MOST_RECENT";
|
|
67
|
+
id: string | null;
|
|
68
|
+
};
|
|
69
|
+
anchor: (id: string | import("../types/utils").IdObj | null) => {
|
|
70
|
+
type: "SELECTION_ANCHOR";
|
|
71
|
+
id: string | null;
|
|
72
|
+
};
|
|
73
|
+
}> | import("../types/utils").ActionTypes<{
|
|
74
|
+
cursor(cursor: import("../dnd/compute-drop").Cursor): {
|
|
75
|
+
type: "DND_CURSOR";
|
|
76
|
+
cursor: import("../dnd/compute-drop").Cursor;
|
|
77
|
+
};
|
|
78
|
+
dragStart(id: string, dragIds: string[]): {
|
|
79
|
+
type: "DND_DRAG_START";
|
|
80
|
+
id: string;
|
|
81
|
+
dragIds: string[];
|
|
82
|
+
};
|
|
83
|
+
dragEnd(): {
|
|
84
|
+
type: "DND_DRAG_END";
|
|
85
|
+
};
|
|
86
|
+
hovering(parentId: string | null, index: number | null): {
|
|
87
|
+
type: "DND_HOVERING";
|
|
88
|
+
parentId: string | null;
|
|
89
|
+
index: number | null;
|
|
90
|
+
};
|
|
91
|
+
}>, Partial<{
|
|
92
|
+
nodes: never;
|
|
93
|
+
dnd: never;
|
|
94
|
+
}>>;
|
|
95
|
+
export type RootState = ReturnType<typeof rootReducer>;
|
|
96
|
+
export type Actions = ActionFromReducer<typeof rootReducer>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rootReducer = void 0;
|
|
4
|
+
const redux_1 = require("redux");
|
|
5
|
+
const focus_slice_1 = require("./focus-slice");
|
|
6
|
+
const edit_slice_1 = require("./edit-slice");
|
|
7
|
+
const dnd_slice_1 = require("./dnd-slice");
|
|
8
|
+
const selection_slice_1 = require("./selection-slice");
|
|
9
|
+
const open_slice_1 = require("./open-slice");
|
|
10
|
+
const drag_slice_1 = require("./drag-slice");
|
|
11
|
+
exports.rootReducer = (0, redux_1.combineReducers)({
|
|
12
|
+
nodes: (0, redux_1.combineReducers)({
|
|
13
|
+
focus: focus_slice_1.reducer,
|
|
14
|
+
edit: edit_slice_1.reducer,
|
|
15
|
+
open: open_slice_1.reducer,
|
|
16
|
+
selection: selection_slice_1.reducer,
|
|
17
|
+
drag: drag_slice_1.reducer,
|
|
18
|
+
}),
|
|
19
|
+
dnd: dnd_slice_1.reducer,
|
|
20
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reducer = exports.actions = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const initial_1 = require("./initial");
|
|
6
|
+
/* Actions */
|
|
7
|
+
exports.actions = {
|
|
8
|
+
clear: () => ({ type: "SELECTION_CLEAR" }),
|
|
9
|
+
only: (id) => ({
|
|
10
|
+
type: "SELECTION_ONLY",
|
|
11
|
+
id: (0, utils_1.identify)(id),
|
|
12
|
+
}),
|
|
13
|
+
add: (id) => ({
|
|
14
|
+
type: "SELECTION_ADD",
|
|
15
|
+
ids: (Array.isArray(id) ? id : [id]).map(utils_1.identify),
|
|
16
|
+
}),
|
|
17
|
+
remove: (id) => ({
|
|
18
|
+
type: "SELECTION_REMOVE",
|
|
19
|
+
ids: (Array.isArray(id) ? id : [id]).map(utils_1.identify),
|
|
20
|
+
}),
|
|
21
|
+
set: (args) => (Object.assign({ type: "SELECTION_SET" }, args)),
|
|
22
|
+
mostRecent: (id) => ({
|
|
23
|
+
type: "SELECTION_MOST_RECENT",
|
|
24
|
+
id: id === null ? null : (0, utils_1.identify)(id),
|
|
25
|
+
}),
|
|
26
|
+
anchor: (id) => ({
|
|
27
|
+
type: "SELECTION_ANCHOR",
|
|
28
|
+
id: id === null ? null : (0, utils_1.identify)(id),
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
/* Reducer */
|
|
32
|
+
function reducer(state = (0, initial_1.initialState)()["nodes"]["selection"], action) {
|
|
33
|
+
const ids = state.ids;
|
|
34
|
+
switch (action.type) {
|
|
35
|
+
case "SELECTION_CLEAR":
|
|
36
|
+
return Object.assign(Object.assign({}, state), { ids: new Set() });
|
|
37
|
+
case "SELECTION_ONLY":
|
|
38
|
+
return Object.assign(Object.assign({}, state), { ids: new Set([action.id]) });
|
|
39
|
+
case "SELECTION_ADD":
|
|
40
|
+
if (action.ids.length === 0)
|
|
41
|
+
return state;
|
|
42
|
+
action.ids.forEach((id) => ids.add(id));
|
|
43
|
+
return Object.assign(Object.assign({}, state), { ids: new Set(ids) });
|
|
44
|
+
case "SELECTION_REMOVE":
|
|
45
|
+
if (action.ids.length === 0)
|
|
46
|
+
return state;
|
|
47
|
+
action.ids.forEach((id) => ids.delete(id));
|
|
48
|
+
return Object.assign(Object.assign({}, state), { ids: new Set(ids) });
|
|
49
|
+
case "SELECTION_SET":
|
|
50
|
+
return Object.assign(Object.assign({}, state), { ids: action.ids, mostRecent: action.mostRecent, anchor: action.anchor });
|
|
51
|
+
case "SELECTION_MOST_RECENT":
|
|
52
|
+
return Object.assign(Object.assign({}, state), { mostRecent: action.id });
|
|
53
|
+
case "SELECTION_ANCHOR":
|
|
54
|
+
return Object.assign(Object.assign({}, state), { anchor: action.id });
|
|
55
|
+
default:
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.reducer = reducer;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { NodeApi } from "../interfaces/node-api";
|
|
2
2
|
import { IdObj } from "./utils";
|
|
3
|
-
export
|
|
3
|
+
export type CreateHandler<T> = (args: {
|
|
4
4
|
parentId: string | null;
|
|
5
5
|
parentNode: NodeApi<T> | null;
|
|
6
6
|
index: number;
|
|
7
7
|
type: "internal" | "leaf";
|
|
8
8
|
}) => (IdObj | null) | Promise<IdObj | null>;
|
|
9
|
-
export
|
|
9
|
+
export type MoveHandler<T> = (args: {
|
|
10
10
|
dragIds: string[];
|
|
11
11
|
dragNodes: NodeApi<T>[];
|
|
12
12
|
parentId: string | null;
|
|
13
13
|
parentNode: NodeApi<T> | null;
|
|
14
14
|
index: number;
|
|
15
15
|
}) => void | Promise<void>;
|
|
16
|
-
export
|
|
16
|
+
export type RenameHandler<T> = (args: {
|
|
17
17
|
id: string;
|
|
18
18
|
name: string;
|
|
19
19
|
node: NodeApi<T>;
|
|
20
20
|
}) => void | Promise<void>;
|
|
21
|
-
export
|
|
21
|
+
export type DeleteHandler<T> = (args: {
|
|
22
22
|
ids: string[];
|
|
23
23
|
nodes: NodeApi<T>[];
|
|
24
24
|
}) => void | Promise<void>;
|
|
25
|
-
export
|
|
25
|
+
export type EditResult = {
|
|
26
26
|
cancelled: true;
|
|
27
27
|
} | {
|
|
28
28
|
cancelled: false;
|
|
@@ -2,27 +2,27 @@ import { CSSProperties, HTMLAttributes, ReactElement } from "react";
|
|
|
2
2
|
import { NodeApi } from "../interfaces/node-api";
|
|
3
3
|
import { TreeApi } from "../interfaces/tree-api";
|
|
4
4
|
import { XYCoord } from "react-dnd";
|
|
5
|
-
export
|
|
5
|
+
export type NodeRendererProps<T> = {
|
|
6
6
|
style: CSSProperties;
|
|
7
7
|
node: NodeApi<T>;
|
|
8
8
|
tree: TreeApi<T>;
|
|
9
9
|
dragHandle?: (el: HTMLDivElement | null) => void;
|
|
10
10
|
preview?: boolean;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type RowRendererProps<T> = {
|
|
13
13
|
node: NodeApi<T>;
|
|
14
14
|
innerRef: (el: HTMLDivElement | null) => void;
|
|
15
15
|
attrs: HTMLAttributes<any>;
|
|
16
16
|
children: ReactElement;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type DragPreviewProps = {
|
|
19
19
|
offset: XYCoord | null;
|
|
20
20
|
mouse: XYCoord | null;
|
|
21
21
|
id: string | null;
|
|
22
22
|
dragIds: string[];
|
|
23
23
|
isDragging: boolean;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type CursorProps = {
|
|
26
26
|
top: number;
|
|
27
27
|
left: number;
|
|
28
28
|
indent: number;
|
|
@@ -26,7 +26,7 @@ export interface TreeProps<T> {
|
|
|
26
26
|
paddingTop?: number;
|
|
27
27
|
paddingBottom?: number;
|
|
28
28
|
padding?: number;
|
|
29
|
-
childrenAccessor?: string | ((d: T) => T[] | null);
|
|
29
|
+
childrenAccessor?: string | ((d: T) => readonly T[] | null);
|
|
30
30
|
idAccessor?: string | ((d: T) => string);
|
|
31
31
|
openByDefault?: boolean;
|
|
32
32
|
selectionFollowsFocus?: boolean;
|
|
@@ -3,15 +3,15 @@ import { NodeApi } from "../interfaces/node-api";
|
|
|
3
3
|
export interface IdObj {
|
|
4
4
|
id: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
6
|
+
export type Identity = string | IdObj | null;
|
|
7
|
+
export type BoolFunc<T> = (data: T) => boolean;
|
|
8
|
+
export type ActionTypes<Actions extends {
|
|
9
9
|
[name: string]: (...args: any[]) => AnyAction;
|
|
10
10
|
}> = ReturnType<Actions[keyof Actions]>;
|
|
11
|
-
export
|
|
11
|
+
export type SelectOptions = {
|
|
12
12
|
multi?: boolean;
|
|
13
13
|
contiguous?: boolean;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type NodesById<T> = {
|
|
16
16
|
[id: string]: NodeApi<T>;
|
|
17
17
|
};
|