react-arborist 3.3.0-rc.1 → 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 (204) 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 +1 -1
  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 +1 -1
  50. package/dist/main/interfaces/node-api.js +164 -0
  51. package/dist/{interfaces → main/interfaces}/tree-api.d.ts +87 -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 +1 -1
  56. package/dist/main/state/dnd-slice.js +35 -0
  57. package/dist/{state → main/state}/drag-slice.d.ts +1 -1
  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/main/utils.js +183 -0
  82. package/dist/module/components/cursor.d.ts +1 -0
  83. package/dist/module/components/cursor.js +16 -0
  84. package/dist/module/components/default-container.d.ts +6 -0
  85. package/dist/module/components/default-container.js +234 -0
  86. package/dist/module/components/default-cursor.d.ts +3 -0
  87. package/dist/module/components/default-cursor.js +29 -0
  88. package/dist/module/components/default-drag-preview.d.ts +2 -0
  89. package/dist/module/components/default-drag-preview.js +53 -0
  90. package/dist/module/components/default-node.d.ts +2 -0
  91. package/dist/module/components/default-node.js +28 -0
  92. package/dist/module/components/default-row.d.ts +2 -0
  93. package/dist/module/components/default-row.js +4 -0
  94. package/dist/module/components/drag-preview-container.d.ts +1 -0
  95. package/dist/module/components/drag-preview-container.js +17 -0
  96. package/dist/module/components/list-inner-element.d.ts +2 -0
  97. package/dist/module/components/list-inner-element.js +22 -0
  98. package/dist/module/components/list-outer-element.d.ts +2 -0
  99. package/dist/module/components/list-outer-element.js +35 -0
  100. package/dist/module/components/outer-drop.d.ts +4 -0
  101. package/dist/module/components/outer-drop.js +5 -0
  102. package/dist/module/components/provider.d.ts +10 -0
  103. package/dist/module/components/provider.js +48 -0
  104. package/dist/module/components/row-container.d.ts +7 -0
  105. package/dist/module/components/row-container.js +58 -0
  106. package/dist/module/components/tree-container.d.ts +1 -0
  107. package/dist/module/components/tree-container.js +8 -0
  108. package/dist/module/components/tree.d.ts +8 -0
  109. package/dist/module/components/tree.js +12 -0
  110. package/dist/module/context.d.ts +22 -0
  111. package/dist/module/context.js +26 -0
  112. package/dist/module/data/create-index.d.ts +4 -0
  113. package/dist/module/data/create-index.js +6 -0
  114. package/dist/module/data/create-list.d.ts +3 -0
  115. package/dist/module/data/create-list.js +58 -0
  116. package/dist/module/data/create-root.d.ts +4 -0
  117. package/dist/module/data/create-root.js +39 -0
  118. package/dist/module/data/make-tree.d.ts +5 -0
  119. package/dist/module/data/make-tree.js +36 -0
  120. package/dist/module/data/simple-tree.d.ts +44 -0
  121. package/dist/module/data/simple-tree.js +96 -0
  122. package/dist/module/dnd/compute-drop.d.ts +37 -0
  123. package/dist/module/dnd/compute-drop.js +125 -0
  124. package/dist/module/dnd/drag-hook.d.ts +3 -0
  125. package/dist/module/dnd/drag-hook.js +42 -0
  126. package/dist/module/dnd/drop-hook.d.ts +8 -0
  127. package/dist/module/dnd/drop-hook.js +38 -0
  128. package/dist/module/dnd/measure-hover.d.ts +8 -0
  129. package/dist/module/dnd/measure-hover.js +17 -0
  130. package/dist/module/dnd/outer-drop-hook.d.ts +1 -0
  131. package/dist/module/dnd/outer-drop-hook.js +41 -0
  132. package/dist/module/hooks/use-fresh-node.d.ts +1 -0
  133. package/dist/module/hooks/use-fresh-node.js +14 -0
  134. package/dist/module/hooks/use-simple-tree.d.ts +12 -0
  135. package/dist/module/hooks/use-simple-tree.js +31 -0
  136. package/dist/module/hooks/use-validated-props.d.ts +2 -0
  137. package/dist/module/hooks/use-validated-props.js +25 -0
  138. package/dist/module/index.d.ts +8 -0
  139. package/dist/module/index.js +9 -0
  140. package/dist/module/interfaces/node-api.d.ts +71 -0
  141. package/dist/module/interfaces/node-api.js +160 -0
  142. package/dist/module/interfaces/tree-api.d.ts +214 -0
  143. package/dist/module/interfaces/tree-api.js +622 -0
  144. package/dist/module/interfaces/tree-api.test.d.ts +1 -0
  145. package/dist/module/interfaces/tree-api.test.js +12 -0
  146. package/dist/module/state/dnd-slice.d.ts +29 -0
  147. package/dist/module/state/dnd-slice.js +31 -0
  148. package/dist/module/state/drag-slice.d.ts +9 -0
  149. package/dist/module/state/drag-slice.js +20 -0
  150. package/dist/module/state/edit-slice.d.ts +8 -0
  151. package/dist/module/state/edit-slice.js +13 -0
  152. package/dist/module/state/focus-slice.d.ts +12 -0
  153. package/dist/module/state/focus-slice.js +20 -0
  154. package/dist/module/state/initial.d.ts +3 -0
  155. package/dist/module/state/initial.js +25 -0
  156. package/dist/module/state/open-slice.d.ts +30 -0
  157. package/dist/module/state/open-slice.js +44 -0
  158. package/dist/module/state/root-reducer.d.ts +96 -0
  159. package/dist/module/state/root-reducer.js +17 -0
  160. package/dist/module/state/selection-slice.d.ts +42 -0
  161. package/dist/module/state/selection-slice.js +55 -0
  162. package/dist/module/types/dnd.d.ts +8 -0
  163. package/dist/module/types/dnd.js +1 -0
  164. package/dist/module/types/handlers.d.ts +30 -0
  165. package/dist/module/types/handlers.js +1 -0
  166. package/dist/module/types/renderers.d.ts +29 -0
  167. package/dist/module/types/renderers.js +1 -0
  168. package/dist/module/types/state.d.ts +2 -0
  169. package/dist/module/types/state.js +1 -0
  170. package/dist/module/types/tree-props.d.ts +56 -0
  171. package/dist/module/types/tree-props.js +1 -0
  172. package/dist/module/types/utils.d.ts +17 -0
  173. package/dist/module/types/utils.js +1 -0
  174. package/dist/module/utils.d.ts +24 -0
  175. package/dist/module/utils.js +162 -0
  176. package/package.json +26 -25
  177. package/src/components/default-container.tsx +2 -0
  178. package/src/components/provider.tsx +3 -2
  179. package/src/components/row-container.tsx +1 -1
  180. package/dist/components/cursor.d.ts +0 -2
  181. package/dist/components/drag-preview-container.d.ts +0 -2
  182. package/dist/components/list-outer-element.d.ts +0 -2
  183. package/dist/components/tree-container.d.ts +0 -2
  184. package/dist/index.js +0 -2433
  185. package/dist/index.js.map +0 -1
  186. package/dist/module.js +0 -2406
  187. package/dist/module.js.map +0 -1
  188. package/dist/state/root-reducer.d.ts +0 -13
  189. package/dist/types/state.d.ts +0 -2
  190. package/jest.config.js +0 -5
  191. package/tsconfig.json +0 -4
  192. /package/dist/{components → main/components}/default-cursor.d.ts +0 -0
  193. /package/dist/{components → main/components}/outer-drop.d.ts +0 -0
  194. /package/dist/{data → main/data}/create-index.d.ts +0 -0
  195. /package/dist/{data → main/data}/create-list.d.ts +0 -0
  196. /package/dist/{data → main/data}/create-root.d.ts +0 -0
  197. /package/dist/{dnd → main/dnd}/drag-hook.d.ts +0 -0
  198. /package/dist/{dnd → main/dnd}/outer-drop-hook.d.ts +0 -0
  199. /package/dist/{hooks → main/hooks}/use-fresh-node.d.ts +0 -0
  200. /package/dist/{hooks → main/hooks}/use-validated-props.d.ts +0 -0
  201. /package/dist/{index.d.ts → main/index.d.ts} +0 -0
  202. /package/dist/{state → main/state}/initial.d.ts +0 -0
  203. /package/dist/{types → main/types}/tree-props.d.ts +0 -0
  204. /package/dist/{utils.d.ts → main/utils.d.ts} +0 -0
package/dist/index.js DELETED
@@ -1,2433 +0,0 @@
1
- var $foSVk$reactjsxruntime = require("react/jsx-runtime");
2
- var $foSVk$react = require("react");
3
- var $foSVk$usesyncexternalstoreshim = require("use-sync-external-store/shim");
4
- var $foSVk$reactdndhtml5backend = require("react-dnd-html5-backend");
5
- var $foSVk$reactdnd = require("react-dnd");
6
- var $foSVk$redux = require("redux");
7
- var $foSVk$reactwindow = require("react-window");
8
-
9
- function $parcel$export(e, n, v, s) {
10
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
- }
12
- function $parcel$exportWildcard(dest, source) {
13
- Object.keys(source).forEach(function(key) {
14
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
15
- return;
16
- }
17
-
18
- Object.defineProperty(dest, key, {
19
- enumerable: true,
20
- get: function get() {
21
- return source[key];
22
- }
23
- });
24
- });
25
-
26
- return dest;
27
- }
28
- function $parcel$interopDefault(a) {
29
- return a && a.__esModule ? a.default : a;
30
- }
31
-
32
- $parcel$export(module.exports, "Tree", () => $641461e16d1a2941$export$7fbedc92909ed28e);
33
-
34
-
35
-
36
-
37
-
38
-
39
- const $d5cb84d44d1b8acc$export$feef243b04ff4151 = (0, $foSVk$react.createContext)(null);
40
- function $d5cb84d44d1b8acc$export$367b0f2231a90ba0() {
41
- const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$feef243b04ff4151);
42
- if (value === null) throw new Error("No Tree Api Provided");
43
- return value;
44
- }
45
- const $d5cb84d44d1b8acc$export$f6d467aa8b3786af = (0, $foSVk$react.createContext)(null);
46
- function $d5cb84d44d1b8acc$export$fd23f19d5d8f3033() {
47
- const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$f6d467aa8b3786af);
48
- if (value === null) throw new Error("Provide a NodesContext");
49
- return value;
50
- }
51
- const $d5cb84d44d1b8acc$export$2d5c5ceac203fc1e = (0, $foSVk$react.createContext)(null);
52
- function $d5cb84d44d1b8acc$export$4930f6bf413be70e() {
53
- const value = (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$2d5c5ceac203fc1e);
54
- if (value === null) throw new Error("Provide a DnDContext");
55
- return value;
56
- }
57
- const $d5cb84d44d1b8acc$export$d0c71bc5e3e2d897 = (0, $foSVk$react.createContext)(0);
58
- function $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8() {
59
- (0, $foSVk$react.useContext)($d5cb84d44d1b8acc$export$d0c71bc5e3e2d897);
60
- }
61
-
62
-
63
- var $5c74fef433be2b0a$exports = {};
64
-
65
- $parcel$export($5c74fef433be2b0a$exports, "TreeApi", () => $5c74fef433be2b0a$export$e2da3477247342d1);
66
- var $eb5355379510ac9b$exports = {};
67
-
68
- $parcel$export($eb5355379510ac9b$exports, "bound", () => $eb5355379510ac9b$export$adf7c0fe6059d774);
69
- $parcel$export($eb5355379510ac9b$exports, "isItem", () => $eb5355379510ac9b$export$5318634f2ee07019);
70
- $parcel$export($eb5355379510ac9b$exports, "isClosed", () => $eb5355379510ac9b$export$4210f5ea57fbae57);
71
- $parcel$export($eb5355379510ac9b$exports, "isDescendant", () => $eb5355379510ac9b$export$8503f9d2928f9a64);
72
- $parcel$export($eb5355379510ac9b$exports, "indexOf", () => $eb5355379510ac9b$export$305f7d4e9d4624f2);
73
- $parcel$export($eb5355379510ac9b$exports, "noop", () => $eb5355379510ac9b$export$8793edee2d425525);
74
- $parcel$export($eb5355379510ac9b$exports, "dfs", () => $eb5355379510ac9b$export$51b654aff22fc5a6);
75
- $parcel$export($eb5355379510ac9b$exports, "walk", () => $eb5355379510ac9b$export$588732934346abbf);
76
- $parcel$export($eb5355379510ac9b$exports, "focusNextElement", () => $eb5355379510ac9b$export$3b0237e8566c8d65);
77
- $parcel$export($eb5355379510ac9b$exports, "focusPrevElement", () => $eb5355379510ac9b$export$33b47db07a82b2fb);
78
- $parcel$export($eb5355379510ac9b$exports, "access", () => $eb5355379510ac9b$export$9bb0e144ba4929ca);
79
- $parcel$export($eb5355379510ac9b$exports, "identifyNull", () => $eb5355379510ac9b$export$611823266272db76);
80
- $parcel$export($eb5355379510ac9b$exports, "identify", () => $eb5355379510ac9b$export$65e5b62a4c490288);
81
- $parcel$export($eb5355379510ac9b$exports, "mergeRefs", () => $eb5355379510ac9b$export$c9058316764c140e);
82
- $parcel$export($eb5355379510ac9b$exports, "safeRun", () => $eb5355379510ac9b$export$c6d63370cef03886);
83
- $parcel$export($eb5355379510ac9b$exports, "waitFor", () => $eb5355379510ac9b$export$9bbfceb27f687c1b);
84
- $parcel$export($eb5355379510ac9b$exports, "getInsertIndex", () => $eb5355379510ac9b$export$e12bf2314d0bc2a9);
85
- $parcel$export($eb5355379510ac9b$exports, "getInsertParentId", () => $eb5355379510ac9b$export$58fe32731f07ed56);
86
- function $eb5355379510ac9b$export$adf7c0fe6059d774(n, min, max) {
87
- return Math.max(Math.min(n, max), min);
88
- }
89
- function $eb5355379510ac9b$export$5318634f2ee07019(node) {
90
- return node && node.isLeaf;
91
- }
92
- function $eb5355379510ac9b$export$4210f5ea57fbae57(node) {
93
- return node && node.isInternal && !node.isOpen;
94
- }
95
- const $eb5355379510ac9b$export$8503f9d2928f9a64 = (a, b)=>{
96
- let n = a;
97
- while(n){
98
- if (n.id === b.id) return true;
99
- n = n.parent;
100
- }
101
- return false;
102
- };
103
- const $eb5355379510ac9b$export$305f7d4e9d4624f2 = (node)=>{
104
- if (!node.parent) throw Error("Node does not have a parent");
105
- return node.parent.children.findIndex((c)=>c.id === node.id);
106
- };
107
- function $eb5355379510ac9b$export$8793edee2d425525() {}
108
- function $eb5355379510ac9b$export$51b654aff22fc5a6(node, id) {
109
- if (!node) return null;
110
- if (node.id === id) return node;
111
- if (node.children) for (let child of node.children){
112
- const result = $eb5355379510ac9b$export$51b654aff22fc5a6(child, id);
113
- if (result) return result;
114
- }
115
- return null;
116
- }
117
- function $eb5355379510ac9b$export$588732934346abbf(node, fn) {
118
- fn(node);
119
- if (node.children) for (let child of node.children)$eb5355379510ac9b$export$588732934346abbf(child, fn);
120
- }
121
- function $eb5355379510ac9b$export$3b0237e8566c8d65(target) {
122
- const elements = $eb5355379510ac9b$var$getFocusable(target);
123
- let next;
124
- for(let i = 0; i < elements.length; ++i){
125
- const item = elements[i];
126
- if (item === target) {
127
- next = $eb5355379510ac9b$var$nextItem(elements, i);
128
- break;
129
- }
130
- }
131
- // @ts-ignore ??
132
- next?.focus();
133
- }
134
- function $eb5355379510ac9b$export$33b47db07a82b2fb(target) {
135
- const elements = $eb5355379510ac9b$var$getFocusable(target);
136
- let next;
137
- for(let i = 0; i < elements.length; ++i){
138
- const item = elements[i];
139
- if (item === target) {
140
- next = $eb5355379510ac9b$var$prevItem(elements, i);
141
- break;
142
- }
143
- }
144
- // @ts-ignore
145
- next?.focus();
146
- }
147
- function $eb5355379510ac9b$var$nextItem(list, index) {
148
- if (index + 1 < list.length) return list[index + 1];
149
- else return list[0];
150
- }
151
- function $eb5355379510ac9b$var$prevItem(list, index) {
152
- if (index - 1 >= 0) return list[index - 1];
153
- else return list[list.length - 1];
154
- }
155
- function $eb5355379510ac9b$var$getFocusable(target) {
156
- return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter((e)=>e === target || !target.contains(e));
157
- }
158
- function $eb5355379510ac9b$export$9bb0e144ba4929ca(obj, accessor) {
159
- if (typeof accessor === "boolean") return accessor;
160
- if (typeof accessor === "string") return obj[accessor];
161
- return accessor(obj);
162
- }
163
- function $eb5355379510ac9b$export$611823266272db76(obj) {
164
- if (obj === null) return null;
165
- else return $eb5355379510ac9b$export$65e5b62a4c490288(obj);
166
- }
167
- function $eb5355379510ac9b$export$65e5b62a4c490288(obj) {
168
- return typeof obj === "string" ? obj : obj.id;
169
- }
170
- function $eb5355379510ac9b$export$c9058316764c140e(...refs) {
171
- return (instance)=>{
172
- refs.forEach((ref)=>{
173
- if (typeof ref === "function") ref(instance);
174
- else if (ref != null) ref.current = instance;
175
- });
176
- };
177
- }
178
- function $eb5355379510ac9b$export$c6d63370cef03886(fn, ...args) {
179
- if (fn) return fn(...args);
180
- }
181
- function $eb5355379510ac9b$export$9bbfceb27f687c1b(fn) {
182
- return new Promise((resolve, reject)=>{
183
- let tries = 0;
184
- function check() {
185
- tries += 1;
186
- if (tries === 100) reject();
187
- if (fn()) resolve();
188
- else setTimeout(check, 10);
189
- }
190
- check();
191
- });
192
- }
193
- function $eb5355379510ac9b$export$e12bf2314d0bc2a9(tree) {
194
- const focus = tree.focusedNode;
195
- if (!focus) return tree.root.children?.length ?? 0;
196
- if (focus.isOpen) return 0;
197
- if (focus.parent) return focus.childIndex + 1;
198
- return 0;
199
- }
200
- function $eb5355379510ac9b$export$58fe32731f07ed56(tree) {
201
- const focus = tree.focusedNode;
202
- if (!focus) return null;
203
- if (focus.isOpen) return focus.id;
204
- if (focus.parent && !focus.parent.isRoot) return focus.parent.id;
205
- return null;
206
- }
207
-
208
-
209
-
210
-
211
- const $c79fefb0d0a1d13b$var$placeholderStyle = {
212
- display: "flex",
213
- alignItems: "center",
214
- zIndex: 1
215
- };
216
- const $c79fefb0d0a1d13b$var$lineStyle = {
217
- flex: 1,
218
- height: "2px",
219
- background: "#4B91E2",
220
- borderRadius: "1px"
221
- };
222
- const $c79fefb0d0a1d13b$var$circleStyle = {
223
- width: "4px",
224
- height: "4px",
225
- boxShadow: "0 0 0 3px #4B91E2",
226
- borderRadius: "50%"
227
- };
228
- const $c79fefb0d0a1d13b$export$6cb3c16721363d11 = /*#__PURE__*/ (0, ($parcel$interopDefault($foSVk$react))).memo(function DefaultCursor({ top: top , left: left , indent: indent }) {
229
- const style = {
230
- position: "absolute",
231
- pointerEvents: "none",
232
- top: top - 2 + "px",
233
- left: left + "px",
234
- right: indent + "px"
235
- };
236
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
237
- style: {
238
- ...$c79fefb0d0a1d13b$var$placeholderStyle,
239
- ...style
240
- },
241
- children: [
242
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
243
- style: {
244
- ...$c79fefb0d0a1d13b$var$circleStyle
245
- }
246
- }),
247
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
248
- style: {
249
- ...$c79fefb0d0a1d13b$var$lineStyle
250
- }
251
- })
252
- ]
253
- });
254
- });
255
-
256
-
257
-
258
-
259
- function $ff6862a32cc2ac81$export$f9c541e71856c524({ node: node , attrs: attrs , innerRef: innerRef , children: children }) {
260
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
261
- ...attrs,
262
- ref: innerRef,
263
- onFocus: (e)=>e.stopPropagation(),
264
- onClick: node.handleClick,
265
- children: children
266
- });
267
- }
268
-
269
-
270
-
271
-
272
- function $3240a4b0b5620968$export$909e23cbfbbd3351(props) {
273
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
274
- ref: props.dragHandle,
275
- style: props.style,
276
- children: [
277
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("span", {
278
- onClick: (e)=>{
279
- e.stopPropagation();
280
- props.node.toggle();
281
- },
282
- children: props.node.isLeaf ? "\uD83C\uDF33" : props.node.isOpen ? "\uD83D\uDDC1" : "\uD83D\uDDC0"
283
- }),
284
- " ",
285
- props.node.isEditing ? /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($3240a4b0b5620968$var$Edit, {
286
- ...props
287
- }) : /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($3240a4b0b5620968$var$Show, {
288
- ...props
289
- })
290
- ]
291
- });
292
- }
293
- function $3240a4b0b5620968$var$Show(props) {
294
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactjsxruntime.Fragment), {
295
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("span", {
296
- children: props.node.data.name
297
- })
298
- });
299
- }
300
- function $3240a4b0b5620968$var$Edit({ node: node }) {
301
- const input = (0, $foSVk$react.useRef)();
302
- (0, $foSVk$react.useEffect)(()=>{
303
- input.current?.focus();
304
- input.current?.select();
305
- }, []);
306
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("input", {
307
- ref: input,
308
- // @ts-ignore
309
- defaultValue: node.data.name,
310
- onBlur: ()=>node.reset(),
311
- onKeyDown: (e)=>{
312
- if (e.key === "Escape") node.reset();
313
- if (e.key === "Enter") node.submit(input.current?.value || "");
314
- }
315
- });
316
- }
317
-
318
-
319
- function $1297c48a54b69bac$export$e1a8e267487c59d1(id) {
320
- return {
321
- type: "EDIT",
322
- id: id
323
- };
324
- }
325
- function $1297c48a54b69bac$export$1650419e431d3ba3(state = {
326
- id: null
327
- }, action) {
328
- if (action.type === "EDIT") return {
329
- ...state,
330
- id: action.id
331
- };
332
- else return state;
333
- }
334
-
335
-
336
- function $61ef7f2c3c9633e7$export$d7ddd398f22d79ef(id) {
337
- return {
338
- type: "FOCUS",
339
- id: id
340
- };
341
- }
342
- function $61ef7f2c3c9633e7$export$6b6c976e46a06288() {
343
- return {
344
- type: "TREE_BLUR"
345
- };
346
- }
347
- function $61ef7f2c3c9633e7$export$1650419e431d3ba3(state = {
348
- id: null,
349
- treeFocused: false
350
- }, action) {
351
- if (action.type === "FOCUS") return {
352
- ...state,
353
- id: action.id,
354
- treeFocused: true
355
- };
356
- else if (action.type === "TREE_BLUR") return {
357
- ...state,
358
- treeFocused: false
359
- };
360
- else return state;
361
- }
362
-
363
-
364
- var $9b37fe5960a1a3c6$exports = {};
365
-
366
- $parcel$export($9b37fe5960a1a3c6$exports, "NodeApi", () => $9b37fe5960a1a3c6$export$d4b903da0f522dc8);
367
-
368
- class $9b37fe5960a1a3c6$export$d4b903da0f522dc8 {
369
- constructor(params){
370
- this.tree = params.tree;
371
- this.id = params.id;
372
- this.data = params.data;
373
- this.level = params.level;
374
- this.children = params.children;
375
- this.parent = params.parent;
376
- this.isDraggable = params.isDraggable;
377
- this.rowIndex = params.rowIndex;
378
- }
379
- get isRoot() {
380
- return this.id === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c);
381
- }
382
- get isLeaf() {
383
- return !Array.isArray(this.children);
384
- }
385
- get isInternal() {
386
- return !this.isLeaf;
387
- }
388
- get isOpen() {
389
- return this.isLeaf ? false : this.tree.isOpen(this.id);
390
- }
391
- get isClosed() {
392
- return this.isLeaf ? false : !this.tree.isOpen(this.id);
393
- }
394
- get isEditable() {
395
- return this.tree.isEditable(this.data);
396
- }
397
- get isEditing() {
398
- return this.tree.editingId === this.id;
399
- }
400
- get isSelected() {
401
- return this.tree.isSelected(this.id);
402
- }
403
- get isOnlySelection() {
404
- return this.isSelected && this.tree.hasOneSelection;
405
- }
406
- get isSelectedStart() {
407
- return this.isSelected && !this.prev?.isSelected;
408
- }
409
- get isSelectedEnd() {
410
- return this.isSelected && !this.next?.isSelected;
411
- }
412
- get isFocused() {
413
- return this.tree.isFocused(this.id);
414
- }
415
- get isDragging() {
416
- return this.tree.isDragging(this.id);
417
- }
418
- get willReceiveDrop() {
419
- return this.tree.willReceiveDrop(this.id);
420
- }
421
- get state() {
422
- return {
423
- isClosed: this.isClosed,
424
- isDragging: this.isDragging,
425
- isEditing: this.isEditing,
426
- isFocused: this.isFocused,
427
- isInternal: this.isInternal,
428
- isLeaf: this.isLeaf,
429
- isOpen: this.isOpen,
430
- isSelected: this.isSelected,
431
- isSelectedEnd: this.isSelectedEnd,
432
- isSelectedStart: this.isSelectedStart,
433
- willReceiveDrop: this.willReceiveDrop
434
- };
435
- }
436
- get childIndex() {
437
- if (this.parent && this.parent.children) return this.parent.children.findIndex((child)=>child.id === this.id);
438
- else return -1;
439
- }
440
- get next() {
441
- if (this.rowIndex === null) return null;
442
- return this.tree.at(this.rowIndex + 1);
443
- }
444
- get prev() {
445
- if (this.rowIndex === null) return null;
446
- return this.tree.at(this.rowIndex - 1);
447
- }
448
- get nextSibling() {
449
- const i = this.childIndex;
450
- return this.parent?.children[i + 1] ?? null;
451
- }
452
- isAncestorOf(node) {
453
- if (!node) return false;
454
- let ancestor = node;
455
- while(ancestor){
456
- if (ancestor.id === this.id) return true;
457
- ancestor = ancestor.parent;
458
- }
459
- return false;
460
- }
461
- select() {
462
- this.tree.select(this);
463
- }
464
- deselect() {
465
- this.tree.deselect(this);
466
- }
467
- selectMulti() {
468
- this.tree.selectMulti(this);
469
- }
470
- selectContiguous() {
471
- this.tree.selectContiguous(this);
472
- }
473
- activate() {
474
- this.tree.activate(this);
475
- }
476
- focus() {
477
- this.tree.focus(this);
478
- }
479
- toggle() {
480
- this.tree.toggle(this);
481
- }
482
- open() {
483
- this.tree.open(this);
484
- }
485
- openParents() {
486
- this.tree.openParents(this);
487
- }
488
- close() {
489
- this.tree.close(this);
490
- }
491
- submit(value) {
492
- this.tree.submit(this, value);
493
- }
494
- reset() {
495
- this.tree.reset();
496
- }
497
- clone() {
498
- return new $9b37fe5960a1a3c6$export$d4b903da0f522dc8({
499
- ...this
500
- });
501
- }
502
- edit() {
503
- return this.tree.edit(this);
504
- }
505
- handleClick = (e)=>{
506
- if (e.metaKey && !this.tree.props.disableMultiSelection) this.isSelected ? this.deselect() : this.selectMulti();
507
- else if (e.shiftKey && !this.tree.props.disableMultiSelection) this.selectContiguous();
508
- else {
509
- this.select();
510
- this.activate();
511
- }
512
- };
513
- }
514
-
515
-
516
- const $0d7f39915c1a8ae9$export$ec71a3379b43ae5c = "__REACT_ARBORIST_INTERNAL_ROOT__";
517
- function $0d7f39915c1a8ae9$export$882461b6382ed46c(tree) {
518
- function visitSelfAndChildren(data, level, parent) {
519
- const id = tree.accessId(data);
520
- const node = new (0, $9b37fe5960a1a3c6$export$d4b903da0f522dc8)({
521
- tree: tree,
522
- data: data,
523
- level: level,
524
- parent: parent,
525
- id: id,
526
- children: null,
527
- isDraggable: tree.isDraggable(data),
528
- rowIndex: null
529
- });
530
- const children = tree.accessChildren(data);
531
- if (children) node.children = children.map((child)=>visitSelfAndChildren(child, level + 1, node));
532
- return node;
533
- }
534
- const root = new (0, $9b37fe5960a1a3c6$export$d4b903da0f522dc8)({
535
- tree: tree,
536
- id: $0d7f39915c1a8ae9$export$ec71a3379b43ae5c,
537
- // @ts-ignore
538
- data: {
539
- id: $0d7f39915c1a8ae9$export$ec71a3379b43ae5c
540
- },
541
- level: -1,
542
- parent: null,
543
- children: null,
544
- isDraggable: true,
545
- rowIndex: null
546
- });
547
- const data = tree.props.data ?? [];
548
- root.children = data.map((child)=>{
549
- return visitSelfAndChildren(child, 0, root);
550
- });
551
- return root;
552
- }
553
-
554
-
555
- const $d519ceb3313d9d0e$export$e324594224ef24da = {
556
- open (id, filtered) {
557
- return {
558
- type: "VISIBILITY_OPEN",
559
- id: id,
560
- filtered: filtered
561
- };
562
- },
563
- close (id, filtered) {
564
- return {
565
- type: "VISIBILITY_CLOSE",
566
- id: id,
567
- filtered: filtered
568
- };
569
- },
570
- toggle (id, filtered) {
571
- return {
572
- type: "VISIBILITY_TOGGLE",
573
- id: id,
574
- filtered: filtered
575
- };
576
- },
577
- clear (filtered) {
578
- return {
579
- type: "VISIBILITY_CLEAR",
580
- filtered: filtered
581
- };
582
- }
583
- };
584
- /* Reducer */ function $d519ceb3313d9d0e$var$openMapReducer(state = {}, action) {
585
- if (action.type === "VISIBILITY_OPEN") return {
586
- ...state,
587
- [action.id]: true
588
- };
589
- else if (action.type === "VISIBILITY_CLOSE") return {
590
- ...state,
591
- [action.id]: false
592
- };
593
- else if (action.type === "VISIBILITY_TOGGLE") {
594
- const prev = state[action.id];
595
- return {
596
- ...state,
597
- [action.id]: !prev
598
- };
599
- } else if (action.type === "VISIBILITY_CLEAR") return {};
600
- else return state;
601
- }
602
- function $d519ceb3313d9d0e$export$1650419e431d3ba3(state = {
603
- filtered: {},
604
- unfiltered: {}
605
- }, action) {
606
- if (!action.type.startsWith("VISIBILITY")) return state;
607
- if (action.filtered) return {
608
- ...state,
609
- filtered: $d519ceb3313d9d0e$var$openMapReducer(state.filtered, action)
610
- };
611
- else return {
612
- ...state,
613
- unfiltered: $d519ceb3313d9d0e$var$openMapReducer(state.unfiltered, action)
614
- };
615
- }
616
-
617
-
618
-
619
- const $9d556ecd8e421ffe$export$d4c72bab9d6cc13a = (props)=>({
620
- nodes: {
621
- // Changes together
622
- open: {
623
- filtered: {},
624
- unfiltered: props?.initialOpenState ?? {}
625
- },
626
- focus: {
627
- id: null,
628
- treeFocused: false
629
- },
630
- edit: {
631
- id: null
632
- },
633
- drag: {
634
- id: null,
635
- selectedIds: [],
636
- destinationParentId: null,
637
- destinationIndex: null
638
- },
639
- selection: {
640
- ids: new Set(),
641
- anchor: null,
642
- mostRecent: null
643
- }
644
- },
645
- dnd: {
646
- cursor: {
647
- type: "none"
648
- },
649
- dragId: null,
650
- dragIds: [],
651
- parentId: null,
652
- index: -1
653
- }
654
- });
655
-
656
-
657
- const $58f9381615aa3d17$export$e324594224ef24da = {
658
- clear: ()=>({
659
- type: "SELECTION_CLEAR"
660
- }),
661
- only: (id)=>({
662
- type: "SELECTION_ONLY",
663
- id: (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
664
- }),
665
- add: (id)=>({
666
- type: "SELECTION_ADD",
667
- ids: (Array.isArray(id) ? id : [
668
- id
669
- ]).map((0, $eb5355379510ac9b$export$65e5b62a4c490288))
670
- }),
671
- remove: (id)=>({
672
- type: "SELECTION_REMOVE",
673
- ids: (Array.isArray(id) ? id : [
674
- id
675
- ]).map((0, $eb5355379510ac9b$export$65e5b62a4c490288))
676
- }),
677
- set: (args)=>({
678
- type: "SELECTION_SET",
679
- ...args
680
- }),
681
- mostRecent: (id)=>({
682
- type: "SELECTION_MOST_RECENT",
683
- id: id === null ? null : (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
684
- }),
685
- anchor: (id)=>({
686
- type: "SELECTION_ANCHOR",
687
- id: id === null ? null : (0, $eb5355379510ac9b$export$65e5b62a4c490288)(id)
688
- })
689
- };
690
- function $58f9381615aa3d17$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["nodes"]["selection"], action) {
691
- const ids = state.ids;
692
- switch(action.type){
693
- case "SELECTION_CLEAR":
694
- return {
695
- ...state,
696
- ids: new Set()
697
- };
698
- case "SELECTION_ONLY":
699
- return {
700
- ...state,
701
- ids: new Set([
702
- action.id
703
- ])
704
- };
705
- case "SELECTION_ADD":
706
- if (action.ids.length === 0) return state;
707
- action.ids.forEach((id)=>ids.add(id));
708
- return {
709
- ...state,
710
- ids: new Set(ids)
711
- };
712
- case "SELECTION_REMOVE":
713
- if (action.ids.length === 0) return state;
714
- action.ids.forEach((id)=>ids.delete(id));
715
- return {
716
- ...state,
717
- ids: new Set(ids)
718
- };
719
- case "SELECTION_SET":
720
- return {
721
- ...state,
722
- ids: action.ids,
723
- mostRecent: action.mostRecent,
724
- anchor: action.anchor
725
- };
726
- case "SELECTION_MOST_RECENT":
727
- return {
728
- ...state,
729
- mostRecent: action.id
730
- };
731
- case "SELECTION_ANCHOR":
732
- return {
733
- ...state,
734
- anchor: action.id
735
- };
736
- default:
737
- return state;
738
- }
739
- }
740
-
741
-
742
-
743
- const $7d98f5b84ecaa66b$export$e324594224ef24da = {
744
- cursor (cursor) {
745
- return {
746
- type: "DND_CURSOR",
747
- cursor: cursor
748
- };
749
- },
750
- dragStart (id, dragIds) {
751
- return {
752
- type: "DND_DRAG_START",
753
- id: id,
754
- dragIds: dragIds
755
- };
756
- },
757
- dragEnd () {
758
- return {
759
- type: "DND_DRAG_END"
760
- };
761
- },
762
- hovering (parentId, index) {
763
- return {
764
- type: "DND_HOVERING",
765
- parentId: parentId,
766
- index: index
767
- };
768
- }
769
- };
770
- function $7d98f5b84ecaa66b$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"], action) {
771
- switch(action.type){
772
- case "DND_CURSOR":
773
- return {
774
- ...state,
775
- cursor: action.cursor
776
- };
777
- case "DND_DRAG_START":
778
- return {
779
- ...state,
780
- dragId: action.id,
781
- dragIds: action.dragIds
782
- };
783
- case "DND_DRAG_END":
784
- return (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"];
785
- case "DND_HOVERING":
786
- return {
787
- ...state,
788
- parentId: action.parentId,
789
- index: action.index
790
- };
791
- default:
792
- return state;
793
- }
794
- }
795
-
796
-
797
-
798
-
799
-
800
- const $6e3db8c23c41dfc9$var$layerStyles = {
801
- position: "fixed",
802
- pointerEvents: "none",
803
- zIndex: 100,
804
- left: 0,
805
- top: 0,
806
- width: "100%",
807
- height: "100%"
808
- };
809
- const $6e3db8c23c41dfc9$var$getStyle = (offset)=>{
810
- if (!offset) return {
811
- display: "none"
812
- };
813
- const { x: x , y: y } = offset;
814
- return {
815
- transform: `translate(${x}px, ${y}px)`
816
- };
817
- };
818
- const $6e3db8c23c41dfc9$var$getCountStyle = (offset)=>{
819
- if (!offset) return {
820
- display: "none"
821
- };
822
- const { x: x , y: y } = offset;
823
- return {
824
- transform: `translate(${x + 10}px, ${y + 10}px)`
825
- };
826
- };
827
- function $6e3db8c23c41dfc9$export$84e211ad8431a387({ offset: offset , mouse: mouse , id: id , dragIds: dragIds , isDragging: isDragging }) {
828
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)($6e3db8c23c41dfc9$var$Overlay, {
829
- isDragging: isDragging,
830
- children: [
831
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$Position, {
832
- offset: offset,
833
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$PreviewNode, {
834
- id: id,
835
- dragIds: dragIds
836
- })
837
- }),
838
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($6e3db8c23c41dfc9$var$Count, {
839
- mouse: mouse,
840
- count: dragIds.length
841
- })
842
- ]
843
- });
844
- }
845
- const $6e3db8c23c41dfc9$var$Overlay = /*#__PURE__*/ (0, $foSVk$react.memo)(function Overlay(props) {
846
- if (!props.isDragging) return null;
847
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
848
- style: $6e3db8c23c41dfc9$var$layerStyles,
849
- children: props.children
850
- });
851
- });
852
- function $6e3db8c23c41dfc9$var$Position(props) {
853
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
854
- className: "row preview",
855
- style: $6e3db8c23c41dfc9$var$getStyle(props.offset),
856
- children: props.children
857
- });
858
- }
859
- function $6e3db8c23c41dfc9$var$Count(props) {
860
- const { count: count , mouse: mouse } = props;
861
- if (count > 1) return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
862
- className: "selected-count",
863
- style: $6e3db8c23c41dfc9$var$getCountStyle(mouse),
864
- children: count
865
- });
866
- else return null;
867
- }
868
- const $6e3db8c23c41dfc9$var$PreviewNode = /*#__PURE__*/ (0, $foSVk$react.memo)(function PreviewNode(props) {
869
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
870
- const node = tree.get(props.id);
871
- if (!node) return null;
872
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(tree.renderNode, {
873
- preview: true,
874
- node: node,
875
- style: {
876
- paddingLeft: node.level * tree.indent,
877
- opacity: 0.2,
878
- background: "transparent"
879
- },
880
- tree: tree
881
- });
882
- });
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
- function $e527b4e3d64e6932$export$b6a79797ad180576() {
895
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
896
- const state = (0, $d5cb84d44d1b8acc$export$4930f6bf413be70e)();
897
- const cursor = state.cursor;
898
- if (!cursor || cursor.type !== "line") return null;
899
- const indent = tree.indent;
900
- const top = tree.rowHeight * cursor.index + ((tree.props.padding ?? tree.props.paddingTop) ?? 0);
901
- const left = indent * cursor.level;
902
- const Cursor = tree.renderCursor;
903
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Cursor, {
904
- top: top,
905
- left: left,
906
- indent: indent
907
- });
908
- }
909
-
910
-
911
- const $0e2adc7837d85ac3$export$70c2b8898b86d3ad = /*#__PURE__*/ (0, $foSVk$react.forwardRef)(function Outer(props, ref) {
912
- const { children: children , ...rest } = props;
913
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
914
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)("div", {
915
- // @ts-ignore
916
- ref: ref,
917
- ...rest,
918
- onClick: (e)=>{
919
- if (e.currentTarget === e.target) tree.deselectAll();
920
- },
921
- children: [
922
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)($0e2adc7837d85ac3$var$DropContainer, {}),
923
- children
924
- ]
925
- });
926
- });
927
- const $0e2adc7837d85ac3$var$DropContainer = ()=>{
928
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
929
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
930
- style: {
931
- height: tree.visibleNodes.length * tree.rowHeight,
932
- width: "100%",
933
- position: "absolute",
934
- left: "0",
935
- right: "0"
936
- },
937
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $e527b4e3d64e6932$export$b6a79797ad180576), {})
938
- });
939
- };
940
-
941
-
942
-
943
-
944
-
945
-
946
- const $472f3c5b35f3bf96$export$a9af0da3ae60cd00 = /*#__PURE__*/ (0, $foSVk$react.forwardRef)(function InnerElement({ style: style , ...rest }, ref) {
947
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
948
- const paddingTop = (tree.props.padding ?? tree.props.paddingTop) ?? 0;
949
- const paddingBottom = (tree.props.padding ?? tree.props.paddingBottom) ?? 0;
950
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
951
- ref: ref,
952
- style: {
953
- ...style,
954
- height: `${parseFloat(style.height) + paddingTop + paddingBottom}px`
955
- },
956
- ...rest
957
- });
958
- });
959
-
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
-
971
- function $74bee24dbb0f3e2b$export$715c0d031ede7907(node) {
972
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
973
- const ids = tree.selectedIds;
974
- const [_, ref, preview] = (0, $foSVk$reactdnd.useDrag)(()=>({
975
- canDrag: ()=>node.isDraggable,
976
- type: "NODE",
977
- item: ()=>{
978
- // This is fired once at the begging of a drag operation
979
- const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [
980
- node.id
981
- ];
982
- tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragStart(node.id, dragIds));
983
- return {
984
- id: node.id
985
- };
986
- },
987
- end: ()=>{
988
- tree.hideCursor();
989
- let { parentId: parentId , index: index , dragIds: dragIds } = tree.state.dnd;
990
- // If they held down meta, we need to create a copy
991
- // if (drop.dropEffect === "copy")
992
- if (tree.canDrop()) {
993
- (0, $eb5355379510ac9b$export$c6d63370cef03886)(tree.props.onMove, {
994
- dragIds: dragIds,
995
- parentId: parentId === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c) ? null : parentId,
996
- index: index === null ? 0 : index,
997
- dragNodes: tree.dragNodes,
998
- parentNode: tree.get(parentId)
999
- });
1000
- tree.open(parentId);
1001
- }
1002
- tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragEnd());
1003
- }
1004
- }), [
1005
- ids,
1006
- node
1007
- ]);
1008
- (0, $foSVk$react.useEffect)(()=>{
1009
- preview((0, $foSVk$reactdndhtml5backend.getEmptyImage)());
1010
- }, [
1011
- preview
1012
- ]);
1013
- return ref;
1014
- }
1015
-
1016
-
1017
-
1018
-
1019
-
1020
- function $462841de7cc5b715$var$measureHover(el, offset) {
1021
- const rect = el.getBoundingClientRect();
1022
- const x = offset.x - Math.round(rect.x);
1023
- const y = offset.y - Math.round(rect.y);
1024
- const height = rect.height;
1025
- const inTopHalf = y < height / 2;
1026
- const inBottomHalf = !inTopHalf;
1027
- const pad = height / 4;
1028
- const inMiddle = y > pad && y < height - pad;
1029
- const atTop = !inMiddle && inTopHalf;
1030
- const atBottom = !inMiddle && inBottomHalf;
1031
- return {
1032
- x: x,
1033
- inTopHalf: inTopHalf,
1034
- inBottomHalf: inBottomHalf,
1035
- inMiddle: inMiddle,
1036
- atTop: atTop,
1037
- atBottom: atBottom
1038
- };
1039
- }
1040
- function $462841de7cc5b715$var$getNodesAroundCursor(node, prev, next, hover) {
1041
- if (!node) // We're hovering over the empty part of the list, not over an item,
1042
- // Put the cursor below the last item which is "prev"
1043
- return [
1044
- prev,
1045
- null
1046
- ];
1047
- if (node.isInternal) {
1048
- if (hover.atTop) return [
1049
- prev,
1050
- node
1051
- ];
1052
- else if (hover.inMiddle) return [
1053
- node,
1054
- node
1055
- ];
1056
- else return [
1057
- node,
1058
- next
1059
- ];
1060
- } else {
1061
- if (hover.inTopHalf) return [
1062
- prev,
1063
- node
1064
- ];
1065
- else return [
1066
- node,
1067
- next
1068
- ];
1069
- }
1070
- }
1071
- function $462841de7cc5b715$var$getDropLevel(hovering, aboveCursor, belowCursor, indent) {
1072
- const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
1073
- let min, max;
1074
- if (!aboveCursor) {
1075
- max = 0;
1076
- min = 0;
1077
- } else if (!belowCursor) {
1078
- max = aboveCursor.level;
1079
- min = 0;
1080
- } else {
1081
- max = aboveCursor.level;
1082
- min = belowCursor.level;
1083
- }
1084
- return (0, $eb5355379510ac9b$export$adf7c0fe6059d774)(hoverLevel, min, max);
1085
- }
1086
- function $462841de7cc5b715$var$dropAt(parentId, index) {
1087
- return {
1088
- parentId: parentId || null,
1089
- index: index
1090
- };
1091
- }
1092
- function $462841de7cc5b715$var$lineCursor(index, level) {
1093
- return {
1094
- type: "line",
1095
- index: index,
1096
- level: level
1097
- };
1098
- }
1099
- function $462841de7cc5b715$var$noCursor() {
1100
- return {
1101
- type: "none"
1102
- };
1103
- }
1104
- function $462841de7cc5b715$var$highlightCursor(id) {
1105
- return {
1106
- type: "highlight",
1107
- id: id
1108
- };
1109
- }
1110
- function $462841de7cc5b715$var$walkUpFrom(node, level) {
1111
- let drop = node;
1112
- while(drop.parent && drop.level > level)drop = drop.parent;
1113
- const parentId = drop.parent?.id || null;
1114
- const index = (0, $eb5355379510ac9b$export$305f7d4e9d4624f2)(drop) + 1;
1115
- return {
1116
- parentId: parentId,
1117
- index: index
1118
- };
1119
- }
1120
- function $462841de7cc5b715$export$f502ca02ebb85a1c(args) {
1121
- const hover = $462841de7cc5b715$var$measureHover(args.element, args.offset);
1122
- const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
1123
- const [above, below] = $462841de7cc5b715$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
1124
- /* Hovering over the middle of a folder */ if (node && node.isInternal && hover.inMiddle) return {
1125
- drop: $462841de7cc5b715$var$dropAt(node.id, null),
1126
- cursor: $462841de7cc5b715$var$highlightCursor(node.id)
1127
- };
1128
- /* At the top of the list */ if (!above) return {
1129
- drop: $462841de7cc5b715$var$dropAt(below?.parent?.id, 0),
1130
- cursor: $462841de7cc5b715$var$lineCursor(0, 0)
1131
- };
1132
- /* The above node is an item or a closed folder */ if ((0, $eb5355379510ac9b$export$5318634f2ee07019)(above) || (0, $eb5355379510ac9b$export$4210f5ea57fbae57)(above)) {
1133
- const level = $462841de7cc5b715$var$getDropLevel(hover, above, below, args.indent);
1134
- return {
1135
- drop: $462841de7cc5b715$var$walkUpFrom(above, level),
1136
- cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, level)
1137
- };
1138
- }
1139
- /* The above node is an open folder */ return {
1140
- drop: $462841de7cc5b715$var$dropAt(above?.id, 0),
1141
- cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, above.level + 1)
1142
- };
1143
- }
1144
-
1145
-
1146
-
1147
- function $cf8ebdb33758b119$export$57afafec4637d997(el, node) {
1148
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
1149
- const [_, dropRef] = (0, $foSVk$reactdnd.useDrop)(()=>({
1150
- accept: "NODE",
1151
- canDrop: ()=>tree.canDrop(),
1152
- hover: (_item, m)=>{
1153
- const offset = m.getClientOffset();
1154
- if (!el.current || !offset) return;
1155
- const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
1156
- element: el.current,
1157
- offset: offset,
1158
- indent: tree.indent,
1159
- node: node,
1160
- prevNode: node.prev,
1161
- nextNode: node.next
1162
- });
1163
- if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
1164
- if (m.canDrop()) {
1165
- if (cursor) tree.showCursor(cursor);
1166
- } else tree.hideCursor();
1167
- },
1168
- drop: (_, m)=>{
1169
- if (!m.canDrop()) return null;
1170
- }
1171
- }), [
1172
- node,
1173
- el.current,
1174
- tree.props
1175
- ]);
1176
- return dropRef;
1177
- }
1178
-
1179
-
1180
-
1181
-
1182
- function $3105f2bcc0822e0d$export$d75ab90b05ebbfaa(index) {
1183
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
1184
- const original = tree.at(index);
1185
- if (!original) throw new Error(`Could not find node for index: ${index}`);
1186
- return (0, $foSVk$react.useMemo)(()=>{
1187
- const fresh = original.clone();
1188
- tree.visibleNodes[index] = fresh; // sneaky
1189
- return fresh;
1190
- // Return a fresh instance if the state values change
1191
- }, [
1192
- ...Object.values(original.state),
1193
- original
1194
- ]);
1195
- }
1196
-
1197
-
1198
- const $37e3f46f8fd1101f$export$a9754b3c8daa5172 = /*#__PURE__*/ (0, ($parcel$interopDefault($foSVk$react))).memo(function RowContainer({ index: index , style: style }) {
1199
- /* When will the <Row> will re-render.
1200
- *
1201
- * The row component is memo'd so it will only render
1202
- * when a new instance of the NodeApi class is passed
1203
- * to it.
1204
- *
1205
- * The TreeApi instance is stable. It does not
1206
- * change when the internal state changes.
1207
- *
1208
- * The TreeApi has all the references to the nodes.
1209
- * We need to clone the nodes when their state
1210
- * changes. The node class contains no state itself,
1211
- * It always checks the tree for state. The tree's
1212
- * state will always be up to date.
1213
- */ (0, $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8)(); // Re-render when tree props or visability changes
1214
- const _ = (0, $d5cb84d44d1b8acc$export$fd23f19d5d8f3033)(); // So that we re-render appropriately
1215
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)(); // Tree already has the fresh state
1216
- const node = (0, $3105f2bcc0822e0d$export$d75ab90b05ebbfaa)(index);
1217
- const el = (0, $foSVk$react.useRef)(null);
1218
- const dragRef = (0, $74bee24dbb0f3e2b$export$715c0d031ede7907)(node);
1219
- const dropRef = (0, $cf8ebdb33758b119$export$57afafec4637d997)(el, node);
1220
- const innerRef = (0, $foSVk$react.useCallback)((n)=>{
1221
- el.current = n;
1222
- dropRef(n);
1223
- }, [
1224
- dropRef
1225
- ]);
1226
- const indent = tree.indent * node.level;
1227
- const nodeStyle = (0, $foSVk$react.useMemo)(()=>({
1228
- paddingLeft: indent
1229
- }), [
1230
- indent
1231
- ]);
1232
- const rowStyle = (0, $foSVk$react.useMemo)(()=>({
1233
- ...style,
1234
- top: parseFloat(style.top) + ((tree.props.padding ?? tree.props.paddingTop) ?? 0)
1235
- }), [
1236
- style,
1237
- tree.props.padding,
1238
- tree.props.paddingTop
1239
- ]);
1240
- const rowAttrs = {
1241
- role: "treeitem",
1242
- "aria-level": node.level,
1243
- "aria-selected": node.isSelected,
1244
- style: rowStyle,
1245
- tabIndex: -1,
1246
- className: tree.props.rowClassName
1247
- };
1248
- (0, $foSVk$react.useEffect)(()=>{
1249
- if (!node.isEditing && node.isFocused) el.current?.focus({
1250
- preventScroll: true
1251
- });
1252
- }, [
1253
- node.isEditing,
1254
- node.isFocused,
1255
- el.current
1256
- ]);
1257
- const Node = tree.renderNode;
1258
- const Row = tree.renderRow;
1259
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Row, {
1260
- node: node,
1261
- innerRef: innerRef,
1262
- attrs: rowAttrs,
1263
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Node, {
1264
- node: node,
1265
- tree: tree,
1266
- style: nodeStyle,
1267
- dragHandle: dragRef
1268
- })
1269
- });
1270
- });
1271
-
1272
-
1273
- let $bb9a1e34249689ac$var$focusSearchTerm = "";
1274
- let $bb9a1e34249689ac$var$timeoutId = null;
1275
- function $bb9a1e34249689ac$export$ff4858a4110d9246() {
1276
- (0, $d5cb84d44d1b8acc$export$83a4f9dc3b36edb8)();
1277
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
1278
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)("div", {
1279
- style: {
1280
- height: tree.height,
1281
- width: tree.width,
1282
- minHeight: 0,
1283
- minWidth: 0
1284
- },
1285
- onContextMenu: tree.props.onContextMenu,
1286
- onClick: tree.props.onClick,
1287
- tabIndex: 0,
1288
- onFocus: (e)=>{
1289
- if (!e.currentTarget.contains(e.relatedTarget)) tree.onFocus();
1290
- },
1291
- onBlur: (e)=>{
1292
- if (!e.currentTarget.contains(e.relatedTarget)) tree.onBlur();
1293
- },
1294
- onKeyDown: (e)=>{
1295
- if (tree.isEditing) return;
1296
- if (e.key === "Backspace") {
1297
- if (!tree.props.onDelete) return;
1298
- const ids = Array.from(tree.selectedIds);
1299
- if (ids.length > 1) {
1300
- let nextFocus = tree.mostRecentNode;
1301
- while(nextFocus && nextFocus.isSelected)nextFocus = nextFocus.nextSibling;
1302
- if (!nextFocus) nextFocus = tree.lastNode;
1303
- tree.focus(nextFocus, {
1304
- scroll: false
1305
- });
1306
- tree.delete(Array.from(ids));
1307
- } else {
1308
- const node = tree.focusedNode;
1309
- if (node) {
1310
- const sib = node.nextSibling;
1311
- const parent = node.parent;
1312
- tree.focus(sib || parent, {
1313
- scroll: false
1314
- });
1315
- tree.delete(node);
1316
- }
1317
- }
1318
- return;
1319
- }
1320
- if (e.key === "Tab" && !e.shiftKey) {
1321
- e.preventDefault();
1322
- (0, $eb5355379510ac9b$export$3b0237e8566c8d65)(e.currentTarget);
1323
- return;
1324
- }
1325
- if (e.key === "Tab" && e.shiftKey) {
1326
- e.preventDefault();
1327
- (0, $eb5355379510ac9b$export$33b47db07a82b2fb)(e.currentTarget);
1328
- return;
1329
- }
1330
- if (e.key === "ArrowDown") {
1331
- e.preventDefault();
1332
- const next = tree.nextNode;
1333
- if (e.metaKey) {
1334
- tree.select(tree.focusedNode);
1335
- tree.activate(tree.focusedNode);
1336
- return;
1337
- } else if (!e.shiftKey || tree.props.disableMultiSelection) {
1338
- tree.focus(next);
1339
- return;
1340
- } else {
1341
- if (!next) return;
1342
- const current = tree.focusedNode;
1343
- if (!current) tree.focus(tree.firstNode);
1344
- else if (current.isSelected) tree.selectContiguous(next);
1345
- else tree.selectMulti(next);
1346
- return;
1347
- }
1348
- }
1349
- if (e.key === "ArrowUp") {
1350
- e.preventDefault();
1351
- const prev = tree.prevNode;
1352
- if (!e.shiftKey || tree.props.disableMultiSelection) {
1353
- tree.focus(prev);
1354
- return;
1355
- } else {
1356
- if (!prev) return;
1357
- const current1 = tree.focusedNode;
1358
- if (!current1) tree.focus(tree.lastNode); // ?
1359
- else if (current1.isSelected) tree.selectContiguous(prev);
1360
- else tree.selectMulti(prev);
1361
- return;
1362
- }
1363
- }
1364
- if (e.key === "ArrowRight") {
1365
- const node1 = tree.focusedNode;
1366
- if (!node1) return;
1367
- if (node1.isInternal && node1.isOpen) tree.focus(tree.nextNode);
1368
- else if (node1.isInternal) tree.open(node1.id);
1369
- return;
1370
- }
1371
- if (e.key === "ArrowLeft") {
1372
- const node2 = tree.focusedNode;
1373
- if (!node2 || node2.isRoot) return;
1374
- if (node2.isInternal && node2.isOpen) tree.close(node2.id);
1375
- else if (!node2.parent?.isRoot) tree.focus(node2.parent);
1376
- return;
1377
- }
1378
- if (e.key === "a" && e.metaKey && !tree.props.disableMultiSelection) {
1379
- e.preventDefault();
1380
- tree.selectAll();
1381
- return;
1382
- }
1383
- if (e.key === "a" && !e.metaKey && tree.props.onCreate) {
1384
- tree.createLeaf();
1385
- return;
1386
- }
1387
- if (e.key === "A" && !e.metaKey) {
1388
- if (!tree.props.onCreate) return;
1389
- tree.createInternal();
1390
- return;
1391
- }
1392
- if (e.key === "Home") {
1393
- // add shift keys
1394
- e.preventDefault();
1395
- tree.focus(tree.firstNode);
1396
- return;
1397
- }
1398
- if (e.key === "End") {
1399
- // add shift keys
1400
- e.preventDefault();
1401
- tree.focus(tree.lastNode);
1402
- return;
1403
- }
1404
- if (e.key === "Enter") {
1405
- const node3 = tree.focusedNode;
1406
- if (!node3) return;
1407
- if (!node3.isEditable || !tree.props.onRename) return;
1408
- setTimeout(()=>{
1409
- if (node3) tree.edit(node3);
1410
- });
1411
- return;
1412
- }
1413
- if (e.key === " ") {
1414
- e.preventDefault();
1415
- const node4 = tree.focusedNode;
1416
- if (!node4) return;
1417
- if (node4.isLeaf) {
1418
- node4.select();
1419
- node4.activate();
1420
- } else node4.toggle();
1421
- return;
1422
- }
1423
- if (e.key === "*") {
1424
- const node5 = tree.focusedNode;
1425
- if (!node5) return;
1426
- tree.openSiblings(node5);
1427
- return;
1428
- }
1429
- if (e.key === "PageUp") {
1430
- e.preventDefault();
1431
- tree.pageUp();
1432
- return;
1433
- }
1434
- if (e.key === "PageDown") {
1435
- e.preventDefault();
1436
- tree.pageDown();
1437
- }
1438
- // If they type a sequence of characters
1439
- // collect them. Reset them after a timeout.
1440
- // Use it to search the tree for a node, then focus it.
1441
- // Clean this up a bit later
1442
- clearTimeout($bb9a1e34249689ac$var$timeoutId);
1443
- $bb9a1e34249689ac$var$focusSearchTerm += e.key;
1444
- $bb9a1e34249689ac$var$timeoutId = setTimeout(()=>{
1445
- $bb9a1e34249689ac$var$focusSearchTerm = "";
1446
- }, 600);
1447
- const node6 = tree.visibleNodes.find((n)=>{
1448
- // @ts-ignore
1449
- const name = n.data.name;
1450
- if (typeof name === "string") return name.toLowerCase().startsWith($bb9a1e34249689ac$var$focusSearchTerm);
1451
- else return false;
1452
- });
1453
- if (node6) tree.focus(node6.id);
1454
- },
1455
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactwindow.FixedSizeList), {
1456
- className: tree.props.className,
1457
- outerRef: tree.listEl,
1458
- itemCount: tree.visibleNodes.length,
1459
- height: tree.height,
1460
- width: tree.width,
1461
- itemSize: tree.rowHeight,
1462
- overscanCount: tree.overscanCount,
1463
- itemKey: (index)=>tree.visibleNodes[index]?.id || index,
1464
- outerElementType: (0, $0e2adc7837d85ac3$export$70c2b8898b86d3ad),
1465
- innerElementType: (0, $472f3c5b35f3bf96$export$a9af0da3ae60cd00),
1466
- onScroll: tree.props.onScroll,
1467
- onItemsRendered: tree.onItemsRendered.bind(tree),
1468
- ref: tree.list,
1469
- children: (0, $37e3f46f8fd1101f$export$a9754b3c8daa5172)
1470
- })
1471
- });
1472
- }
1473
-
1474
-
1475
- function $07d1cda4da20dc54$export$5897d8d7c7a3d871(tree) {
1476
- if (tree.isFiltered) return $07d1cda4da20dc54$var$flattenAndFilterTree(tree.root, tree.isMatch.bind(tree));
1477
- else return $07d1cda4da20dc54$var$flattenTree(tree.root);
1478
- }
1479
- function $07d1cda4da20dc54$var$flattenTree(root) {
1480
- const list = [];
1481
- function collect(node) {
1482
- if (node.level >= 0) list.push(node);
1483
- if (node.isOpen) node.children?.forEach(collect);
1484
- }
1485
- collect(root);
1486
- list.forEach($07d1cda4da20dc54$var$assignRowIndex);
1487
- return list;
1488
- }
1489
- function $07d1cda4da20dc54$var$flattenAndFilterTree(root, isMatch) {
1490
- const matches = {};
1491
- const list = [];
1492
- function markMatch(node) {
1493
- const yes = !node.isRoot && isMatch(node);
1494
- if (yes) {
1495
- matches[node.id] = true;
1496
- let parent = node.parent;
1497
- while(parent){
1498
- matches[parent.id] = true;
1499
- parent = parent.parent;
1500
- }
1501
- }
1502
- if (node.children) for (let child of node.children)markMatch(child);
1503
- }
1504
- function collect(node) {
1505
- if (node.level >= 0 && matches[node.id]) list.push(node);
1506
- if (node.isOpen) node.children?.forEach(collect);
1507
- }
1508
- markMatch(root);
1509
- collect(root);
1510
- list.forEach($07d1cda4da20dc54$var$assignRowIndex);
1511
- return list;
1512
- }
1513
- function $07d1cda4da20dc54$var$assignRowIndex(node, index) {
1514
- node.rowIndex = index;
1515
- }
1516
-
1517
-
1518
- const $db9e6e601e34ba08$export$c6d108d7c8095f19 = (nodes)=>{
1519
- return nodes.reduce((map, node, index)=>{
1520
- map[node.id] = index;
1521
- return map;
1522
- }, {});
1523
- };
1524
-
1525
-
1526
- const { safeRun: $5c74fef433be2b0a$var$safeRun , identify: $5c74fef433be2b0a$var$identify , identifyNull: $5c74fef433be2b0a$var$identifyNull } = $eb5355379510ac9b$exports;
1527
- class $5c74fef433be2b0a$export$e2da3477247342d1 {
1528
- constructor(store, props, list, listEl){
1529
- this.store = store;
1530
- this.props = props;
1531
- this.list = list;
1532
- this.listEl = listEl;
1533
- this.visibleStartIndex = 0;
1534
- this.visibleStopIndex = 0;
1535
- /* Changes here must also be made in update() */ this.root = (0, $0d7f39915c1a8ae9$export$882461b6382ed46c)(this);
1536
- this.visibleNodes = (0, $07d1cda4da20dc54$export$5897d8d7c7a3d871)(this);
1537
- this.idToIndex = (0, $db9e6e601e34ba08$export$c6d108d7c8095f19)(this.visibleNodes);
1538
- }
1539
- /* Changes here must also be made in constructor() */ update(props) {
1540
- this.props = props;
1541
- this.root = (0, $0d7f39915c1a8ae9$export$882461b6382ed46c)(this);
1542
- this.visibleNodes = (0, $07d1cda4da20dc54$export$5897d8d7c7a3d871)(this);
1543
- this.idToIndex = (0, $db9e6e601e34ba08$export$c6d108d7c8095f19)(this.visibleNodes);
1544
- }
1545
- /* Store helpers */ dispatch(action) {
1546
- return this.store.dispatch(action);
1547
- }
1548
- get state() {
1549
- return this.store.getState();
1550
- }
1551
- get openState() {
1552
- return this.state.nodes.open.unfiltered;
1553
- }
1554
- /* Tree Props */ get width() {
1555
- return this.props.width ?? 300;
1556
- }
1557
- get height() {
1558
- return this.props.height ?? 500;
1559
- }
1560
- get indent() {
1561
- return this.props.indent ?? 24;
1562
- }
1563
- get rowHeight() {
1564
- return this.props.rowHeight ?? 24;
1565
- }
1566
- get overscanCount() {
1567
- return this.props.overscanCount ?? 1;
1568
- }
1569
- get searchTerm() {
1570
- return (this.props.searchTerm || "").trim();
1571
- }
1572
- get matchFn() {
1573
- const match = this.props.searchMatch ?? ((node, term)=>{
1574
- const string = JSON.stringify(Object.values(node.data));
1575
- return string.toLocaleLowerCase().includes(term.toLocaleLowerCase());
1576
- });
1577
- return (node)=>match(node, this.searchTerm);
1578
- }
1579
- accessChildren(data) {
1580
- const get = this.props.childrenAccessor || "children";
1581
- return $eb5355379510ac9b$exports.access(data, get) ?? null;
1582
- }
1583
- accessId(data) {
1584
- const get = this.props.idAccessor || "id";
1585
- const id = $eb5355379510ac9b$exports.access(data, get);
1586
- if (!id) throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");
1587
- return id;
1588
- }
1589
- /* Node Access */ get firstNode() {
1590
- return this.visibleNodes[0] ?? null;
1591
- }
1592
- get lastNode() {
1593
- return this.visibleNodes[this.visibleNodes.length - 1] ?? null;
1594
- }
1595
- get focusedNode() {
1596
- return this.get(this.state.nodes.focus.id) ?? null;
1597
- }
1598
- get mostRecentNode() {
1599
- return this.get(this.state.nodes.selection.mostRecent) ?? null;
1600
- }
1601
- get nextNode() {
1602
- const index = this.indexOf(this.focusedNode);
1603
- if (index === null) return null;
1604
- else return this.at(index + 1);
1605
- }
1606
- get prevNode() {
1607
- const index = this.indexOf(this.focusedNode);
1608
- if (index === null) return null;
1609
- else return this.at(index - 1);
1610
- }
1611
- get(id) {
1612
- if (!id) return null;
1613
- if (id in this.idToIndex) return this.visibleNodes[this.idToIndex[id]] || null;
1614
- else return null;
1615
- }
1616
- at(index) {
1617
- return this.visibleNodes[index] || null;
1618
- }
1619
- nodesBetween(startId, endId) {
1620
- if (startId === null || endId === null) return [];
1621
- const index1 = this.indexOf(startId) ?? 0;
1622
- const index2 = this.indexOf(endId);
1623
- if (index2 === null) return [];
1624
- const start = Math.min(index1, index2);
1625
- const end = Math.max(index1, index2);
1626
- return this.visibleNodes.slice(start, end + 1);
1627
- }
1628
- indexOf(id) {
1629
- const key = $eb5355379510ac9b$exports.identifyNull(id);
1630
- if (!key) return null;
1631
- return this.idToIndex[key];
1632
- }
1633
- /* Data Operations */ get editingId() {
1634
- return this.state.nodes.edit.id;
1635
- }
1636
- createInternal() {
1637
- return this.create({
1638
- type: "internal"
1639
- });
1640
- }
1641
- createLeaf() {
1642
- return this.create({
1643
- type: "leaf"
1644
- });
1645
- }
1646
- async create(opts = {}) {
1647
- const parentId = opts.parentId === undefined ? $eb5355379510ac9b$exports.getInsertParentId(this) : opts.parentId;
1648
- const index = opts.index ?? $eb5355379510ac9b$exports.getInsertIndex(this);
1649
- const type = opts.type ?? "leaf";
1650
- const data = await $5c74fef433be2b0a$var$safeRun(this.props.onCreate, {
1651
- type: type,
1652
- parentId: parentId,
1653
- index: index,
1654
- parentNode: this.get(parentId)
1655
- });
1656
- if (data) {
1657
- this.focus(data);
1658
- setTimeout(()=>{
1659
- this.edit(data).then(()=>{
1660
- this.select(data);
1661
- this.activate(data);
1662
- });
1663
- });
1664
- }
1665
- }
1666
- async delete(node) {
1667
- if (!node) return;
1668
- const idents = Array.isArray(node) ? node : [
1669
- node
1670
- ];
1671
- const ids = idents.map($5c74fef433be2b0a$var$identify);
1672
- const nodes = ids.map((id)=>this.get(id)).filter((n)=>!!n);
1673
- await $5c74fef433be2b0a$var$safeRun(this.props.onDelete, {
1674
- nodes: nodes,
1675
- ids: ids
1676
- });
1677
- }
1678
- edit(node) {
1679
- const id = $5c74fef433be2b0a$var$identify(node);
1680
- this.resolveEdit({
1681
- cancelled: true
1682
- });
1683
- this.scrollTo(id);
1684
- this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(id));
1685
- return new Promise((resolve)=>{
1686
- $5c74fef433be2b0a$export$e2da3477247342d1.editPromise = resolve;
1687
- });
1688
- }
1689
- async submit(identity, value) {
1690
- if (!identity) return;
1691
- const id = $5c74fef433be2b0a$var$identify(identity);
1692
- await $5c74fef433be2b0a$var$safeRun(this.props.onRename, {
1693
- id: id,
1694
- name: value,
1695
- node: this.get(id)
1696
- });
1697
- this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(null));
1698
- this.resolveEdit({
1699
- cancelled: false,
1700
- value: value
1701
- });
1702
- setTimeout(()=>this.onFocus()); // Return focus to element;
1703
- }
1704
- reset() {
1705
- this.dispatch((0, $1297c48a54b69bac$export$e1a8e267487c59d1)(null));
1706
- this.resolveEdit({
1707
- cancelled: true
1708
- });
1709
- setTimeout(()=>this.onFocus()); // Return focus to element;
1710
- }
1711
- activate(id) {
1712
- const node = this.get($5c74fef433be2b0a$var$identifyNull(id));
1713
- if (!node) return;
1714
- $5c74fef433be2b0a$var$safeRun(this.props.onActivate, node);
1715
- }
1716
- resolveEdit(value) {
1717
- const resolve = $5c74fef433be2b0a$export$e2da3477247342d1.editPromise;
1718
- if (resolve) resolve(value);
1719
- $5c74fef433be2b0a$export$e2da3477247342d1.editPromise = null;
1720
- }
1721
- /* Focus and Selection */ get selectedIds() {
1722
- return this.state.nodes.selection.ids;
1723
- }
1724
- get selectedNodes() {
1725
- let nodes = [];
1726
- for (let id of Array.from(this.selectedIds)){
1727
- const node = this.get(id);
1728
- if (node) nodes.push(node);
1729
- }
1730
- return nodes;
1731
- }
1732
- focus(node, opts = {}) {
1733
- if (!node) return;
1734
- /* Focus is responsible for scrolling, while selection is
1735
- * responsible for focus. If selectionFollowsFocus, then
1736
- * just select it. */ if (this.props.selectionFollowsFocus) this.select(node);
1737
- else {
1738
- this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)($5c74fef433be2b0a$var$identify(node)));
1739
- if (opts.scroll !== false) this.scrollTo(node);
1740
- if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
1741
- }
1742
- }
1743
- pageUp() {
1744
- const start = this.visibleStartIndex;
1745
- const stop = this.visibleStopIndex;
1746
- const page = stop - start;
1747
- let index = this.focusedNode?.rowIndex ?? 0;
1748
- if (index > start) index = start;
1749
- else index = Math.max(start - page, 0);
1750
- this.focus(this.at(index));
1751
- }
1752
- pageDown() {
1753
- const start = this.visibleStartIndex;
1754
- const stop = this.visibleStopIndex;
1755
- const page = stop - start;
1756
- let index = this.focusedNode?.rowIndex ?? 0;
1757
- if (index < stop) index = stop;
1758
- else index = Math.min(index + page, this.visibleNodes.length - 1);
1759
- this.focus(this.at(index));
1760
- }
1761
- select(node, opts = {}) {
1762
- if (!node) return;
1763
- const changeFocus = opts.focus !== false;
1764
- const id = $5c74fef433be2b0a$var$identify(node);
1765
- if (changeFocus) this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(id));
1766
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).only(id));
1767
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).anchor(id));
1768
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(id));
1769
- this.scrollTo(id, opts.align);
1770
- if (this.focusedNode && changeFocus) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
1771
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1772
- }
1773
- deselect(node) {
1774
- if (!node) return;
1775
- const id = $5c74fef433be2b0a$var$identify(node);
1776
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).remove(id));
1777
- }
1778
- selectMulti(identity) {
1779
- const node = this.get($5c74fef433be2b0a$var$identifyNull(identity));
1780
- if (!node) return;
1781
- this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(node.id));
1782
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).add(node.id));
1783
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).anchor(node.id));
1784
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(node.id));
1785
- this.scrollTo(node);
1786
- if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
1787
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1788
- }
1789
- selectContiguous(identity) {
1790
- if (!identity) return;
1791
- const id = $5c74fef433be2b0a$var$identify(identity);
1792
- const { anchor: anchor , mostRecent: mostRecent } = this.state.nodes.selection;
1793
- this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(id));
1794
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).remove(this.nodesBetween(anchor, mostRecent)));
1795
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).add(this.nodesBetween(anchor, $5c74fef433be2b0a$var$identifyNull(id))));
1796
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).mostRecent(id));
1797
- this.scrollTo(id);
1798
- if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
1799
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1800
- }
1801
- deselectAll() {
1802
- this.setSelection({
1803
- ids: [],
1804
- anchor: null,
1805
- mostRecent: null
1806
- });
1807
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1808
- }
1809
- selectAll() {
1810
- this.setSelection({
1811
- ids: Object.keys(this.idToIndex),
1812
- anchor: this.firstNode,
1813
- mostRecent: this.lastNode
1814
- });
1815
- this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(this.lastNode?.id));
1816
- if (this.focusedNode) $5c74fef433be2b0a$var$safeRun(this.props.onFocus, this.focusedNode);
1817
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1818
- }
1819
- setSelection(args) {
1820
- const ids = new Set(args.ids?.map($5c74fef433be2b0a$var$identify));
1821
- const anchor = $5c74fef433be2b0a$var$identifyNull(args.anchor);
1822
- const mostRecent = $5c74fef433be2b0a$var$identifyNull(args.mostRecent);
1823
- this.dispatch((0, $58f9381615aa3d17$export$e324594224ef24da).set({
1824
- ids: ids,
1825
- anchor: anchor,
1826
- mostRecent: mostRecent
1827
- }));
1828
- $5c74fef433be2b0a$var$safeRun(this.props.onSelect, this.selectedNodes);
1829
- }
1830
- /* Drag and Drop */ get cursorParentId() {
1831
- const { cursor: cursor } = this.state.dnd;
1832
- switch(cursor.type){
1833
- case "highlight":
1834
- return cursor.id;
1835
- default:
1836
- return null;
1837
- }
1838
- }
1839
- get cursorOverFolder() {
1840
- return this.state.dnd.cursor.type === "highlight";
1841
- }
1842
- get dragNodes() {
1843
- return this.state.dnd.dragIds.map((id)=>this.get(id)).filter((n)=>!!n);
1844
- }
1845
- get dragNode() {
1846
- return this.get(this.state.nodes.drag.id);
1847
- }
1848
- get dragDestinationParent() {
1849
- return this.get(this.state.nodes.drag.destinationParentId);
1850
- }
1851
- get dragDestinationIndex() {
1852
- return this.state.nodes.drag.destinationIndex;
1853
- }
1854
- canDrop() {
1855
- if (this.isFiltered) return false;
1856
- const parentNode = this.get(this.state.dnd.parentId) ?? this.root;
1857
- const dragNodes = this.dragNodes;
1858
- const isDisabled = this.props.disableDrop;
1859
- for (const drag of dragNodes){
1860
- if (!drag) return false;
1861
- if (!parentNode) return false;
1862
- if (drag.isInternal && $eb5355379510ac9b$exports.isDescendant(parentNode, drag)) return false;
1863
- }
1864
- // Allow the user to insert their own logic
1865
- if (typeof isDisabled == "function") return !isDisabled({
1866
- parentNode: parentNode,
1867
- dragNodes: this.dragNodes,
1868
- index: this.state.dnd.index || 0
1869
- });
1870
- else if (typeof isDisabled == "string") // @ts-ignore
1871
- return !parentNode.data[isDisabled];
1872
- else if (typeof isDisabled === "boolean") return !isDisabled;
1873
- else return true;
1874
- }
1875
- hideCursor() {
1876
- this.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).cursor({
1877
- type: "none"
1878
- }));
1879
- }
1880
- showCursor(cursor) {
1881
- this.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).cursor(cursor));
1882
- }
1883
- /* Visibility */ open(identity) {
1884
- const id = $5c74fef433be2b0a$var$identifyNull(identity);
1885
- if (!id) return;
1886
- if (this.isOpen(id)) return;
1887
- this.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).open(id, this.isFiltered));
1888
- $5c74fef433be2b0a$var$safeRun(this.props.onToggle, id);
1889
- }
1890
- close(identity) {
1891
- const id = $5c74fef433be2b0a$var$identifyNull(identity);
1892
- if (!id) return;
1893
- if (!this.isOpen(id)) return;
1894
- this.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).close(id, this.isFiltered));
1895
- $5c74fef433be2b0a$var$safeRun(this.props.onToggle, id);
1896
- }
1897
- toggle(identity) {
1898
- const id = $5c74fef433be2b0a$var$identifyNull(identity);
1899
- if (!id) return;
1900
- return this.isOpen(id) ? this.close(id) : this.open(id);
1901
- }
1902
- openParents(identity) {
1903
- const id = $5c74fef433be2b0a$var$identifyNull(identity);
1904
- if (!id) return;
1905
- const node = $eb5355379510ac9b$exports.dfs(this.root, id);
1906
- let parent = node?.parent;
1907
- while(parent){
1908
- this.open(parent.id);
1909
- parent = parent.parent;
1910
- }
1911
- }
1912
- openSiblings(node) {
1913
- const parent = node.parent;
1914
- if (!parent) this.toggle(node.id);
1915
- else if (parent.children) {
1916
- const isOpen = node.isOpen;
1917
- for (let sibling of parent.children)if (sibling.isInternal) isOpen ? this.close(sibling.id) : this.open(sibling.id);
1918
- this.scrollTo(this.focusedNode);
1919
- }
1920
- }
1921
- openAll() {
1922
- $eb5355379510ac9b$exports.walk(this.root, (node)=>{
1923
- if (node.isInternal) node.open();
1924
- });
1925
- }
1926
- closeAll() {
1927
- $eb5355379510ac9b$exports.walk(this.root, (node)=>{
1928
- if (node.isInternal) node.close();
1929
- });
1930
- }
1931
- /* Scrolling */ scrollTo(identity, align = "smart") {
1932
- if (!identity) return;
1933
- const id = $5c74fef433be2b0a$var$identify(identity);
1934
- this.openParents(id);
1935
- return $eb5355379510ac9b$exports.waitFor(()=>id in this.idToIndex).then(()=>{
1936
- const index = this.idToIndex[id];
1937
- if (index === undefined) return;
1938
- this.list.current?.scrollToItem(index, align);
1939
- }).catch(()=>{
1940
- // Id: ${id} never appeared in the list.
1941
- });
1942
- }
1943
- /* State Checks */ get isEditing() {
1944
- return this.state.nodes.edit.id !== null;
1945
- }
1946
- get isFiltered() {
1947
- return !!this.props.searchTerm?.trim();
1948
- }
1949
- get hasFocus() {
1950
- return this.state.nodes.focus.treeFocused;
1951
- }
1952
- get hasNoSelection() {
1953
- return this.state.nodes.selection.ids.size === 0;
1954
- }
1955
- get hasOneSelection() {
1956
- return this.state.nodes.selection.ids.size === 1;
1957
- }
1958
- get hasMultipleSelections() {
1959
- return this.state.nodes.selection.ids.size > 1;
1960
- }
1961
- isSelected(id) {
1962
- if (!id) return false;
1963
- return this.state.nodes.selection.ids.has(id);
1964
- }
1965
- isOpen(id) {
1966
- if (!id) return false;
1967
- if (id === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c)) return true;
1968
- const def = this.props.openByDefault ?? true;
1969
- if (this.isFiltered) return this.state.nodes.open.filtered[id] ?? true; // Filtered folders are always opened by default
1970
- else return this.state.nodes.open.unfiltered[id] ?? def;
1971
- }
1972
- isEditable(data) {
1973
- const check = this.props.disableEdit || (()=>false);
1974
- return !$eb5355379510ac9b$exports.access(data, check) ?? true;
1975
- }
1976
- isDraggable(data) {
1977
- const check = this.props.disableDrag || (()=>false);
1978
- return !$eb5355379510ac9b$exports.access(data, check) ?? true;
1979
- }
1980
- isDragging(node) {
1981
- const id = $5c74fef433be2b0a$var$identifyNull(node);
1982
- if (!id) return false;
1983
- return this.state.nodes.drag.id === id;
1984
- }
1985
- isFocused(id) {
1986
- return this.hasFocus && this.state.nodes.focus.id === id;
1987
- }
1988
- isMatch(node) {
1989
- return this.matchFn(node);
1990
- }
1991
- willReceiveDrop(node) {
1992
- const id = $5c74fef433be2b0a$var$identifyNull(node);
1993
- if (!id) return false;
1994
- const { destinationParentId: destinationParentId , destinationIndex: destinationIndex } = this.state.nodes.drag;
1995
- return id === destinationParentId && destinationIndex === null;
1996
- }
1997
- /* Tree Event Handlers */ onFocus() {
1998
- const node = this.focusedNode || this.firstNode;
1999
- if (node) this.dispatch((0, $61ef7f2c3c9633e7$export$d7ddd398f22d79ef)(node.id));
2000
- }
2001
- onBlur() {
2002
- this.dispatch((0, $61ef7f2c3c9633e7$export$6b6c976e46a06288)());
2003
- }
2004
- onItemsRendered(args) {
2005
- this.visibleStartIndex = args.visibleStartIndex;
2006
- this.visibleStopIndex = args.visibleStopIndex;
2007
- }
2008
- /* Get Renderers */ get renderContainer() {
2009
- return this.props.renderContainer || (0, $bb9a1e34249689ac$export$ff4858a4110d9246);
2010
- }
2011
- get renderRow() {
2012
- return this.props.renderRow || (0, $ff6862a32cc2ac81$export$f9c541e71856c524);
2013
- }
2014
- get renderNode() {
2015
- return this.props.children || (0, $3240a4b0b5620968$export$909e23cbfbbd3351);
2016
- }
2017
- get renderDragPreview() {
2018
- return this.props.renderDragPreview || (0, $6e3db8c23c41dfc9$export$84e211ad8431a387);
2019
- }
2020
- get renderCursor() {
2021
- return this.props.renderCursor || (0, $c79fefb0d0a1d13b$export$6cb3c16721363d11);
2022
- }
2023
- }
2024
-
2025
-
2026
-
2027
-
2028
-
2029
-
2030
-
2031
-
2032
-
2033
-
2034
- function $2f73c1963cd9aa06$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)().nodes.drag, action) {
2035
- switch(action.type){
2036
- case "DND_DRAG_START":
2037
- return {
2038
- ...state,
2039
- id: action.id,
2040
- selectedIds: action.dragIds
2041
- };
2042
- case "DND_DRAG_END":
2043
- return {
2044
- ...state,
2045
- id: null,
2046
- destinationParentId: null,
2047
- destinationIndex: null,
2048
- selectedIds: []
2049
- };
2050
- case "DND_HOVERING":
2051
- if (action.parentId !== state.destinationParentId || action.index != state.destinationIndex) return {
2052
- ...state,
2053
- destinationParentId: action.parentId,
2054
- destinationIndex: action.index
2055
- };
2056
- else return state;
2057
- default:
2058
- return state;
2059
- }
2060
- }
2061
-
2062
-
2063
- const $cdb8f316fadc608f$export$a8a69c316169e623 = (0, $foSVk$redux.combineReducers)({
2064
- nodes: (0, $foSVk$redux.combineReducers)({
2065
- focus: $61ef7f2c3c9633e7$export$1650419e431d3ba3,
2066
- edit: $1297c48a54b69bac$export$1650419e431d3ba3,
2067
- open: $d519ceb3313d9d0e$export$1650419e431d3ba3,
2068
- selection: $58f9381615aa3d17$export$1650419e431d3ba3,
2069
- drag: $2f73c1963cd9aa06$export$1650419e431d3ba3
2070
- }),
2071
- dnd: $7d98f5b84ecaa66b$export$1650419e431d3ba3
2072
- });
2073
-
2074
-
2075
-
2076
-
2077
-
2078
-
2079
- const $9511ad6af37da13b$var$SERVER_STATE = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)();
2080
- function $9511ad6af37da13b$export$c49dab5eb1b4ce0c({ treeProps: treeProps , imperativeHandle: imperativeHandle , children: children }) {
2081
- const list = (0, $foSVk$react.useRef)(null);
2082
- const listEl = (0, $foSVk$react.useRef)(null);
2083
- const store = (0, $foSVk$react.useRef)((0, $foSVk$redux.createStore)((0, $cdb8f316fadc608f$export$a8a69c316169e623), (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)(treeProps)));
2084
- const state = (0, $foSVk$usesyncexternalstoreshim.useSyncExternalStore)(store.current.subscribe, store.current.getState, ()=>$9511ad6af37da13b$var$SERVER_STATE);
2085
- /* The tree api object is stable. */ const api = (0, $foSVk$react.useMemo)(()=>{
2086
- return new (0, $5c74fef433be2b0a$export$e2da3477247342d1)(store.current, treeProps, list, listEl);
2087
- }, []);
2088
- /* Make sure the tree instance stays in sync */ const updateCount = (0, $foSVk$react.useRef)(0);
2089
- (0, $foSVk$react.useMemo)(()=>{
2090
- updateCount.current += 1;
2091
- api.update(treeProps);
2092
- }, [
2093
- ...Object.values(treeProps),
2094
- state.nodes.open
2095
- ]);
2096
- /* Expose the tree api */ (0, $foSVk$react.useImperativeHandle)(imperativeHandle, ()=>api);
2097
- /* Change selection based on props */ (0, $foSVk$react.useEffect)(()=>{
2098
- if (api.props.selection) api.select(api.props.selection, {
2099
- focus: false
2100
- });
2101
- else api.deselectAll();
2102
- }, [
2103
- api.props.selection
2104
- ]);
2105
- /* Clear visability for filtered nodes */ (0, $foSVk$react.useEffect)(()=>{
2106
- if (!api.props.searchTerm) store.current.dispatch((0, $d519ceb3313d9d0e$export$e324594224ef24da).clear(true));
2107
- }, [
2108
- api.props.searchTerm
2109
- ]);
2110
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$feef243b04ff4151).Provider, {
2111
- value: api,
2112
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$d0c71bc5e3e2d897).Provider, {
2113
- value: updateCount.current,
2114
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$f6d467aa8b3786af).Provider, {
2115
- value: state.nodes,
2116
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $d5cb84d44d1b8acc$export$2d5c5ceac203fc1e).Provider, {
2117
- value: state.dnd,
2118
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactdnd.DndProvider), {
2119
- backend: (0, $foSVk$reactdndhtml5backend.HTML5Backend),
2120
- options: {
2121
- rootElement: api.props.dndRootElement || undefined
2122
- },
2123
- ...treeProps.dndManager && {
2124
- manager: treeProps.dndManager
2125
- },
2126
- children: children
2127
- })
2128
- })
2129
- })
2130
- })
2131
- });
2132
- }
2133
-
2134
-
2135
-
2136
-
2137
-
2138
-
2139
- function $6c0a9a91d5e7ff45$export$5a6c424b1725f44f() {
2140
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
2141
- // In case we drop an item at the bottom of the list
2142
- const [, drop] = (0, $foSVk$reactdnd.useDrop)(()=>({
2143
- accept: "NODE",
2144
- canDrop: (_item, m)=>{
2145
- if (!m.isOver({
2146
- shallow: true
2147
- })) return false;
2148
- return tree.canDrop();
2149
- },
2150
- hover: (_item, m)=>{
2151
- if (!m.isOver({
2152
- shallow: true
2153
- })) return;
2154
- const offset = m.getClientOffset();
2155
- if (!tree.listEl.current || !offset) return;
2156
- const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
2157
- element: tree.listEl.current,
2158
- offset: offset,
2159
- indent: tree.indent,
2160
- node: null,
2161
- prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
2162
- nextNode: null
2163
- });
2164
- if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
2165
- if (m.canDrop()) {
2166
- if (cursor) tree.showCursor(cursor);
2167
- } else tree.hideCursor();
2168
- }
2169
- }), [
2170
- tree
2171
- ]);
2172
- drop(tree.listEl);
2173
- }
2174
-
2175
-
2176
- function $df8d0340a995314b$export$a6ee728c3c6ef11d(props) {
2177
- (0, $6c0a9a91d5e7ff45$export$5a6c424b1725f44f)();
2178
- return props.children;
2179
- }
2180
-
2181
-
2182
-
2183
-
2184
-
2185
-
2186
- function $17a87d0a329a3eaa$export$cdf2ef3f6364d85() {
2187
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
2188
- const Container = tree.props.renderContainer || (0, $bb9a1e34249689ac$export$ff4858a4110d9246);
2189
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactjsxruntime.Fragment), {
2190
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(Container, {})
2191
- });
2192
- }
2193
-
2194
-
2195
-
2196
-
2197
-
2198
-
2199
- function $ed13b1d404b3872b$export$3e21b60650ec7e55() {
2200
- const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
2201
- const { offset: offset , mouse: mouse , item: item , isDragging: isDragging } = (0, $foSVk$reactdnd.useDragLayer)((m)=>{
2202
- return {
2203
- offset: m.getSourceClientOffset(),
2204
- mouse: m.getClientOffset(),
2205
- item: m.getItem(),
2206
- isDragging: m.isDragging()
2207
- };
2208
- });
2209
- const DragPreview = tree.props.renderDragPreview || (0, $6e3db8c23c41dfc9$export$84e211ad8431a387);
2210
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)(DragPreview, {
2211
- offset: offset,
2212
- mouse: mouse,
2213
- id: item?.id || null,
2214
- dragIds: item?.dragIds || [],
2215
- isDragging: isDragging
2216
- });
2217
- }
2218
-
2219
-
2220
- var $2492d77b1ec82005$exports = {};
2221
-
2222
- $parcel$export($2492d77b1ec82005$exports, "useSimpleTree", () => $2492d77b1ec82005$export$dcd27aa2043b2724);
2223
-
2224
- var $ce2da9e8a36b0fcd$exports = {};
2225
-
2226
- $parcel$export($ce2da9e8a36b0fcd$exports, "SimpleTree", () => $ce2da9e8a36b0fcd$export$e32206264f456dce);
2227
- class $ce2da9e8a36b0fcd$export$e32206264f456dce {
2228
- constructor(data){
2229
- this.root = $ce2da9e8a36b0fcd$var$createRoot(data);
2230
- }
2231
- get data() {
2232
- return this.root.children?.map((node)=>node.data) ?? [];
2233
- }
2234
- create(args) {
2235
- const parent = args.parentId ? this.find(args.parentId) : this.root;
2236
- if (!parent) return null;
2237
- parent.addChild(args.data, args.index);
2238
- }
2239
- move(args) {
2240
- const src = this.find(args.id);
2241
- const parent = args.parentId ? this.find(args.parentId) : this.root;
2242
- if (!src || !parent) return;
2243
- parent.addChild(src.data, args.index);
2244
- src.drop();
2245
- }
2246
- update(args) {
2247
- const node = this.find(args.id);
2248
- if (node) node.update(args.changes);
2249
- }
2250
- drop(args) {
2251
- const node = this.find(args.id);
2252
- if (node) node.drop();
2253
- }
2254
- find(id, node = this.root) {
2255
- if (!node) return null;
2256
- if (node.id === id) return node;
2257
- if (node.children) {
2258
- for (let child of node.children){
2259
- const found = this.find(id, child);
2260
- if (found) return found;
2261
- }
2262
- return null;
2263
- }
2264
- return null;
2265
- }
2266
- }
2267
- function $ce2da9e8a36b0fcd$var$createRoot(data) {
2268
- const root = new $ce2da9e8a36b0fcd$var$SimpleNode({
2269
- id: "ROOT"
2270
- }, null);
2271
- root.children = data.map((d)=>$ce2da9e8a36b0fcd$var$createNode(d, root));
2272
- return root;
2273
- }
2274
- function $ce2da9e8a36b0fcd$var$createNode(data, parent) {
2275
- const node = new $ce2da9e8a36b0fcd$var$SimpleNode(data, parent);
2276
- if (data.children) node.children = data.children.map((d)=>$ce2da9e8a36b0fcd$var$createNode(d, node));
2277
- return node;
2278
- }
2279
- class $ce2da9e8a36b0fcd$var$SimpleNode {
2280
- constructor(data, parent){
2281
- this.data = data;
2282
- this.parent = parent;
2283
- this.id = data.id;
2284
- }
2285
- hasParent() {
2286
- return !!this.parent;
2287
- }
2288
- get childIndex() {
2289
- return this.hasParent() ? this.parent.children.indexOf(this) : -1;
2290
- }
2291
- addChild(data, index) {
2292
- const node = $ce2da9e8a36b0fcd$var$createNode(data, this);
2293
- this.children = this.children ?? [];
2294
- this.children.splice(index, 0, node);
2295
- this.data.children = this.data.children ?? [];
2296
- this.data.children.splice(index, 0, data);
2297
- }
2298
- removeChild(index) {
2299
- this.children?.splice(index, 1);
2300
- this.data.children?.splice(index, 1);
2301
- }
2302
- update(changes) {
2303
- if (this.hasParent()) {
2304
- const i = this.childIndex;
2305
- this.parent.addChild({
2306
- ...this.data,
2307
- ...changes
2308
- }, i);
2309
- this.drop();
2310
- }
2311
- }
2312
- drop() {
2313
- if (this.hasParent()) this.parent.removeChild(this.childIndex);
2314
- }
2315
- }
2316
-
2317
-
2318
- let $2492d77b1ec82005$var$nextId = 0;
2319
- function $2492d77b1ec82005$export$dcd27aa2043b2724(initialData) {
2320
- const [data, setData] = (0, $foSVk$react.useState)(initialData);
2321
- const tree = (0, $foSVk$react.useMemo)(()=>new (0, $ce2da9e8a36b0fcd$export$e32206264f456dce)(data), [
2322
- data
2323
- ]);
2324
- const onMove = (args)=>{
2325
- for (const id of args.dragIds)tree.move({
2326
- id: id,
2327
- parentId: args.parentId,
2328
- index: args.index
2329
- });
2330
- setData(tree.data);
2331
- };
2332
- const onRename = ({ name: name , id: id })=>{
2333
- tree.update({
2334
- id: id,
2335
- changes: {
2336
- name: name
2337
- }
2338
- });
2339
- setData(tree.data);
2340
- };
2341
- const onCreate = ({ parentId: parentId , index: index , type: type })=>{
2342
- const data = {
2343
- id: `simple-tree-id-${$2492d77b1ec82005$var$nextId++}`,
2344
- name: ""
2345
- };
2346
- if (type === "internal") data.children = [];
2347
- tree.create({
2348
- parentId: parentId,
2349
- index: index,
2350
- data: data
2351
- });
2352
- setData(tree.data);
2353
- return data;
2354
- };
2355
- const onDelete = (args)=>{
2356
- args.ids.forEach((id)=>tree.drop({
2357
- id: id
2358
- }));
2359
- setData(tree.data);
2360
- };
2361
- const controller = {
2362
- onMove: onMove,
2363
- onRename: onRename,
2364
- onCreate: onCreate,
2365
- onDelete: onDelete
2366
- };
2367
- return [
2368
- data,
2369
- controller
2370
- ];
2371
- }
2372
-
2373
-
2374
- function $8e1ae4dab2259e77$export$d227906824a13416(props) {
2375
- if (props.initialData && props.data) throw new Error(`React Arborist Tree => Provide either a data or initialData prop, but not both.`);
2376
- if (props.initialData && (props.onCreate || props.onDelete || props.onMove || props.onRename)) throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
2377
- Use the data prop if you want to provide your own handlers.`);
2378
- if (props.initialData) {
2379
- /**
2380
- * Let's break the rules of hooks here. If the initialData prop
2381
- * is provided, we will assume it will not change for the life of
2382
- * the component.
2383
- *
2384
- * We will provide the real data and the handlers to update it.
2385
- * */ const [data, controller] = (0, $2492d77b1ec82005$export$dcd27aa2043b2724)(props.initialData);
2386
- return {
2387
- ...props,
2388
- ...controller,
2389
- data: data
2390
- };
2391
- } else return props;
2392
- }
2393
-
2394
-
2395
- function $641461e16d1a2941$var$TreeComponent(props, ref) {
2396
- const treeProps = (0, $8e1ae4dab2259e77$export$d227906824a13416)(props);
2397
- return /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsxs)((0, $9511ad6af37da13b$export$c49dab5eb1b4ce0c), {
2398
- treeProps: treeProps,
2399
- imperativeHandle: ref,
2400
- children: [
2401
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $df8d0340a995314b$export$a6ee728c3c6ef11d), {
2402
- children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $17a87d0a329a3eaa$export$cdf2ef3f6364d85), {})
2403
- }),
2404
- /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $ed13b1d404b3872b$export$3e21b60650ec7e55), {})
2405
- ]
2406
- });
2407
- }
2408
- const $641461e16d1a2941$export$7fbedc92909ed28e = /*#__PURE__*/ (0, $foSVk$react.forwardRef)($641461e16d1a2941$var$TreeComponent);
2409
-
2410
-
2411
- var $73c61fb8fd3b5237$exports = {};
2412
-
2413
-
2414
- var $6740b53b975d3884$exports = {};
2415
-
2416
-
2417
- var $6cfe0c91f2a90e78$exports = {};
2418
-
2419
-
2420
-
2421
-
2422
-
2423
-
2424
- $parcel$exportWildcard(module.exports, $73c61fb8fd3b5237$exports);
2425
- $parcel$exportWildcard(module.exports, $6740b53b975d3884$exports);
2426
- $parcel$exportWildcard(module.exports, $6cfe0c91f2a90e78$exports);
2427
- $parcel$exportWildcard(module.exports, $9b37fe5960a1a3c6$exports);
2428
- $parcel$exportWildcard(module.exports, $5c74fef433be2b0a$exports);
2429
- $parcel$exportWildcard(module.exports, $ce2da9e8a36b0fcd$exports);
2430
- $parcel$exportWildcard(module.exports, $2492d77b1ec82005$exports);
2431
-
2432
-
2433
- //# sourceMappingURL=index.js.map