react-arborist 0.1.14 → 0.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{lib/components → components}/drop-cursor.d.ts +1 -0
- package/dist/{lib/components → components}/preview.d.ts +1 -0
- package/dist/{lib/components → components}/row.d.ts +0 -0
- package/dist/{lib/components → components}/tree.d.ts +0 -0
- package/dist/{lib/context.d.ts → context.d.ts} +0 -0
- package/dist/{lib/data → data}/enrich-tree.d.ts +0 -0
- package/dist/{lib/data → data}/flatten-tree.d.ts +0 -0
- package/dist/{lib/dnd → dnd}/compute-drop.d.ts +0 -0
- package/dist/{lib/dnd → dnd}/drag-hook.d.ts +0 -0
- package/dist/{lib/dnd → dnd}/drop-hook.d.ts +0 -0
- package/dist/{lib/dnd → dnd}/outer-drop-hook.d.ts +0 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1354 -0
- package/dist/index.js.map +1 -0
- package/dist/module.js +1346 -0
- package/dist/module.js.map +1 -0
- package/dist/{lib/provider.d.ts → provider.d.ts} +1 -0
- package/dist/{lib/reducer.d.ts → reducer.d.ts} +0 -0
- package/dist/{lib/selection → selection}/range.d.ts +0 -0
- package/dist/{lib/selection → selection}/selection-hook.d.ts +0 -0
- package/dist/{lib/selection → selection}/selection.d.ts +0 -0
- package/dist/{lib/tree-api-hook.d.ts → tree-api-hook.d.ts} +0 -0
- package/dist/{lib/tree-api.d.ts → tree-api.d.ts} +1 -1
- package/dist/{lib/types.d.ts → types.d.ts} +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/{lib/utils.d.ts → utils.d.ts} +0 -0
- package/package.json +16 -44
- package/src/components/drop-cursor.tsx +47 -0
- package/src/components/preview.tsx +108 -0
- package/src/components/row.tsx +119 -0
- package/src/components/tree.tsx +118 -0
- package/src/context.tsx +52 -0
- package/src/data/enrich-tree.ts +74 -0
- package/src/data/flatten-tree.ts +17 -0
- package/src/data/make-tree.ts +37 -0
- package/src/dnd/compute-drop.ts +184 -0
- package/src/dnd/drag-hook.ts +48 -0
- package/src/dnd/drop-hook.ts +66 -0
- package/src/dnd/measure-hover.ts +26 -0
- package/src/dnd/outer-drop-hook.ts +50 -0
- package/src/index.ts +5 -0
- package/src/provider.tsx +61 -0
- package/src/reducer.ts +161 -0
- package/src/selection/range.ts +41 -0
- package/src/selection/selection-hook.ts +24 -0
- package/src/selection/selection.test.ts +111 -0
- package/src/selection/selection.ts +186 -0
- package/src/tree-api-hook.ts +34 -0
- package/src/tree-api.ts +129 -0
- package/src/types.ts +147 -0
- package/src/utils.ts +35 -0
- package/tsconfig.json +28 -0
- package/README.md +0 -197
- package/dist/lib/components/drop-cursor.js +0 -53
- package/dist/lib/components/preview.js +0 -91
- package/dist/lib/components/row.js +0 -122
- package/dist/lib/components/tree.js +0 -76
- package/dist/lib/context.js +0 -57
- package/dist/lib/data/enrich-tree.js +0 -48
- package/dist/lib/data/flatten-tree.js +0 -20
- package/dist/lib/data/make-tree.d.ts +0 -5
- package/dist/lib/data/make-tree.js +0 -40
- package/dist/lib/data/visible-nodes-hook.d.ts +0 -2
- package/dist/lib/data/visible-nodes-hook.js +0 -19
- package/dist/lib/dnd/compute-drop.js +0 -146
- package/dist/lib/dnd/drag-hook.js +0 -36
- package/dist/lib/dnd/drop-hook.js +0 -59
- package/dist/lib/dnd/measure-hover.d.ts +0 -8
- package/dist/lib/dnd/measure-hover.js +0 -21
- package/dist/lib/dnd/outer-drop-hook.js +0 -51
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/index.js +0 -7
- package/dist/lib/provider.js +0 -46
- package/dist/lib/reducer.js +0 -147
- package/dist/lib/selection/range.js +0 -45
- package/dist/lib/selection/selection-hook.js +0 -24
- package/dist/lib/selection/selection.js +0 -192
- package/dist/lib/selection/selection.test.d.ts +0 -1
- package/dist/lib/selection/selection.test.js +0 -102
- package/dist/lib/tree-api-hook.js +0 -26
- package/dist/lib/tree-api.js +0 -130
- package/dist/lib/tree-monitor.d.ts +0 -15
- package/dist/lib/tree-monitor.js +0 -32
- package/dist/lib/types.js +0 -2
- package/dist/lib/utils.js +0 -39
package/dist/index.js
ADDED
|
@@ -0,0 +1,1354 @@
|
|
|
1
|
+
var $foSVk$reactjsxruntime = require("react/jsx-runtime");
|
|
2
|
+
var $foSVk$react = require("react");
|
|
3
|
+
var $foSVk$reactdnd = require("react-dnd");
|
|
4
|
+
var $foSVk$reactdndhtml5backend = require("react-dnd-html5-backend");
|
|
5
|
+
var $foSVk$reactwindow = require("react-window");
|
|
6
|
+
var $foSVk$memoizeone = require("memoize-one");
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
function $parcel$interopDefault(a) {
|
|
12
|
+
return a && a.__esModule ? a.default : a;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
$parcel$export(module.exports, "Tree", () => $641461e16d1a2941$export$7fbedc92909ed28e);
|
|
16
|
+
$parcel$export(module.exports, "TreeApi", () => $f02bc7cefcb30793$export$e2da3477247342d1);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class $13a483230b6b2ece$export$9a58ef0d7ad3278c {
|
|
24
|
+
constructor(start, end){
|
|
25
|
+
this.start = start;
|
|
26
|
+
this.end = end;
|
|
27
|
+
if (this.start > this.end) throw new Error("Invalid range: start larger than end");
|
|
28
|
+
}
|
|
29
|
+
serialize() {
|
|
30
|
+
return [
|
|
31
|
+
this.start,
|
|
32
|
+
this.end
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
contains(n) {
|
|
36
|
+
return n >= this.start && n <= this.end;
|
|
37
|
+
}
|
|
38
|
+
overlaps(r) {
|
|
39
|
+
return this.contains(r.start - 1) || this.contains(r.end + 1);
|
|
40
|
+
}
|
|
41
|
+
combine(r) {
|
|
42
|
+
this.start = Math.min(r.start, this.start);
|
|
43
|
+
this.end = Math.max(r.end, this.end);
|
|
44
|
+
}
|
|
45
|
+
get size() {
|
|
46
|
+
return this.end - this.start + 1;
|
|
47
|
+
}
|
|
48
|
+
clone() {
|
|
49
|
+
return new $13a483230b6b2ece$export$9a58ef0d7ad3278c(this.start, this.end);
|
|
50
|
+
}
|
|
51
|
+
map(fn) {
|
|
52
|
+
let returns = [];
|
|
53
|
+
for(let i = this.start; i <= this.end; i++)returns.push(fn(i));
|
|
54
|
+
return returns;
|
|
55
|
+
}
|
|
56
|
+
isEqual(other) {
|
|
57
|
+
return this.start === other.start && this.end === other.end;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class $974b6ba4b06bc58f$export$52baac22726c72bf {
|
|
63
|
+
static parse(data, items) {
|
|
64
|
+
if (data) return new $974b6ba4b06bc58f$export$52baac22726c72bf(data.ranges, data.currentIndex, data.direction, items);
|
|
65
|
+
else return new $974b6ba4b06bc58f$export$52baac22726c72bf();
|
|
66
|
+
}
|
|
67
|
+
constructor(ranges = [], currentIndex = ranges.length ? ranges.length - 1 : null, direction = "none", items = []){
|
|
68
|
+
this.ranges = [];
|
|
69
|
+
this.direction = "none";
|
|
70
|
+
ranges.forEach(([s, e])=>this.addRange(s, e)
|
|
71
|
+
);
|
|
72
|
+
this.currentIndex = currentIndex;
|
|
73
|
+
this.direction = direction;
|
|
74
|
+
this.items = items;
|
|
75
|
+
}
|
|
76
|
+
get current() {
|
|
77
|
+
if (this.currentIndex === null) return null;
|
|
78
|
+
const range = this.ranges[this.currentIndex];
|
|
79
|
+
if (!range) return null;
|
|
80
|
+
else return range;
|
|
81
|
+
}
|
|
82
|
+
select(n) {
|
|
83
|
+
if (n < 0 || n >= this.items.length) return;
|
|
84
|
+
this.clear();
|
|
85
|
+
this.currentIndex = this.addRange(n, n);
|
|
86
|
+
}
|
|
87
|
+
multiSelect(n) {
|
|
88
|
+
if (n < 0 || n >= this.items.length) return;
|
|
89
|
+
if (this.contains(n)) return;
|
|
90
|
+
this.currentIndex = this.addRange(n, n);
|
|
91
|
+
this.compact(n);
|
|
92
|
+
}
|
|
93
|
+
deselect(n) {
|
|
94
|
+
if (n < 0 || n >= this.items.length) return;
|
|
95
|
+
const r1 = this.ranges.find((r)=>r.contains(n)
|
|
96
|
+
);
|
|
97
|
+
if (!r1) return;
|
|
98
|
+
else if (r1.size === 1) this.removeRange(r1);
|
|
99
|
+
else if (r1.start === n) r1.start++;
|
|
100
|
+
else if (r1.end === n) r1.end--;
|
|
101
|
+
else {
|
|
102
|
+
this.removeRange(r1);
|
|
103
|
+
this.addRange(r1.start, n - 1);
|
|
104
|
+
this.currentIndex = this.addRange(n + 1, r1.end);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
getSelectedItems() {
|
|
108
|
+
return this.ranges.flatMap((range)=>range.map((index)=>this.items[index]
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
extend(n) {
|
|
113
|
+
if (n < 0 || n >= this.items.length) return;
|
|
114
|
+
if (this.isEmpty()) this.select(n);
|
|
115
|
+
else {
|
|
116
|
+
const anchor = this.getAnchor();
|
|
117
|
+
if (anchor !== null && this.current) {
|
|
118
|
+
const [start, end] = [
|
|
119
|
+
n,
|
|
120
|
+
anchor
|
|
121
|
+
].sort((a, b)=>a - b
|
|
122
|
+
);
|
|
123
|
+
this.current.start = start;
|
|
124
|
+
this.current.end = end;
|
|
125
|
+
this.compact(n);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
contains(n) {
|
|
130
|
+
if (n === null) return false;
|
|
131
|
+
return this.ranges.some((r)=>r.contains(n)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
getRanges() {
|
|
135
|
+
return this.ranges.map((r)=>r.serialize()
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
clear() {
|
|
139
|
+
this.ranges = [];
|
|
140
|
+
this.currentIndex = null;
|
|
141
|
+
this.direction = "none";
|
|
142
|
+
}
|
|
143
|
+
serialize() {
|
|
144
|
+
return {
|
|
145
|
+
ranges: this.getRanges(),
|
|
146
|
+
currentIndex: this.currentIndex,
|
|
147
|
+
direction: this.direction
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
isEqual(other) {
|
|
151
|
+
if (other.ranges.length !== this.ranges.length) return false;
|
|
152
|
+
for(let i = 0; i < this.ranges.length; ++i){
|
|
153
|
+
if (!this.ranges[i].isEqual(other.ranges[i])) return false;
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
addRange(start, end) {
|
|
158
|
+
const r2 = new $13a483230b6b2ece$export$9a58ef0d7ad3278c(start, end);
|
|
159
|
+
// Keep ranges sorted by start
|
|
160
|
+
const index = this.ranges.findIndex((r)=>r.start >= start
|
|
161
|
+
);
|
|
162
|
+
if (index === -1) this.ranges.push(r2);
|
|
163
|
+
else this.ranges.splice(index, 0, r2);
|
|
164
|
+
return index === -1 ? this.ranges.length - 1 : index;
|
|
165
|
+
}
|
|
166
|
+
removeRange(r) {
|
|
167
|
+
const index = this.ranges.indexOf(r);
|
|
168
|
+
this.ranges.splice(index, 1);
|
|
169
|
+
if (this.isEmpty()) this.currentIndex = null;
|
|
170
|
+
else if (index === this.currentIndex) this.currentIndex = this.ranges.length - 1;
|
|
171
|
+
}
|
|
172
|
+
isEmpty() {
|
|
173
|
+
return this.ranges.length === 0;
|
|
174
|
+
}
|
|
175
|
+
getAnchor() {
|
|
176
|
+
if (!this.current) return null;
|
|
177
|
+
return this.direction === "backward" ? this.current.end : this.current.start;
|
|
178
|
+
}
|
|
179
|
+
getFocus() {
|
|
180
|
+
if (!this.current) return -1;
|
|
181
|
+
return this.direction === "backward" ? this.current.start : this.current.end;
|
|
182
|
+
}
|
|
183
|
+
compact(focus) {
|
|
184
|
+
const removals = [];
|
|
185
|
+
const current = this.current;
|
|
186
|
+
for (let r3 of this.ranges){
|
|
187
|
+
if (!this.current || r3 === this.current) continue;
|
|
188
|
+
if (this.current.overlaps(r3)) {
|
|
189
|
+
this.current.combine(r3);
|
|
190
|
+
removals.push(r3);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
removals.forEach((r)=>this.removeRange(r)
|
|
194
|
+
);
|
|
195
|
+
if (current) this.currentIndex = this.ranges.indexOf(current);
|
|
196
|
+
if (!this.current) return;
|
|
197
|
+
if (this.current.start < focus) this.direction = "forward";
|
|
198
|
+
else if (this.current.end > focus) this.direction = "backward";
|
|
199
|
+
else this.direction = "none";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
const $6723c76b9de38fd1$export$7380e5d4146ff2ce = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
205
|
+
function $6723c76b9de38fd1$export$8e294ac6de4c921f() {
|
|
206
|
+
return $foSVk$react.useContext($6723c76b9de38fd1$export$7380e5d4146ff2ce);
|
|
207
|
+
}
|
|
208
|
+
const $6723c76b9de38fd1$export$86fe4415b73783a1 = /*#__PURE__*/ $foSVk$react.createContext(false);
|
|
209
|
+
function $6723c76b9de38fd1$export$f3ad962ff713505f() {
|
|
210
|
+
return $foSVk$react.useContext($6723c76b9de38fd1$export$86fe4415b73783a1);
|
|
211
|
+
}
|
|
212
|
+
const $6723c76b9de38fd1$export$76f51715425ee155 = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
213
|
+
function $6723c76b9de38fd1$export$6c87584817ff2461() {
|
|
214
|
+
return $foSVk$react.useContext($6723c76b9de38fd1$export$76f51715425ee155);
|
|
215
|
+
}
|
|
216
|
+
const $6723c76b9de38fd1$export$c1b9a1d3af45b7b6 = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
217
|
+
function $6723c76b9de38fd1$export$ea6c3ae2bd3a5510() {
|
|
218
|
+
const value = $foSVk$react.useContext($6723c76b9de38fd1$export$c1b9a1d3af45b7b6);
|
|
219
|
+
if (!value) throw new Error("Context must be in a provider");
|
|
220
|
+
return value;
|
|
221
|
+
}
|
|
222
|
+
const $6723c76b9de38fd1$export$f34e95fabff36a8f = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
223
|
+
function $6723c76b9de38fd1$export$8ad76b76a4c905f8() {
|
|
224
|
+
const dispatch = $foSVk$react.useContext($6723c76b9de38fd1$export$f34e95fabff36a8f);
|
|
225
|
+
if (!dispatch) throw new Error("No dispatch provided");
|
|
226
|
+
return dispatch;
|
|
227
|
+
}
|
|
228
|
+
const $6723c76b9de38fd1$export$7c7a4fd7f1336e2c = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
229
|
+
function $6723c76b9de38fd1$export$1c9b7756eccadc96() {
|
|
230
|
+
const value = $foSVk$react.useContext($6723c76b9de38fd1$export$7c7a4fd7f1336e2c);
|
|
231
|
+
if (!value) throw new Error("Must provide selection context");
|
|
232
|
+
return value.ids;
|
|
233
|
+
}
|
|
234
|
+
function $6723c76b9de38fd1$export$fb40a80c530e5f2b() {
|
|
235
|
+
const value = $foSVk$react.useContext($6723c76b9de38fd1$export$7c7a4fd7f1336e2c);
|
|
236
|
+
if (!value) throw new Error("Must provide selection context");
|
|
237
|
+
const s = $foSVk$react.useMemo(()=>$974b6ba4b06bc58f$export$52baac22726c72bf.parse(value.data, [])
|
|
238
|
+
, [
|
|
239
|
+
value.data
|
|
240
|
+
]);
|
|
241
|
+
return (i)=>s.contains(i)
|
|
242
|
+
;
|
|
243
|
+
}
|
|
244
|
+
const $6723c76b9de38fd1$export$7f994e57c9e78355 = /*#__PURE__*/ $foSVk$react.createContext(null);
|
|
245
|
+
function $6723c76b9de38fd1$export$9ab192f953c1b33b() {
|
|
246
|
+
return $foSVk$react.useContext($6723c76b9de38fd1$export$7f994e57c9e78355);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
function $2d914ccbe0a16edd$var$createNode(model, level, parent, children, isOpen, isDraggable, isDroppable) {
|
|
251
|
+
return {
|
|
252
|
+
id: model.id,
|
|
253
|
+
level: level,
|
|
254
|
+
parent: parent,
|
|
255
|
+
children: children,
|
|
256
|
+
isOpen: isOpen,
|
|
257
|
+
isDraggable: isDraggable,
|
|
258
|
+
isDroppable: isDroppable,
|
|
259
|
+
model: model,
|
|
260
|
+
rowIndex: null
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function $2d914ccbe0a16edd$var$access(obj, accessor) {
|
|
264
|
+
if (typeof accessor === "boolean") return accessor;
|
|
265
|
+
if (typeof accessor === "string") return obj[accessor];
|
|
266
|
+
return accessor(obj);
|
|
267
|
+
}
|
|
268
|
+
function $2d914ccbe0a16edd$export$9c537176392280a0(model1, hideRoot = false, getChildren = "children", isOpen = "isOpen", disableDrag = false, disableDrop = false, openByDefault = true) {
|
|
269
|
+
function visitSelfAndChildren(model, level, parent) {
|
|
270
|
+
const open = $2d914ccbe0a16edd$var$access(model, isOpen);
|
|
271
|
+
const draggable = !$2d914ccbe0a16edd$var$access(model, disableDrag);
|
|
272
|
+
const droppable = !$2d914ccbe0a16edd$var$access(model, disableDrop);
|
|
273
|
+
const node = $2d914ccbe0a16edd$var$createNode(model, level, parent, null, open === undefined ? openByDefault : open, draggable, droppable);
|
|
274
|
+
const children = $2d914ccbe0a16edd$var$access(model, getChildren);
|
|
275
|
+
if (children) node.children = children.map((child)=>visitSelfAndChildren(child, level + 1, node)
|
|
276
|
+
);
|
|
277
|
+
return node;
|
|
278
|
+
}
|
|
279
|
+
return visitSelfAndChildren(model1, hideRoot ? -1 : 0, null);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
function $eb5355379510ac9b$export$adf7c0fe6059d774(n, min, max) {
|
|
286
|
+
return Math.max(Math.min(n, max), min);
|
|
287
|
+
}
|
|
288
|
+
const $eb5355379510ac9b$export$769c5e872f5f8638 = (node)=>!!node.children
|
|
289
|
+
;
|
|
290
|
+
function $eb5355379510ac9b$export$5318634f2ee07019(node) {
|
|
291
|
+
return node && !$eb5355379510ac9b$export$769c5e872f5f8638(node);
|
|
292
|
+
}
|
|
293
|
+
function $eb5355379510ac9b$export$4210f5ea57fbae57(node) {
|
|
294
|
+
return node && $eb5355379510ac9b$export$769c5e872f5f8638(node) && !node.isOpen;
|
|
295
|
+
}
|
|
296
|
+
const $eb5355379510ac9b$export$1e38f72c6c546f70 = (a, b)=>{
|
|
297
|
+
let n = a;
|
|
298
|
+
while(n){
|
|
299
|
+
if (n.id === b.id) return true;
|
|
300
|
+
n = n.parent;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
};
|
|
304
|
+
const $eb5355379510ac9b$export$305f7d4e9d4624f2 = (node)=>{
|
|
305
|
+
// This should probably not throw an error, but instead return null
|
|
306
|
+
if (!node.parent) throw Error("Node does not have a parent");
|
|
307
|
+
return node.parent.children.findIndex((c)=>c.id === node.id
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
function $eb5355379510ac9b$export$8793edee2d425525() {
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
function $462841de7cc5b715$var$measureHover(el, offset) {
|
|
315
|
+
const rect = el.getBoundingClientRect();
|
|
316
|
+
const x = offset.x - Math.round(rect.x);
|
|
317
|
+
const y = offset.y - Math.round(rect.y);
|
|
318
|
+
const height = rect.height;
|
|
319
|
+
const inTopHalf = y < height / 2;
|
|
320
|
+
const inBottomHalf = !inTopHalf;
|
|
321
|
+
const pad = height / 4;
|
|
322
|
+
const inMiddle = y > pad && y < height - pad;
|
|
323
|
+
const atTop = !inMiddle && inTopHalf;
|
|
324
|
+
const atBottom = !inMiddle && inBottomHalf;
|
|
325
|
+
return {
|
|
326
|
+
x: x,
|
|
327
|
+
inTopHalf: inTopHalf,
|
|
328
|
+
inBottomHalf: inBottomHalf,
|
|
329
|
+
inMiddle: inMiddle,
|
|
330
|
+
atTop: atTop,
|
|
331
|
+
atBottom: atBottom
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function $462841de7cc5b715$var$getNodesAroundCursor(node, prev, next, hover) {
|
|
335
|
+
if (!node) // We're hoving over the empty part of the list, not over an item,
|
|
336
|
+
// Put the cursor below the last item which is "prev"
|
|
337
|
+
return [
|
|
338
|
+
prev,
|
|
339
|
+
null
|
|
340
|
+
];
|
|
341
|
+
if ($eb5355379510ac9b$export$769c5e872f5f8638(node)) {
|
|
342
|
+
if (hover.atTop) return [
|
|
343
|
+
prev,
|
|
344
|
+
node
|
|
345
|
+
];
|
|
346
|
+
else if (hover.inMiddle) return [
|
|
347
|
+
node,
|
|
348
|
+
node
|
|
349
|
+
];
|
|
350
|
+
else return [
|
|
351
|
+
node,
|
|
352
|
+
next
|
|
353
|
+
];
|
|
354
|
+
} else {
|
|
355
|
+
if (hover.inTopHalf) return [
|
|
356
|
+
prev,
|
|
357
|
+
node
|
|
358
|
+
];
|
|
359
|
+
else return [
|
|
360
|
+
node,
|
|
361
|
+
next
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function $462841de7cc5b715$var$getDropLevel(hovering, aboveCursor, belowCursor, indent) {
|
|
366
|
+
const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
|
|
367
|
+
let min, max;
|
|
368
|
+
if (!aboveCursor) {
|
|
369
|
+
max = 0;
|
|
370
|
+
min = 0;
|
|
371
|
+
} else if (!belowCursor) {
|
|
372
|
+
max = aboveCursor.level;
|
|
373
|
+
min = 0;
|
|
374
|
+
} else {
|
|
375
|
+
max = aboveCursor.level;
|
|
376
|
+
min = belowCursor.level;
|
|
377
|
+
}
|
|
378
|
+
return $eb5355379510ac9b$export$adf7c0fe6059d774(hoverLevel, min, max);
|
|
379
|
+
}
|
|
380
|
+
function $462841de7cc5b715$var$canDrop(above, below) {
|
|
381
|
+
if (!above) return true;
|
|
382
|
+
let n = above;
|
|
383
|
+
if ($eb5355379510ac9b$export$4210f5ea57fbae57(above) && above !== below) n = above.parent;
|
|
384
|
+
while(n){
|
|
385
|
+
if (!n.isDroppable) return false;
|
|
386
|
+
n = n.parent;
|
|
387
|
+
}
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
function $462841de7cc5b715$var$dropAt(parentId, index) {
|
|
391
|
+
return {
|
|
392
|
+
parentId: parentId || null,
|
|
393
|
+
index: index
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function $462841de7cc5b715$var$lineCursor(index, level) {
|
|
397
|
+
return {
|
|
398
|
+
type: "line",
|
|
399
|
+
index: index,
|
|
400
|
+
level: level
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function $462841de7cc5b715$var$noCursor() {
|
|
404
|
+
return {
|
|
405
|
+
type: "none"
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function $462841de7cc5b715$var$highlightCursor(id) {
|
|
409
|
+
return {
|
|
410
|
+
type: "highlight",
|
|
411
|
+
id: id
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function $462841de7cc5b715$var$walkUpFrom(node, level) {
|
|
415
|
+
let drop = node;
|
|
416
|
+
while(drop.parent && drop.level > level)drop = drop.parent;
|
|
417
|
+
const parentId = drop.parent?.id || null;
|
|
418
|
+
const index = $eb5355379510ac9b$export$305f7d4e9d4624f2(drop) + 1;
|
|
419
|
+
return {
|
|
420
|
+
parentId: parentId,
|
|
421
|
+
index: index
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function $462841de7cc5b715$export$f502ca02ebb85a1c(args) {
|
|
425
|
+
const hover = $462841de7cc5b715$var$measureHover(args.element, args.offset);
|
|
426
|
+
const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
|
|
427
|
+
const [above, below] = $462841de7cc5b715$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
|
|
428
|
+
if (!$462841de7cc5b715$var$canDrop(above, below)) return {
|
|
429
|
+
drop: null,
|
|
430
|
+
cursor: $462841de7cc5b715$var$noCursor()
|
|
431
|
+
};
|
|
432
|
+
/* Hovering over the middle of a folder */ if (node && $eb5355379510ac9b$export$769c5e872f5f8638(node) && hover.inMiddle) return {
|
|
433
|
+
drop: $462841de7cc5b715$var$dropAt(node.id, 0),
|
|
434
|
+
cursor: $462841de7cc5b715$var$highlightCursor(node.id)
|
|
435
|
+
};
|
|
436
|
+
/* At the top of the list */ if (!above) return {
|
|
437
|
+
drop: $462841de7cc5b715$var$dropAt(below?.parent?.id, 0),
|
|
438
|
+
cursor: $462841de7cc5b715$var$lineCursor(0, 0)
|
|
439
|
+
};
|
|
440
|
+
/* The above node is an item or a closed folder */ if ($eb5355379510ac9b$export$5318634f2ee07019(above) || $eb5355379510ac9b$export$4210f5ea57fbae57(above)) {
|
|
441
|
+
const level = $462841de7cc5b715$var$getDropLevel(hover, above, below, args.indent);
|
|
442
|
+
return {
|
|
443
|
+
drop: $462841de7cc5b715$var$walkUpFrom(above, level),
|
|
444
|
+
cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, level)
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/* The above node is an open folder */ return {
|
|
448
|
+
drop: $462841de7cc5b715$var$dropAt(above?.id, 0),
|
|
449
|
+
cursor: $462841de7cc5b715$var$lineCursor(above.rowIndex + 1, above.level + 1)
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
function $6c0a9a91d5e7ff45$export$5a6c424b1725f44f() {
|
|
455
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
456
|
+
// In case we drop an item at the bottom of the list
|
|
457
|
+
const [, drop1] = $foSVk$reactdnd.useDrop(()=>({
|
|
458
|
+
accept: "NODE",
|
|
459
|
+
hover: (item, m)=>{
|
|
460
|
+
if (!m.isOver({
|
|
461
|
+
shallow: true
|
|
462
|
+
})) return;
|
|
463
|
+
const offset = m.getClientOffset();
|
|
464
|
+
if (!tree.listEl.current || !offset) return;
|
|
465
|
+
const { cursor: cursor } = $462841de7cc5b715$export$f502ca02ebb85a1c({
|
|
466
|
+
element: tree.listEl.current,
|
|
467
|
+
offset: offset,
|
|
468
|
+
indent: tree.indent,
|
|
469
|
+
node: null,
|
|
470
|
+
prevNode: tree.api.visibleNodes[tree.api.visibleNodes.length - 1],
|
|
471
|
+
nextNode: null
|
|
472
|
+
});
|
|
473
|
+
if (cursor) tree.api.showCursor(cursor);
|
|
474
|
+
},
|
|
475
|
+
canDrop: (item, m)=>{
|
|
476
|
+
return m.isOver({
|
|
477
|
+
shallow: true
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
drop: (item, m)=>{
|
|
481
|
+
if (m.didDrop()) return;
|
|
482
|
+
const offset = m.getClientOffset();
|
|
483
|
+
if (!tree.listEl.current || !offset) return;
|
|
484
|
+
const { drop: drop } = $462841de7cc5b715$export$f502ca02ebb85a1c({
|
|
485
|
+
element: tree.listEl.current,
|
|
486
|
+
offset: offset,
|
|
487
|
+
indent: tree.indent,
|
|
488
|
+
node: null,
|
|
489
|
+
prevNode: tree.api.visibleNodes[tree.api.visibleNodes.length - 1],
|
|
490
|
+
nextNode: null
|
|
491
|
+
});
|
|
492
|
+
return drop;
|
|
493
|
+
}
|
|
494
|
+
})
|
|
495
|
+
, [
|
|
496
|
+
tree
|
|
497
|
+
]);
|
|
498
|
+
drop1(tree.listEl);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
const $da0693b023d53dfe$export$f6196a6c6bb539b4 = ()=>({
|
|
507
|
+
visibleIds: [],
|
|
508
|
+
cursor: {
|
|
509
|
+
type: "none"
|
|
510
|
+
},
|
|
511
|
+
editingId: null,
|
|
512
|
+
selection: {
|
|
513
|
+
data: null,
|
|
514
|
+
ids: []
|
|
515
|
+
}
|
|
516
|
+
})
|
|
517
|
+
;
|
|
518
|
+
const $da0693b023d53dfe$export$e324594224ef24da = {
|
|
519
|
+
setCursorLocation: (cursor)=>({
|
|
520
|
+
type: "SET_CURSOR_LOCATION",
|
|
521
|
+
cursor: cursor
|
|
522
|
+
})
|
|
523
|
+
,
|
|
524
|
+
setVisibleIds: (ids, idMap // id to index
|
|
525
|
+
)=>({
|
|
526
|
+
type: "SET_VISIBLE_IDS",
|
|
527
|
+
ids: ids,
|
|
528
|
+
idMap: idMap
|
|
529
|
+
})
|
|
530
|
+
,
|
|
531
|
+
select: (index, meta, shift)=>({
|
|
532
|
+
type: "SELECT",
|
|
533
|
+
index: index,
|
|
534
|
+
meta: meta,
|
|
535
|
+
shift: shift
|
|
536
|
+
})
|
|
537
|
+
,
|
|
538
|
+
selectId: (id)=>({
|
|
539
|
+
type: "SELECT_ID",
|
|
540
|
+
id: id
|
|
541
|
+
})
|
|
542
|
+
,
|
|
543
|
+
edit: (id)=>({
|
|
544
|
+
type: "EDIT",
|
|
545
|
+
id: id
|
|
546
|
+
})
|
|
547
|
+
,
|
|
548
|
+
stepUp: (shift, ids)=>({
|
|
549
|
+
type: "STEP_UP",
|
|
550
|
+
shift: shift
|
|
551
|
+
})
|
|
552
|
+
,
|
|
553
|
+
stepDown: (shift, ids)=>({
|
|
554
|
+
type: "STEP_DOWN",
|
|
555
|
+
shift: shift
|
|
556
|
+
})
|
|
557
|
+
};
|
|
558
|
+
function $da0693b023d53dfe$export$1650419e431d3ba3(state, action) {
|
|
559
|
+
switch(action.type){
|
|
560
|
+
case "EDIT":
|
|
561
|
+
return {
|
|
562
|
+
...state,
|
|
563
|
+
editingId: action.id
|
|
564
|
+
};
|
|
565
|
+
case "SET_CURSOR_LOCATION":
|
|
566
|
+
if ($da0693b023d53dfe$var$equal(state.cursor, action.cursor)) return state;
|
|
567
|
+
else return {
|
|
568
|
+
...state,
|
|
569
|
+
cursor: action.cursor
|
|
570
|
+
};
|
|
571
|
+
case "SELECT":
|
|
572
|
+
var s = $974b6ba4b06bc58f$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
|
|
573
|
+
if (action.index === null) s.clear();
|
|
574
|
+
else if (action.meta) {
|
|
575
|
+
if (s.contains(action.index)) s.deselect(action.index);
|
|
576
|
+
else s.multiSelect(action.index);
|
|
577
|
+
} else if (action.shift) s.extend(action.index);
|
|
578
|
+
else s.select(action.index);
|
|
579
|
+
return {
|
|
580
|
+
...state,
|
|
581
|
+
selection: {
|
|
582
|
+
data: s.serialize(),
|
|
583
|
+
ids: s.getSelectedItems()
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
case "SELECT_ID":
|
|
587
|
+
return {
|
|
588
|
+
...state,
|
|
589
|
+
selection: {
|
|
590
|
+
...state.selection,
|
|
591
|
+
ids: [
|
|
592
|
+
action.id
|
|
593
|
+
]
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
case "STEP_UP":
|
|
597
|
+
var s3 = $974b6ba4b06bc58f$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
|
|
598
|
+
var f = s3.getFocus();
|
|
599
|
+
if (action.shift) s3.extend(f - 1);
|
|
600
|
+
else s3.select(f - 1);
|
|
601
|
+
return {
|
|
602
|
+
...state,
|
|
603
|
+
selection: {
|
|
604
|
+
data: s3.serialize(),
|
|
605
|
+
ids: s3.getSelectedItems()
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
case "STEP_DOWN":
|
|
609
|
+
var s6 = $974b6ba4b06bc58f$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
|
|
610
|
+
var f2 = s6.getFocus();
|
|
611
|
+
if (action.shift) s6.extend(f2 + 1);
|
|
612
|
+
else s6.select(f2 + 1);
|
|
613
|
+
return {
|
|
614
|
+
...state,
|
|
615
|
+
selection: {
|
|
616
|
+
data: s6.serialize(),
|
|
617
|
+
ids: s6.getSelectedItems()
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
case "SET_VISIBLE_IDS":
|
|
621
|
+
// The visible ids changed
|
|
622
|
+
var ids = state.selection.ids;
|
|
623
|
+
// Start with a blank selection
|
|
624
|
+
var s2 = new $974b6ba4b06bc58f$export$52baac22726c72bf([], null, "none", state.visibleIds);
|
|
625
|
+
// Add each of the old selected ids to this new selection
|
|
626
|
+
for (let id of ids)if (id in action.idMap) s2.multiSelect(action.idMap[id]);
|
|
627
|
+
return {
|
|
628
|
+
...state,
|
|
629
|
+
visibleIds: action.ids,
|
|
630
|
+
selection: {
|
|
631
|
+
ids: ids,
|
|
632
|
+
data: s2.serialize()
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
default:
|
|
636
|
+
return state;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function $da0693b023d53dfe$var$equal(a, b) {
|
|
640
|
+
if (a === null || b === null) return false;
|
|
641
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
function $c63d681a73fa226b$export$de605877a37dc399(ref, api) {
|
|
647
|
+
$foSVk$react.useEffect(()=>{
|
|
648
|
+
const el = ref.current;
|
|
649
|
+
const cb = (e)=>{
|
|
650
|
+
if (e.code === "ArrowDown") {
|
|
651
|
+
e.preventDefault();
|
|
652
|
+
api.selectDownwards(e.shiftKey);
|
|
653
|
+
} else if (e.code === "ArrowUp") {
|
|
654
|
+
e.preventDefault();
|
|
655
|
+
api.selectUpwards(e.shiftKey);
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
el?.addEventListener("keydown", cb);
|
|
659
|
+
return ()=>{
|
|
660
|
+
el?.removeEventListener("keydown", cb);
|
|
661
|
+
};
|
|
662
|
+
}, [
|
|
663
|
+
ref,
|
|
664
|
+
api
|
|
665
|
+
]);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
function $d5c6a0d3e116bf17$export$79f9fa345a841d8b(root) {
|
|
673
|
+
const list = [];
|
|
674
|
+
let index = 0;
|
|
675
|
+
function collect(node) {
|
|
676
|
+
if (node.level >= 0) {
|
|
677
|
+
node.rowIndex = index++;
|
|
678
|
+
list.push(node);
|
|
679
|
+
}
|
|
680
|
+
if (node.isOpen) node.children?.forEach(collect);
|
|
681
|
+
}
|
|
682
|
+
collect(root);
|
|
683
|
+
return list;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
class $f02bc7cefcb30793$export$e2da3477247342d1 {
|
|
689
|
+
constructor(dispatch, state, props, list){
|
|
690
|
+
this.dispatch = dispatch;
|
|
691
|
+
this.state = state;
|
|
692
|
+
this.props = props;
|
|
693
|
+
this.list = list;
|
|
694
|
+
}
|
|
695
|
+
assign(dispatch, state, props, list) {
|
|
696
|
+
this.dispatch = dispatch;
|
|
697
|
+
this.state = state;
|
|
698
|
+
this.props = props;
|
|
699
|
+
this.list = list;
|
|
700
|
+
}
|
|
701
|
+
getNode(id) {
|
|
702
|
+
if (id in this.idToIndex) return this.visibleNodes[this.idToIndex[id]] || null;
|
|
703
|
+
else return null;
|
|
704
|
+
}
|
|
705
|
+
getSelectedIds() {
|
|
706
|
+
return this.state.selection.ids;
|
|
707
|
+
}
|
|
708
|
+
edit(id) {
|
|
709
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.edit(id ? id.toString() : null));
|
|
710
|
+
}
|
|
711
|
+
select(index, meta, shift) {
|
|
712
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.select(index, meta, shift));
|
|
713
|
+
}
|
|
714
|
+
selectUpwards(shiftKey) {
|
|
715
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.stepUp(shiftKey, this.visibleIds));
|
|
716
|
+
}
|
|
717
|
+
selectDownwards(shiftKey) {
|
|
718
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.stepDown(shiftKey, this.visibleIds));
|
|
719
|
+
}
|
|
720
|
+
hideCursor() {
|
|
721
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.setCursorLocation({
|
|
722
|
+
type: "none"
|
|
723
|
+
}));
|
|
724
|
+
}
|
|
725
|
+
showCursor(cursor) {
|
|
726
|
+
this.dispatch($da0693b023d53dfe$export$e324594224ef24da.setCursorLocation(cursor));
|
|
727
|
+
}
|
|
728
|
+
scrollToId(id) {
|
|
729
|
+
if (!this.list) return;
|
|
730
|
+
const index1 = this.idToIndex[id];
|
|
731
|
+
if (index1) this.list.scrollToItem(index1, "start");
|
|
732
|
+
else {
|
|
733
|
+
this.openParents(id);
|
|
734
|
+
// This appears to be synchronous
|
|
735
|
+
// But I've only tested it in the console and
|
|
736
|
+
// not in an event handler which will be batched...
|
|
737
|
+
// We may need to wrap this in a timeout or trigger an effect somehow
|
|
738
|
+
setTimeout(()=>{
|
|
739
|
+
const index = this.idToIndex[id];
|
|
740
|
+
if (index) this.list?.scrollToItem(index, "start");
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
open(id) {
|
|
745
|
+
this.props.onToggle(id, true);
|
|
746
|
+
}
|
|
747
|
+
openParents(id) {
|
|
748
|
+
const node = $f02bc7cefcb30793$var$dfs(this.props.root, id);
|
|
749
|
+
let parent = node?.parent;
|
|
750
|
+
while(parent){
|
|
751
|
+
this.open(parent.id);
|
|
752
|
+
parent = parent.parent;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
get visibleIds() {
|
|
756
|
+
return $f02bc7cefcb30793$var$getIds(this.visibleNodes);
|
|
757
|
+
}
|
|
758
|
+
get idToIndex() {
|
|
759
|
+
return $f02bc7cefcb30793$var$createIndex(this.visibleNodes);
|
|
760
|
+
}
|
|
761
|
+
get visibleNodes() {
|
|
762
|
+
return $f02bc7cefcb30793$var$createList(this.props.root);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const $f02bc7cefcb30793$var$getIds = ($parcel$interopDefault($foSVk$memoizeone))((nodes)=>nodes.map((n)=>n.id
|
|
766
|
+
)
|
|
767
|
+
);
|
|
768
|
+
const $f02bc7cefcb30793$var$createIndex = ($parcel$interopDefault($foSVk$memoizeone))((nodes)=>{
|
|
769
|
+
return nodes.reduce((map, node, index)=>{
|
|
770
|
+
map[node.id] = index;
|
|
771
|
+
return map;
|
|
772
|
+
}, {
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
const $f02bc7cefcb30793$var$createList = ($parcel$interopDefault($foSVk$memoizeone))($d5c6a0d3e116bf17$export$79f9fa345a841d8b);
|
|
776
|
+
function $f02bc7cefcb30793$var$dfs(node, id) {
|
|
777
|
+
if (!node) return null;
|
|
778
|
+
if (node.id === id) return node;
|
|
779
|
+
if (node.children) for (let child of node.children){
|
|
780
|
+
const result = $f02bc7cefcb30793$var$dfs(child, id);
|
|
781
|
+
if (result) return result;
|
|
782
|
+
}
|
|
783
|
+
return null;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
function $bf7f5844af5991a0$export$367b0f2231a90ba0(state, dispatch, props, list) {
|
|
788
|
+
/**
|
|
789
|
+
* We only ever want one instance of the api object
|
|
790
|
+
* It will get updated as the props change, but the
|
|
791
|
+
* reference will not.
|
|
792
|
+
*/ const api = $foSVk$react.useMemo(()=>new $f02bc7cefcb30793$export$e2da3477247342d1(dispatch, state, props, list)
|
|
793
|
+
, // eslint-disable-next-line
|
|
794
|
+
[]);
|
|
795
|
+
api.assign(dispatch, state, props, list);
|
|
796
|
+
/**
|
|
797
|
+
* This ensures that the selection remains correct even
|
|
798
|
+
* after opening and closing a folders
|
|
799
|
+
*/ $foSVk$react.useLayoutEffect(()=>{
|
|
800
|
+
dispatch($da0693b023d53dfe$export$e324594224ef24da.setVisibleIds(api.visibleIds, api.idToIndex));
|
|
801
|
+
}, [
|
|
802
|
+
dispatch,
|
|
803
|
+
api,
|
|
804
|
+
props.root
|
|
805
|
+
]);
|
|
806
|
+
return api;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
function $59c6116b7d090f1c$export$6a399b2f7f12632c(props) {
|
|
811
|
+
const [state, dispatch] = $foSVk$react.useReducer($da0693b023d53dfe$export$1650419e431d3ba3, $da0693b023d53dfe$export$f6196a6c6bb539b4());
|
|
812
|
+
const list = $foSVk$react.useRef();
|
|
813
|
+
const api = $bf7f5844af5991a0$export$367b0f2231a90ba0(state, dispatch, props, list.current);
|
|
814
|
+
$foSVk$react.useImperativeHandle(props.imperativeHandle, ()=>api
|
|
815
|
+
);
|
|
816
|
+
$c63d681a73fa226b$export$de605877a37dc399(props.listEl, api);
|
|
817
|
+
const staticValue = $foSVk$react.useMemo(()=>({
|
|
818
|
+
...props,
|
|
819
|
+
api: api,
|
|
820
|
+
list: list
|
|
821
|
+
})
|
|
822
|
+
, [
|
|
823
|
+
props,
|
|
824
|
+
api,
|
|
825
|
+
list
|
|
826
|
+
]);
|
|
827
|
+
/**
|
|
828
|
+
* This context pattern is ridiculous, next time use redux.
|
|
829
|
+
*/ return(// @ts-ignore
|
|
830
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$c1b9a1d3af45b7b6.Provider, {
|
|
831
|
+
value: staticValue,
|
|
832
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$7f994e57c9e78355.Provider, {
|
|
833
|
+
value: state.editingId,
|
|
834
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$7c7a4fd7f1336e2c.Provider, {
|
|
835
|
+
value: state.selection,
|
|
836
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$7380e5d4146ff2ce.Provider, {
|
|
837
|
+
value: $59c6116b7d090f1c$var$getParentId(state.cursor),
|
|
838
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$86fe4415b73783a1.Provider, {
|
|
839
|
+
value: $59c6116b7d090f1c$var$isOverFolder(state),
|
|
840
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($6723c76b9de38fd1$export$76f51715425ee155.Provider, {
|
|
841
|
+
value: state.cursor,
|
|
842
|
+
children: props.children
|
|
843
|
+
})
|
|
844
|
+
})
|
|
845
|
+
})
|
|
846
|
+
})
|
|
847
|
+
})
|
|
848
|
+
}));
|
|
849
|
+
}
|
|
850
|
+
function $59c6116b7d090f1c$var$getParentId(cursor) {
|
|
851
|
+
switch(cursor.type){
|
|
852
|
+
case "highlight":
|
|
853
|
+
return cursor.id;
|
|
854
|
+
default:
|
|
855
|
+
return null;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function $59c6116b7d090f1c$var$isOverFolder(state) {
|
|
859
|
+
return state.cursor.type === "highlight";
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
function $8fbadd7be430f501$export$ef961593063b03e8() {
|
|
868
|
+
const treeView = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
869
|
+
const cursor = $6723c76b9de38fd1$export$6c87584817ff2461();
|
|
870
|
+
if (!cursor || cursor.type !== "line") return null;
|
|
871
|
+
const top = treeView.rowHeight * cursor.index;
|
|
872
|
+
const left = treeView.indent * cursor.level;
|
|
873
|
+
const style = {
|
|
874
|
+
position: "absolute",
|
|
875
|
+
pointerEvents: "none",
|
|
876
|
+
top: top - 2 + "px",
|
|
877
|
+
left: treeView.indent + left + "px",
|
|
878
|
+
right: treeView.indent + "px"
|
|
879
|
+
};
|
|
880
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8fbadd7be430f501$var$DefaultCursor, {
|
|
881
|
+
style: style
|
|
882
|
+
}));
|
|
883
|
+
}
|
|
884
|
+
const $8fbadd7be430f501$var$placeholderStyle = {
|
|
885
|
+
display: "flex",
|
|
886
|
+
alignItems: "center"
|
|
887
|
+
};
|
|
888
|
+
const $8fbadd7be430f501$var$lineStyle = {
|
|
889
|
+
flex: 1,
|
|
890
|
+
height: "2px",
|
|
891
|
+
background: "#4B91E2",
|
|
892
|
+
borderRadius: "1px"
|
|
893
|
+
};
|
|
894
|
+
const $8fbadd7be430f501$var$circleStyle = {
|
|
895
|
+
width: "4px",
|
|
896
|
+
height: "4px",
|
|
897
|
+
boxShadow: "0 0 0 3px #4B91E2",
|
|
898
|
+
borderRadius: "50%"
|
|
899
|
+
};
|
|
900
|
+
function $8fbadd7be430f501$var$DefaultCursor({ style: style }) {
|
|
901
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsxs("div", {
|
|
902
|
+
style: {
|
|
903
|
+
...$8fbadd7be430f501$var$placeholderStyle,
|
|
904
|
+
...style
|
|
905
|
+
},
|
|
906
|
+
children: [
|
|
907
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
908
|
+
style: {
|
|
909
|
+
...$8fbadd7be430f501$var$circleStyle
|
|
910
|
+
}
|
|
911
|
+
}),
|
|
912
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
913
|
+
style: {
|
|
914
|
+
...$8fbadd7be430f501$var$lineStyle
|
|
915
|
+
}
|
|
916
|
+
})
|
|
917
|
+
]
|
|
918
|
+
}));
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
const $8317ba945ccd0ce3$var$layerStyles = {
|
|
927
|
+
position: "fixed",
|
|
928
|
+
pointerEvents: "none",
|
|
929
|
+
zIndex: 100,
|
|
930
|
+
left: 0,
|
|
931
|
+
top: 0,
|
|
932
|
+
width: "100%",
|
|
933
|
+
height: "100%"
|
|
934
|
+
};
|
|
935
|
+
const $8317ba945ccd0ce3$var$getStyle = (offset)=>{
|
|
936
|
+
if (!offset) return {
|
|
937
|
+
display: "none"
|
|
938
|
+
};
|
|
939
|
+
const { x: x , y: y } = offset;
|
|
940
|
+
return {
|
|
941
|
+
transform: `translate(${x}px, ${y}px)`
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
const $8317ba945ccd0ce3$var$getCountStyle = (offset)=>{
|
|
945
|
+
if (!offset) return {
|
|
946
|
+
display: "none"
|
|
947
|
+
};
|
|
948
|
+
const { x: x , y: y } = offset;
|
|
949
|
+
return {
|
|
950
|
+
transform: `translate(${x + 10}px, ${y + 10}px)`
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
function $8317ba945ccd0ce3$export$133773870222880f() {
|
|
954
|
+
const { offset: offset , mouse: mouse , item: item , isDragging: isDragging } = $foSVk$reactdnd.useDragLayer((m)=>({
|
|
955
|
+
offset: m.getSourceClientOffset(),
|
|
956
|
+
mouse: m.getClientOffset(),
|
|
957
|
+
item: m.getItem(),
|
|
958
|
+
isDragging: m.isDragging()
|
|
959
|
+
})
|
|
960
|
+
);
|
|
961
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsxs($8317ba945ccd0ce3$var$Overlay, {
|
|
962
|
+
isDragging: isDragging,
|
|
963
|
+
children: [
|
|
964
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8317ba945ccd0ce3$var$Position, {
|
|
965
|
+
offset: offset,
|
|
966
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8317ba945ccd0ce3$var$PreviewNode, {
|
|
967
|
+
item: item
|
|
968
|
+
})
|
|
969
|
+
}),
|
|
970
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8317ba945ccd0ce3$var$Count, {
|
|
971
|
+
mouse: mouse,
|
|
972
|
+
item: item
|
|
973
|
+
})
|
|
974
|
+
]
|
|
975
|
+
}));
|
|
976
|
+
}
|
|
977
|
+
const $8317ba945ccd0ce3$var$Overlay = /*#__PURE__*/ $foSVk$react.memo(function Overlay(props) {
|
|
978
|
+
if (!props.isDragging) return null;
|
|
979
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
980
|
+
style: $8317ba945ccd0ce3$var$layerStyles,
|
|
981
|
+
children: props.children
|
|
982
|
+
}));
|
|
983
|
+
});
|
|
984
|
+
function $8317ba945ccd0ce3$var$Position(props) {
|
|
985
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
986
|
+
className: "row preview",
|
|
987
|
+
style: $8317ba945ccd0ce3$var$getStyle(props.offset),
|
|
988
|
+
children: props.children
|
|
989
|
+
}));
|
|
990
|
+
}
|
|
991
|
+
function $8317ba945ccd0ce3$var$Count(props) {
|
|
992
|
+
const { item: item , mouse: mouse } = props;
|
|
993
|
+
if (item?.dragIds?.length > 1) return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
994
|
+
className: "selected-count",
|
|
995
|
+
style: $8317ba945ccd0ce3$var$getCountStyle(mouse),
|
|
996
|
+
children: item.dragIds.length
|
|
997
|
+
}));
|
|
998
|
+
else return null;
|
|
999
|
+
}
|
|
1000
|
+
const $8317ba945ccd0ce3$var$PreviewNode = /*#__PURE__*/ $foSVk$react.memo(function PreviewNode(props) {
|
|
1001
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1002
|
+
if (!props.item) return null;
|
|
1003
|
+
const node = tree.api.getNode(props.item.id);
|
|
1004
|
+
if (!node) return null;
|
|
1005
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx(tree.renderer, {
|
|
1006
|
+
preview: true,
|
|
1007
|
+
innerRef: ()=>{
|
|
1008
|
+
},
|
|
1009
|
+
data: node.model,
|
|
1010
|
+
styles: {
|
|
1011
|
+
row: {
|
|
1012
|
+
},
|
|
1013
|
+
indent: {
|
|
1014
|
+
paddingLeft: node.level * tree.indent
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
tree: tree.api,
|
|
1018
|
+
state: {
|
|
1019
|
+
isDragging: false,
|
|
1020
|
+
isEditing: false,
|
|
1021
|
+
isSelected: false,
|
|
1022
|
+
isFirstOfSelected: false,
|
|
1023
|
+
isLastOfSelected: false,
|
|
1024
|
+
isHoveringOverChild: false,
|
|
1025
|
+
isOpen: node.isOpen
|
|
1026
|
+
},
|
|
1027
|
+
handlers: {
|
|
1028
|
+
edit: ()=>{
|
|
1029
|
+
},
|
|
1030
|
+
select: ()=>{
|
|
1031
|
+
},
|
|
1032
|
+
toggle: ()=>{
|
|
1033
|
+
},
|
|
1034
|
+
submit: ()=>{
|
|
1035
|
+
},
|
|
1036
|
+
reset: ()=>{
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}));
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
function $74bee24dbb0f3e2b$export$715c0d031ede7907(node) {
|
|
1051
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1052
|
+
const isSelected = $6723c76b9de38fd1$export$fb40a80c530e5f2b();
|
|
1053
|
+
const ids = $6723c76b9de38fd1$export$1c9b7756eccadc96();
|
|
1054
|
+
const [{ isDragging: isDragging }, ref, preview] = $foSVk$reactdnd.useDrag(()=>({
|
|
1055
|
+
canDrag: ()=>node.isDraggable
|
|
1056
|
+
,
|
|
1057
|
+
type: "NODE",
|
|
1058
|
+
item: ()=>({
|
|
1059
|
+
id: node.id,
|
|
1060
|
+
dragIds: isSelected(node.rowIndex) ? ids : [
|
|
1061
|
+
node.id
|
|
1062
|
+
]
|
|
1063
|
+
})
|
|
1064
|
+
,
|
|
1065
|
+
collect: (m)=>({
|
|
1066
|
+
isDragging: m.isDragging()
|
|
1067
|
+
})
|
|
1068
|
+
,
|
|
1069
|
+
end: (item, monitor)=>{
|
|
1070
|
+
tree.api.hideCursor();
|
|
1071
|
+
const drop = monitor.getDropResult();
|
|
1072
|
+
if (drop && drop.parentId) {
|
|
1073
|
+
tree.onMove(item.dragIds, drop.parentId, drop.index);
|
|
1074
|
+
tree.onToggle(drop.parentId, true);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
})
|
|
1078
|
+
, [
|
|
1079
|
+
ids,
|
|
1080
|
+
node
|
|
1081
|
+
]);
|
|
1082
|
+
$foSVk$react.useEffect(()=>{
|
|
1083
|
+
preview($foSVk$reactdndhtml5backend.getEmptyImage());
|
|
1084
|
+
}, [
|
|
1085
|
+
preview
|
|
1086
|
+
]);
|
|
1087
|
+
return [
|
|
1088
|
+
{
|
|
1089
|
+
isDragging: isDragging
|
|
1090
|
+
},
|
|
1091
|
+
ref
|
|
1092
|
+
];
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
function $cf8ebdb33758b119$export$57afafec4637d997(el, node, prev, next) {
|
|
1101
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1102
|
+
return $foSVk$reactdnd.useDrop(()=>({
|
|
1103
|
+
accept: "NODE",
|
|
1104
|
+
canDrop: (item)=>{
|
|
1105
|
+
for (let id of item.dragIds){
|
|
1106
|
+
const drag = tree.api.getNode(id);
|
|
1107
|
+
if (!drag) return false;
|
|
1108
|
+
if ($eb5355379510ac9b$export$769c5e872f5f8638(drag) && $eb5355379510ac9b$export$1e38f72c6c546f70(node, drag)) return false;
|
|
1109
|
+
}
|
|
1110
|
+
return true;
|
|
1111
|
+
},
|
|
1112
|
+
hover: (item, m)=>{
|
|
1113
|
+
if (m.canDrop()) {
|
|
1114
|
+
const offset = m.getClientOffset();
|
|
1115
|
+
if (!el.current || !offset) return;
|
|
1116
|
+
const { cursor: cursor } = $462841de7cc5b715$export$f502ca02ebb85a1c({
|
|
1117
|
+
element: el.current,
|
|
1118
|
+
offset: offset,
|
|
1119
|
+
indent: tree.indent,
|
|
1120
|
+
node: node,
|
|
1121
|
+
prevNode: prev,
|
|
1122
|
+
nextNode: next
|
|
1123
|
+
});
|
|
1124
|
+
if (cursor) tree.api.showCursor(cursor);
|
|
1125
|
+
} else tree.api.hideCursor();
|
|
1126
|
+
},
|
|
1127
|
+
drop: (item, m)=>{
|
|
1128
|
+
const offset = m.getClientOffset();
|
|
1129
|
+
if (!el.current || !offset) return;
|
|
1130
|
+
const { drop: drop } = $462841de7cc5b715$export$f502ca02ebb85a1c({
|
|
1131
|
+
element: el.current,
|
|
1132
|
+
offset: offset,
|
|
1133
|
+
indent: tree.indent,
|
|
1134
|
+
node: node,
|
|
1135
|
+
prevNode: prev,
|
|
1136
|
+
nextNode: next
|
|
1137
|
+
});
|
|
1138
|
+
return drop;
|
|
1139
|
+
}
|
|
1140
|
+
})
|
|
1141
|
+
, [
|
|
1142
|
+
node,
|
|
1143
|
+
prev,
|
|
1144
|
+
el,
|
|
1145
|
+
tree
|
|
1146
|
+
]);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
const $9a2860bfaab93091$export$b59bdbef9ce70de2 = /*#__PURE__*/ ($parcel$interopDefault($foSVk$react)).memo(function $9a2860bfaab93091$export$b59bdbef9ce70de2({ index: index , style: style }) {
|
|
1151
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1152
|
+
const selected = $6723c76b9de38fd1$export$fb40a80c530e5f2b();
|
|
1153
|
+
const node = tree.api.visibleNodes[index];
|
|
1154
|
+
const next = tree.api.visibleNodes[index + 1] || null;
|
|
1155
|
+
const prev = tree.api.visibleNodes[index - 1] || null;
|
|
1156
|
+
const cursorParentId = $6723c76b9de38fd1$export$8e294ac6de4c921f();
|
|
1157
|
+
const cursorOverFolder = $6723c76b9de38fd1$export$f3ad962ff713505f();
|
|
1158
|
+
const el = $foSVk$react.useRef(null);
|
|
1159
|
+
const [{ isDragging: isDragging }, dragRef] = $74bee24dbb0f3e2b$export$715c0d031ede7907(node);
|
|
1160
|
+
const [, dropRef] = $cf8ebdb33758b119$export$57afafec4637d997(el, node, prev, next);
|
|
1161
|
+
const isEditing = node.id === $6723c76b9de38fd1$export$9ab192f953c1b33b();
|
|
1162
|
+
const isSelected = selected(index);
|
|
1163
|
+
const nextSelected = next && selected(index + 1);
|
|
1164
|
+
const prevSelected = prev && selected(index - 1);
|
|
1165
|
+
const isHoveringOverChild = node.id === cursorParentId;
|
|
1166
|
+
const isOverFolder = node.id === cursorParentId && cursorOverFolder;
|
|
1167
|
+
const isOpen = node.isOpen;
|
|
1168
|
+
const indent = tree.indent * node.level;
|
|
1169
|
+
const state = $foSVk$react.useMemo(()=>{
|
|
1170
|
+
return {
|
|
1171
|
+
isEditing: isEditing,
|
|
1172
|
+
isDragging: isDragging,
|
|
1173
|
+
isFirstOfSelected: isSelected && !prevSelected,
|
|
1174
|
+
isLastOfSelected: isSelected && !nextSelected,
|
|
1175
|
+
isSelected: isSelected,
|
|
1176
|
+
isHoveringOverChild: isHoveringOverChild,
|
|
1177
|
+
isOpen: isOpen,
|
|
1178
|
+
isOverFolder: isOverFolder
|
|
1179
|
+
};
|
|
1180
|
+
}, [
|
|
1181
|
+
isEditing,
|
|
1182
|
+
isSelected,
|
|
1183
|
+
prevSelected,
|
|
1184
|
+
nextSelected,
|
|
1185
|
+
isHoveringOverChild,
|
|
1186
|
+
isOpen,
|
|
1187
|
+
isDragging,
|
|
1188
|
+
isOverFolder,
|
|
1189
|
+
]);
|
|
1190
|
+
if (isSelected) console.log({
|
|
1191
|
+
id: node.id,
|
|
1192
|
+
state: state
|
|
1193
|
+
});
|
|
1194
|
+
const ref = $foSVk$react.useCallback((n)=>{
|
|
1195
|
+
el.current = n;
|
|
1196
|
+
dragRef(dropRef(n));
|
|
1197
|
+
}, [
|
|
1198
|
+
dragRef,
|
|
1199
|
+
dropRef
|
|
1200
|
+
]);
|
|
1201
|
+
const styles = $foSVk$react.useMemo(()=>({
|
|
1202
|
+
row: {
|
|
1203
|
+
...style
|
|
1204
|
+
},
|
|
1205
|
+
indent: {
|
|
1206
|
+
paddingLeft: indent
|
|
1207
|
+
}
|
|
1208
|
+
})
|
|
1209
|
+
, [
|
|
1210
|
+
indent,
|
|
1211
|
+
style
|
|
1212
|
+
]);
|
|
1213
|
+
const handlers = $foSVk$react.useMemo(()=>{
|
|
1214
|
+
return {
|
|
1215
|
+
select: (e, selectOnClick = true)=>{
|
|
1216
|
+
if (node.rowIndex === null) return;
|
|
1217
|
+
if (selectOnClick || e.metaKey || e.shiftKey) tree.api.select(node.rowIndex, e.metaKey, e.shiftKey);
|
|
1218
|
+
else tree.api.select(null, false, false);
|
|
1219
|
+
},
|
|
1220
|
+
toggle: (e)=>{
|
|
1221
|
+
e.stopPropagation();
|
|
1222
|
+
tree.onToggle(node.id, !node.isOpen);
|
|
1223
|
+
},
|
|
1224
|
+
edit: ()=>{
|
|
1225
|
+
tree.api.edit(node.id);
|
|
1226
|
+
},
|
|
1227
|
+
submit: (name)=>{
|
|
1228
|
+
if (name.trim()) tree.onEdit(node.id, name);
|
|
1229
|
+
tree.api.edit(null);
|
|
1230
|
+
},
|
|
1231
|
+
reset: ()=>{
|
|
1232
|
+
tree.api.edit(null);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
}, [
|
|
1236
|
+
tree,
|
|
1237
|
+
node
|
|
1238
|
+
]);
|
|
1239
|
+
const Renderer = $foSVk$react.useMemo(()=>{
|
|
1240
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($foSVk$react)).memo(tree.renderer));
|
|
1241
|
+
}, [
|
|
1242
|
+
tree.renderer
|
|
1243
|
+
]);
|
|
1244
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx(Renderer, {
|
|
1245
|
+
innerRef: ref,
|
|
1246
|
+
data: node.model,
|
|
1247
|
+
styles: styles,
|
|
1248
|
+
state: state,
|
|
1249
|
+
handlers: handlers,
|
|
1250
|
+
preview: false,
|
|
1251
|
+
tree: tree.api
|
|
1252
|
+
}));
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
const $641461e16d1a2941$var$OuterElement = /*#__PURE__*/ $foSVk$react.forwardRef(function Outer(props, ref) {
|
|
1257
|
+
const { children: children , ...rest } = props;
|
|
1258
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1259
|
+
return(// @ts-ignore
|
|
1260
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsxs("div", {
|
|
1261
|
+
ref: ref,
|
|
1262
|
+
...rest,
|
|
1263
|
+
onClick: tree.onClick,
|
|
1264
|
+
children: [
|
|
1265
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
1266
|
+
style: {
|
|
1267
|
+
height: tree.api.visibleNodes.length * tree.rowHeight,
|
|
1268
|
+
width: "100%",
|
|
1269
|
+
overflow: "hidden",
|
|
1270
|
+
position: "absolute",
|
|
1271
|
+
left: "0",
|
|
1272
|
+
right: "0"
|
|
1273
|
+
},
|
|
1274
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8fbadd7be430f501$export$ef961593063b03e8, {
|
|
1275
|
+
})
|
|
1276
|
+
}),
|
|
1277
|
+
children
|
|
1278
|
+
]
|
|
1279
|
+
}));
|
|
1280
|
+
});
|
|
1281
|
+
function $641461e16d1a2941$var$List(props) {
|
|
1282
|
+
const tree = $6723c76b9de38fd1$export$ea6c3ae2bd3a5510();
|
|
1283
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx("div", {
|
|
1284
|
+
style: {
|
|
1285
|
+
height: tree.height,
|
|
1286
|
+
width: tree.width,
|
|
1287
|
+
overflow: "hidden"
|
|
1288
|
+
},
|
|
1289
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($foSVk$reactwindow.FixedSizeList, {
|
|
1290
|
+
className: props.className,
|
|
1291
|
+
outerRef: tree.listEl,
|
|
1292
|
+
itemCount: tree.api.visibleNodes.length,
|
|
1293
|
+
height: tree.height,
|
|
1294
|
+
width: tree.width,
|
|
1295
|
+
itemSize: tree.rowHeight,
|
|
1296
|
+
itemKey: (index)=>tree.api.visibleNodes[index]?.id || index
|
|
1297
|
+
,
|
|
1298
|
+
outerElementType: $641461e16d1a2941$var$OuterElement,
|
|
1299
|
+
// @ts-ignore
|
|
1300
|
+
ref: tree.list,
|
|
1301
|
+
children: $9a2860bfaab93091$export$b59bdbef9ce70de2
|
|
1302
|
+
})
|
|
1303
|
+
}));
|
|
1304
|
+
}
|
|
1305
|
+
function $641461e16d1a2941$var$OuterDrop(props) {
|
|
1306
|
+
$6c0a9a91d5e7ff45$export$5a6c424b1725f44f();
|
|
1307
|
+
return props.children;
|
|
1308
|
+
}
|
|
1309
|
+
const $641461e16d1a2941$export$7fbedc92909ed28e = /*#__PURE__*/ $foSVk$react.forwardRef(function $641461e16d1a2941$export$7fbedc92909ed28e(props, ref) {
|
|
1310
|
+
const root = $foSVk$react.useMemo(()=>$2d914ccbe0a16edd$export$9c537176392280a0(props.data, props.hideRoot, props.getChildren, props.isOpen, props.disableDrag, props.disableDrop, props.openByDefault)
|
|
1311
|
+
, [
|
|
1312
|
+
props.data,
|
|
1313
|
+
props.hideRoot,
|
|
1314
|
+
props.getChildren,
|
|
1315
|
+
props.isOpen,
|
|
1316
|
+
props.disableDrag,
|
|
1317
|
+
props.disableDrop,
|
|
1318
|
+
props.openByDefault,
|
|
1319
|
+
]);
|
|
1320
|
+
return(/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($59c6116b7d090f1c$export$6a399b2f7f12632c, {
|
|
1321
|
+
imperativeHandle: ref,
|
|
1322
|
+
root: root,
|
|
1323
|
+
listEl: $foSVk$react.useRef(null),
|
|
1324
|
+
renderer: props.children,
|
|
1325
|
+
width: props.width === undefined ? 300 : props.width,
|
|
1326
|
+
height: props.height === undefined ? 500 : props.height,
|
|
1327
|
+
indent: props.indent === undefined ? 24 : props.indent,
|
|
1328
|
+
rowHeight: props.rowHeight === undefined ? 24 : props.rowHeight,
|
|
1329
|
+
onMove: props.onMove || $eb5355379510ac9b$export$8793edee2d425525,
|
|
1330
|
+
onToggle: props.onToggle || $eb5355379510ac9b$export$8793edee2d425525,
|
|
1331
|
+
onEdit: props.onEdit || $eb5355379510ac9b$export$8793edee2d425525,
|
|
1332
|
+
onClick: props.onClick,
|
|
1333
|
+
onContextMenu: props.onContextMenu,
|
|
1334
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsxs($foSVk$reactdnd.DndProvider, {
|
|
1335
|
+
backend: $foSVk$reactdndhtml5backend.HTML5Backend,
|
|
1336
|
+
children: [
|
|
1337
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($641461e16d1a2941$var$OuterDrop, {
|
|
1338
|
+
children: /*#__PURE__*/ $foSVk$reactjsxruntime.jsx($641461e16d1a2941$var$List, {
|
|
1339
|
+
className: props.className,
|
|
1340
|
+
onClick: props.onClick
|
|
1341
|
+
})
|
|
1342
|
+
}),
|
|
1343
|
+
/*#__PURE__*/ $foSVk$reactjsxruntime.jsx($8317ba945ccd0ce3$export$133773870222880f, {
|
|
1344
|
+
})
|
|
1345
|
+
]
|
|
1346
|
+
})
|
|
1347
|
+
}));
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
//# sourceMappingURL=index.js.map
|