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.
Files changed (213) hide show
  1. package/dist/main/components/cursor.d.ts +1 -0
  2. package/dist/main/components/cursor.js +20 -0
  3. package/dist/{components → main/components}/default-container.d.ts +1 -2
  4. package/dist/main/components/default-container.js +238 -0
  5. package/dist/main/components/default-cursor.js +35 -0
  6. package/dist/{components → main/components}/default-drag-preview.d.ts +1 -2
  7. package/dist/main/components/default-drag-preview.js +57 -0
  8. package/dist/{components → main/components}/default-node.d.ts +1 -2
  9. package/dist/main/components/default-node.js +32 -0
  10. package/dist/{components → main/components}/default-row.d.ts +1 -2
  11. package/dist/main/components/default-row.js +8 -0
  12. package/dist/main/components/drag-preview-container.d.ts +1 -0
  13. package/dist/main/components/drag-preview-container.js +21 -0
  14. package/dist/{components → main/components}/list-inner-element.d.ts +1 -1
  15. package/dist/main/components/list-inner-element.js +25 -0
  16. package/dist/main/components/list-outer-element.d.ts +2 -0
  17. package/dist/main/components/list-outer-element.js +38 -0
  18. package/dist/main/components/outer-drop.js +9 -0
  19. package/dist/{components → main/components}/provider.d.ts +2 -2
  20. package/dist/main/components/provider.js +52 -0
  21. package/dist/{components → main/components}/row-container.d.ts +2 -2
  22. package/dist/main/components/row-container.js +84 -0
  23. package/dist/main/components/tree-container.d.ts +1 -0
  24. package/dist/main/components/tree-container.js +12 -0
  25. package/dist/{components → main/components}/tree.d.ts +1 -1
  26. package/dist/main/components/tree.js +15 -0
  27. package/dist/{context.d.ts → main/context.d.ts} +4 -4
  28. package/dist/main/context.js +33 -0
  29. package/dist/main/data/create-index.js +10 -0
  30. package/dist/main/data/create-list.js +62 -0
  31. package/dist/main/data/create-root.js +43 -0
  32. package/dist/main/data/make-tree.d.ts +5 -0
  33. package/dist/main/data/make-tree.js +40 -0
  34. package/dist/{data → main/data}/simple-tree.d.ts +1 -1
  35. package/dist/main/data/simple-tree.js +100 -0
  36. package/dist/{dnd → main/dnd}/compute-drop.d.ts +6 -6
  37. package/dist/main/dnd/compute-drop.js +129 -0
  38. package/dist/main/dnd/drag-hook.js +46 -0
  39. package/dist/{dnd → main/dnd}/drop-hook.d.ts +2 -2
  40. package/dist/main/dnd/drop-hook.js +42 -0
  41. package/dist/main/dnd/measure-hover.d.ts +8 -0
  42. package/dist/main/dnd/measure-hover.js +21 -0
  43. package/dist/main/dnd/outer-drop-hook.js +45 -0
  44. package/dist/main/hooks/use-fresh-node.js +18 -0
  45. package/dist/{hooks → main/hooks}/use-simple-tree.d.ts +1 -1
  46. package/dist/main/hooks/use-simple-tree.js +35 -0
  47. package/dist/main/hooks/use-validated-props.js +29 -0
  48. package/dist/main/index.js +27 -0
  49. package/dist/{interfaces → main/interfaces}/node-api.d.ts +2 -1
  50. package/dist/main/interfaces/node-api.js +164 -0
  51. package/dist/{interfaces → main/interfaces}/tree-api.d.ts +90 -7
  52. package/dist/main/interfaces/tree-api.js +649 -0
  53. package/dist/main/interfaces/tree-api.test.d.ts +1 -0
  54. package/dist/main/interfaces/tree-api.test.js +14 -0
  55. package/dist/{state → main/state}/dnd-slice.d.ts +4 -4
  56. package/dist/main/state/dnd-slice.js +35 -0
  57. package/dist/{state → main/state}/drag-slice.d.ts +4 -2
  58. package/dist/main/state/drag-slice.js +24 -0
  59. package/dist/{state → main/state}/edit-slice.d.ts +1 -1
  60. package/dist/main/state/edit-slice.js +18 -0
  61. package/dist/{state → main/state}/focus-slice.d.ts +1 -1
  62. package/dist/main/state/focus-slice.js +26 -0
  63. package/dist/main/state/initial.js +29 -0
  64. package/dist/{state → main/state}/open-slice.d.ts +2 -2
  65. package/dist/main/state/open-slice.js +48 -0
  66. package/dist/main/state/root-reducer.d.ts +96 -0
  67. package/dist/main/state/root-reducer.js +20 -0
  68. package/dist/{state → main/state}/selection-slice.d.ts +1 -1
  69. package/dist/main/state/selection-slice.js +59 -0
  70. package/dist/{types → main/types}/dnd.d.ts +2 -2
  71. package/dist/main/types/dnd.js +2 -0
  72. package/dist/{types → main/types}/handlers.d.ts +5 -5
  73. package/dist/main/types/handlers.js +2 -0
  74. package/dist/{types → main/types}/renderers.d.ts +4 -4
  75. package/dist/main/types/renderers.js +2 -0
  76. package/dist/main/types/state.d.ts +2 -0
  77. package/dist/main/types/state.js +2 -0
  78. package/dist/main/types/tree-props.js +2 -0
  79. package/dist/{types → main/types}/utils.d.ts +5 -5
  80. package/dist/main/types/utils.js +2 -0
  81. package/dist/{utils.d.ts → main/utils.d.ts} +2 -2
  82. package/dist/main/utils.js +183 -0
  83. package/dist/module/components/cursor.d.ts +1 -0
  84. package/dist/module/components/cursor.js +16 -0
  85. package/dist/module/components/default-container.d.ts +6 -0
  86. package/dist/module/components/default-container.js +234 -0
  87. package/dist/module/components/default-cursor.d.ts +3 -0
  88. package/dist/module/components/default-cursor.js +29 -0
  89. package/dist/module/components/default-drag-preview.d.ts +2 -0
  90. package/dist/module/components/default-drag-preview.js +53 -0
  91. package/dist/module/components/default-node.d.ts +2 -0
  92. package/dist/module/components/default-node.js +28 -0
  93. package/dist/module/components/default-row.d.ts +2 -0
  94. package/dist/module/components/default-row.js +4 -0
  95. package/dist/module/components/drag-preview-container.d.ts +1 -0
  96. package/dist/module/components/drag-preview-container.js +17 -0
  97. package/dist/module/components/list-inner-element.d.ts +2 -0
  98. package/dist/module/components/list-inner-element.js +22 -0
  99. package/dist/module/components/list-outer-element.d.ts +2 -0
  100. package/dist/module/components/list-outer-element.js +35 -0
  101. package/dist/module/components/outer-drop.d.ts +4 -0
  102. package/dist/module/components/outer-drop.js +5 -0
  103. package/dist/module/components/provider.d.ts +10 -0
  104. package/dist/module/components/provider.js +48 -0
  105. package/dist/module/components/row-container.d.ts +7 -0
  106. package/dist/module/components/row-container.js +58 -0
  107. package/dist/module/components/tree-container.d.ts +1 -0
  108. package/dist/module/components/tree-container.js +8 -0
  109. package/dist/module/components/tree.d.ts +8 -0
  110. package/dist/module/components/tree.js +12 -0
  111. package/dist/module/context.d.ts +22 -0
  112. package/dist/module/context.js +26 -0
  113. package/dist/module/data/create-index.d.ts +4 -0
  114. package/dist/module/data/create-index.js +6 -0
  115. package/dist/module/data/create-list.d.ts +3 -0
  116. package/dist/module/data/create-list.js +58 -0
  117. package/dist/module/data/create-root.d.ts +4 -0
  118. package/dist/module/data/create-root.js +39 -0
  119. package/dist/module/data/make-tree.d.ts +5 -0
  120. package/dist/module/data/make-tree.js +36 -0
  121. package/dist/module/data/simple-tree.d.ts +44 -0
  122. package/dist/module/data/simple-tree.js +96 -0
  123. package/dist/module/dnd/compute-drop.d.ts +37 -0
  124. package/dist/module/dnd/compute-drop.js +125 -0
  125. package/dist/module/dnd/drag-hook.d.ts +3 -0
  126. package/dist/module/dnd/drag-hook.js +42 -0
  127. package/dist/module/dnd/drop-hook.d.ts +8 -0
  128. package/dist/module/dnd/drop-hook.js +38 -0
  129. package/dist/module/dnd/measure-hover.d.ts +8 -0
  130. package/dist/module/dnd/measure-hover.js +17 -0
  131. package/dist/module/dnd/outer-drop-hook.d.ts +1 -0
  132. package/dist/module/dnd/outer-drop-hook.js +41 -0
  133. package/dist/module/hooks/use-fresh-node.d.ts +1 -0
  134. package/dist/module/hooks/use-fresh-node.js +14 -0
  135. package/dist/module/hooks/use-simple-tree.d.ts +12 -0
  136. package/dist/module/hooks/use-simple-tree.js +31 -0
  137. package/dist/module/hooks/use-validated-props.d.ts +2 -0
  138. package/dist/module/hooks/use-validated-props.js +25 -0
  139. package/dist/module/index.d.ts +8 -0
  140. package/dist/module/index.js +9 -0
  141. package/dist/module/interfaces/node-api.d.ts +71 -0
  142. package/dist/module/interfaces/node-api.js +160 -0
  143. package/dist/module/interfaces/tree-api.d.ts +214 -0
  144. package/dist/module/interfaces/tree-api.js +622 -0
  145. package/dist/module/interfaces/tree-api.test.d.ts +1 -0
  146. package/dist/module/interfaces/tree-api.test.js +12 -0
  147. package/dist/module/state/dnd-slice.d.ts +29 -0
  148. package/dist/module/state/dnd-slice.js +31 -0
  149. package/dist/module/state/drag-slice.d.ts +9 -0
  150. package/dist/module/state/drag-slice.js +20 -0
  151. package/dist/module/state/edit-slice.d.ts +8 -0
  152. package/dist/module/state/edit-slice.js +13 -0
  153. package/dist/module/state/focus-slice.d.ts +12 -0
  154. package/dist/module/state/focus-slice.js +20 -0
  155. package/dist/module/state/initial.d.ts +3 -0
  156. package/dist/module/state/initial.js +25 -0
  157. package/dist/module/state/open-slice.d.ts +30 -0
  158. package/dist/module/state/open-slice.js +44 -0
  159. package/dist/module/state/root-reducer.d.ts +96 -0
  160. package/dist/module/state/root-reducer.js +17 -0
  161. package/dist/module/state/selection-slice.d.ts +42 -0
  162. package/dist/module/state/selection-slice.js +55 -0
  163. package/dist/module/types/dnd.d.ts +8 -0
  164. package/dist/module/types/dnd.js +1 -0
  165. package/dist/module/types/handlers.d.ts +30 -0
  166. package/dist/module/types/handlers.js +1 -0
  167. package/dist/module/types/renderers.d.ts +29 -0
  168. package/dist/module/types/renderers.js +1 -0
  169. package/dist/module/types/state.d.ts +2 -0
  170. package/dist/module/types/state.js +1 -0
  171. package/dist/module/types/tree-props.d.ts +56 -0
  172. package/dist/module/types/tree-props.js +1 -0
  173. package/dist/module/types/utils.d.ts +17 -0
  174. package/dist/module/types/utils.js +1 -0
  175. package/dist/module/utils.d.ts +24 -0
  176. package/dist/module/utils.js +162 -0
  177. package/package.json +26 -25
  178. package/src/components/default-container.tsx +2 -0
  179. package/src/components/provider.tsx +3 -2
  180. package/src/components/row-container.tsx +1 -1
  181. package/src/dnd/compute-drop.ts +6 -3
  182. package/src/dnd/drag-hook.ts +1 -1
  183. package/src/dnd/drop-hook.ts +1 -1
  184. package/src/interfaces/node-api.ts +10 -0
  185. package/src/interfaces/tree-api.ts +16 -3
  186. package/src/state/dnd-slice.ts +2 -2
  187. package/src/state/drag-slice.ts +27 -11
  188. package/src/state/initial.ts +6 -1
  189. package/src/utils.ts +2 -2
  190. package/dist/components/cursor.d.ts +0 -2
  191. package/dist/components/drag-preview-container.d.ts +0 -2
  192. package/dist/components/list-outer-element.d.ts +0 -2
  193. package/dist/components/tree-container.d.ts +0 -2
  194. package/dist/index.js +0 -2414
  195. package/dist/index.js.map +0 -1
  196. package/dist/module.js +0 -2387
  197. package/dist/module.js.map +0 -1
  198. package/dist/state/root-reducer.d.ts +0 -13
  199. package/dist/types/state.d.ts +0 -2
  200. package/jest.config.js +0 -5
  201. package/tsconfig.json +0 -4
  202. /package/dist/{components → main/components}/default-cursor.d.ts +0 -0
  203. /package/dist/{components → main/components}/outer-drop.d.ts +0 -0
  204. /package/dist/{data → main/data}/create-index.d.ts +0 -0
  205. /package/dist/{data → main/data}/create-list.d.ts +0 -0
  206. /package/dist/{data → main/data}/create-root.d.ts +0 -0
  207. /package/dist/{dnd → main/dnd}/drag-hook.d.ts +0 -0
  208. /package/dist/{dnd → main/dnd}/outer-drop-hook.d.ts +0 -0
  209. /package/dist/{hooks → main/hooks}/use-fresh-node.d.ts +0 -0
  210. /package/dist/{hooks → main/hooks}/use-validated-props.d.ts +0 -0
  211. /package/dist/{index.d.ts → main/index.d.ts} +0 -0
  212. /package/dist/{state → main/state}/initial.d.ts +0 -0
  213. /package/dist/{types → main/types}/tree-props.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;
@@ -1,7 +1,9 @@
1
1
  import { ActionTypes } from "../types/utils";
2
2
  import { actions as dnd } from "./dnd-slice";
3
- export declare type DragSlice = {
3
+ export type DragSlice = {
4
4
  id: string | null;
5
- idWillReceiveDrop: string | null;
5
+ selectedIds: string[];
6
+ destinationParentId: string | null;
7
+ destinationIndex: number | null;
6
8
  };
7
9
  export declare function reducer(state: DragSlice | undefined, action: ActionTypes<typeof dnd>): DragSlice;
@@ -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;
@@ -1,4 +1,4 @@
1
- export declare type EditState = {
1
+ export type EditState = {
2
2
  id: string | null;
3
3
  };
4
4
  export declare function edit(id: string | null): {
@@ -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;
@@ -1,4 +1,4 @@
1
- export declare type FocusState = {
1
+ export type FocusState = {
2
2
  id: string | null;
3
3
  treeFocused: boolean;
4
4
  };
@@ -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;
@@ -1,8 +1,8 @@
1
1
  import { ActionTypes } from "../types/utils";
2
- export declare type OpenMap = {
2
+ export type OpenMap = {
3
3
  [id: string]: boolean;
4
4
  };
5
- export declare type OpenSlice = {
5
+ export type OpenSlice = {
6
6
  unfiltered: OpenMap;
7
7
  filtered: OpenMap;
8
8
  };
@@ -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
+ });
@@ -1,5 +1,5 @@
1
1
  import { ActionTypes, IdObj } from "../types/utils";
2
- export declare type SelectionState = {
2
+ export type SelectionState = {
3
3
  ids: Set<string>;
4
4
  anchor: string | null;
5
5
  mostRecent: string | null;
@@ -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,8 +1,8 @@
1
- export declare type CursorLocation = {
1
+ export type CursorLocation = {
2
2
  index: number | null;
3
3
  level: number | null;
4
4
  parentId: string | null;
5
5
  };
6
- export declare type DragItem = {
6
+ export type DragItem = {
7
7
  id: string;
8
8
  };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,28 +1,28 @@
1
1
  import { NodeApi } from "../interfaces/node-api";
2
2
  import { IdObj } from "./utils";
3
- export declare type CreateHandler<T> = (args: {
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 declare type MoveHandler<T> = (args: {
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 declare type RenameHandler<T> = (args: {
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 declare type DeleteHandler<T> = (args: {
21
+ export type DeleteHandler<T> = (args: {
22
22
  ids: string[];
23
23
  nodes: NodeApi<T>[];
24
24
  }) => void | Promise<void>;
25
- export declare type EditResult = {
25
+ export type EditResult = {
26
26
  cancelled: true;
27
27
  } | {
28
28
  cancelled: false;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 declare type NodeRendererProps<T> = {
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 declare type RowRendererProps<T> = {
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 declare type DragPreviewProps = {
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 declare type CursorProps = {
25
+ export type CursorProps = {
26
26
  top: number;
27
27
  left: number;
28
28
  indent: number;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { NodeApi } from "../interfaces/node-api";
2
+ export type NodeState = typeof NodeApi.prototype["state"];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,15 +3,15 @@ import { NodeApi } from "../interfaces/node-api";
3
3
  export interface IdObj {
4
4
  id: string;
5
5
  }
6
- export declare type Identity = string | IdObj | null;
7
- export declare type BoolFunc<T> = (data: T) => boolean;
8
- export declare type ActionTypes<Actions extends {
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 declare type SelectOptions = {
11
+ export type SelectOptions = {
12
12
  multi?: boolean;
13
13
  contiguous?: boolean;
14
14
  };
15
- export declare type NodesById<T> = {
15
+ export type NodesById<T> = {
16
16
  [id: string]: NodeApi<T>;
17
17
  };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,9 +5,9 @@ export declare function bound(n: number, min: number, max: number): number;
5
5
  export declare function isItem(node: NodeApi<any> | null): boolean | null;
6
6
  export declare function isClosed(node: NodeApi<any> | null): boolean | null;
7
7
  /**
8
- * Is first param a decendent of the second param
8
+ * Is first param a descendant of the second param
9
9
  */
10
- export declare const isDecendent: (a: NodeApi<any>, b: NodeApi<any>) => boolean;
10
+ export declare const isDescendant: (a: NodeApi<any>, b: NodeApi<any>) => boolean;
11
11
  export declare const indexOf: (node: NodeApi<any>) => number;
12
12
  export declare function noop(): void;
13
13
  export declare function dfs(node: NodeApi<any>, id: string): NodeApi<any> | null;