@limble/limble-tree 0.12.4 → 0.13.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/README.md +149 -149
- package/{esm2015/lib/classes/Branch.js → esm2020/lib/classes/Branch.mjs} +1 -1
- package/{esm2015/lib/classes/DropZone.js → esm2020/lib/classes/DropZone.mjs} +1 -1
- package/{esm2015/lib/classes/DropZoneLocation.js → esm2020/lib/classes/DropZoneLocation.mjs} +1 -1
- package/{esm2015/lib/custom-event-bindings/dragleave-no-change-detect.directive.js → esm2020/lib/custom-event-bindings/dragleave-no-change-detect.directive.mjs} +0 -0
- package/{esm2015/lib/custom-event-bindings/dragover-no-change-detect.directive.js → esm2020/lib/custom-event-bindings/dragover-no-change-detect.directive.mjs} +1 -1
- package/esm2020/lib/drop-zone/drop-zone.component.mjs +75 -0
- package/esm2020/lib/limble-tree-branch/limble-tree-branch.component.mjs +110 -0
- package/esm2020/lib/limble-tree-node/limble-tree-node.component.mjs +467 -0
- package/{esm2015/lib/limble-tree-placeholder/limble-tree-placeholder.component.js → esm2020/lib/limble-tree-placeholder/limble-tree-placeholder.component.mjs} +3 -8
- package/esm2020/lib/limble-tree-root/drop-zone.service.mjs +376 -0
- package/esm2020/lib/limble-tree-root/limble-tree-root.component.mjs +172 -0
- package/{esm2015/lib/limble-tree-root/tree-construction-status.service.js → esm2020/lib/limble-tree-root/tree-construction-status.service.mjs} +1 -1
- package/esm2020/lib/limble-tree-root/tree.service.mjs +297 -0
- package/{esm2015/lib/limble-tree.module.js → esm2020/lib/limble-tree.module.mjs} +5 -5
- package/{esm2015/lib/singletons/component-creator.service.js → esm2020/lib/singletons/component-creator.service.mjs} +1 -1
- package/esm2020/lib/singletons/drag-state.service.mjs +63 -0
- package/esm2020/lib/singletons/global-events.service.mjs +136 -0
- package/{esm2015/lib/util.js → esm2020/lib/util.mjs} +1 -1
- package/{esm2015/limble-limble-tree.js → esm2020/limble-limble-tree.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +1 -1
- package/fesm2015/limble-limble-tree.mjs +2256 -0
- package/fesm2015/limble-limble-tree.mjs.map +1 -0
- package/{fesm2015/limble-limble-tree.js → fesm2020/limble-limble-tree.mjs} +89 -136
- package/fesm2020/limble-limble-tree.mjs.map +1 -0
- package/{limble-limble-tree.d.ts → index.d.ts} +0 -0
- package/lib/custom-event-bindings/dragleave-no-change-detect.directive.d.ts +1 -1
- package/lib/custom-event-bindings/dragover-no-change-detect.directive.d.ts +1 -1
- package/lib/drop-zone/drop-zone.component.d.ts +1 -1
- package/lib/limble-tree-branch/limble-tree-branch.component.d.ts +1 -1
- package/lib/limble-tree-node/limble-tree-node.component.d.ts +1 -1
- package/lib/limble-tree-placeholder/limble-tree-placeholder.component.d.ts +1 -1
- package/lib/limble-tree-root/limble-tree-root.component.d.ts +1 -1
- package/package.json +22 -9
- package/bundles/limble-limble-tree.umd.js +0 -2910
- package/bundles/limble-limble-tree.umd.js.map +0 -1
- package/esm2015/lib/drop-zone/drop-zone.component.js +0 -81
- package/esm2015/lib/limble-tree-branch/limble-tree-branch.component.js +0 -116
- package/esm2015/lib/limble-tree-node/limble-tree-node.component.js +0 -484
- package/esm2015/lib/limble-tree-root/drop-zone.service.js +0 -377
- package/esm2015/lib/limble-tree-root/limble-tree-root.component.js +0 -178
- package/esm2015/lib/limble-tree-root/tree.service.js +0 -301
- package/esm2015/lib/singletons/drag-state.service.js +0 -64
- package/esm2015/lib/singletons/global-events.service.js +0 -137
- package/fesm2015/limble-limble-tree.js.map +0 -1
|
@@ -1,2910 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@limble/limble-tree', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.limble = global.limble || {}, global.limble['limble-tree'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.common));
|
|
5
|
-
}(this, (function (exports, i0, rxjs, operators, i2) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n['default'] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
|
-
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
29
|
-
|
|
30
|
-
/*! *****************************************************************************
|
|
31
|
-
Copyright (c) Microsoft Corporation.
|
|
32
|
-
|
|
33
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
34
|
-
purpose with or without fee is hereby granted.
|
|
35
|
-
|
|
36
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
37
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
38
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
39
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
40
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
43
|
-
***************************************************************************** */
|
|
44
|
-
/* global Reflect, Promise */
|
|
45
|
-
var extendStatics = function (d, b) {
|
|
46
|
-
extendStatics = Object.setPrototypeOf ||
|
|
47
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
48
|
-
function (d, b) { for (var p in b)
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
50
|
-
d[p] = b[p]; };
|
|
51
|
-
return extendStatics(d, b);
|
|
52
|
-
};
|
|
53
|
-
function __extends(d, b) {
|
|
54
|
-
if (typeof b !== "function" && b !== null)
|
|
55
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
56
|
-
extendStatics(d, b);
|
|
57
|
-
function __() { this.constructor = d; }
|
|
58
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
59
|
-
}
|
|
60
|
-
var __assign = function () {
|
|
61
|
-
__assign = Object.assign || function __assign(t) {
|
|
62
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
63
|
-
s = arguments[i];
|
|
64
|
-
for (var p in s)
|
|
65
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
66
|
-
t[p] = s[p];
|
|
67
|
-
}
|
|
68
|
-
return t;
|
|
69
|
-
};
|
|
70
|
-
return __assign.apply(this, arguments);
|
|
71
|
-
};
|
|
72
|
-
function __rest(s, e) {
|
|
73
|
-
var t = {};
|
|
74
|
-
for (var p in s)
|
|
75
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
76
|
-
t[p] = s[p];
|
|
77
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
78
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
79
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
80
|
-
t[p[i]] = s[p[i]];
|
|
81
|
-
}
|
|
82
|
-
return t;
|
|
83
|
-
}
|
|
84
|
-
function __decorate(decorators, target, key, desc) {
|
|
85
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
86
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
87
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
88
|
-
else
|
|
89
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
90
|
-
if (d = decorators[i])
|
|
91
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
92
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
93
|
-
}
|
|
94
|
-
function __param(paramIndex, decorator) {
|
|
95
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
96
|
-
}
|
|
97
|
-
function __metadata(metadataKey, metadataValue) {
|
|
98
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
99
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
100
|
-
}
|
|
101
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
102
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
103
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
104
|
-
function fulfilled(value) { try {
|
|
105
|
-
step(generator.next(value));
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
reject(e);
|
|
109
|
-
} }
|
|
110
|
-
function rejected(value) { try {
|
|
111
|
-
step(generator["throw"](value));
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
reject(e);
|
|
115
|
-
} }
|
|
116
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
117
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function __generator(thisArg, body) {
|
|
121
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
122
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
123
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
124
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
125
|
-
function step(op) {
|
|
126
|
-
if (f)
|
|
127
|
-
throw new TypeError("Generator is already executing.");
|
|
128
|
-
while (_)
|
|
129
|
-
try {
|
|
130
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
131
|
-
return t;
|
|
132
|
-
if (y = 0, t)
|
|
133
|
-
op = [op[0] & 2, t.value];
|
|
134
|
-
switch (op[0]) {
|
|
135
|
-
case 0:
|
|
136
|
-
case 1:
|
|
137
|
-
t = op;
|
|
138
|
-
break;
|
|
139
|
-
case 4:
|
|
140
|
-
_.label++;
|
|
141
|
-
return { value: op[1], done: false };
|
|
142
|
-
case 5:
|
|
143
|
-
_.label++;
|
|
144
|
-
y = op[1];
|
|
145
|
-
op = [0];
|
|
146
|
-
continue;
|
|
147
|
-
case 7:
|
|
148
|
-
op = _.ops.pop();
|
|
149
|
-
_.trys.pop();
|
|
150
|
-
continue;
|
|
151
|
-
default:
|
|
152
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
153
|
-
_ = 0;
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
157
|
-
_.label = op[1];
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
161
|
-
_.label = t[1];
|
|
162
|
-
t = op;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
if (t && _.label < t[2]) {
|
|
166
|
-
_.label = t[2];
|
|
167
|
-
_.ops.push(op);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
if (t[2])
|
|
171
|
-
_.ops.pop();
|
|
172
|
-
_.trys.pop();
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
op = body.call(thisArg, _);
|
|
176
|
-
}
|
|
177
|
-
catch (e) {
|
|
178
|
-
op = [6, e];
|
|
179
|
-
y = 0;
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
f = t = 0;
|
|
183
|
-
}
|
|
184
|
-
if (op[0] & 5)
|
|
185
|
-
throw op[1];
|
|
186
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
190
|
-
if (k2 === undefined)
|
|
191
|
-
k2 = k;
|
|
192
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
193
|
-
}) : (function (o, m, k, k2) {
|
|
194
|
-
if (k2 === undefined)
|
|
195
|
-
k2 = k;
|
|
196
|
-
o[k2] = m[k];
|
|
197
|
-
});
|
|
198
|
-
function __exportStar(m, o) {
|
|
199
|
-
for (var p in m)
|
|
200
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
201
|
-
__createBinding(o, m, p);
|
|
202
|
-
}
|
|
203
|
-
function __values(o) {
|
|
204
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
205
|
-
if (m)
|
|
206
|
-
return m.call(o);
|
|
207
|
-
if (o && typeof o.length === "number")
|
|
208
|
-
return {
|
|
209
|
-
next: function () {
|
|
210
|
-
if (o && i >= o.length)
|
|
211
|
-
o = void 0;
|
|
212
|
-
return { value: o && o[i++], done: !o };
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
216
|
-
}
|
|
217
|
-
function __read(o, n) {
|
|
218
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
219
|
-
if (!m)
|
|
220
|
-
return o;
|
|
221
|
-
var i = m.call(o), r, ar = [], e;
|
|
222
|
-
try {
|
|
223
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
224
|
-
ar.push(r.value);
|
|
225
|
-
}
|
|
226
|
-
catch (error) {
|
|
227
|
-
e = { error: error };
|
|
228
|
-
}
|
|
229
|
-
finally {
|
|
230
|
-
try {
|
|
231
|
-
if (r && !r.done && (m = i["return"]))
|
|
232
|
-
m.call(i);
|
|
233
|
-
}
|
|
234
|
-
finally {
|
|
235
|
-
if (e)
|
|
236
|
-
throw e.error;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return ar;
|
|
240
|
-
}
|
|
241
|
-
/** @deprecated */
|
|
242
|
-
function __spread() {
|
|
243
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
244
|
-
ar = ar.concat(__read(arguments[i]));
|
|
245
|
-
return ar;
|
|
246
|
-
}
|
|
247
|
-
/** @deprecated */
|
|
248
|
-
function __spreadArrays() {
|
|
249
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
250
|
-
s += arguments[i].length;
|
|
251
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
252
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
253
|
-
r[k] = a[j];
|
|
254
|
-
return r;
|
|
255
|
-
}
|
|
256
|
-
function __spreadArray(to, from, pack) {
|
|
257
|
-
if (pack || arguments.length === 2)
|
|
258
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
259
|
-
if (ar || !(i in from)) {
|
|
260
|
-
if (!ar)
|
|
261
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
262
|
-
ar[i] = from[i];
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return to.concat(ar || from);
|
|
266
|
-
}
|
|
267
|
-
function __await(v) {
|
|
268
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
269
|
-
}
|
|
270
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
271
|
-
if (!Symbol.asyncIterator)
|
|
272
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
273
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
274
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
275
|
-
function verb(n) { if (g[n])
|
|
276
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
277
|
-
function resume(n, v) { try {
|
|
278
|
-
step(g[n](v));
|
|
279
|
-
}
|
|
280
|
-
catch (e) {
|
|
281
|
-
settle(q[0][3], e);
|
|
282
|
-
} }
|
|
283
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
284
|
-
function fulfill(value) { resume("next", value); }
|
|
285
|
-
function reject(value) { resume("throw", value); }
|
|
286
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
287
|
-
resume(q[0][0], q[0][1]); }
|
|
288
|
-
}
|
|
289
|
-
function __asyncDelegator(o) {
|
|
290
|
-
var i, p;
|
|
291
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
292
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
293
|
-
}
|
|
294
|
-
function __asyncValues(o) {
|
|
295
|
-
if (!Symbol.asyncIterator)
|
|
296
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
297
|
-
var m = o[Symbol.asyncIterator], i;
|
|
298
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
299
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
300
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
301
|
-
}
|
|
302
|
-
function __makeTemplateObject(cooked, raw) {
|
|
303
|
-
if (Object.defineProperty) {
|
|
304
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
cooked.raw = raw;
|
|
308
|
-
}
|
|
309
|
-
return cooked;
|
|
310
|
-
}
|
|
311
|
-
;
|
|
312
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
313
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
314
|
-
}) : function (o, v) {
|
|
315
|
-
o["default"] = v;
|
|
316
|
-
};
|
|
317
|
-
function __importStar(mod) {
|
|
318
|
-
if (mod && mod.__esModule)
|
|
319
|
-
return mod;
|
|
320
|
-
var result = {};
|
|
321
|
-
if (mod != null)
|
|
322
|
-
for (var k in mod)
|
|
323
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
324
|
-
__createBinding(result, mod, k);
|
|
325
|
-
__setModuleDefault(result, mod);
|
|
326
|
-
return result;
|
|
327
|
-
}
|
|
328
|
-
function __importDefault(mod) {
|
|
329
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
330
|
-
}
|
|
331
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
332
|
-
if (kind === "a" && !f)
|
|
333
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
334
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
335
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
336
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
337
|
-
}
|
|
338
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
339
|
-
if (kind === "m")
|
|
340
|
-
throw new TypeError("Private method is not writable");
|
|
341
|
-
if (kind === "a" && !f)
|
|
342
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
343
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
344
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
345
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function arraysAreEqual(array1, array2) {
|
|
349
|
-
var e_1, _a;
|
|
350
|
-
if (array1.length !== array2.length) {
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
try {
|
|
354
|
-
for (var _b = __values(array1.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
355
|
-
var _d = __read(_c.value, 2), index = _d[0], value1 = _d[1];
|
|
356
|
-
var value2 = array2[index];
|
|
357
|
-
if (value1 instanceof Array && value2 instanceof Array) {
|
|
358
|
-
if (!arraysAreEqual(value1, value2)) {
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
else if (value1 !== value2) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
368
|
-
finally {
|
|
369
|
-
try {
|
|
370
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
371
|
-
}
|
|
372
|
-
finally { if (e_1) throw e_1.error; }
|
|
373
|
-
}
|
|
374
|
-
return true;
|
|
375
|
-
}
|
|
376
|
-
function isElementDescendant(potentialAncestor, potentialDescendant) {
|
|
377
|
-
if (potentialAncestor === potentialDescendant) {
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
var cursor = potentialDescendant.parentNode;
|
|
381
|
-
while (cursor !== document) {
|
|
382
|
-
if (cursor === null) {
|
|
383
|
-
//Did not reach `document` or ancestor. potentialDescendant is not part of the DOM.
|
|
384
|
-
return undefined;
|
|
385
|
-
}
|
|
386
|
-
if (cursor === potentialAncestor) {
|
|
387
|
-
return true;
|
|
388
|
-
}
|
|
389
|
-
cursor = cursor.parentNode;
|
|
390
|
-
}
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
function isNestingAllowed(options, nodeData) {
|
|
394
|
-
return (options !== undefined &&
|
|
395
|
-
(options.allowNesting === true ||
|
|
396
|
-
(typeof options.allowNesting === "function" &&
|
|
397
|
-
nodeData !== undefined &&
|
|
398
|
-
options.allowNesting(nodeData) === true)));
|
|
399
|
-
}
|
|
400
|
-
function isDraggingAllowed(options, nodeData) {
|
|
401
|
-
return (options !== undefined &&
|
|
402
|
-
(options.allowDragging === true ||
|
|
403
|
-
(typeof options.allowDragging === "function" &&
|
|
404
|
-
nodeData !== undefined &&
|
|
405
|
-
options.allowDragging(nodeData) === true)));
|
|
406
|
-
}
|
|
407
|
-
function isFirefox() {
|
|
408
|
-
return navigator.userAgent.includes("Firefox");
|
|
409
|
-
}
|
|
410
|
-
/** Because drop zones can disappear when the mouse moves, sometimes
|
|
411
|
-
* moving the mouse just a little bit inside the tree causes the tree to
|
|
412
|
-
* shrink such that the mouse is no longer over the tree. In this case,
|
|
413
|
-
* a dragleave event may not fire, and we can't clear the drop zones. This
|
|
414
|
-
* function is used to catch this edge case.
|
|
415
|
-
*/
|
|
416
|
-
function suddenTreeExit(event) {
|
|
417
|
-
if (event.target === null || !(event.target instanceof Element)) {
|
|
418
|
-
throw new Error("failed to get event target element");
|
|
419
|
-
}
|
|
420
|
-
var treeEventHost = event.target.closest(".tree-event-host");
|
|
421
|
-
if (treeEventHost === null) {
|
|
422
|
-
console.log(event.target);
|
|
423
|
-
throw new Error("failed to find treeEventHost");
|
|
424
|
-
}
|
|
425
|
-
var rect = treeEventHost.getBoundingClientRect();
|
|
426
|
-
var clientY = event.clientY;
|
|
427
|
-
if (clientY > rect.bottom || clientY < rect.top) {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
var DropZoneLocation = /** @class */ (function () {
|
|
434
|
-
function DropZoneLocation(parentCoordinates, insertIndex) {
|
|
435
|
-
this.parentCoordinates = parentCoordinates;
|
|
436
|
-
this.insertIndex = insertIndex;
|
|
437
|
-
}
|
|
438
|
-
DropZoneLocation.prototype.getFullInsertCoordinates = function () {
|
|
439
|
-
return __spreadArray(__spreadArray([], __read(this.parentCoordinates)), [this.insertIndex]);
|
|
440
|
-
};
|
|
441
|
-
DropZoneLocation.prototype.setParentCoordinates = function (coordinates) {
|
|
442
|
-
this.parentCoordinates = coordinates;
|
|
443
|
-
};
|
|
444
|
-
DropZoneLocation.prototype.setInsertIndex = function (index) {
|
|
445
|
-
this.insertIndex = index;
|
|
446
|
-
};
|
|
447
|
-
return DropZoneLocation;
|
|
448
|
-
}());
|
|
449
|
-
|
|
450
|
-
var DropZone = /** @class */ (function () {
|
|
451
|
-
function DropZone(parentCoordinates, insertIndex) {
|
|
452
|
-
this.location = new DropZoneLocation(parentCoordinates, insertIndex);
|
|
453
|
-
this.rendered = false;
|
|
454
|
-
this.visible = false;
|
|
455
|
-
this.active = false;
|
|
456
|
-
this.commChannel = new rxjs.Subject();
|
|
457
|
-
}
|
|
458
|
-
DropZone.dropZoneLocationsAreEqual = function (valueA, valueB) {
|
|
459
|
-
return arraysAreEqual(valueA.getFullInsertCoordinates(), valueB.getFullInsertCoordinates());
|
|
460
|
-
};
|
|
461
|
-
DropZone.prototype.isRendered = function (set) {
|
|
462
|
-
if (set === void 0) { set = undefined; }
|
|
463
|
-
if (set !== undefined) {
|
|
464
|
-
this.rendered = set;
|
|
465
|
-
if (this.commChannel !== undefined) {
|
|
466
|
-
this.commChannel.next("checkRendered");
|
|
467
|
-
}
|
|
468
|
-
if (this.rendered === false) {
|
|
469
|
-
this.isVisible(false);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return this.rendered;
|
|
473
|
-
};
|
|
474
|
-
DropZone.prototype.isVisible = function (set) {
|
|
475
|
-
if (set === void 0) { set = undefined; }
|
|
476
|
-
if (set !== undefined) {
|
|
477
|
-
this.visible = set;
|
|
478
|
-
if (this.commChannel !== undefined) {
|
|
479
|
-
this.commChannel.next("checkVisible");
|
|
480
|
-
}
|
|
481
|
-
if (this.visible === false) {
|
|
482
|
-
this.isActive(false);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
return this.visible;
|
|
486
|
-
};
|
|
487
|
-
DropZone.prototype.isActive = function (set) {
|
|
488
|
-
if (set === void 0) { set = undefined; }
|
|
489
|
-
if (set !== undefined) {
|
|
490
|
-
this.active = set;
|
|
491
|
-
if (this.commChannel !== undefined) {
|
|
492
|
-
this.commChannel.next("checkActive");
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return this.active;
|
|
496
|
-
};
|
|
497
|
-
DropZone.prototype.getLocation = function () {
|
|
498
|
-
return this.location;
|
|
499
|
-
};
|
|
500
|
-
DropZone.prototype.getFamily = function () {
|
|
501
|
-
return this.family;
|
|
502
|
-
};
|
|
503
|
-
DropZone.prototype.setFamily = function (family) {
|
|
504
|
-
this.family = family;
|
|
505
|
-
};
|
|
506
|
-
DropZone.prototype.getCommChannel = function () {
|
|
507
|
-
return this.commChannel;
|
|
508
|
-
};
|
|
509
|
-
DropZone.prototype.getFullInsertCoordinates = function () {
|
|
510
|
-
return this.location.getFullInsertCoordinates();
|
|
511
|
-
};
|
|
512
|
-
DropZone.prototype.setHost = function (host) {
|
|
513
|
-
this.host = host;
|
|
514
|
-
return this.host;
|
|
515
|
-
};
|
|
516
|
-
DropZone.prototype.getHost = function () {
|
|
517
|
-
return this.host;
|
|
518
|
-
};
|
|
519
|
-
return DropZone;
|
|
520
|
-
}());
|
|
521
|
-
|
|
522
|
-
var DragStateService = /** @class */ (function () {
|
|
523
|
-
function DragStateService() {
|
|
524
|
-
this.state = "idle";
|
|
525
|
-
this.state$ = new rxjs.BehaviorSubject(this.state);
|
|
526
|
-
}
|
|
527
|
-
/** Called to indicate that something is being dragged. Stores that something for later. */
|
|
528
|
-
DragStateService.prototype.dragging = function (branch, parentContainer) {
|
|
529
|
-
this._tempData = {
|
|
530
|
-
branch: branch,
|
|
531
|
-
parentContainer: parentContainer
|
|
532
|
-
};
|
|
533
|
-
this.state = "dragging";
|
|
534
|
-
this.state$.next(this.state);
|
|
535
|
-
};
|
|
536
|
-
/** Called to indicate that there is a valid active drop zone. Drop is now possible. */
|
|
537
|
-
DragStateService.prototype.droppable = function () {
|
|
538
|
-
if (this.state !== "dragging") {
|
|
539
|
-
throw new Error("Can only call `droppable` when state is `dragging`");
|
|
540
|
-
}
|
|
541
|
-
this.state = "droppable";
|
|
542
|
-
this.state$.next(this.state);
|
|
543
|
-
};
|
|
544
|
-
/** Called to indicate that there is no longer a valid active drop zone. Drop is no longer possible. */
|
|
545
|
-
DragStateService.prototype.notDroppable = function () {
|
|
546
|
-
if (this.state !== "droppable") {
|
|
547
|
-
throw new Error("Can only call `notDroppable` when state is `droppable`");
|
|
548
|
-
}
|
|
549
|
-
this.state = "dragging";
|
|
550
|
-
this.state$.next(this.state);
|
|
551
|
-
};
|
|
552
|
-
/** Called to indicate that a drop into a valid drop zone has occurred. Returns the item that was dropped. */
|
|
553
|
-
DragStateService.prototype.capture = function () {
|
|
554
|
-
var _a;
|
|
555
|
-
if (this.state !== "droppable") {
|
|
556
|
-
throw new Error("Can only move to `captured` state from `droppable` state");
|
|
557
|
-
}
|
|
558
|
-
this.state = "captured";
|
|
559
|
-
this.state$.next(this.state);
|
|
560
|
-
return (_a = this._tempData) === null || _a === void 0 ? void 0 : _a.branch;
|
|
561
|
-
};
|
|
562
|
-
/** Called to reset the service for future drags */
|
|
563
|
-
DragStateService.prototype.release = function () {
|
|
564
|
-
this._tempData = undefined;
|
|
565
|
-
this.state = "idle";
|
|
566
|
-
this.state$.next(this.state);
|
|
567
|
-
};
|
|
568
|
-
/** gets the current thing being dragged, if any. */
|
|
569
|
-
DragStateService.prototype.getData = function () {
|
|
570
|
-
return this._tempData;
|
|
571
|
-
};
|
|
572
|
-
/** gets the current state */
|
|
573
|
-
DragStateService.prototype.getState = function () {
|
|
574
|
-
return this.state;
|
|
575
|
-
};
|
|
576
|
-
return DragStateService;
|
|
577
|
-
}());
|
|
578
|
-
DragStateService.ɵfac = function DragStateService_Factory(t) { return new (t || DragStateService)(); };
|
|
579
|
-
DragStateService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: DragStateService, factory: DragStateService.ɵfac });
|
|
580
|
-
(function () {
|
|
581
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DragStateService, [{
|
|
582
|
-
type: i0.Injectable
|
|
583
|
-
}], function () { return []; }, null);
|
|
584
|
-
})();
|
|
585
|
-
|
|
586
|
-
var TreeConstructionStatus = /** @class */ (function () {
|
|
587
|
-
function TreeConstructionStatus() {
|
|
588
|
-
this.beingBuilt = 0;
|
|
589
|
-
this.isReady = false;
|
|
590
|
-
this.stable$ = new rxjs.BehaviorSubject(this.treeIsStable());
|
|
591
|
-
}
|
|
592
|
-
TreeConstructionStatus.prototype.constructing = function () {
|
|
593
|
-
this.beingBuilt++;
|
|
594
|
-
this.emit();
|
|
595
|
-
};
|
|
596
|
-
TreeConstructionStatus.prototype.doneConstructing = function () {
|
|
597
|
-
this.beingBuilt--;
|
|
598
|
-
this.emit();
|
|
599
|
-
};
|
|
600
|
-
TreeConstructionStatus.prototype.treeIsStable = function () {
|
|
601
|
-
return this.isReady === true && this.beingBuilt === 0;
|
|
602
|
-
};
|
|
603
|
-
TreeConstructionStatus.prototype.ready = function (val) {
|
|
604
|
-
this.isReady = val;
|
|
605
|
-
};
|
|
606
|
-
TreeConstructionStatus.prototype.emit = function () {
|
|
607
|
-
this.stable$.next(this.treeIsStable());
|
|
608
|
-
};
|
|
609
|
-
return TreeConstructionStatus;
|
|
610
|
-
}());
|
|
611
|
-
TreeConstructionStatus.ɵfac = function TreeConstructionStatus_Factory(t) { return new (t || TreeConstructionStatus)(); };
|
|
612
|
-
TreeConstructionStatus.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: TreeConstructionStatus, factory: TreeConstructionStatus.ɵfac });
|
|
613
|
-
(function () {
|
|
614
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TreeConstructionStatus, [{
|
|
615
|
-
type: i0.Injectable
|
|
616
|
-
}], function () { return []; }, null);
|
|
617
|
-
})();
|
|
618
|
-
|
|
619
|
-
function sortFamily(memberA, memberB) {
|
|
620
|
-
var aCoordinates = memberA.getFullInsertCoordinates();
|
|
621
|
-
var bCoordinates = memberB.getFullInsertCoordinates();
|
|
622
|
-
if (aCoordinates.length > bCoordinates.length) {
|
|
623
|
-
return -1;
|
|
624
|
-
}
|
|
625
|
-
if (aCoordinates.length < bCoordinates.length) {
|
|
626
|
-
return 1;
|
|
627
|
-
}
|
|
628
|
-
return 0;
|
|
629
|
-
}
|
|
630
|
-
var DropZoneService = /** @class */ (function () {
|
|
631
|
-
function DropZoneService(dragStateService, treeConstructionStatus) {
|
|
632
|
-
var _this = this;
|
|
633
|
-
this.dragStateService = dragStateService;
|
|
634
|
-
this.dropZoneArchive = new Set();
|
|
635
|
-
this.dropZoneInventory = [];
|
|
636
|
-
this.dropZoneFamilies = [];
|
|
637
|
-
this.visibleFamily = null;
|
|
638
|
-
this.activeDropZone = null;
|
|
639
|
-
this.tempFamilies = [];
|
|
640
|
-
this.setActiveDropZone(null);
|
|
641
|
-
var treeIsStable = false;
|
|
642
|
-
var treeIsStable$ = treeConstructionStatus.stable$.pipe(operators.tap(function (value) {
|
|
643
|
-
treeIsStable = value;
|
|
644
|
-
}), operators.filter(function (value) { return value === true; }));
|
|
645
|
-
this.update$ = new rxjs.Subject();
|
|
646
|
-
this.update$
|
|
647
|
-
.pipe(operators.debounce(function () {
|
|
648
|
-
if (treeIsStable === true) {
|
|
649
|
-
//If tree is stable, continue right away
|
|
650
|
-
return Promise.resolve();
|
|
651
|
-
}
|
|
652
|
-
//If tree is not stable, wait for it to become so.
|
|
653
|
-
return treeIsStable$;
|
|
654
|
-
}))
|
|
655
|
-
.subscribe(function () {
|
|
656
|
-
setTimeout(function () {
|
|
657
|
-
_this.updateDropZones();
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
DropZoneService.prototype.addDropZone = function (newDropZone) {
|
|
662
|
-
this.dropZoneArchive.add(newDropZone);
|
|
663
|
-
};
|
|
664
|
-
/** hides all drop zones */
|
|
665
|
-
DropZoneService.prototype.clearVisibleZones = function () {
|
|
666
|
-
var e_1, _e;
|
|
667
|
-
if (this.visibleFamily !== null) {
|
|
668
|
-
try {
|
|
669
|
-
for (var _f = __values(this.visibleFamily.members), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
670
|
-
var member = _g.value;
|
|
671
|
-
member.isVisible(false);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
675
|
-
finally {
|
|
676
|
-
try {
|
|
677
|
-
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
678
|
-
}
|
|
679
|
-
finally { if (e_1) throw e_1.error; }
|
|
680
|
-
}
|
|
681
|
-
this.visibleFamily = null;
|
|
682
|
-
}
|
|
683
|
-
this.setActiveDropZone(null);
|
|
684
|
-
};
|
|
685
|
-
DropZoneService.prototype.getActiveDropZone = function () {
|
|
686
|
-
return this.activeDropZone;
|
|
687
|
-
};
|
|
688
|
-
DropZoneService.prototype.getDropZone = function (coordinates) {
|
|
689
|
-
var parent = __spreadArray([], __read(coordinates));
|
|
690
|
-
parent.pop();
|
|
691
|
-
var index = coordinates[coordinates.length - 1];
|
|
692
|
-
var location = new DropZoneLocation(parent, index);
|
|
693
|
-
return this.dropZoneInventory.find(function (dropZone) { return DropZone.dropZoneLocationsAreEqual(dropZone, location); });
|
|
694
|
-
};
|
|
695
|
-
DropZoneService.prototype.init = function (tree, treeOptions) {
|
|
696
|
-
this.tree = tree;
|
|
697
|
-
this.treeOptions = treeOptions;
|
|
698
|
-
this.update();
|
|
699
|
-
};
|
|
700
|
-
DropZoneService.prototype.removeDropZone = function (dropZone) {
|
|
701
|
-
this.dropZoneArchive.delete(dropZone);
|
|
702
|
-
};
|
|
703
|
-
/** hides all drop zones, deletes all the family assignments,
|
|
704
|
-
* and empties the dropZoneInventory
|
|
705
|
-
*/
|
|
706
|
-
DropZoneService.prototype.reset = function () {
|
|
707
|
-
this.clearVisibleZones();
|
|
708
|
-
this.dropZoneFamilies.length = 0;
|
|
709
|
-
this.dropZoneInventory.length = 0;
|
|
710
|
-
};
|
|
711
|
-
/**
|
|
712
|
-
* Restores the service to its initial state: hides all drop zones,
|
|
713
|
-
* deletes all the family assignments, and empties the dropZoneInventory
|
|
714
|
-
* and dropZoneArchive.
|
|
715
|
-
*/
|
|
716
|
-
DropZoneService.prototype.restart = function () {
|
|
717
|
-
this.reset();
|
|
718
|
-
this.dropZoneArchive.clear();
|
|
719
|
-
};
|
|
720
|
-
DropZoneService.prototype.restoreFamilies = function () {
|
|
721
|
-
var e_2, _e, e_3, _f;
|
|
722
|
-
if (this.tempFamilies.length === 2) {
|
|
723
|
-
this.dropZoneFamilies.pop();
|
|
724
|
-
this.dropZoneFamilies.push(this.tempFamilies[0]);
|
|
725
|
-
try {
|
|
726
|
-
for (var _g = __values(this.tempFamilies[0].members), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
727
|
-
var member = _h.value;
|
|
728
|
-
member.setFamily(this.tempFamilies[0]);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
732
|
-
finally {
|
|
733
|
-
try {
|
|
734
|
-
if (_h && !_h.done && (_e = _g.return)) _e.call(_g);
|
|
735
|
-
}
|
|
736
|
-
finally { if (e_2) throw e_2.error; }
|
|
737
|
-
}
|
|
738
|
-
if (this.tempFamilies[1] !== null) {
|
|
739
|
-
this.dropZoneFamilies.push(this.tempFamilies[1]);
|
|
740
|
-
try {
|
|
741
|
-
for (var _j = __values(this.tempFamilies[1].members), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
742
|
-
var member = _k.value;
|
|
743
|
-
member.setFamily(this.tempFamilies[1]);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
747
|
-
finally {
|
|
748
|
-
try {
|
|
749
|
-
if (_k && !_k.done && (_f = _j.return)) _f.call(_j);
|
|
750
|
-
}
|
|
751
|
-
finally { if (e_3) throw e_3.error; }
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
this.tempFamilies = [];
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
/**
|
|
758
|
-
* Shows the drop zone family of the drop zone indicated by `coordinates`.
|
|
759
|
-
*/
|
|
760
|
-
DropZoneService.prototype.showDropZoneFamily = function (
|
|
761
|
-
/** Note: this drop zone may not exist in the dropZoneInventory; we have to search the inventory based on its location */
|
|
762
|
-
dropZone, options) {
|
|
763
|
-
var e_4, _e, e_5, _f, e_6, _g;
|
|
764
|
-
if (options === void 0) { options = { joinFamilies: false, activateLowestInsteadOfFounder: false }; }
|
|
765
|
-
if (this.activeDropZone !== null &&
|
|
766
|
-
DropZone.dropZoneLocationsAreEqual(this.activeDropZone, dropZone)) {
|
|
767
|
-
//Already showing the family with the appropriate active drop zone
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
if (this.visibleFamily !== null || this.activeDropZone !== null) {
|
|
771
|
-
this.clearVisibleZones();
|
|
772
|
-
}
|
|
773
|
-
var target = this.dropZoneInventory.find(function (zone) { return DropZone.dropZoneLocationsAreEqual(zone, dropZone); });
|
|
774
|
-
if (target === undefined) {
|
|
775
|
-
throw new Error("Could not find drop zone to show. location: " + JSON.stringify(dropZone.getLocation()));
|
|
776
|
-
}
|
|
777
|
-
var family = target.getFamily();
|
|
778
|
-
if (options.joinFamilies === true) {
|
|
779
|
-
var location1 = dropZone.getLocation();
|
|
780
|
-
var location2_1 = new DropZoneLocation(__spreadArray([], __read(location1.parentCoordinates)), location1.insertIndex + 1);
|
|
781
|
-
var target2 = this.dropZoneInventory.find(function (zone) { return DropZone.dropZoneLocationsAreEqual(zone, location2_1); });
|
|
782
|
-
if (target2 === undefined) {
|
|
783
|
-
throw new Error("Could not find drop zone to show");
|
|
784
|
-
}
|
|
785
|
-
var family2 = target2.getFamily();
|
|
786
|
-
if (family === undefined || family2 === undefined) {
|
|
787
|
-
throw new Error("No family");
|
|
788
|
-
}
|
|
789
|
-
var newFamily = {
|
|
790
|
-
founder: family.founder,
|
|
791
|
-
members: __spreadArray([], __read(family.members))
|
|
792
|
-
};
|
|
793
|
-
this.showDropZone(family.founder, true);
|
|
794
|
-
try {
|
|
795
|
-
for (var _h = __values(family.members.sort(sortFamily)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
796
|
-
var member = _j.value;
|
|
797
|
-
member.setFamily(newFamily);
|
|
798
|
-
if (member !== family.founder) {
|
|
799
|
-
if (this.activeDropZone === null) {
|
|
800
|
-
//Failed to activate a zone so far, so activate this one instead
|
|
801
|
-
this.showDropZone(member, true);
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
this.showDropZone(member);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
810
|
-
finally {
|
|
811
|
-
try {
|
|
812
|
-
if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
|
|
813
|
-
}
|
|
814
|
-
finally { if (e_4) throw e_4.error; }
|
|
815
|
-
}
|
|
816
|
-
try {
|
|
817
|
-
for (var _k = __values(family2.members), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
818
|
-
var member = _l.value;
|
|
819
|
-
member.setFamily(newFamily);
|
|
820
|
-
if (member.getLocation().parentCoordinates.length <
|
|
821
|
-
target2.getLocation().parentCoordinates.length) {
|
|
822
|
-
newFamily.members.push(member);
|
|
823
|
-
this.showDropZone(member);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
828
|
-
finally {
|
|
829
|
-
try {
|
|
830
|
-
if (_l && !_l.done && (_f = _k.return)) _f.call(_k);
|
|
831
|
-
}
|
|
832
|
-
finally { if (e_5) throw e_5.error; }
|
|
833
|
-
}
|
|
834
|
-
//Temporarily store the old families
|
|
835
|
-
this.tempFamilies = [family, family2];
|
|
836
|
-
//Remove the old families
|
|
837
|
-
var familyIndex = this.dropZoneFamilies.indexOf(family);
|
|
838
|
-
this.dropZoneFamilies.splice(familyIndex, 1);
|
|
839
|
-
var family2Index = this.dropZoneFamilies.indexOf(family2);
|
|
840
|
-
this.dropZoneFamilies.splice(family2Index, 1);
|
|
841
|
-
//Add the new family
|
|
842
|
-
this.dropZoneFamilies.push(newFamily);
|
|
843
|
-
this.visibleFamily = newFamily;
|
|
844
|
-
}
|
|
845
|
-
else {
|
|
846
|
-
if (family === undefined) {
|
|
847
|
-
throw new Error("No family");
|
|
848
|
-
}
|
|
849
|
-
this.visibleFamily = family;
|
|
850
|
-
this.showDropZone(family.founder, true);
|
|
851
|
-
if (family.members.length > 1) {
|
|
852
|
-
try {
|
|
853
|
-
for (var _m = __values(family.members.sort(sortFamily)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
854
|
-
var member = _o.value;
|
|
855
|
-
if (member !== family.founder) {
|
|
856
|
-
if (this.activeDropZone === null) {
|
|
857
|
-
//Failed to activate a zone so far, so activate this one instead
|
|
858
|
-
this.showDropZone(member, true);
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
this.showDropZone(member);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
867
|
-
finally {
|
|
868
|
-
try {
|
|
869
|
-
if (_o && !_o.done && (_g = _m.return)) _g.call(_m);
|
|
870
|
-
}
|
|
871
|
-
finally { if (e_6) throw e_6.error; }
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
if (options.activateLowestInsteadOfFounder === true &&
|
|
876
|
-
this.visibleFamily.members.length > 1) {
|
|
877
|
-
var lowestMember = __spreadArray([], __read(this.visibleFamily.members)).sort(sortFamily)
|
|
878
|
-
.pop();
|
|
879
|
-
if (lowestMember === undefined) {
|
|
880
|
-
throw new Error("Could not get lowest member");
|
|
881
|
-
}
|
|
882
|
-
this.swapActiveDropZone(lowestMember);
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
DropZoneService.prototype.swapActiveDropZone = function (newActiveDropZone) {
|
|
886
|
-
if (this.visibleFamily === null) {
|
|
887
|
-
throw new Error("No visible family available for swapping");
|
|
888
|
-
}
|
|
889
|
-
var index = this.visibleFamily.members.findIndex(function (dropZone) { return dropZone === newActiveDropZone; });
|
|
890
|
-
if (index === -1) {
|
|
891
|
-
throw new Error("failed to swap active drop zone");
|
|
892
|
-
}
|
|
893
|
-
this.setActiveDropZone(newActiveDropZone);
|
|
894
|
-
};
|
|
895
|
-
DropZoneService.prototype.update = function () {
|
|
896
|
-
this.update$.next(null);
|
|
897
|
-
};
|
|
898
|
-
DropZoneService.prototype.assignFamilies = function () {
|
|
899
|
-
var e_7, _e, e_8, _f, e_9, _g;
|
|
900
|
-
var orphanZones = __spreadArray([], __read(this.dropZoneInventory));
|
|
901
|
-
var deepestMembers = orphanZones
|
|
902
|
-
.filter(function (zone) {
|
|
903
|
-
var location = zone.getLocation();
|
|
904
|
-
return (location.insertIndex === 0 &&
|
|
905
|
-
location.parentCoordinates.length > 0);
|
|
906
|
-
})
|
|
907
|
-
.sort(function (valueA, valueB) {
|
|
908
|
-
var _a, _b, _c, _d;
|
|
909
|
-
var aCoordinates = valueA.getFullInsertCoordinates();
|
|
910
|
-
var bCoordinates = valueB.getFullInsertCoordinates();
|
|
911
|
-
var length = Math.max(aCoordinates.length, bCoordinates.length);
|
|
912
|
-
for (var index = 0; index < length; index++) {
|
|
913
|
-
if (((_a = aCoordinates[index]) !== null && _a !== void 0 ? _a : -1) > ((_b = bCoordinates[index]) !== null && _b !== void 0 ? _b : -1)) {
|
|
914
|
-
return -1;
|
|
915
|
-
}
|
|
916
|
-
else if (((_c = aCoordinates[index]) !== null && _c !== void 0 ? _c : -1) < ((_d = bCoordinates[index]) !== null && _d !== void 0 ? _d : -1)) {
|
|
917
|
-
return 1;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return 0;
|
|
921
|
-
});
|
|
922
|
-
var _loop_1 = function (dropZone) {
|
|
923
|
-
if (!orphanZones.includes(dropZone)) {
|
|
924
|
-
return "continue";
|
|
925
|
-
}
|
|
926
|
-
var family = {
|
|
927
|
-
founder: dropZone,
|
|
928
|
-
members: []
|
|
929
|
-
};
|
|
930
|
-
dropZone.setFamily(family);
|
|
931
|
-
//See if there are any orphans that belong to this family and claim them.
|
|
932
|
-
var cursor = __spreadArray([], __read(dropZone.getFullInsertCoordinates()));
|
|
933
|
-
while (cursor.length > 0) {
|
|
934
|
-
var familyMemberIndex = orphanZones.findIndex(function (zone) { return arraysAreEqual(zone.getFullInsertCoordinates(), cursor); });
|
|
935
|
-
if (familyMemberIndex !== -1) {
|
|
936
|
-
var familyMember = orphanZones.splice(familyMemberIndex, 1)[0];
|
|
937
|
-
family.members.push(familyMember);
|
|
938
|
-
familyMember.setFamily(family);
|
|
939
|
-
}
|
|
940
|
-
cursor.pop();
|
|
941
|
-
cursor[cursor.length - 1]++;
|
|
942
|
-
}
|
|
943
|
-
this_1.dropZoneFamilies.push(family);
|
|
944
|
-
};
|
|
945
|
-
var this_1 = this;
|
|
946
|
-
try {
|
|
947
|
-
for (var deepestMembers_1 = __values(deepestMembers), deepestMembers_1_1 = deepestMembers_1.next(); !deepestMembers_1_1.done; deepestMembers_1_1 = deepestMembers_1.next()) {
|
|
948
|
-
var dropZone = deepestMembers_1_1.value;
|
|
949
|
-
_loop_1(dropZone);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
953
|
-
finally {
|
|
954
|
-
try {
|
|
955
|
-
if (deepestMembers_1_1 && !deepestMembers_1_1.done && (_e = deepestMembers_1.return)) _e.call(deepestMembers_1);
|
|
956
|
-
}
|
|
957
|
-
finally { if (e_7) throw e_7.error; }
|
|
958
|
-
}
|
|
959
|
-
try {
|
|
960
|
-
for (var _h = __values(orphanZones.filter(function (zone) { return zone.getFullInsertCoordinates().length === 1; })), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
961
|
-
var dropZone = _j.value;
|
|
962
|
-
var family = {
|
|
963
|
-
founder: dropZone,
|
|
964
|
-
members: [dropZone]
|
|
965
|
-
};
|
|
966
|
-
dropZone.setFamily(family);
|
|
967
|
-
this.dropZoneFamilies.push(family);
|
|
968
|
-
orphanZones.splice(orphanZones.indexOf(dropZone), 1);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
972
|
-
finally {
|
|
973
|
-
try {
|
|
974
|
-
if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
|
|
975
|
-
}
|
|
976
|
-
finally { if (e_8) throw e_8.error; }
|
|
977
|
-
}
|
|
978
|
-
if (orphanZones.length !== 0) {
|
|
979
|
-
var orphans = "";
|
|
980
|
-
try {
|
|
981
|
-
for (var orphanZones_1 = __values(orphanZones), orphanZones_1_1 = orphanZones_1.next(); !orphanZones_1_1.done; orphanZones_1_1 = orphanZones_1.next()) {
|
|
982
|
-
var zone = orphanZones_1_1.value;
|
|
983
|
-
orphans += JSON.stringify(zone.getLocation()) + ", ";
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
987
|
-
finally {
|
|
988
|
-
try {
|
|
989
|
-
if (orphanZones_1_1 && !orphanZones_1_1.done && (_g = orphanZones_1.return)) _g.call(orphanZones_1);
|
|
990
|
-
}
|
|
991
|
-
finally { if (e_9) throw e_9.error; }
|
|
992
|
-
}
|
|
993
|
-
orphans = orphans.slice(0, orphans.length - 2);
|
|
994
|
-
throw new Error("Some zones were not assigned to a family. The orphan zones have the following locations: " + orphans);
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
DropZoneService.prototype.buildInventory = function () {
|
|
998
|
-
var e_10, _e;
|
|
999
|
-
//We do this funky string array because it is faster than doing direct array comparisons
|
|
1000
|
-
var inventoryCoordinates = [];
|
|
1001
|
-
try {
|
|
1002
|
-
for (var _f = __values(this.dropZoneArchive), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1003
|
-
var dropZone = _g.value;
|
|
1004
|
-
var coordinates = dropZone.getFullInsertCoordinates().join(",");
|
|
1005
|
-
if (inventoryCoordinates.includes(coordinates)) {
|
|
1006
|
-
dropZone.isRendered(false);
|
|
1007
|
-
}
|
|
1008
|
-
else {
|
|
1009
|
-
this.dropZoneInventory.push(dropZone);
|
|
1010
|
-
inventoryCoordinates.push(coordinates);
|
|
1011
|
-
dropZone.isRendered(true);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1016
|
-
finally {
|
|
1017
|
-
try {
|
|
1018
|
-
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
1019
|
-
}
|
|
1020
|
-
finally { if (e_10) throw e_10.error; }
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
DropZoneService.prototype.setActiveDropZone = function (dropZone) {
|
|
1024
|
-
if (this.activeDropZone !== null) {
|
|
1025
|
-
this.activeDropZone.isActive(false);
|
|
1026
|
-
}
|
|
1027
|
-
this.activeDropZone = dropZone;
|
|
1028
|
-
if (this.activeDropZone !== null &&
|
|
1029
|
-
this.dragStateService.getState() !== "droppable") {
|
|
1030
|
-
this.dragStateService.droppable();
|
|
1031
|
-
}
|
|
1032
|
-
else if (this.activeDropZone === null &&
|
|
1033
|
-
this.dragStateService.getState() === "droppable") {
|
|
1034
|
-
this.dragStateService.notDroppable();
|
|
1035
|
-
}
|
|
1036
|
-
if (this.activeDropZone !== null) {
|
|
1037
|
-
this.activeDropZone.isActive(true);
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
DropZoneService.prototype.showDropZone = function (dropZone, active) {
|
|
1041
|
-
if (active === void 0) { active = false; }
|
|
1042
|
-
if (this.tree === undefined) {
|
|
1043
|
-
throw new Error("DropZoneService not initialized");
|
|
1044
|
-
}
|
|
1045
|
-
if (!this.zoneIsAllowed(dropZone)) {
|
|
1046
|
-
//User settings indicate to skip this drop zone
|
|
1047
|
-
return false;
|
|
1048
|
-
}
|
|
1049
|
-
var parent = this.tree.findByCoordinates(dropZone.getLocation().parentCoordinates);
|
|
1050
|
-
if (parent === undefined) {
|
|
1051
|
-
throw new Error("Bad family member");
|
|
1052
|
-
}
|
|
1053
|
-
dropZone.isVisible(true);
|
|
1054
|
-
if (active === true) {
|
|
1055
|
-
this.setActiveDropZone(dropZone);
|
|
1056
|
-
}
|
|
1057
|
-
return true;
|
|
1058
|
-
};
|
|
1059
|
-
DropZoneService.prototype.updateDropZones = function () {
|
|
1060
|
-
this.reset();
|
|
1061
|
-
this.buildInventory();
|
|
1062
|
-
this.assignFamilies();
|
|
1063
|
-
};
|
|
1064
|
-
DropZoneService.prototype.zoneIsAllowed = function (dropZone) {
|
|
1065
|
-
if (this.treeOptions === undefined || this.tree === undefined) {
|
|
1066
|
-
throw new Error("dropZoneService not initialized");
|
|
1067
|
-
}
|
|
1068
|
-
var data = this.dragStateService.getData();
|
|
1069
|
-
if (data === undefined) {
|
|
1070
|
-
throw new Error("Can't get dragged node");
|
|
1071
|
-
}
|
|
1072
|
-
var parentCoordinates = dropZone.getLocation().parentCoordinates;
|
|
1073
|
-
var dropZoneParent = this.tree.findByCoordinates(parentCoordinates);
|
|
1074
|
-
if (dropZoneParent === undefined) {
|
|
1075
|
-
throw new Error("Could not get drop zone parent");
|
|
1076
|
-
}
|
|
1077
|
-
if (parentCoordinates.length > 0 &&
|
|
1078
|
-
!isNestingAllowed(this.treeOptions, dropZoneParent.data)) {
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1081
|
-
var dropZoneIndex = dropZone.getLocation().insertIndex;
|
|
1082
|
-
if (dropZoneIndex === undefined) {
|
|
1083
|
-
throw new Error("Could not get drop zone index");
|
|
1084
|
-
}
|
|
1085
|
-
var draggedNode = data.branch;
|
|
1086
|
-
if (!this.treeOptions.allowDrop(draggedNode.data, dropZoneParent.data, dropZoneIndex)) {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
return true;
|
|
1090
|
-
};
|
|
1091
|
-
return DropZoneService;
|
|
1092
|
-
}());
|
|
1093
|
-
DropZoneService.ɵfac = function DropZoneService_Factory(t) { return new (t || DropZoneService)(i0__namespace.ɵɵinject(DragStateService), i0__namespace.ɵɵinject(TreeConstructionStatus)); };
|
|
1094
|
-
DropZoneService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: DropZoneService, factory: DropZoneService.ɵfac });
|
|
1095
|
-
(function () {
|
|
1096
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DropZoneService, [{
|
|
1097
|
-
type: i0.Injectable
|
|
1098
|
-
}], function () { return [{ type: DragStateService }, { type: TreeConstructionStatus }]; }, null);
|
|
1099
|
-
})();
|
|
1100
|
-
|
|
1101
|
-
var Branch = /** @class */ (function () {
|
|
1102
|
-
function Branch(data) {
|
|
1103
|
-
this.data = data;
|
|
1104
|
-
this.children = [];
|
|
1105
|
-
this.parent = null;
|
|
1106
|
-
}
|
|
1107
|
-
Branch.prototype.isRoot = function () {
|
|
1108
|
-
return this.parent === null;
|
|
1109
|
-
};
|
|
1110
|
-
Branch.prototype.getParent = function () {
|
|
1111
|
-
return this.parent;
|
|
1112
|
-
};
|
|
1113
|
-
Branch.prototype.setParent = function (parent) {
|
|
1114
|
-
this.parent = parent;
|
|
1115
|
-
};
|
|
1116
|
-
Branch.prototype.findByCoordinates = function (relativeCoordinates) {
|
|
1117
|
-
var e_1, _a;
|
|
1118
|
-
var cursor = this;
|
|
1119
|
-
try {
|
|
1120
|
-
for (var _b = __values(relativeCoordinates.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1121
|
-
var index = _c.value;
|
|
1122
|
-
cursor = cursor.getChild(index);
|
|
1123
|
-
if (cursor === undefined) {
|
|
1124
|
-
return undefined;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1129
|
-
finally {
|
|
1130
|
-
try {
|
|
1131
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1132
|
-
}
|
|
1133
|
-
finally { if (e_1) throw e_1.error; }
|
|
1134
|
-
}
|
|
1135
|
-
return cursor;
|
|
1136
|
-
};
|
|
1137
|
-
Branch.prototype.getCoordinates = function () {
|
|
1138
|
-
var coordinates = [];
|
|
1139
|
-
var cursor = this;
|
|
1140
|
-
while (cursor.parent !== null) {
|
|
1141
|
-
var cursorIndex = cursor.getIndex();
|
|
1142
|
-
if (cursorIndex === undefined || cursorIndex === null) {
|
|
1143
|
-
throw new Error("Could not get cursor index");
|
|
1144
|
-
}
|
|
1145
|
-
coordinates.unshift(cursorIndex);
|
|
1146
|
-
cursor = cursor.parent;
|
|
1147
|
-
}
|
|
1148
|
-
return coordinates;
|
|
1149
|
-
};
|
|
1150
|
-
Branch.prototype.getChild = function (index) {
|
|
1151
|
-
return this.children[index];
|
|
1152
|
-
};
|
|
1153
|
-
Branch.prototype.getChildren = function () {
|
|
1154
|
-
return this.children;
|
|
1155
|
-
};
|
|
1156
|
-
Branch.prototype.clearChildren = function () {
|
|
1157
|
-
var e_2, _a;
|
|
1158
|
-
try {
|
|
1159
|
-
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1160
|
-
var child = _c.value;
|
|
1161
|
-
child.setParent(null);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1165
|
-
finally {
|
|
1166
|
-
try {
|
|
1167
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1168
|
-
}
|
|
1169
|
-
finally { if (e_2) throw e_2.error; }
|
|
1170
|
-
}
|
|
1171
|
-
this.children.length = 0;
|
|
1172
|
-
};
|
|
1173
|
-
Branch.prototype.getIndex = function () {
|
|
1174
|
-
var _this = this;
|
|
1175
|
-
if (this.parent === null) {
|
|
1176
|
-
return null;
|
|
1177
|
-
}
|
|
1178
|
-
var index = this.parent.children.findIndex(function (branch) { return branch === _this; });
|
|
1179
|
-
if (index === -1) {
|
|
1180
|
-
return undefined;
|
|
1181
|
-
}
|
|
1182
|
-
return index;
|
|
1183
|
-
};
|
|
1184
|
-
Branch.prototype.getDescendant = function (relativeCoordinates) {
|
|
1185
|
-
var e_3, _a;
|
|
1186
|
-
var cursor = this;
|
|
1187
|
-
try {
|
|
1188
|
-
for (var relativeCoordinates_1 = __values(relativeCoordinates), relativeCoordinates_1_1 = relativeCoordinates_1.next(); !relativeCoordinates_1_1.done; relativeCoordinates_1_1 = relativeCoordinates_1.next()) {
|
|
1189
|
-
var index = relativeCoordinates_1_1.value;
|
|
1190
|
-
cursor = cursor.children[index];
|
|
1191
|
-
if (cursor === undefined) {
|
|
1192
|
-
return undefined;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1197
|
-
finally {
|
|
1198
|
-
try {
|
|
1199
|
-
if (relativeCoordinates_1_1 && !relativeCoordinates_1_1.done && (_a = relativeCoordinates_1.return)) _a.call(relativeCoordinates_1);
|
|
1200
|
-
}
|
|
1201
|
-
finally { if (e_3) throw e_3.error; }
|
|
1202
|
-
}
|
|
1203
|
-
return cursor;
|
|
1204
|
-
};
|
|
1205
|
-
Branch.prototype.findDescendant = function (predicate) {
|
|
1206
|
-
var e_4, _a;
|
|
1207
|
-
if (predicate(this.data) === true) {
|
|
1208
|
-
return this;
|
|
1209
|
-
}
|
|
1210
|
-
if (this.children.length > 0) {
|
|
1211
|
-
try {
|
|
1212
|
-
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1213
|
-
var child = _c.value;
|
|
1214
|
-
var foundDeeper = child.findDescendant(predicate);
|
|
1215
|
-
if (foundDeeper !== undefined) {
|
|
1216
|
-
return foundDeeper;
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1221
|
-
finally {
|
|
1222
|
-
try {
|
|
1223
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1224
|
-
}
|
|
1225
|
-
finally { if (e_4) throw e_4.error; }
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
return undefined;
|
|
1229
|
-
};
|
|
1230
|
-
Branch.prototype.getAncestors = function () {
|
|
1231
|
-
var result = [];
|
|
1232
|
-
var cursor = this;
|
|
1233
|
-
while (cursor.parent !== null) {
|
|
1234
|
-
result.push(cursor.parent);
|
|
1235
|
-
cursor = cursor.parent;
|
|
1236
|
-
}
|
|
1237
|
-
return result;
|
|
1238
|
-
};
|
|
1239
|
-
Branch.prototype.appendChild = function (child) {
|
|
1240
|
-
if (child.getParent() !== null) {
|
|
1241
|
-
child.remove();
|
|
1242
|
-
}
|
|
1243
|
-
child.setParent(this);
|
|
1244
|
-
this.children.push(child);
|
|
1245
|
-
return child;
|
|
1246
|
-
};
|
|
1247
|
-
Branch.prototype.insertChild = function (child, index) {
|
|
1248
|
-
var isOwnChild = this.children.indexOf(child);
|
|
1249
|
-
if (isOwnChild === -1) {
|
|
1250
|
-
if (child.getParent() !== null) {
|
|
1251
|
-
child.remove();
|
|
1252
|
-
}
|
|
1253
|
-
child.setParent(this);
|
|
1254
|
-
this.children.splice(index, 0, child);
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
if (index > isOwnChild) {
|
|
1258
|
-
//Insert first, then remove
|
|
1259
|
-
this.children.splice(index, 0, child);
|
|
1260
|
-
this.removeChild(isOwnChild);
|
|
1261
|
-
child.setParent(this);
|
|
1262
|
-
}
|
|
1263
|
-
else {
|
|
1264
|
-
//remove first, then insert
|
|
1265
|
-
child.remove();
|
|
1266
|
-
this.children.splice(index, 0, child);
|
|
1267
|
-
child.setParent(this);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
return child;
|
|
1271
|
-
};
|
|
1272
|
-
Branch.prototype.removeChild = function (index) {
|
|
1273
|
-
var target = this.children.splice(index, 1)[0];
|
|
1274
|
-
target.setParent(null);
|
|
1275
|
-
return target;
|
|
1276
|
-
};
|
|
1277
|
-
Branch.prototype.remove = function () {
|
|
1278
|
-
var index = this.getIndex();
|
|
1279
|
-
if (this.parent === null || index === undefined || index === null) {
|
|
1280
|
-
throw new Error("can't remove root");
|
|
1281
|
-
}
|
|
1282
|
-
return this.parent.removeChild(index);
|
|
1283
|
-
};
|
|
1284
|
-
Branch.prototype.copy = function () {
|
|
1285
|
-
var copy = this.copyHelper();
|
|
1286
|
-
copy.setParent(null);
|
|
1287
|
-
return copy;
|
|
1288
|
-
};
|
|
1289
|
-
Branch.prototype.copyHelper = function () {
|
|
1290
|
-
var e_5, _a;
|
|
1291
|
-
var copy = new Branch(this.data);
|
|
1292
|
-
try {
|
|
1293
|
-
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1294
|
-
var child = _c.value;
|
|
1295
|
-
var newChild = copy.appendChild(child.copyHelper());
|
|
1296
|
-
newChild.parent = copy;
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1300
|
-
finally {
|
|
1301
|
-
try {
|
|
1302
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1303
|
-
}
|
|
1304
|
-
finally { if (e_5) throw e_5.error; }
|
|
1305
|
-
}
|
|
1306
|
-
return copy;
|
|
1307
|
-
};
|
|
1308
|
-
return Branch;
|
|
1309
|
-
}());
|
|
1310
|
-
|
|
1311
|
-
var _c0$3 = function (a0, a1) { return { active: a0, related: a1 }; };
|
|
1312
|
-
function DropZoneComponent_div_0_Template(rf, ctx) {
|
|
1313
|
-
if (rf & 1) {
|
|
1314
|
-
var _r2_1 = i0__namespace.ɵɵgetCurrentView();
|
|
1315
|
-
i0__namespace.ɵɵelementStart(0, "div", 1);
|
|
1316
|
-
i0__namespace.ɵɵlistener("dragenter", function DropZoneComponent_div_0_Template_div_dragenter_0_listener() { i0__namespace.ɵɵrestoreView(_r2_1); var ctx_r1 = i0__namespace.ɵɵnextContext(); return ctx_r1.dragenterHandler(); });
|
|
1317
|
-
i0__namespace.ɵɵelement(1, "div", 2);
|
|
1318
|
-
i0__namespace.ɵɵelementEnd();
|
|
1319
|
-
}
|
|
1320
|
-
if (rf & 2) {
|
|
1321
|
-
var ctx_r0 = i0__namespace.ɵɵnextContext();
|
|
1322
|
-
i0__namespace.ɵɵadvance(1);
|
|
1323
|
-
i0__namespace.ɵɵproperty("ngClass", i0__namespace.ɵɵpureFunction2(1, _c0$3, ctx_r0.active, !ctx_r0.active));
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
var DropZoneComponent = /** @class */ (function () {
|
|
1327
|
-
function DropZoneComponent(dropZoneService, changeDetectorRef) {
|
|
1328
|
-
this.dropZoneService = dropZoneService;
|
|
1329
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
1330
|
-
this.visible = false;
|
|
1331
|
-
this.active = false;
|
|
1332
|
-
}
|
|
1333
|
-
DropZoneComponent.prototype.dragenterHandler = function () {
|
|
1334
|
-
if (this.dropZone === undefined || this.active === true) {
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
this.dropZoneService.swapActiveDropZone(this.dropZone);
|
|
1338
|
-
};
|
|
1339
|
-
DropZoneComponent.prototype.ngOnInit = function () {
|
|
1340
|
-
var _this = this;
|
|
1341
|
-
if (this.dropZone === undefined) {
|
|
1342
|
-
throw new Error("No drop zone object at component initialization");
|
|
1343
|
-
}
|
|
1344
|
-
this.commSubscription = this.dropZone
|
|
1345
|
-
.getCommChannel()
|
|
1346
|
-
.subscribe(function (message) {
|
|
1347
|
-
var _a, _b, _c, _d;
|
|
1348
|
-
switch (message) {
|
|
1349
|
-
case "checkVisible": {
|
|
1350
|
-
_this.visible = (_b = (_a = _this.dropZone) === null || _a === void 0 ? void 0 : _a.isVisible()) !== null && _b !== void 0 ? _b : false;
|
|
1351
|
-
break;
|
|
1352
|
-
}
|
|
1353
|
-
case "checkActive": {
|
|
1354
|
-
_this.active = (_d = (_c = _this.dropZone) === null || _c === void 0 ? void 0 : _c.isActive()) !== null && _d !== void 0 ? _d : false;
|
|
1355
|
-
break;
|
|
1356
|
-
}
|
|
1357
|
-
case "checkRendered": {
|
|
1358
|
-
//Do nothing. This message is for other subscribers
|
|
1359
|
-
break;
|
|
1360
|
-
}
|
|
1361
|
-
default: {
|
|
1362
|
-
throw new Error("unhandled comm message");
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
_this.changeDetectorRef.detectChanges();
|
|
1366
|
-
});
|
|
1367
|
-
};
|
|
1368
|
-
DropZoneComponent.prototype.ngOnDestroy = function () {
|
|
1369
|
-
if (this.commSubscription !== undefined) {
|
|
1370
|
-
this.commSubscription.unsubscribe();
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
return DropZoneComponent;
|
|
1374
|
-
}());
|
|
1375
|
-
DropZoneComponent.ɵfac = function DropZoneComponent_Factory(t) { return new (t || DropZoneComponent)(i0__namespace.ɵɵdirectiveInject(DropZoneService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef)); };
|
|
1376
|
-
DropZoneComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: DropZoneComponent, selectors: [["drop-zone"]], inputs: { dropZone: "dropZone" }, decls: 1, vars: 1, consts: [["class", "dropZoneContainer", 3, "dragenter", 4, "ngIf"], [1, "dropZoneContainer", 3, "dragenter"], [3, "ngClass"]], template: function DropZoneComponent_Template(rf, ctx) {
|
|
1377
|
-
if (rf & 1) {
|
|
1378
|
-
i0__namespace.ɵɵtemplate(0, DropZoneComponent_div_0_Template, 2, 4, "div", 0);
|
|
1379
|
-
}
|
|
1380
|
-
if (rf & 2) {
|
|
1381
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.visible);
|
|
1382
|
-
}
|
|
1383
|
-
}, directives: [i2__namespace.NgIf, i2__namespace.NgClass], styles: [".active[_ngcontent-%COMP%]{margin:10px 0;width:calc(100% - 20px);height:105px;border-radius:5px;background:#f0f9ff;border:2px dashed #bed2db;box-sizing:border-box}.related[_ngcontent-%COMP%]{margin:10px 0;width:calc(100% - 20px);height:30px;border-radius:5px;background:#fff6f0;border:1px dashed #dbccbe;box-sizing:border-box;opacity:.8}.dropZoneContainer[_ngcontent-%COMP%]{position:relative}"], changeDetection: 0 });
|
|
1384
|
-
(function () {
|
|
1385
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DropZoneComponent, [{
|
|
1386
|
-
type: i0.Component,
|
|
1387
|
-
args: [{
|
|
1388
|
-
selector: "drop-zone",
|
|
1389
|
-
templateUrl: "./drop-zone.component.html",
|
|
1390
|
-
styleUrls: ["./drop-zone.component.scss"],
|
|
1391
|
-
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1392
|
-
}]
|
|
1393
|
-
}], function () { return [{ type: DropZoneService }, { type: i0__namespace.ChangeDetectorRef }]; }, { dropZone: [{
|
|
1394
|
-
type: i0.Input
|
|
1395
|
-
}] });
|
|
1396
|
-
})();
|
|
1397
|
-
|
|
1398
|
-
var _c0$2 = ["children"];
|
|
1399
|
-
function LimbleTreeBranchComponent_drop_zone_1_Template(rf, ctx) {
|
|
1400
|
-
if (rf & 1) {
|
|
1401
|
-
i0__namespace.ɵɵelement(0, "drop-zone", 3);
|
|
1402
|
-
}
|
|
1403
|
-
if (rf & 2) {
|
|
1404
|
-
var ctx_r0 = i0__namespace.ɵɵnextContext();
|
|
1405
|
-
i0__namespace.ɵɵproperty("dropZone", ctx_r0.dropZoneInside);
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
function LimbleTreeBranchComponent_ng_template_3_Template(rf, ctx) { }
|
|
1409
|
-
var LimbleTreeBranchComponent = /** @class */ (function () {
|
|
1410
|
-
function LimbleTreeBranchComponent(treeService, changeDetectorRef, dropZoneService, treeConstructionStatus, ngZone) {
|
|
1411
|
-
var _a;
|
|
1412
|
-
this.treeService = treeService;
|
|
1413
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
1414
|
-
this.dropZoneService = dropZoneService;
|
|
1415
|
-
this.treeConstructionStatus = treeConstructionStatus;
|
|
1416
|
-
this.ngZone = ngZone;
|
|
1417
|
-
this.treeConstructionStatus.constructing();
|
|
1418
|
-
this.indent = (_a = this.treeService.treeOptions) === null || _a === void 0 ? void 0 : _a.indent;
|
|
1419
|
-
this.renderDropZoneInside = false;
|
|
1420
|
-
}
|
|
1421
|
-
LimbleTreeBranchComponent.prototype.ngOnInit = function () {
|
|
1422
|
-
var _this = this;
|
|
1423
|
-
this.addDropZoneInside();
|
|
1424
|
-
this.ngZone.runOutsideAngular(function () {
|
|
1425
|
-
if (_this.dropZoneInside === undefined) {
|
|
1426
|
-
throw new Error("drop zone inside is not defined");
|
|
1427
|
-
}
|
|
1428
|
-
_this.dropZoneInside
|
|
1429
|
-
.getCommChannel()
|
|
1430
|
-
.pipe(operators.filter(function (message) { return message === "checkRendered"; }))
|
|
1431
|
-
.subscribe(function () {
|
|
1432
|
-
if (_this.dropZoneInside === undefined ||
|
|
1433
|
-
_this.branch === undefined) {
|
|
1434
|
-
throw new Error("Zones not registered");
|
|
1435
|
-
}
|
|
1436
|
-
if (isNestingAllowed(_this.treeService.treeOptions, _this.branch.data)) {
|
|
1437
|
-
_this.renderDropZoneInside = _this.dropZoneInside.isRendered();
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
});
|
|
1441
|
-
};
|
|
1442
|
-
LimbleTreeBranchComponent.prototype.ngAfterViewInit = function () {
|
|
1443
|
-
this.reRender();
|
|
1444
|
-
this.setDropZoneHost();
|
|
1445
|
-
this.treeConstructionStatus.doneConstructing();
|
|
1446
|
-
this.changeDetectorRef.detectChanges();
|
|
1447
|
-
};
|
|
1448
|
-
LimbleTreeBranchComponent.prototype.ngOnDestroy = function () {
|
|
1449
|
-
if (this.dropZoneInside !== undefined) {
|
|
1450
|
-
this.dropZoneService.removeDropZone(this.dropZoneInside);
|
|
1451
|
-
}
|
|
1452
|
-
this.treeService.cleanupSignal$.next(true);
|
|
1453
|
-
};
|
|
1454
|
-
LimbleTreeBranchComponent.prototype.addDropZoneInside = function () {
|
|
1455
|
-
if (this.branch === undefined) {
|
|
1456
|
-
throw new Error("failed to register drop zone inside");
|
|
1457
|
-
}
|
|
1458
|
-
this.dropZoneInside = new DropZone(__spreadArray([], __read(this.branch.getCoordinates())), 0);
|
|
1459
|
-
this.dropZoneService.addDropZone(this.dropZoneInside);
|
|
1460
|
-
};
|
|
1461
|
-
LimbleTreeBranchComponent.prototype.reRender = function () {
|
|
1462
|
-
if (this.children === undefined || this.branch === undefined) {
|
|
1463
|
-
throw new Error("Failed to render limble tree branch");
|
|
1464
|
-
}
|
|
1465
|
-
this.treeService.renderBranch(this.children, this.branch);
|
|
1466
|
-
};
|
|
1467
|
-
LimbleTreeBranchComponent.prototype.setDropZoneHost = function () {
|
|
1468
|
-
if (this.children === undefined || this.dropZoneInside === undefined) {
|
|
1469
|
-
throw new Error("Failed to add drop zone host");
|
|
1470
|
-
}
|
|
1471
|
-
this.dropZoneInside.setHost(this.children);
|
|
1472
|
-
};
|
|
1473
|
-
return LimbleTreeBranchComponent;
|
|
1474
|
-
}());
|
|
1475
|
-
LimbleTreeBranchComponent.ɵfac = function LimbleTreeBranchComponent_Factory(t) { return new (t || LimbleTreeBranchComponent)(i0__namespace.ɵɵdirectiveInject(TreeService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(DropZoneService), i0__namespace.ɵɵdirectiveInject(TreeConstructionStatus), i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone)); };
|
|
1476
|
-
LimbleTreeBranchComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: LimbleTreeBranchComponent, selectors: [["limble-tree-branch"]], viewQuery: function LimbleTreeBranchComponent_Query(rf, ctx) {
|
|
1477
|
-
if (rf & 1) {
|
|
1478
|
-
i0__namespace.ɵɵviewQuery(_c0$2, 5, i0.ViewContainerRef);
|
|
1479
|
-
}
|
|
1480
|
-
if (rf & 2) {
|
|
1481
|
-
var _t = void 0;
|
|
1482
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.children = _t.first);
|
|
1483
|
-
}
|
|
1484
|
-
}, inputs: { branch: "branch" }, decls: 5, vars: 4, consts: [[3, "dropZone", 4, "ngIf"], [1, "limble-child-nodes", 3, "hidden"], ["children", ""], [3, "dropZone"]], template: function LimbleTreeBranchComponent_Template(rf, ctx) {
|
|
1485
|
-
if (rf & 1) {
|
|
1486
|
-
i0__namespace.ɵɵelementStart(0, "div");
|
|
1487
|
-
i0__namespace.ɵɵtemplate(1, LimbleTreeBranchComponent_drop_zone_1_Template, 1, 1, "drop-zone", 0);
|
|
1488
|
-
i0__namespace.ɵɵelementStart(2, "span", 1);
|
|
1489
|
-
i0__namespace.ɵɵtemplate(3, LimbleTreeBranchComponent_ng_template_3_Template, 0, 0, "ng-template", null, 2, i0__namespace.ɵɵtemplateRefExtractor);
|
|
1490
|
-
i0__namespace.ɵɵelementEnd();
|
|
1491
|
-
i0__namespace.ɵɵelementEnd();
|
|
1492
|
-
}
|
|
1493
|
-
if (rf & 2) {
|
|
1494
|
-
i0__namespace.ɵɵstyleProp("margin-left", ctx.indent, "px");
|
|
1495
|
-
i0__namespace.ɵɵadvance(1);
|
|
1496
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.renderDropZoneInside);
|
|
1497
|
-
i0__namespace.ɵɵadvance(1);
|
|
1498
|
-
i0__namespace.ɵɵproperty("hidden", ctx.branch && ctx.branch.data.collapsed);
|
|
1499
|
-
}
|
|
1500
|
-
}, directives: [i2__namespace.NgIf, DropZoneComponent], styles: [""] });
|
|
1501
|
-
(function () {
|
|
1502
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LimbleTreeBranchComponent, [{
|
|
1503
|
-
type: i0.Component,
|
|
1504
|
-
args: [{
|
|
1505
|
-
selector: "limble-tree-branch",
|
|
1506
|
-
templateUrl: "./limble-tree-branch.component.html",
|
|
1507
|
-
styleUrls: ["./limble-tree-branch.component.scss"]
|
|
1508
|
-
}]
|
|
1509
|
-
}], function () { return [{ type: TreeService }, { type: i0__namespace.ChangeDetectorRef }, { type: DropZoneService }, { type: TreeConstructionStatus }, { type: i0__namespace.NgZone }]; }, { branch: [{
|
|
1510
|
-
type: i0.Input
|
|
1511
|
-
}], children: [{
|
|
1512
|
-
type: i0.ViewChild,
|
|
1513
|
-
args: ["children", { read: i0.ViewContainerRef }]
|
|
1514
|
-
}] });
|
|
1515
|
-
})();
|
|
1516
|
-
|
|
1517
|
-
var ComponentCreatorService = /** @class */ (function () {
|
|
1518
|
-
function ComponentCreatorService(factoryResolver) {
|
|
1519
|
-
this.factoryResolver = factoryResolver;
|
|
1520
|
-
this.factoryResolver = factoryResolver;
|
|
1521
|
-
}
|
|
1522
|
-
ComponentCreatorService.prototype.appendComponent = function (component, viewContainerRef, index) {
|
|
1523
|
-
if (index === void 0) { index = undefined; }
|
|
1524
|
-
var componentFactory = this.factoryResolver.resolveComponentFactory(component);
|
|
1525
|
-
var componentRef = viewContainerRef.createComponent(componentFactory, index);
|
|
1526
|
-
return componentRef;
|
|
1527
|
-
};
|
|
1528
|
-
return ComponentCreatorService;
|
|
1529
|
-
}());
|
|
1530
|
-
ComponentCreatorService.ɵfac = function ComponentCreatorService_Factory(t) { return new (t || ComponentCreatorService)(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver)); };
|
|
1531
|
-
ComponentCreatorService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: ComponentCreatorService, factory: ComponentCreatorService.ɵfac });
|
|
1532
|
-
(function () {
|
|
1533
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ComponentCreatorService, [{
|
|
1534
|
-
type: i0.Injectable
|
|
1535
|
-
}], function () { return [{ type: i0__namespace.ComponentFactoryResolver }]; }, null);
|
|
1536
|
-
})();
|
|
1537
|
-
|
|
1538
|
-
function getScrollParent(element) {
|
|
1539
|
-
var e_1, _b;
|
|
1540
|
-
var _a;
|
|
1541
|
-
var regex = /(auto|scroll)/;
|
|
1542
|
-
var parents = function (_node, parentList) {
|
|
1543
|
-
if (_node === null || _node.parentNode === null) {
|
|
1544
|
-
return parentList;
|
|
1545
|
-
}
|
|
1546
|
-
return parents(_node.parentElement, parentList.concat([_node]));
|
|
1547
|
-
};
|
|
1548
|
-
var style = function (_node, prop) { return getComputedStyle(_node, null).getPropertyValue(prop); };
|
|
1549
|
-
var overflow = function (_node) { return style(_node, "overflow") +
|
|
1550
|
-
style(_node, "overflow-y") +
|
|
1551
|
-
style(_node, "overflow-x"); };
|
|
1552
|
-
var scroll = function (_node) { return regex.test(overflow(_node)); };
|
|
1553
|
-
var parentList = parents(element.parentElement, []);
|
|
1554
|
-
try {
|
|
1555
|
-
for (var parentList_1 = __values(parentList), parentList_1_1 = parentList_1.next(); !parentList_1_1.done; parentList_1_1 = parentList_1.next()) {
|
|
1556
|
-
var parent = parentList_1_1.value;
|
|
1557
|
-
if (scroll(parent)) {
|
|
1558
|
-
return parent;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1563
|
-
finally {
|
|
1564
|
-
try {
|
|
1565
|
-
if (parentList_1_1 && !parentList_1_1.done && (_b = parentList_1.return)) _b.call(parentList_1);
|
|
1566
|
-
}
|
|
1567
|
-
finally { if (e_1) throw e_1.error; }
|
|
1568
|
-
}
|
|
1569
|
-
return ((_a = document.scrollingElement) !== null && _a !== void 0 ? _a : document.documentElement);
|
|
1570
|
-
}
|
|
1571
|
-
var GlobalEventsService = /** @class */ (function () {
|
|
1572
|
-
function GlobalEventsService(ngZone) {
|
|
1573
|
-
var _this = this;
|
|
1574
|
-
this.ngZone = ngZone;
|
|
1575
|
-
this.ngZone.runOutsideAngular(function () {
|
|
1576
|
-
_this.globalDrag$ = rxjs.fromEvent(document, "drag");
|
|
1577
|
-
});
|
|
1578
|
-
this.scrolling = false;
|
|
1579
|
-
}
|
|
1580
|
-
GlobalEventsService.prototype.addScrolling = function () {
|
|
1581
|
-
var _this = this;
|
|
1582
|
-
this.ngZone.runOutsideAngular(function () {
|
|
1583
|
-
if (_this.globalDragSubscription !== undefined) {
|
|
1584
|
-
return;
|
|
1585
|
-
}
|
|
1586
|
-
if (_this.globalDrag$ === undefined) {
|
|
1587
|
-
throw new Error("Could not get observable");
|
|
1588
|
-
}
|
|
1589
|
-
var viewPortHeight;
|
|
1590
|
-
var scrollAreaSize;
|
|
1591
|
-
var edgeTop;
|
|
1592
|
-
var edgeBottom;
|
|
1593
|
-
var isInTopScrollArea;
|
|
1594
|
-
var isInBottomScrollArea;
|
|
1595
|
-
var timer;
|
|
1596
|
-
var scrollableDiv;
|
|
1597
|
-
var relativeY;
|
|
1598
|
-
_this.globalDragSubscription = _this.globalDrag$
|
|
1599
|
-
.pipe(operators.throttleTime(25), operators.filter(function (event) {
|
|
1600
|
-
if (!event.target) {
|
|
1601
|
-
return false;
|
|
1602
|
-
}
|
|
1603
|
-
scrollableDiv = getScrollParent(event.target);
|
|
1604
|
-
viewPortHeight = scrollableDiv.clientHeight;
|
|
1605
|
-
var viewPortWidth = scrollableDiv.clientWidth;
|
|
1606
|
-
var relativeX;
|
|
1607
|
-
if (window
|
|
1608
|
-
.getComputedStyle(scrollableDiv)
|
|
1609
|
-
.getPropertyValue("position")
|
|
1610
|
-
.toLowerCase() === "fixed") {
|
|
1611
|
-
relativeX = event.clientX;
|
|
1612
|
-
relativeY = event.clientY;
|
|
1613
|
-
}
|
|
1614
|
-
else {
|
|
1615
|
-
var boundingRect = scrollableDiv.getBoundingClientRect();
|
|
1616
|
-
var scrollableDivAncestor = getScrollParent(scrollableDiv);
|
|
1617
|
-
relativeX =
|
|
1618
|
-
event.clientX -
|
|
1619
|
-
(boundingRect.left + scrollableDivAncestor.scrollLeft);
|
|
1620
|
-
relativeY =
|
|
1621
|
-
event.clientY -
|
|
1622
|
-
(boundingRect.top + scrollableDivAncestor.scrollTop);
|
|
1623
|
-
}
|
|
1624
|
-
if (relativeX < 0 ||
|
|
1625
|
-
relativeX > viewPortWidth ||
|
|
1626
|
-
relativeY < 0 ||
|
|
1627
|
-
relativeY > viewPortHeight) {
|
|
1628
|
-
//Outside of scrollable div
|
|
1629
|
-
return false;
|
|
1630
|
-
}
|
|
1631
|
-
scrollAreaSize = Math.max(viewPortHeight * 0.1, 100);
|
|
1632
|
-
edgeTop = scrollAreaSize;
|
|
1633
|
-
edgeBottom = viewPortHeight - scrollAreaSize;
|
|
1634
|
-
isInTopScrollArea = relativeY < edgeTop;
|
|
1635
|
-
isInBottomScrollArea = relativeY > edgeBottom;
|
|
1636
|
-
return isInTopScrollArea || isInBottomScrollArea;
|
|
1637
|
-
}))
|
|
1638
|
-
.subscribe(function () {
|
|
1639
|
-
if (scrollableDiv === null) {
|
|
1640
|
-
return;
|
|
1641
|
-
}
|
|
1642
|
-
var height = scrollableDiv.scrollHeight;
|
|
1643
|
-
var maxScrollY = height - viewPortHeight;
|
|
1644
|
-
var currentScrollY = scrollableDiv.scrollTop;
|
|
1645
|
-
var canScrollUp = currentScrollY > 0;
|
|
1646
|
-
var canScrollDown = currentScrollY < maxScrollY;
|
|
1647
|
-
var nextScrollY;
|
|
1648
|
-
var maxStep = 75;
|
|
1649
|
-
if (isInTopScrollArea && canScrollUp) {
|
|
1650
|
-
var intensity = (edgeTop - relativeY) / scrollAreaSize;
|
|
1651
|
-
nextScrollY = currentScrollY - maxStep * intensity;
|
|
1652
|
-
}
|
|
1653
|
-
else if (isInBottomScrollArea && canScrollDown) {
|
|
1654
|
-
var intensity = (relativeY - edgeBottom) / scrollAreaSize;
|
|
1655
|
-
nextScrollY = currentScrollY + maxStep * intensity;
|
|
1656
|
-
}
|
|
1657
|
-
else {
|
|
1658
|
-
return;
|
|
1659
|
-
}
|
|
1660
|
-
nextScrollY = Math.max(0, Math.min(maxScrollY, nextScrollY));
|
|
1661
|
-
if (nextScrollY !== currentScrollY) {
|
|
1662
|
-
scrollableDiv.scrollTo({ top: nextScrollY });
|
|
1663
|
-
_this.scrolling = true;
|
|
1664
|
-
clearTimeout(timer);
|
|
1665
|
-
timer = setTimeout(function () {
|
|
1666
|
-
_this.scrolling = false;
|
|
1667
|
-
}, 100);
|
|
1668
|
-
}
|
|
1669
|
-
});
|
|
1670
|
-
});
|
|
1671
|
-
};
|
|
1672
|
-
GlobalEventsService.prototype.removeScrolling = function () {
|
|
1673
|
-
if (this.globalDragSubscription !== undefined) {
|
|
1674
|
-
this.globalDragSubscription.unsubscribe();
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
return GlobalEventsService;
|
|
1678
|
-
}());
|
|
1679
|
-
GlobalEventsService.ɵfac = function GlobalEventsService_Factory(t) { return new (t || GlobalEventsService)(i0__namespace.ɵɵinject(i0__namespace.NgZone)); };
|
|
1680
|
-
GlobalEventsService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: GlobalEventsService, factory: GlobalEventsService.ɵfac });
|
|
1681
|
-
(function () {
|
|
1682
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(GlobalEventsService, [{
|
|
1683
|
-
type: i0.Injectable
|
|
1684
|
-
}], function () { return [{ type: i0__namespace.NgZone }]; }, null);
|
|
1685
|
-
})();
|
|
1686
|
-
|
|
1687
|
-
var _c0$1 = ["nodeHost"];
|
|
1688
|
-
var _c1 = ["draggableDiv"];
|
|
1689
|
-
var _c2 = ["nodeHostContainer"];
|
|
1690
|
-
var _c3 = ["innerBranch"];
|
|
1691
|
-
function LimbleTreeNodeComponent_drop_zone_0_Template(rf, ctx) {
|
|
1692
|
-
if (rf & 1) {
|
|
1693
|
-
i0__namespace.ɵɵelement(0, "drop-zone", 7);
|
|
1694
|
-
}
|
|
1695
|
-
if (rf & 2) {
|
|
1696
|
-
var ctx_r0 = i0__namespace.ɵɵnextContext();
|
|
1697
|
-
i0__namespace.ɵɵproperty("dropZone", ctx_r0.dropZoneAbove);
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
function LimbleTreeNodeComponent_ng_template_5_Template(rf, ctx) { }
|
|
1701
|
-
function LimbleTreeNodeComponent_limble_tree_branch_7_Template(rf, ctx) {
|
|
1702
|
-
if (rf & 1) {
|
|
1703
|
-
i0__namespace.ɵɵelement(0, "limble-tree-branch", 8, 9);
|
|
1704
|
-
}
|
|
1705
|
-
if (rf & 2) {
|
|
1706
|
-
var ctx_r5 = i0__namespace.ɵɵnextContext();
|
|
1707
|
-
i0__namespace.ɵɵproperty("branch", ctx_r5.branch);
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
function LimbleTreeNodeComponent_drop_zone_8_Template(rf, ctx) {
|
|
1711
|
-
if (rf & 1) {
|
|
1712
|
-
i0__namespace.ɵɵelement(0, "drop-zone", 7);
|
|
1713
|
-
}
|
|
1714
|
-
if (rf & 2) {
|
|
1715
|
-
var ctx_r6 = i0__namespace.ɵɵnextContext();
|
|
1716
|
-
i0__namespace.ɵɵproperty("dropZone", ctx_r6.dropZoneBelow);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
var LimbleTreeNodeComponent = /** @class */ (function () {
|
|
1720
|
-
function LimbleTreeNodeComponent(componentCreatorService, changeDetectorRef, dragStateService, dropZoneService, treeService, globalEventsService, ngZone, treeConstructionStatus) {
|
|
1721
|
-
var _this = this;
|
|
1722
|
-
this.componentCreatorService = componentCreatorService;
|
|
1723
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
1724
|
-
this.dragStateService = dragStateService;
|
|
1725
|
-
this.dropZoneService = dropZoneService;
|
|
1726
|
-
this.treeService = treeService;
|
|
1727
|
-
this.globalEventsService = globalEventsService;
|
|
1728
|
-
this.ngZone = ngZone;
|
|
1729
|
-
this.treeConstructionStatus = treeConstructionStatus;
|
|
1730
|
-
this.treeConstructionStatus.constructing();
|
|
1731
|
-
if (this.treeService.treeOptions !== undefined &&
|
|
1732
|
-
this.treeService.treeOptions.listMode !== true) {
|
|
1733
|
-
this.renderInnerBranch = true;
|
|
1734
|
-
}
|
|
1735
|
-
else {
|
|
1736
|
-
this.renderInnerBranch = false;
|
|
1737
|
-
}
|
|
1738
|
-
this.renderDropZoneBelow = false;
|
|
1739
|
-
this.renderDropZoneAbove = false;
|
|
1740
|
-
this.treeChangeSubscription = this.treeService.changes$
|
|
1741
|
-
.pipe(
|
|
1742
|
-
//The first one is the initial tree render, which we can ignore
|
|
1743
|
-
operators.skip(1))
|
|
1744
|
-
.subscribe(function () {
|
|
1745
|
-
_this.treeChangeHandler();
|
|
1746
|
-
});
|
|
1747
|
-
}
|
|
1748
|
-
LimbleTreeNodeComponent.prototype.treeChangeHandler = function () {
|
|
1749
|
-
if (this.branch !== undefined &&
|
|
1750
|
-
this.currentBranchCoordinates !== undefined &&
|
|
1751
|
-
!arraysAreEqual(this.branch.getCoordinates(), this.currentBranchCoordinates)) {
|
|
1752
|
-
this.updateDropZones();
|
|
1753
|
-
}
|
|
1754
|
-
};
|
|
1755
|
-
LimbleTreeNodeComponent.prototype.ngOnInit = function () {
|
|
1756
|
-
var _this = this;
|
|
1757
|
-
var _a, _b, _c;
|
|
1758
|
-
if (((_a = this.treeService.treeOptions) === null || _a === void 0 ? void 0 : _a.allowDragging) === false) {
|
|
1759
|
-
return;
|
|
1760
|
-
}
|
|
1761
|
-
var parent = (_b = this.branch) === null || _b === void 0 ? void 0 : _b.getParent();
|
|
1762
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.data) !== null) {
|
|
1763
|
-
var parentData = parent === null || parent === void 0 ? void 0 : parent.data;
|
|
1764
|
-
if (!isNestingAllowed(this.treeService.treeOptions, parentData)) {
|
|
1765
|
-
this.renderInnerBranch = false;
|
|
1766
|
-
return;
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
this.registerDropZones();
|
|
1770
|
-
this.currentBranchCoordinates = (_c = this.branch) === null || _c === void 0 ? void 0 : _c.getCoordinates();
|
|
1771
|
-
this.ngZone.runOutsideAngular(function () {
|
|
1772
|
-
if (_this.dropZoneAbove === undefined ||
|
|
1773
|
-
_this.dropZoneBelow === undefined) {
|
|
1774
|
-
throw new Error("Zones not registered");
|
|
1775
|
-
}
|
|
1776
|
-
rxjs.merge(_this.dropZoneAbove.getCommChannel(), _this.dropZoneBelow.getCommChannel())
|
|
1777
|
-
.pipe(operators.filter(function (message) { return message === "checkRendered"; }))
|
|
1778
|
-
.subscribe(function () {
|
|
1779
|
-
if (_this.dropZoneAbove === undefined ||
|
|
1780
|
-
_this.dropZoneBelow === undefined ||
|
|
1781
|
-
_this.branch === undefined) {
|
|
1782
|
-
throw new Error("Zones not registered");
|
|
1783
|
-
}
|
|
1784
|
-
_this.renderDropZoneAbove = _this.dropZoneAbove.isRendered();
|
|
1785
|
-
_this.renderDropZoneBelow = _this.dropZoneBelow.isRendered();
|
|
1786
|
-
});
|
|
1787
|
-
});
|
|
1788
|
-
};
|
|
1789
|
-
LimbleTreeNodeComponent.prototype.ngAfterViewInit = function () {
|
|
1790
|
-
this.renderNode();
|
|
1791
|
-
this.setDropZoneHosts();
|
|
1792
|
-
this.checkForHandle();
|
|
1793
|
-
this.treeConstructionStatus.doneConstructing();
|
|
1794
|
-
this.changeDetectorRef.detectChanges();
|
|
1795
|
-
};
|
|
1796
|
-
LimbleTreeNodeComponent.prototype.ngOnDestroy = function () {
|
|
1797
|
-
this.treeChangeSubscription.unsubscribe();
|
|
1798
|
-
if (this.dropZoneAbove !== undefined) {
|
|
1799
|
-
this.dropZoneService.removeDropZone(this.dropZoneAbove);
|
|
1800
|
-
}
|
|
1801
|
-
if (this.dropZoneBelow !== undefined) {
|
|
1802
|
-
this.dropZoneService.removeDropZone(this.dropZoneBelow);
|
|
1803
|
-
}
|
|
1804
|
-
this.treeService.cleanupSignal$.next(true);
|
|
1805
|
-
};
|
|
1806
|
-
LimbleTreeNodeComponent.prototype.dragstartHandler = function (event) {
|
|
1807
|
-
var _this = this;
|
|
1808
|
-
var _a;
|
|
1809
|
-
event.stopPropagation();
|
|
1810
|
-
if (event.dataTransfer === null ||
|
|
1811
|
-
this.branch === undefined ||
|
|
1812
|
-
this.parentHost === undefined) {
|
|
1813
|
-
throw new Error("failed to run dragstartHandler");
|
|
1814
|
-
}
|
|
1815
|
-
var draggedElement = event.target;
|
|
1816
|
-
if (((_a = draggedElement.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) !== "LIMBLE-TREE-NODE") {
|
|
1817
|
-
//Don't drag stuff that isn't part of the tree
|
|
1818
|
-
event.preventDefault();
|
|
1819
|
-
return;
|
|
1820
|
-
}
|
|
1821
|
-
event.dataTransfer.effectAllowed = "move";
|
|
1822
|
-
this.dragStateService.dragging(this.branch, this.parentHost);
|
|
1823
|
-
var treeElement = draggedElement.closest("limble-tree-root");
|
|
1824
|
-
if (treeElement === null) {
|
|
1825
|
-
throw new Error("could not get root of tree");
|
|
1826
|
-
}
|
|
1827
|
-
this.ngZone.runOutsideAngular(function () {
|
|
1828
|
-
//We have to use a setTimeout due to a bug in chrome: https://stackoverflow.com/a/20733870/8796651
|
|
1829
|
-
setTimeout(function () {
|
|
1830
|
-
var _a, _b;
|
|
1831
|
-
draggedElement.classList.add("dragging");
|
|
1832
|
-
if (((_a = _this.treeService.treeData) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
|
|
1833
|
-
((_b = _this.branch) === null || _b === void 0 ? void 0 : _b.getCoordinates().length) === 1) {
|
|
1834
|
-
//We are dragging the only element in the tree, so we have to use the placeholder system
|
|
1835
|
-
_this.treeService.placeholder$.next(true);
|
|
1836
|
-
}
|
|
1837
|
-
});
|
|
1838
|
-
//We use this weird subscription/timeout combo in order to avoid a strange bug where the dragleave event
|
|
1839
|
-
//does not fire if the user drags out of the tree too quickly. This issue would make the drop zone
|
|
1840
|
-
//remain in the UI, potentially causing drop zones to appear in multiple trees at a time. This subscription
|
|
1841
|
-
//waits for the dragover event on the tree to fire before rendering any drop zones. If the dragover
|
|
1842
|
-
//event does not fire within a half second, we know the mouse left the tree too quickly, and we won't
|
|
1843
|
-
//render the drop zone at all.
|
|
1844
|
-
var dragSubscription = rxjs.fromEvent(treeElement, "dragover")
|
|
1845
|
-
.pipe(operators.first())
|
|
1846
|
-
.subscribe(function (dragoverEvent) {
|
|
1847
|
-
dragoverEvent.stopPropagation();
|
|
1848
|
-
if (_this.branch === undefined) {
|
|
1849
|
-
throw new Error("Could not show surrounding drop zones");
|
|
1850
|
-
}
|
|
1851
|
-
var parent = _this.branch.getParent();
|
|
1852
|
-
var parentData;
|
|
1853
|
-
var parentNestingAllowed = true;
|
|
1854
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.data) !== null) {
|
|
1855
|
-
parentData = parent === null || parent === void 0 ? void 0 : parent.data;
|
|
1856
|
-
parentNestingAllowed = isNestingAllowed(_this.treeService.treeOptions, parentData);
|
|
1857
|
-
}
|
|
1858
|
-
if (_this.dropZoneAbove !== undefined && parentNestingAllowed) {
|
|
1859
|
-
_this.dropZoneService.showDropZoneFamily(_this.dropZoneAbove, {
|
|
1860
|
-
joinFamilies: true
|
|
1861
|
-
});
|
|
1862
|
-
}
|
|
1863
|
-
});
|
|
1864
|
-
setTimeout(function () {
|
|
1865
|
-
if (!dragSubscription.closed) {
|
|
1866
|
-
dragSubscription.unsubscribe();
|
|
1867
|
-
}
|
|
1868
|
-
}, 500);
|
|
1869
|
-
});
|
|
1870
|
-
};
|
|
1871
|
-
LimbleTreeNodeComponent.prototype.dragendHandler = function (event) {
|
|
1872
|
-
var _a, _b;
|
|
1873
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
1874
|
-
if (this.draggableDiv === undefined) {
|
|
1875
|
-
throw new Error("could not get draggable div");
|
|
1876
|
-
}
|
|
1877
|
-
this.draggableDiv.nativeElement.classList.remove("dragging");
|
|
1878
|
-
if (this.dragStateService.getState() === "captured") {
|
|
1879
|
-
if (this.treeService.captured === false) {
|
|
1880
|
-
//Dropped in a different tree. Remove the one in this tree
|
|
1881
|
-
if (this.branch === undefined) {
|
|
1882
|
-
throw new Error("could not get branch in dragendHandler");
|
|
1883
|
-
}
|
|
1884
|
-
this.treeService.cleanupSignal$.next(true);
|
|
1885
|
-
this.treeService.captured = false;
|
|
1886
|
-
}
|
|
1887
|
-
this.dragStateService.release();
|
|
1888
|
-
}
|
|
1889
|
-
else {
|
|
1890
|
-
//Wasn't dropped into a valid tree, so reset for next drag and
|
|
1891
|
-
//don't do anything else.
|
|
1892
|
-
this.dragStateService.release();
|
|
1893
|
-
this.dropZoneService.clearVisibleZones();
|
|
1894
|
-
this.dropZoneService.restoreFamilies();
|
|
1895
|
-
if (((_a = this.treeService.treeData) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
|
|
1896
|
-
((_b = this.branch) === null || _b === void 0 ? void 0 : _b.getCoordinates().length) === 1) {
|
|
1897
|
-
//We were dragging the only element in the tree, so we have to
|
|
1898
|
-
//remove the placeholder that we added in the dragstart
|
|
1899
|
-
this.treeService.placeholder$.next(false);
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
LimbleTreeNodeComponent.prototype.dragoverHandler = function (event) {
|
|
1904
|
-
var _a, _b, _c;
|
|
1905
|
-
if (this.globalEventsService.scrolling === true) {
|
|
1906
|
-
return;
|
|
1907
|
-
}
|
|
1908
|
-
if (this.branch === undefined) {
|
|
1909
|
-
throw new Error("Can't get current branch during dragover event");
|
|
1910
|
-
}
|
|
1911
|
-
var data = this.dragStateService.getData();
|
|
1912
|
-
if (data === undefined) {
|
|
1913
|
-
//They might be dragging something that isn't a node. Just ignore it.
|
|
1914
|
-
return;
|
|
1915
|
-
}
|
|
1916
|
-
var sourceBranch = data.branch;
|
|
1917
|
-
//If trying to drop on self, return.
|
|
1918
|
-
if (sourceBranch === this.branch ||
|
|
1919
|
-
this.branch.getAncestors().includes(sourceBranch)) {
|
|
1920
|
-
return;
|
|
1921
|
-
}
|
|
1922
|
-
var target = event.currentTarget.closest(".node-host-container");
|
|
1923
|
-
if (!(target instanceof HTMLElement)) {
|
|
1924
|
-
throw new Error("Failed to find node host container while dragging");
|
|
1925
|
-
}
|
|
1926
|
-
var topLine;
|
|
1927
|
-
var bottomLine;
|
|
1928
|
-
if (((_a = this.innerBranch) === null || _a === void 0 ? void 0 : _a.renderDropZoneInside) === false) {
|
|
1929
|
-
topLine = target.offsetHeight / 2 - 6;
|
|
1930
|
-
bottomLine = topLine;
|
|
1931
|
-
}
|
|
1932
|
-
else {
|
|
1933
|
-
topLine = target.offsetHeight / 3 - 3; //an imaginary line 1/3 of the way down from the top of the element;
|
|
1934
|
-
bottomLine = topLine * 2; //an imaginary line 1/3 of the way up from the bottom of the element;
|
|
1935
|
-
}
|
|
1936
|
-
var parent = this.branch.getParent();
|
|
1937
|
-
var parentData;
|
|
1938
|
-
var parentNestingAllowed = true;
|
|
1939
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.data) !== null) {
|
|
1940
|
-
parentData = parent === null || parent === void 0 ? void 0 : parent.data;
|
|
1941
|
-
parentNestingAllowed = isNestingAllowed(this.treeService.treeOptions, parentData);
|
|
1942
|
-
}
|
|
1943
|
-
/** The y-coordinates of the mouse in relation to the node it is hovering over */
|
|
1944
|
-
var offsetY = event.clientY - target.getBoundingClientRect().top;
|
|
1945
|
-
var activeDropZone = this.dropZoneService.getActiveDropZone();
|
|
1946
|
-
if (offsetY < topLine &&
|
|
1947
|
-
this.dropZoneAbove !== undefined &&
|
|
1948
|
-
parentNestingAllowed &&
|
|
1949
|
-
(activeDropZone === null ||
|
|
1950
|
-
!DropZone.dropZoneLocationsAreEqual(activeDropZone, this.dropZoneAbove))) {
|
|
1951
|
-
var index = this.branch.getIndex();
|
|
1952
|
-
if (index === undefined || index === null) {
|
|
1953
|
-
throw new Error("can't get branch index");
|
|
1954
|
-
}
|
|
1955
|
-
this.dropZoneService.showDropZoneFamily(this.dropZoneAbove, {
|
|
1956
|
-
activateLowestInsteadOfFounder: true
|
|
1957
|
-
});
|
|
1958
|
-
if (suddenTreeExit(event)) {
|
|
1959
|
-
this.dropZoneService.clearVisibleZones();
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
else if (offsetY < bottomLine &&
|
|
1963
|
-
offsetY > topLine &&
|
|
1964
|
-
((_b = this.innerBranch) === null || _b === void 0 ? void 0 : _b.renderDropZoneInside) === true &&
|
|
1965
|
-
((_c = this.innerBranch) === null || _c === void 0 ? void 0 : _c.dropZoneInside) !== undefined &&
|
|
1966
|
-
(activeDropZone === null ||
|
|
1967
|
-
!DropZone.dropZoneLocationsAreEqual(activeDropZone, this.innerBranch.dropZoneInside))) {
|
|
1968
|
-
this.dropZoneService.showDropZoneFamily(this.innerBranch.dropZoneInside);
|
|
1969
|
-
if (suddenTreeExit(event)) {
|
|
1970
|
-
this.dropZoneService.clearVisibleZones();
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
else if (offsetY >= bottomLine &&
|
|
1974
|
-
this.dropZoneBelow !== undefined &&
|
|
1975
|
-
parentNestingAllowed &&
|
|
1976
|
-
(activeDropZone === null ||
|
|
1977
|
-
!DropZone.dropZoneLocationsAreEqual(activeDropZone, this.dropZoneBelow)) &&
|
|
1978
|
-
this.branch.getChildren().length === 0) {
|
|
1979
|
-
var index = this.branch.getIndex();
|
|
1980
|
-
if (index === undefined || index === null) {
|
|
1981
|
-
throw new Error("can't get branch index");
|
|
1982
|
-
}
|
|
1983
|
-
this.dropZoneService.showDropZoneFamily(this.dropZoneBelow);
|
|
1984
|
-
if (suddenTreeExit(event)) {
|
|
1985
|
-
this.dropZoneService.clearVisibleZones();
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
};
|
|
1989
|
-
LimbleTreeNodeComponent.prototype.renderNode = function () {
|
|
1990
|
-
var _a;
|
|
1991
|
-
if (this.nodeHost === undefined || this.branch === undefined) {
|
|
1992
|
-
throw new Error("Failed to render tree node");
|
|
1993
|
-
}
|
|
1994
|
-
var component = this.branch.data.component;
|
|
1995
|
-
if (component === undefined) {
|
|
1996
|
-
component = (_a = this.treeService.treeOptions) === null || _a === void 0 ? void 0 : _a.defaultComponent;
|
|
1997
|
-
}
|
|
1998
|
-
if (component === undefined) {
|
|
1999
|
-
throw new Error("limbleTree requires a component to render");
|
|
2000
|
-
}
|
|
2001
|
-
var componentRef = this.componentCreatorService.appendComponent(component.class, this.nodeHost);
|
|
2002
|
-
componentRef.instance.nodeData = this.branch.data;
|
|
2003
|
-
for (var binding in component.bindings) {
|
|
2004
|
-
componentRef.instance[binding] = component.bindings[binding];
|
|
2005
|
-
}
|
|
2006
|
-
};
|
|
2007
|
-
LimbleTreeNodeComponent.prototype.registerDropZones = function () {
|
|
2008
|
-
this.addDropZoneAbove();
|
|
2009
|
-
this.addDropZoneBelow();
|
|
2010
|
-
};
|
|
2011
|
-
LimbleTreeNodeComponent.prototype.addDropZoneAbove = function () {
|
|
2012
|
-
var _a;
|
|
2013
|
-
if (this.branch === undefined) {
|
|
2014
|
-
throw new Error("failed to register drop zone above");
|
|
2015
|
-
}
|
|
2016
|
-
var parent = this.branch.getParent();
|
|
2017
|
-
var currentCoordinates = this.branch.getCoordinates();
|
|
2018
|
-
var index = currentCoordinates[currentCoordinates.length - 1];
|
|
2019
|
-
this.dropZoneAbove = new DropZone(__spreadArray([], __read(((_a = parent === null || parent === void 0 ? void 0 : parent.getCoordinates()) !== null && _a !== void 0 ? _a : []))), index);
|
|
2020
|
-
this.dropZoneService.addDropZone(this.dropZoneAbove);
|
|
2021
|
-
};
|
|
2022
|
-
LimbleTreeNodeComponent.prototype.addDropZoneBelow = function () {
|
|
2023
|
-
var _a;
|
|
2024
|
-
if (this.branch === undefined) {
|
|
2025
|
-
throw new Error("failed to register drop zone below");
|
|
2026
|
-
}
|
|
2027
|
-
var parent = this.branch.getParent();
|
|
2028
|
-
var currentCoordinates = this.branch.getCoordinates();
|
|
2029
|
-
var index = currentCoordinates[currentCoordinates.length - 1];
|
|
2030
|
-
this.dropZoneBelow = new DropZone(__spreadArray([], __read(((_a = parent === null || parent === void 0 ? void 0 : parent.getCoordinates()) !== null && _a !== void 0 ? _a : []))), index + 1);
|
|
2031
|
-
this.dropZoneService.addDropZone(this.dropZoneBelow);
|
|
2032
|
-
};
|
|
2033
|
-
LimbleTreeNodeComponent.prototype.updateDropZones = function () {
|
|
2034
|
-
var _a;
|
|
2035
|
-
this.currentBranchCoordinates = (_a = this.branch) === null || _a === void 0 ? void 0 : _a.getCoordinates();
|
|
2036
|
-
this.updateDropZoneAbove();
|
|
2037
|
-
this.updateDropZoneBelow();
|
|
2038
|
-
this.updateDropZoneInside();
|
|
2039
|
-
this.setDropZoneHosts();
|
|
2040
|
-
};
|
|
2041
|
-
LimbleTreeNodeComponent.prototype.updateDropZoneAbove = function () {
|
|
2042
|
-
var _a;
|
|
2043
|
-
if (this.branch === undefined || this.dropZoneAbove === undefined) {
|
|
2044
|
-
throw new Error("failed to update drop zone above");
|
|
2045
|
-
}
|
|
2046
|
-
var parent = this.branch.getParent();
|
|
2047
|
-
var currentCoordinates = this.branch.getCoordinates();
|
|
2048
|
-
var index = currentCoordinates[currentCoordinates.length - 1];
|
|
2049
|
-
var location = this.dropZoneAbove.getLocation();
|
|
2050
|
-
location.setParentCoordinates(__spreadArray([], __read(((_a = parent === null || parent === void 0 ? void 0 : parent.getCoordinates()) !== null && _a !== void 0 ? _a : []))));
|
|
2051
|
-
location.setInsertIndex(index);
|
|
2052
|
-
};
|
|
2053
|
-
LimbleTreeNodeComponent.prototype.updateDropZoneBelow = function () {
|
|
2054
|
-
var _a;
|
|
2055
|
-
if (this.branch === undefined || this.dropZoneBelow === undefined) {
|
|
2056
|
-
throw new Error("failed to update drop zone below");
|
|
2057
|
-
}
|
|
2058
|
-
var parent = this.branch.getParent();
|
|
2059
|
-
var currentCoordinates = this.branch.getCoordinates();
|
|
2060
|
-
var index = currentCoordinates[currentCoordinates.length - 1];
|
|
2061
|
-
var location = this.dropZoneBelow.getLocation();
|
|
2062
|
-
location.setParentCoordinates(__spreadArray([], __read(((_a = parent === null || parent === void 0 ? void 0 : parent.getCoordinates()) !== null && _a !== void 0 ? _a : []))));
|
|
2063
|
-
location.setInsertIndex(index + 1);
|
|
2064
|
-
};
|
|
2065
|
-
LimbleTreeNodeComponent.prototype.updateDropZoneInside = function () {
|
|
2066
|
-
var _a;
|
|
2067
|
-
if (((_a = this.innerBranch) === null || _a === void 0 ? void 0 : _a.dropZoneInside) === undefined) {
|
|
2068
|
-
return;
|
|
2069
|
-
}
|
|
2070
|
-
if (this.branch === undefined) {
|
|
2071
|
-
throw new Error("failed to update drop zone inside");
|
|
2072
|
-
}
|
|
2073
|
-
var location = this.innerBranch.dropZoneInside.getLocation();
|
|
2074
|
-
location.setParentCoordinates(__spreadArray([], __read(this.branch.getCoordinates())));
|
|
2075
|
-
};
|
|
2076
|
-
LimbleTreeNodeComponent.prototype.setDropZoneHosts = function () {
|
|
2077
|
-
if (this.dropZoneAbove === undefined ||
|
|
2078
|
-
this.dropZoneBelow === undefined) {
|
|
2079
|
-
return;
|
|
2080
|
-
}
|
|
2081
|
-
this.dropZoneAbove.setHost(this.parentHost);
|
|
2082
|
-
this.dropZoneBelow.setHost(this.parentHost);
|
|
2083
|
-
};
|
|
2084
|
-
LimbleTreeNodeComponent.prototype.checkForHandle = function () {
|
|
2085
|
-
var _this = this;
|
|
2086
|
-
var _a;
|
|
2087
|
-
if (this.nodeHostContainer === undefined ||
|
|
2088
|
-
this.draggableDiv === undefined) {
|
|
2089
|
-
return;
|
|
2090
|
-
}
|
|
2091
|
-
var nodeHostContainerElement = this.nodeHostContainer.nativeElement;
|
|
2092
|
-
var handle = nodeHostContainerElement.querySelector(".limble-tree-handle");
|
|
2093
|
-
var draggableDivElement = this.draggableDiv.nativeElement;
|
|
2094
|
-
if (!isDraggingAllowed(this.treeService.treeOptions, (_a = this.branch) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
2095
|
-
draggableDivElement.setAttribute("draggable", "false");
|
|
2096
|
-
}
|
|
2097
|
-
else if (handle === null) {
|
|
2098
|
-
draggableDivElement.setAttribute("draggable", "true");
|
|
2099
|
-
}
|
|
2100
|
-
else {
|
|
2101
|
-
handle.addEventListener("mousedown", function () {
|
|
2102
|
-
draggableDivElement.setAttribute("draggable", "true");
|
|
2103
|
-
//For some reason mouseup doesn't fire after a drag, so we use this observable sequence instead.
|
|
2104
|
-
var dragging = _this.dragStateService.state$.pipe(operators.filter(function (state) { return state === "dragging"; }), operators.first());
|
|
2105
|
-
_this.dragStateService.state$
|
|
2106
|
-
.pipe(operators.skipUntil(dragging), operators.filter(function (state) { return state === "idle"; }), operators.first())
|
|
2107
|
-
.subscribe(function () {
|
|
2108
|
-
draggableDivElement.setAttribute("draggable", "false");
|
|
2109
|
-
});
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
};
|
|
2113
|
-
return LimbleTreeNodeComponent;
|
|
2114
|
-
}());
|
|
2115
|
-
LimbleTreeNodeComponent.ɵfac = function LimbleTreeNodeComponent_Factory(t) { return new (t || LimbleTreeNodeComponent)(i0__namespace.ɵɵdirectiveInject(ComponentCreatorService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(DragStateService), i0__namespace.ɵɵdirectiveInject(DropZoneService), i0__namespace.ɵɵdirectiveInject(TreeService), i0__namespace.ɵɵdirectiveInject(GlobalEventsService), i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone), i0__namespace.ɵɵdirectiveInject(TreeConstructionStatus)); };
|
|
2116
|
-
LimbleTreeNodeComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: LimbleTreeNodeComponent, selectors: [["limble-tree-node"]], viewQuery: function LimbleTreeNodeComponent_Query(rf, ctx) {
|
|
2117
|
-
if (rf & 1) {
|
|
2118
|
-
i0__namespace.ɵɵviewQuery(_c0$1, 5, i0.ViewContainerRef);
|
|
2119
|
-
i0__namespace.ɵɵviewQuery(_c1, 5, i0.ElementRef);
|
|
2120
|
-
i0__namespace.ɵɵviewQuery(_c2, 5, i0.ElementRef);
|
|
2121
|
-
i0__namespace.ɵɵviewQuery(_c3, 5, LimbleTreeBranchComponent);
|
|
2122
|
-
}
|
|
2123
|
-
if (rf & 2) {
|
|
2124
|
-
var _t = void 0;
|
|
2125
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.nodeHost = _t.first);
|
|
2126
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.draggableDiv = _t.first);
|
|
2127
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.nodeHostContainer = _t.first);
|
|
2128
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.innerBranch = _t.first);
|
|
2129
|
-
}
|
|
2130
|
-
}, inputs: { branch: "branch", parentHost: "parentHost" }, decls: 9, vars: 4, consts: [[3, "dropZone", 4, "ngIf"], [1, "limble-parent-container", 3, "dragstart", "dragend"], ["draggableDiv", ""], [1, "node-host-container", 3, "dragoverEventThrottle", "dragoverNoChangeDetect"], ["nodeHostContainer", ""], ["nodeHost", ""], [3, "branch", 4, "ngIf"], [3, "dropZone"], [3, "branch"], ["innerBranch", ""]], template: function LimbleTreeNodeComponent_Template(rf, ctx) {
|
|
2131
|
-
if (rf & 1) {
|
|
2132
|
-
i0__namespace.ɵɵtemplate(0, LimbleTreeNodeComponent_drop_zone_0_Template, 1, 1, "drop-zone", 0);
|
|
2133
|
-
i0__namespace.ɵɵelementStart(1, "div", 1, 2);
|
|
2134
|
-
i0__namespace.ɵɵlistener("dragstart", function LimbleTreeNodeComponent_Template_div_dragstart_1_listener($event) { return ctx.dragstartHandler($event); })("dragend", function LimbleTreeNodeComponent_Template_div_dragend_1_listener($event) { return ctx.dragendHandler($event); });
|
|
2135
|
-
i0__namespace.ɵɵelementStart(3, "div", 3, 4);
|
|
2136
|
-
i0__namespace.ɵɵlistener("dragoverNoChangeDetect", function LimbleTreeNodeComponent_Template_div_dragoverNoChangeDetect_3_listener($event) { return ctx.dragoverHandler($event); });
|
|
2137
|
-
i0__namespace.ɵɵtemplate(5, LimbleTreeNodeComponent_ng_template_5_Template, 0, 0, "ng-template", null, 5, i0__namespace.ɵɵtemplateRefExtractor);
|
|
2138
|
-
i0__namespace.ɵɵelementEnd();
|
|
2139
|
-
i0__namespace.ɵɵtemplate(7, LimbleTreeNodeComponent_limble_tree_branch_7_Template, 2, 1, "limble-tree-branch", 6);
|
|
2140
|
-
i0__namespace.ɵɵelementEnd();
|
|
2141
|
-
i0__namespace.ɵɵtemplate(8, LimbleTreeNodeComponent_drop_zone_8_Template, 1, 1, "drop-zone", 0);
|
|
2142
|
-
}
|
|
2143
|
-
if (rf & 2) {
|
|
2144
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.renderDropZoneAbove === true);
|
|
2145
|
-
i0__namespace.ɵɵadvance(3);
|
|
2146
|
-
i0__namespace.ɵɵproperty("dragoverEventThrottle", 10);
|
|
2147
|
-
i0__namespace.ɵɵadvance(4);
|
|
2148
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.branch !== undefined && ctx.renderInnerBranch === true);
|
|
2149
|
-
i0__namespace.ɵɵadvance(1);
|
|
2150
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.renderDropZoneBelow === true);
|
|
2151
|
-
}
|
|
2152
|
-
}, styles: [".dragging[_ngcontent-%COMP%]{position:absolute;transition:transform .01s;transform:translate(-9999px)}"] });
|
|
2153
|
-
(function () {
|
|
2154
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LimbleTreeNodeComponent, [{
|
|
2155
|
-
type: i0.Component,
|
|
2156
|
-
args: [{
|
|
2157
|
-
selector: "limble-tree-node",
|
|
2158
|
-
templateUrl: "./limble-tree-node.component.html",
|
|
2159
|
-
styleUrls: ["./limble-tree-node.component.scss"]
|
|
2160
|
-
}]
|
|
2161
|
-
}], function () { return [{ type: ComponentCreatorService }, { type: i0__namespace.ChangeDetectorRef }, { type: DragStateService }, { type: DropZoneService }, { type: TreeService }, { type: GlobalEventsService }, { type: i0__namespace.NgZone }, { type: TreeConstructionStatus }]; }, { branch: [{
|
|
2162
|
-
type: i0.Input
|
|
2163
|
-
}], nodeHost: [{
|
|
2164
|
-
type: i0.ViewChild,
|
|
2165
|
-
args: ["nodeHost", { read: i0.ViewContainerRef }]
|
|
2166
|
-
}], draggableDiv: [{
|
|
2167
|
-
type: i0.ViewChild,
|
|
2168
|
-
args: ["draggableDiv", { read: i0.ElementRef }]
|
|
2169
|
-
}], nodeHostContainer: [{
|
|
2170
|
-
type: i0.ViewChild,
|
|
2171
|
-
args: ["nodeHostContainer", { read: i0.ElementRef }]
|
|
2172
|
-
}], parentHost: [{
|
|
2173
|
-
type: i0.Input
|
|
2174
|
-
}], innerBranch: [{
|
|
2175
|
-
type: i0.ViewChild,
|
|
2176
|
-
args: ["innerBranch", { read: LimbleTreeBranchComponent }]
|
|
2177
|
-
}] });
|
|
2178
|
-
})();
|
|
2179
|
-
|
|
2180
|
-
/** The default value for the `indent` option */
|
|
2181
|
-
var INDENT = 45;
|
|
2182
|
-
var TreeService = /** @class */ (function () {
|
|
2183
|
-
function TreeService(componentCreatorService, dropZoneService, dragStateService, treeConstructionStatus) {
|
|
2184
|
-
var _this = this;
|
|
2185
|
-
this.componentCreatorService = componentCreatorService;
|
|
2186
|
-
this.dropZoneService = dropZoneService;
|
|
2187
|
-
this.dragStateService = dragStateService;
|
|
2188
|
-
this.treeConstructionStatus = treeConstructionStatus;
|
|
2189
|
-
this.changes$ = new rxjs.Subject();
|
|
2190
|
-
this.drops$ = new rxjs.Subject();
|
|
2191
|
-
this.treeModel = new Branch(null);
|
|
2192
|
-
this.placeholder = false;
|
|
2193
|
-
this.captured = false;
|
|
2194
|
-
this.cleanupSignal$ = new rxjs.Subject();
|
|
2195
|
-
var rebuild = false;
|
|
2196
|
-
var treeIsStable = false;
|
|
2197
|
-
var treeIsStable$ = this.treeConstructionStatus.stable$.pipe(operators.tap(function (value) {
|
|
2198
|
-
treeIsStable = value;
|
|
2199
|
-
}), operators.filter(function (value) { return value === true; }));
|
|
2200
|
-
this.cleanupSignal$
|
|
2201
|
-
.pipe(operators.tap(function (value) {
|
|
2202
|
-
rebuild = value;
|
|
2203
|
-
}), operators.debounce(function () {
|
|
2204
|
-
if (treeIsStable === true) {
|
|
2205
|
-
//If tree is stable, continue right away
|
|
2206
|
-
return rxjs.EMPTY;
|
|
2207
|
-
}
|
|
2208
|
-
//If tree is not stable, wait for it to become so.
|
|
2209
|
-
return treeIsStable$;
|
|
2210
|
-
}),
|
|
2211
|
-
//We use this timed debounce to throttle chained destruction of components
|
|
2212
|
-
operators.debounceTime(5))
|
|
2213
|
-
.subscribe(function () {
|
|
2214
|
-
_this.cleanup(rebuild);
|
|
2215
|
-
rebuild = false;
|
|
2216
|
-
});
|
|
2217
|
-
this.placeholder$ = new rxjs.BehaviorSubject(false);
|
|
2218
|
-
this.placeholder$.subscribe(function (value) {
|
|
2219
|
-
_this.placeholder = value;
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
TreeService.prototype.drop = function (source, targetCoordinates) {
|
|
2223
|
-
var _a;
|
|
2224
|
-
//prep
|
|
2225
|
-
var sourceParent = source.getParent();
|
|
2226
|
-
if (sourceParent === null) {
|
|
2227
|
-
throw new Error("can't drop root of tree");
|
|
2228
|
-
}
|
|
2229
|
-
var sourceIndex = source.getIndex();
|
|
2230
|
-
if (sourceIndex === undefined || sourceIndex === null) {
|
|
2231
|
-
throw new Error("Cannot move the hidden root node");
|
|
2232
|
-
}
|
|
2233
|
-
var targetParentCoordinates;
|
|
2234
|
-
var newIndex;
|
|
2235
|
-
if (this.placeholder === true) {
|
|
2236
|
-
targetParentCoordinates = [];
|
|
2237
|
-
newIndex = 0;
|
|
2238
|
-
}
|
|
2239
|
-
else {
|
|
2240
|
-
targetParentCoordinates = __spreadArray([], __read(targetCoordinates));
|
|
2241
|
-
newIndex = targetParentCoordinates.pop();
|
|
2242
|
-
}
|
|
2243
|
-
if (newIndex === undefined) {
|
|
2244
|
-
throw new Error("target coordinates are empty");
|
|
2245
|
-
}
|
|
2246
|
-
var targetParent = this.treeModel.getDescendant(targetParentCoordinates);
|
|
2247
|
-
if (targetParent === undefined) {
|
|
2248
|
-
throw new Error("could not get to target");
|
|
2249
|
-
}
|
|
2250
|
-
var target = this.dropZoneService.getDropZone(targetCoordinates);
|
|
2251
|
-
var targetIndex = target === null || target === void 0 ? void 0 : target.getLocation().insertIndex;
|
|
2252
|
-
var targetHost = target === null || target === void 0 ? void 0 : target.getHost();
|
|
2253
|
-
var sourceHost = (_a = this.dragStateService.getData()) === null || _a === void 0 ? void 0 : _a.parentContainer;
|
|
2254
|
-
if (this.placeholder === true) {
|
|
2255
|
-
this.placeholder$.next(false);
|
|
2256
|
-
}
|
|
2257
|
-
//Change the treeModel
|
|
2258
|
-
targetParent.insertChild(source, newIndex);
|
|
2259
|
-
//Prepare to update the view
|
|
2260
|
-
if (targetHost === undefined ||
|
|
2261
|
-
sourceHost === undefined ||
|
|
2262
|
-
targetIndex === undefined) {
|
|
2263
|
-
//Hitting this means there is a bug, but not a fatal one.
|
|
2264
|
-
//Just render the whole tree again.
|
|
2265
|
-
console.warn("Could not perform a precise update. Re-rendering the entire tree instead");
|
|
2266
|
-
this.render();
|
|
2267
|
-
this.changes$.next(null);
|
|
2268
|
-
return;
|
|
2269
|
-
}
|
|
2270
|
-
//Update the view
|
|
2271
|
-
var nodesInSource = sourceHost.length;
|
|
2272
|
-
var componentRef = this.componentCreatorService.appendComponent(LimbleTreeNodeComponent, targetHost, newIndex);
|
|
2273
|
-
componentRef.instance.branch = source;
|
|
2274
|
-
componentRef.instance.parentHost = targetHost;
|
|
2275
|
-
if (targetIndex < sourceIndex &&
|
|
2276
|
-
sourceHost.length > nodesInSource &&
|
|
2277
|
-
arraysAreEqual(sourceParent.getCoordinates(), targetParentCoordinates)) {
|
|
2278
|
-
sourceHost.remove(sourceIndex + 1);
|
|
2279
|
-
}
|
|
2280
|
-
else {
|
|
2281
|
-
sourceHost.remove(sourceIndex);
|
|
2282
|
-
}
|
|
2283
|
-
//Update the tree data
|
|
2284
|
-
this.rebuildTreeData();
|
|
2285
|
-
//Publish drop data
|
|
2286
|
-
this.drops$.next({
|
|
2287
|
-
target: source.data,
|
|
2288
|
-
oldParent: sourceParent.data,
|
|
2289
|
-
oldIndex: sourceIndex,
|
|
2290
|
-
newParent: targetParent.data,
|
|
2291
|
-
newIndex: newIndex
|
|
2292
|
-
});
|
|
2293
|
-
this.cleanupSignal$.next(false);
|
|
2294
|
-
};
|
|
2295
|
-
/** Initializes the service and renders the tree.
|
|
2296
|
-
* @param host - The ViewContainerRef into which the tree will be rendered.
|
|
2297
|
-
* @param data - The data array that was passed in to LimbleTreeRoot, which is
|
|
2298
|
-
* the users' representation of the tree
|
|
2299
|
-
* @param options - The options object that was passed in to LimbleTreeRoot
|
|
2300
|
-
*/
|
|
2301
|
-
TreeService.prototype.init = function (host, data, options, itemsPerPage, page) {
|
|
2302
|
-
this.host = host;
|
|
2303
|
-
this.originalData = data;
|
|
2304
|
-
this.treeOptions = this.processOptions(options, itemsPerPage, page);
|
|
2305
|
-
if (this.treeOptions.listMode === true) {
|
|
2306
|
-
var start = this.treeOptions.itemsPerPage * (this.treeOptions.page - 1);
|
|
2307
|
-
if (isNaN(start)) {
|
|
2308
|
-
//This catches the case where itemsPerPage was not passed by the user,
|
|
2309
|
-
//causing `start` to equal infinity*0, which is NaN.
|
|
2310
|
-
start = 0;
|
|
2311
|
-
}
|
|
2312
|
-
var end = start + this.treeOptions.itemsPerPage;
|
|
2313
|
-
this.treeData = this.originalData.slice(start, end);
|
|
2314
|
-
}
|
|
2315
|
-
else {
|
|
2316
|
-
this.treeData = __spreadArray([], __read(this.originalData));
|
|
2317
|
-
}
|
|
2318
|
-
this.render();
|
|
2319
|
-
};
|
|
2320
|
-
TreeService.prototype.cleanup = function (rebuild) {
|
|
2321
|
-
if (rebuild === void 0) { rebuild = false; }
|
|
2322
|
-
var _a;
|
|
2323
|
-
if (rebuild) {
|
|
2324
|
-
this.rebuildTreeData();
|
|
2325
|
-
}
|
|
2326
|
-
if (((_a = this.treeData) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
2327
|
-
//We do a full render here because it isn't actually any slower
|
|
2328
|
-
//when there are no nodes, and it is a little more straightforward
|
|
2329
|
-
this.render();
|
|
2330
|
-
}
|
|
2331
|
-
else {
|
|
2332
|
-
this.changes$.next(null);
|
|
2333
|
-
this.dropZoneService.update();
|
|
2334
|
-
}
|
|
2335
|
-
};
|
|
2336
|
-
/** Renders the entire tree from root to leaves */
|
|
2337
|
-
TreeService.prototype.render = function () {
|
|
2338
|
-
var e_1, _f, e_2, _g;
|
|
2339
|
-
if (this.host === undefined ||
|
|
2340
|
-
this.treeData === undefined ||
|
|
2341
|
-
this.treeOptions === undefined) {
|
|
2342
|
-
throw new Error("TreeModel not initialized");
|
|
2343
|
-
}
|
|
2344
|
-
this.treeConstructionStatus.ready(false);
|
|
2345
|
-
this.host.clear();
|
|
2346
|
-
this.dropZoneService.restart();
|
|
2347
|
-
this.placeholder$.next(false);
|
|
2348
|
-
this.treeModel = new Branch(null);
|
|
2349
|
-
if (this.treeData.length === 0) {
|
|
2350
|
-
//Tree is empty, but we have to to have something there so other trees' items can be dropped into it
|
|
2351
|
-
this.placeholder$.next(true);
|
|
2352
|
-
}
|
|
2353
|
-
else {
|
|
2354
|
-
try {
|
|
2355
|
-
for (var _h = __values(this.treeData), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
2356
|
-
var node = _j.value;
|
|
2357
|
-
var branch = new Branch(node);
|
|
2358
|
-
this.treeModel.appendChild(branch);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2362
|
-
finally {
|
|
2363
|
-
try {
|
|
2364
|
-
if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
|
|
2365
|
-
}
|
|
2366
|
-
finally { if (e_1) throw e_1.error; }
|
|
2367
|
-
}
|
|
2368
|
-
try {
|
|
2369
|
-
for (var _k = __values(this.treeModel.getChildren()), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
2370
|
-
var branch = _l.value;
|
|
2371
|
-
var componentRef = this.componentCreatorService.appendComponent(LimbleTreeNodeComponent, this.host);
|
|
2372
|
-
componentRef.instance.branch = branch;
|
|
2373
|
-
componentRef.instance.parentHost = this.host;
|
|
2374
|
-
//The LimbleTreeNodeComponent will (indirectly) call the `renderBranch` method of this service to render
|
|
2375
|
-
//its own children
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2379
|
-
finally {
|
|
2380
|
-
try {
|
|
2381
|
-
if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
|
|
2382
|
-
}
|
|
2383
|
-
finally { if (e_2) throw e_2.error; }
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
this.treeConstructionStatus.ready(true);
|
|
2387
|
-
this.changes$.next(null);
|
|
2388
|
-
this.dropZoneService.init(this.treeModel, this.treeOptions);
|
|
2389
|
-
};
|
|
2390
|
-
/** Renders a branch of the tree and all of its descendants */
|
|
2391
|
-
TreeService.prototype.renderBranch = function (host, branch) {
|
|
2392
|
-
var e_3, _f;
|
|
2393
|
-
var _a, _b;
|
|
2394
|
-
if (this.treeModel === undefined) {
|
|
2395
|
-
throw new Error("TreeModel not initialized");
|
|
2396
|
-
}
|
|
2397
|
-
host.clear();
|
|
2398
|
-
branch.clearChildren();
|
|
2399
|
-
try {
|
|
2400
|
-
for (var _g = __values((_b = (_a = branch.data) === null || _a === void 0 ? void 0 : _a.nodes) !== null && _b !== void 0 ? _b : []), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2401
|
-
var node = _h.value;
|
|
2402
|
-
var newBranch = new Branch(node);
|
|
2403
|
-
branch.appendChild(newBranch);
|
|
2404
|
-
var componentRef = this.componentCreatorService.appendComponent(LimbleTreeNodeComponent, host);
|
|
2405
|
-
componentRef.instance.branch = newBranch;
|
|
2406
|
-
componentRef.instance.parentHost = host;
|
|
2407
|
-
//The LimbleTreeNodeComponent will (indirectly) call the `renderBranch` method of this service to render
|
|
2408
|
-
//its own children
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2412
|
-
finally {
|
|
2413
|
-
try {
|
|
2414
|
-
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2415
|
-
}
|
|
2416
|
-
finally { if (e_3) throw e_3.error; }
|
|
2417
|
-
}
|
|
2418
|
-
};
|
|
2419
|
-
TreeService.prototype.processOptions = function (options, itemsPerPage, page) {
|
|
2420
|
-
if (options === void 0) { options = {}; }
|
|
2421
|
-
if (itemsPerPage === void 0) { itemsPerPage = Infinity; }
|
|
2422
|
-
if (page === void 0) { page = 1; }
|
|
2423
|
-
var _a, _b, _c, _d, _e;
|
|
2424
|
-
if (options.listMode === true &&
|
|
2425
|
-
options.allowNesting !== undefined &&
|
|
2426
|
-
options.allowNesting !== false) {
|
|
2427
|
-
console.warn("The value of `allowNesting` will be ignored; it must be false when `listMode` is true");
|
|
2428
|
-
}
|
|
2429
|
-
var result = {
|
|
2430
|
-
defaultComponent: options.defaultComponent,
|
|
2431
|
-
indent: (_a = options.indent) !== null && _a !== void 0 ? _a : INDENT,
|
|
2432
|
-
allowNesting: options.listMode !== true && ((_b = options.allowNesting) !== null && _b !== void 0 ? _b : true),
|
|
2433
|
-
allowDragging: (_c = options.allowDragging) !== null && _c !== void 0 ? _c : true,
|
|
2434
|
-
allowDrop: (_d = options.allowDrop) !== null && _d !== void 0 ? _d : (function () { return true; }),
|
|
2435
|
-
listMode: (_e = options.listMode) !== null && _e !== void 0 ? _e : false,
|
|
2436
|
-
itemsPerPage: options.listMode ? itemsPerPage : undefined,
|
|
2437
|
-
page: options.listMode ? page : undefined
|
|
2438
|
-
};
|
|
2439
|
-
return result;
|
|
2440
|
-
};
|
|
2441
|
-
TreeService.prototype.rebuildTreeData = function () {
|
|
2442
|
-
var e_4, _f, _g, _h;
|
|
2443
|
-
if (this.originalData === undefined ||
|
|
2444
|
-
this.treeData === undefined ||
|
|
2445
|
-
this.treeOptions === undefined ||
|
|
2446
|
-
this.host === undefined) {
|
|
2447
|
-
throw new Error("Tree data not initialized");
|
|
2448
|
-
}
|
|
2449
|
-
this.treeData = [];
|
|
2450
|
-
try {
|
|
2451
|
-
for (var _j = __values(this.treeModel.getChildren()), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
2452
|
-
var branch = _k.value;
|
|
2453
|
-
this.treeData.push(this.rebuildBranch(branch));
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
2457
|
-
finally {
|
|
2458
|
-
try {
|
|
2459
|
-
if (_k && !_k.done && (_f = _j.return)) _f.call(_j);
|
|
2460
|
-
}
|
|
2461
|
-
finally { if (e_4) throw e_4.error; }
|
|
2462
|
-
}
|
|
2463
|
-
if (this.treeOptions.listMode === true &&
|
|
2464
|
-
this.treeOptions.itemsPerPage < Infinity) {
|
|
2465
|
-
var itemsPerPage = this.treeOptions.itemsPerPage;
|
|
2466
|
-
var start = itemsPerPage * (this.treeOptions.page - 1);
|
|
2467
|
-
(_g = this.originalData).splice.apply(_g, __spreadArray([start, itemsPerPage], __read(this.treeData)));
|
|
2468
|
-
if (this.treeData.length !== itemsPerPage) {
|
|
2469
|
-
var action = false;
|
|
2470
|
-
if (this.treeData.length < itemsPerPage &&
|
|
2471
|
-
start + itemsPerPage <= this.originalData.length) {
|
|
2472
|
-
//The current page does not have enough nodes. Add some to the view from the next page.
|
|
2473
|
-
var count = itemsPerPage - this.treeData.length;
|
|
2474
|
-
for (var index = itemsPerPage - 1; index < itemsPerPage + count - 1; index++) {
|
|
2475
|
-
var branch = new Branch(this.originalData[start + index]);
|
|
2476
|
-
this.treeModel.appendChild(branch);
|
|
2477
|
-
var componentRef = this.componentCreatorService.appendComponent(LimbleTreeNodeComponent, this.host);
|
|
2478
|
-
componentRef.instance.branch = branch;
|
|
2479
|
-
componentRef.instance.parentHost = this.host;
|
|
2480
|
-
}
|
|
2481
|
-
action = true;
|
|
2482
|
-
}
|
|
2483
|
-
else if (this.treeData.length > itemsPerPage) {
|
|
2484
|
-
//The current page has too many nodes. Remove some of them from the view.
|
|
2485
|
-
var count = this.treeData.length - itemsPerPage;
|
|
2486
|
-
for (var index = itemsPerPage + count - 1; index >= itemsPerPage; index--) {
|
|
2487
|
-
this.treeModel.removeChild(index);
|
|
2488
|
-
this.host.remove(index);
|
|
2489
|
-
}
|
|
2490
|
-
action = true;
|
|
2491
|
-
}
|
|
2492
|
-
if (action === true) {
|
|
2493
|
-
var end = start + itemsPerPage;
|
|
2494
|
-
this.treeData = this.originalData.slice(start, end);
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
else {
|
|
2499
|
-
this.originalData.length = 0;
|
|
2500
|
-
(_h = this.originalData).push.apply(_h, __spreadArray([], __read(this.treeData)));
|
|
2501
|
-
}
|
|
2502
|
-
};
|
|
2503
|
-
TreeService.prototype.rebuildBranch = function (branch) {
|
|
2504
|
-
var e_5, _f;
|
|
2505
|
-
var temp = branch.data;
|
|
2506
|
-
temp.nodes = [];
|
|
2507
|
-
try {
|
|
2508
|
-
for (var _g = __values(branch.getChildren()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2509
|
-
var child = _h.value;
|
|
2510
|
-
temp.nodes.push(this.rebuildBranch(child));
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2514
|
-
finally {
|
|
2515
|
-
try {
|
|
2516
|
-
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2517
|
-
}
|
|
2518
|
-
finally { if (e_5) throw e_5.error; }
|
|
2519
|
-
}
|
|
2520
|
-
return temp;
|
|
2521
|
-
};
|
|
2522
|
-
return TreeService;
|
|
2523
|
-
}());
|
|
2524
|
-
TreeService.ɵfac = function TreeService_Factory(t) { return new (t || TreeService)(i0__namespace.ɵɵinject(ComponentCreatorService), i0__namespace.ɵɵinject(DropZoneService), i0__namespace.ɵɵinject(DragStateService), i0__namespace.ɵɵinject(TreeConstructionStatus)); };
|
|
2525
|
-
TreeService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: TreeService, factory: TreeService.ɵfac });
|
|
2526
|
-
(function () {
|
|
2527
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(TreeService, [{
|
|
2528
|
-
type: i0.Injectable
|
|
2529
|
-
}], function () { return [{ type: ComponentCreatorService }, { type: DropZoneService }, { type: DragStateService }, { type: TreeConstructionStatus }]; }, null);
|
|
2530
|
-
})();
|
|
2531
|
-
|
|
2532
|
-
var DragoverNoChangeDetectDirective = /** @class */ (function () {
|
|
2533
|
-
function DragoverNoChangeDetectDirective(ngZone, el) {
|
|
2534
|
-
this.ngZone = ngZone;
|
|
2535
|
-
this.el = el;
|
|
2536
|
-
this.dragoverNoChangeDetect = new i0.EventEmitter();
|
|
2537
|
-
this.dragoverEventThrottle = 25;
|
|
2538
|
-
}
|
|
2539
|
-
DragoverNoChangeDetectDirective.prototype.ngOnInit = function () {
|
|
2540
|
-
var _this = this;
|
|
2541
|
-
this.ngZone.runOutsideAngular(function () {
|
|
2542
|
-
_this.eventSubscription = rxjs.fromEvent(_this.el.nativeElement, "dragover")
|
|
2543
|
-
.pipe(operators.throttleTime(_this.dragoverEventThrottle))
|
|
2544
|
-
.subscribe(function ($event) {
|
|
2545
|
-
_this.dragoverNoChangeDetect.emit($event);
|
|
2546
|
-
});
|
|
2547
|
-
});
|
|
2548
|
-
};
|
|
2549
|
-
DragoverNoChangeDetectDirective.prototype.ngOnDestroy = function () {
|
|
2550
|
-
if (this.eventSubscription !== undefined) {
|
|
2551
|
-
this.eventSubscription.unsubscribe();
|
|
2552
|
-
}
|
|
2553
|
-
};
|
|
2554
|
-
return DragoverNoChangeDetectDirective;
|
|
2555
|
-
}());
|
|
2556
|
-
DragoverNoChangeDetectDirective.ɵfac = function DragoverNoChangeDetectDirective_Factory(t) { return new (t || DragoverNoChangeDetectDirective)(i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef)); };
|
|
2557
|
-
DragoverNoChangeDetectDirective.ɵdir = /*@__PURE__*/ i0__namespace.ɵɵdefineDirective({ type: DragoverNoChangeDetectDirective, selectors: [["", "dragoverNoChangeDetect", ""]], inputs: { dragoverEventThrottle: "dragoverEventThrottle" }, outputs: { dragoverNoChangeDetect: "dragoverNoChangeDetect" } });
|
|
2558
|
-
(function () {
|
|
2559
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DragoverNoChangeDetectDirective, [{
|
|
2560
|
-
type: i0.Directive,
|
|
2561
|
-
args: [{
|
|
2562
|
-
selector: "[dragoverNoChangeDetect]"
|
|
2563
|
-
}]
|
|
2564
|
-
}], function () { return [{ type: i0__namespace.NgZone }, { type: i0__namespace.ElementRef }]; }, { dragoverEventThrottle: [{
|
|
2565
|
-
type: i0.Input
|
|
2566
|
-
}], dragoverNoChangeDetect: [{
|
|
2567
|
-
type: i0.Output
|
|
2568
|
-
}] });
|
|
2569
|
-
})();
|
|
2570
|
-
|
|
2571
|
-
var DragleaveNoChangeDetectDirective = /** @class */ (function () {
|
|
2572
|
-
function DragleaveNoChangeDetectDirective(ngZone, el) {
|
|
2573
|
-
this.ngZone = ngZone;
|
|
2574
|
-
this.el = el;
|
|
2575
|
-
this.dragleaveNoChangeDetect = new i0.EventEmitter();
|
|
2576
|
-
}
|
|
2577
|
-
DragleaveNoChangeDetectDirective.prototype.ngOnInit = function () {
|
|
2578
|
-
var _this = this;
|
|
2579
|
-
this.ngZone.runOutsideAngular(function () {
|
|
2580
|
-
_this.eventSubscription = rxjs.fromEvent(_this.el.nativeElement, "dragleave").subscribe(function ($event) {
|
|
2581
|
-
_this.dragleaveNoChangeDetect.emit($event);
|
|
2582
|
-
});
|
|
2583
|
-
});
|
|
2584
|
-
};
|
|
2585
|
-
DragleaveNoChangeDetectDirective.prototype.ngOnDestroy = function () {
|
|
2586
|
-
if (this.eventSubscription !== undefined) {
|
|
2587
|
-
this.eventSubscription.unsubscribe();
|
|
2588
|
-
}
|
|
2589
|
-
};
|
|
2590
|
-
return DragleaveNoChangeDetectDirective;
|
|
2591
|
-
}());
|
|
2592
|
-
DragleaveNoChangeDetectDirective.ɵfac = function DragleaveNoChangeDetectDirective_Factory(t) { return new (t || DragleaveNoChangeDetectDirective)(i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef)); };
|
|
2593
|
-
DragleaveNoChangeDetectDirective.ɵdir = /*@__PURE__*/ i0__namespace.ɵɵdefineDirective({ type: DragleaveNoChangeDetectDirective, selectors: [["", "dragleaveNoChangeDetect", ""]], outputs: { dragleaveNoChangeDetect: "dragleaveNoChangeDetect" } });
|
|
2594
|
-
(function () {
|
|
2595
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DragleaveNoChangeDetectDirective, [{
|
|
2596
|
-
type: i0.Directive,
|
|
2597
|
-
args: [{
|
|
2598
|
-
selector: "[dragleaveNoChangeDetect]"
|
|
2599
|
-
}]
|
|
2600
|
-
}], function () { return [{ type: i0__namespace.NgZone }, { type: i0__namespace.ElementRef }]; }, { dragleaveNoChangeDetect: [{
|
|
2601
|
-
type: i0.Output
|
|
2602
|
-
}] });
|
|
2603
|
-
})();
|
|
2604
|
-
|
|
2605
|
-
var LimbleTreePlaceholderComponent = /** @class */ (function () {
|
|
2606
|
-
function LimbleTreePlaceholderComponent(dropZoneService, changeDetectorRef, treeService, treeConstructionStatus) {
|
|
2607
|
-
var _this = this;
|
|
2608
|
-
this.dropZoneService = dropZoneService;
|
|
2609
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
2610
|
-
this.treeService = treeService;
|
|
2611
|
-
this.treeConstructionStatus = treeConstructionStatus;
|
|
2612
|
-
this.treeConstructionStatus.constructing();
|
|
2613
|
-
//This logic is very similar to what the lifecycle hooks of this component do.
|
|
2614
|
-
//We use this subscription because sometimes we can't wait for the lifecycle hooks:
|
|
2615
|
-
//Specifically, the drop zone registration and deregistration sometimes can't happen
|
|
2616
|
-
//asynchronously without causing bugs. So we handle it synchronously here as well.
|
|
2617
|
-
this.placeholderSubscription = this.treeService.placeholder$.subscribe(function (value) {
|
|
2618
|
-
if (_this.dropZone === undefined) {
|
|
2619
|
-
return;
|
|
2620
|
-
}
|
|
2621
|
-
_this.dropZoneService.removeDropZone(_this.dropZone);
|
|
2622
|
-
if (value === true) {
|
|
2623
|
-
_this.dropZoneService.addDropZone(_this.dropZone);
|
|
2624
|
-
_this.dropZone.setHost(_this.treeService.host);
|
|
2625
|
-
}
|
|
2626
|
-
});
|
|
2627
|
-
}
|
|
2628
|
-
LimbleTreePlaceholderComponent.prototype.ngOnInit = function () {
|
|
2629
|
-
this.dropZone = new DropZone([], 0);
|
|
2630
|
-
this.dropZoneService.addDropZone(this.dropZone);
|
|
2631
|
-
};
|
|
2632
|
-
LimbleTreePlaceholderComponent.prototype.ngAfterViewInit = function () {
|
|
2633
|
-
if (this.dropZone === undefined) {
|
|
2634
|
-
throw new Error("placeholder drop zone is not defined");
|
|
2635
|
-
}
|
|
2636
|
-
this.dropZone.setHost(this.treeService.host);
|
|
2637
|
-
this.treeConstructionStatus.doneConstructing();
|
|
2638
|
-
this.changeDetectorRef.detectChanges();
|
|
2639
|
-
};
|
|
2640
|
-
LimbleTreePlaceholderComponent.prototype.dragoverHandler = function () {
|
|
2641
|
-
if (this.dropZone === undefined) {
|
|
2642
|
-
return;
|
|
2643
|
-
}
|
|
2644
|
-
this.dropZoneService.showDropZoneFamily(this.dropZone);
|
|
2645
|
-
};
|
|
2646
|
-
LimbleTreePlaceholderComponent.prototype.ngOnDestroy = function () {
|
|
2647
|
-
this.placeholderSubscription.unsubscribe();
|
|
2648
|
-
if (this.dropZone === undefined) {
|
|
2649
|
-
throw new Error("could not remove placeholder drop zone");
|
|
2650
|
-
}
|
|
2651
|
-
this.dropZoneService.removeDropZone(this.dropZone);
|
|
2652
|
-
};
|
|
2653
|
-
return LimbleTreePlaceholderComponent;
|
|
2654
|
-
}());
|
|
2655
|
-
LimbleTreePlaceholderComponent.ɵfac = function LimbleTreePlaceholderComponent_Factory(t) { return new (t || LimbleTreePlaceholderComponent)(i0__namespace.ɵɵdirectiveInject(DropZoneService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(TreeService), i0__namespace.ɵɵdirectiveInject(TreeConstructionStatus)); };
|
|
2656
|
-
LimbleTreePlaceholderComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: LimbleTreePlaceholderComponent, selectors: [["limble-tree-placeholder"]], decls: 2, vars: 1, consts: [[3, "dropZone"], [1, "placeholder", 3, "dragoverNoChangeDetect"]], template: function LimbleTreePlaceholderComponent_Template(rf, ctx) {
|
|
2657
|
-
if (rf & 1) {
|
|
2658
|
-
i0__namespace.ɵɵelement(0, "drop-zone", 0);
|
|
2659
|
-
i0__namespace.ɵɵelementStart(1, "div", 1);
|
|
2660
|
-
i0__namespace.ɵɵlistener("dragoverNoChangeDetect", function LimbleTreePlaceholderComponent_Template_div_dragoverNoChangeDetect_1_listener() { return ctx.dragoverHandler(); });
|
|
2661
|
-
i0__namespace.ɵɵelementEnd();
|
|
2662
|
-
}
|
|
2663
|
-
if (rf & 2) {
|
|
2664
|
-
i0__namespace.ɵɵproperty("dropZone", ctx.dropZone);
|
|
2665
|
-
}
|
|
2666
|
-
}, directives: [DropZoneComponent, DragoverNoChangeDetectDirective], styles: [".placeholder[_ngcontent-%COMP%]{width:100%;height:20px}"], changeDetection: 0 });
|
|
2667
|
-
(function () {
|
|
2668
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LimbleTreePlaceholderComponent, [{
|
|
2669
|
-
type: i0.Component,
|
|
2670
|
-
args: [{
|
|
2671
|
-
selector: "limble-tree-placeholder",
|
|
2672
|
-
templateUrl: "./limble-tree-placeholder.component.html",
|
|
2673
|
-
styleUrls: ["./limble-tree-placeholder.component.scss"],
|
|
2674
|
-
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
2675
|
-
}]
|
|
2676
|
-
}], function () { return [{ type: DropZoneService }, { type: i0__namespace.ChangeDetectorRef }, { type: TreeService }, { type: TreeConstructionStatus }]; }, null);
|
|
2677
|
-
})();
|
|
2678
|
-
|
|
2679
|
-
var _c0 = ["host"];
|
|
2680
|
-
function LimbleTreeRootComponent_limble_tree_placeholder_1_Template(rf, ctx) {
|
|
2681
|
-
if (rf & 1) {
|
|
2682
|
-
i0__namespace.ɵɵelement(0, "limble-tree-placeholder");
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
function LimbleTreeRootComponent_ng_template_2_Template(rf, ctx) { }
|
|
2686
|
-
var LimbleTreeRootComponent = /** @class */ (function () {
|
|
2687
|
-
function LimbleTreeRootComponent(treeService, dropZoneService, dragStateService, globalEventsService, ngZone, changeDetectorRef, el) {
|
|
2688
|
-
var _this = this;
|
|
2689
|
-
this.treeService = treeService;
|
|
2690
|
-
this.dropZoneService = dropZoneService;
|
|
2691
|
-
this.dragStateService = dragStateService;
|
|
2692
|
-
this.globalEventsService = globalEventsService;
|
|
2693
|
-
this.ngZone = ngZone;
|
|
2694
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
2695
|
-
this.el = el;
|
|
2696
|
-
this.treeChange = new i0.EventEmitter();
|
|
2697
|
-
this.treeDrop = new i0.EventEmitter();
|
|
2698
|
-
this.changesSubscription = this.treeService.changes$.subscribe(function () {
|
|
2699
|
-
//"In dev mode, Angular performs an additional check after each change
|
|
2700
|
-
//detection run, to ensure the bindings haven’t changed." We use a timeout here
|
|
2701
|
-
//to preclude the possibility of causing a binding to update in the parent
|
|
2702
|
-
//component after change detection runs but before the additional check.
|
|
2703
|
-
//See https://angular.io/errors/NG0100 for details.
|
|
2704
|
-
setTimeout(function () {
|
|
2705
|
-
_this.treeChange.emit();
|
|
2706
|
-
});
|
|
2707
|
-
});
|
|
2708
|
-
this.dropSubscription = this.treeService.drops$.subscribe(function (drop) {
|
|
2709
|
-
setTimeout(function () {
|
|
2710
|
-
_this.treeDrop.emit(drop);
|
|
2711
|
-
});
|
|
2712
|
-
});
|
|
2713
|
-
this.placeholder = false;
|
|
2714
|
-
this.treeService.placeholder$.subscribe(function (value) {
|
|
2715
|
-
_this.placeholder = value;
|
|
2716
|
-
if (!i0.NgZone.isInAngularZone()) {
|
|
2717
|
-
_this.changeDetectorRef.detectChanges();
|
|
2718
|
-
}
|
|
2719
|
-
});
|
|
2720
|
-
}
|
|
2721
|
-
LimbleTreeRootComponent.prototype.ngAfterViewInit = function () {
|
|
2722
|
-
var _this = this;
|
|
2723
|
-
var _a;
|
|
2724
|
-
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.listMode) !== true &&
|
|
2725
|
-
(this.itemsPerPage !== undefined || this.page !== undefined)) {
|
|
2726
|
-
console.warn("pagination is only allowed in listMode; `itemsPerPage` and `page` inputs will be ignored");
|
|
2727
|
-
}
|
|
2728
|
-
this.update();
|
|
2729
|
-
this.changeDetectorRef.detectChanges();
|
|
2730
|
-
this.ngZone.runOutsideAngular(function () {
|
|
2731
|
-
//this is for mac os - without this dragover handler drop events aren't firing correctly
|
|
2732
|
-
_this.el.nativeElement.addEventListener("dragover", function (event) {
|
|
2733
|
-
event.preventDefault();
|
|
2734
|
-
});
|
|
2735
|
-
});
|
|
2736
|
-
};
|
|
2737
|
-
LimbleTreeRootComponent.prototype.ngOnChanges = function () {
|
|
2738
|
-
if (this.host !== undefined && this.data !== undefined) {
|
|
2739
|
-
this.update();
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
/** Rebuild the tree */
|
|
2743
|
-
LimbleTreeRootComponent.prototype.update = function () {
|
|
2744
|
-
if (this.host === undefined) {
|
|
2745
|
-
throw new Error("Failed to render limble tree. Failure occurred at root.");
|
|
2746
|
-
}
|
|
2747
|
-
if (this.data === undefined) {
|
|
2748
|
-
throw new Error("limbleTree requires a data object");
|
|
2749
|
-
}
|
|
2750
|
-
this.treeService.init(this.host, this.data, this.options, this.itemsPerPage, this.page);
|
|
2751
|
-
//We check for firefox here because there is a bug in Firefox that causes the
|
|
2752
|
-
//custom scrolling to break. See https://bugzilla.mozilla.org/show_bug.cgi?id=505521#c80
|
|
2753
|
-
if (!isFirefox()) {
|
|
2754
|
-
this.globalEventsService.addScrolling();
|
|
2755
|
-
}
|
|
2756
|
-
};
|
|
2757
|
-
LimbleTreeRootComponent.prototype.dragoverHandler = function (event) {
|
|
2758
|
-
if (event.dataTransfer === null) {
|
|
2759
|
-
return;
|
|
2760
|
-
}
|
|
2761
|
-
event.stopPropagation();
|
|
2762
|
-
event.preventDefault();
|
|
2763
|
-
event.dataTransfer.dropEffect = "move";
|
|
2764
|
-
};
|
|
2765
|
-
LimbleTreeRootComponent.prototype.dragleaveHandler = function (event) {
|
|
2766
|
-
var currentTarget = event.currentTarget;
|
|
2767
|
-
var relatedTarget = event.relatedTarget;
|
|
2768
|
-
if (!(currentTarget instanceof Node) ||
|
|
2769
|
-
!(relatedTarget instanceof Node) ||
|
|
2770
|
-
isElementDescendant(currentTarget, relatedTarget) !== false) {
|
|
2771
|
-
//event came from deeper in the tree. Ignore it.
|
|
2772
|
-
return;
|
|
2773
|
-
}
|
|
2774
|
-
//Mouse has left the tree, so clear the drop zones
|
|
2775
|
-
this.dropZoneService.clearVisibleZones();
|
|
2776
|
-
this.changeDetectorRef.detectChanges();
|
|
2777
|
-
};
|
|
2778
|
-
LimbleTreeRootComponent.prototype.dropHandler = function (event) {
|
|
2779
|
-
var _this = this;
|
|
2780
|
-
event.stopPropagation();
|
|
2781
|
-
if (this.dragStateService.getState() !== "droppable") {
|
|
2782
|
-
return;
|
|
2783
|
-
}
|
|
2784
|
-
var sourceBranch = this.dragStateService.capture();
|
|
2785
|
-
if (sourceBranch === undefined) {
|
|
2786
|
-
throw new Error("failed to get current branch in dragendHandler");
|
|
2787
|
-
}
|
|
2788
|
-
var dropZone = this.dropZoneService.getActiveDropZone();
|
|
2789
|
-
if (dropZone === null) {
|
|
2790
|
-
throw new Error("failed to get active drop zone at drop handler");
|
|
2791
|
-
}
|
|
2792
|
-
this.treeService.captured = true;
|
|
2793
|
-
this.dragStateService.state$
|
|
2794
|
-
.pipe(operators.first(function (message) { return message === "idle"; }))
|
|
2795
|
-
.subscribe(function () {
|
|
2796
|
-
_this.treeService.captured = false;
|
|
2797
|
-
});
|
|
2798
|
-
this.dropZoneService.clearVisibleZones();
|
|
2799
|
-
this.treeService.drop(sourceBranch, dropZone.getFullInsertCoordinates());
|
|
2800
|
-
};
|
|
2801
|
-
LimbleTreeRootComponent.prototype.ngOnDestroy = function () {
|
|
2802
|
-
this.changesSubscription.unsubscribe();
|
|
2803
|
-
this.dropSubscription.unsubscribe();
|
|
2804
|
-
};
|
|
2805
|
-
return LimbleTreeRootComponent;
|
|
2806
|
-
}());
|
|
2807
|
-
LimbleTreeRootComponent.ɵfac = function LimbleTreeRootComponent_Factory(t) { return new (t || LimbleTreeRootComponent)(i0__namespace.ɵɵdirectiveInject(TreeService), i0__namespace.ɵɵdirectiveInject(DropZoneService), i0__namespace.ɵɵdirectiveInject(DragStateService), i0__namespace.ɵɵdirectiveInject(GlobalEventsService), i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef)); };
|
|
2808
|
-
LimbleTreeRootComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: LimbleTreeRootComponent, selectors: [["limble-tree-root"]], viewQuery: function LimbleTreeRootComponent_Query(rf, ctx) {
|
|
2809
|
-
if (rf & 1) {
|
|
2810
|
-
i0__namespace.ɵɵviewQuery(_c0, 5, i0.ViewContainerRef);
|
|
2811
|
-
}
|
|
2812
|
-
if (rf & 2) {
|
|
2813
|
-
var _t = void 0;
|
|
2814
|
-
i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.host = _t.first);
|
|
2815
|
-
}
|
|
2816
|
-
}, inputs: { data: "data", options: "options", itemsPerPage: "itemsPerPage", page: "page" }, outputs: { treeChange: "treeChange", treeDrop: "treeDrop" }, features: [i0__namespace.ɵɵProvidersFeature([TreeService, DropZoneService, TreeConstructionStatus]), i0__namespace.ɵɵNgOnChangesFeature], decls: 4, vars: 1, consts: [[1, "tree-event-host", 3, "dragoverNoChangeDetect", "dragleaveNoChangeDetect", "drop"], [4, "ngIf"], ["host", ""]], template: function LimbleTreeRootComponent_Template(rf, ctx) {
|
|
2817
|
-
if (rf & 1) {
|
|
2818
|
-
i0__namespace.ɵɵelementStart(0, "div", 0);
|
|
2819
|
-
i0__namespace.ɵɵlistener("dragoverNoChangeDetect", function LimbleTreeRootComponent_Template_div_dragoverNoChangeDetect_0_listener($event) { return ctx.dragoverHandler($event); })("dragleaveNoChangeDetect", function LimbleTreeRootComponent_Template_div_dragleaveNoChangeDetect_0_listener($event) { return ctx.dragleaveHandler($event); })("drop", function LimbleTreeRootComponent_Template_div_drop_0_listener($event) { return ctx.dropHandler($event); });
|
|
2820
|
-
i0__namespace.ɵɵtemplate(1, LimbleTreeRootComponent_limble_tree_placeholder_1_Template, 1, 0, "limble-tree-placeholder", 1);
|
|
2821
|
-
i0__namespace.ɵɵtemplate(2, LimbleTreeRootComponent_ng_template_2_Template, 0, 0, "ng-template", null, 2, i0__namespace.ɵɵtemplateRefExtractor);
|
|
2822
|
-
i0__namespace.ɵɵelementEnd();
|
|
2823
|
-
}
|
|
2824
|
-
if (rf & 2) {
|
|
2825
|
-
i0__namespace.ɵɵadvance(1);
|
|
2826
|
-
i0__namespace.ɵɵproperty("ngIf", ctx.placeholder === true);
|
|
2827
|
-
}
|
|
2828
|
-
}, directives: [DragoverNoChangeDetectDirective, DragleaveNoChangeDetectDirective, i2__namespace.NgIf, LimbleTreePlaceholderComponent], styles: [""] });
|
|
2829
|
-
(function () {
|
|
2830
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LimbleTreeRootComponent, [{
|
|
2831
|
-
type: i0.Component,
|
|
2832
|
-
args: [{
|
|
2833
|
-
selector: "limble-tree-root",
|
|
2834
|
-
templateUrl: "./limble-tree-root.component.html",
|
|
2835
|
-
styleUrls: ["./limble-tree-root.component.scss"],
|
|
2836
|
-
providers: [TreeService, DropZoneService, TreeConstructionStatus]
|
|
2837
|
-
}]
|
|
2838
|
-
}], function () { return [{ type: TreeService }, { type: DropZoneService }, { type: DragStateService }, { type: GlobalEventsService }, { type: i0__namespace.NgZone }, { type: i0__namespace.ChangeDetectorRef }, { type: i0__namespace.ElementRef }]; }, { data: [{
|
|
2839
|
-
type: i0.Input
|
|
2840
|
-
}], options: [{
|
|
2841
|
-
type: i0.Input
|
|
2842
|
-
}], itemsPerPage: [{
|
|
2843
|
-
type: i0.Input
|
|
2844
|
-
}], page: [{
|
|
2845
|
-
type: i0.Input
|
|
2846
|
-
}], host: [{
|
|
2847
|
-
type: i0.ViewChild,
|
|
2848
|
-
args: ["host", { read: i0.ViewContainerRef }]
|
|
2849
|
-
}], treeChange: [{
|
|
2850
|
-
type: i0.Output
|
|
2851
|
-
}], treeDrop: [{
|
|
2852
|
-
type: i0.Output
|
|
2853
|
-
}] });
|
|
2854
|
-
})();
|
|
2855
|
-
|
|
2856
|
-
var LimbleTreeModule = /** @class */ (function () {
|
|
2857
|
-
function LimbleTreeModule() {
|
|
2858
|
-
}
|
|
2859
|
-
return LimbleTreeModule;
|
|
2860
|
-
}());
|
|
2861
|
-
LimbleTreeModule.ɵfac = function LimbleTreeModule_Factory(t) { return new (t || LimbleTreeModule)(); };
|
|
2862
|
-
LimbleTreeModule.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: LimbleTreeModule });
|
|
2863
|
-
LimbleTreeModule.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({ providers: [ComponentCreatorService, DragStateService, GlobalEventsService], imports: [[i2.CommonModule]] });
|
|
2864
|
-
(function () {
|
|
2865
|
-
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LimbleTreeModule, [{
|
|
2866
|
-
type: i0.NgModule,
|
|
2867
|
-
args: [{
|
|
2868
|
-
declarations: [
|
|
2869
|
-
LimbleTreeBranchComponent,
|
|
2870
|
-
DropZoneComponent,
|
|
2871
|
-
LimbleTreeNodeComponent,
|
|
2872
|
-
LimbleTreeRootComponent,
|
|
2873
|
-
LimbleTreePlaceholderComponent,
|
|
2874
|
-
DragoverNoChangeDetectDirective,
|
|
2875
|
-
DragleaveNoChangeDetectDirective
|
|
2876
|
-
],
|
|
2877
|
-
imports: [i2.CommonModule],
|
|
2878
|
-
exports: [LimbleTreeRootComponent],
|
|
2879
|
-
providers: [ComponentCreatorService, DragStateService, GlobalEventsService]
|
|
2880
|
-
}]
|
|
2881
|
-
}], null, null);
|
|
2882
|
-
})();
|
|
2883
|
-
(function () {
|
|
2884
|
-
(typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(LimbleTreeModule, { declarations: [LimbleTreeBranchComponent,
|
|
2885
|
-
DropZoneComponent,
|
|
2886
|
-
LimbleTreeNodeComponent,
|
|
2887
|
-
LimbleTreeRootComponent,
|
|
2888
|
-
LimbleTreePlaceholderComponent,
|
|
2889
|
-
DragoverNoChangeDetectDirective,
|
|
2890
|
-
DragleaveNoChangeDetectDirective], imports: [i2.CommonModule], exports: [LimbleTreeRootComponent] });
|
|
2891
|
-
})();
|
|
2892
|
-
i0__namespace.ɵɵsetComponentScope(LimbleTreeNodeComponent, [i2__namespace.NgIf, DropZoneComponent,
|
|
2893
|
-
DragoverNoChangeDetectDirective,
|
|
2894
|
-
LimbleTreeBranchComponent], []);
|
|
2895
|
-
|
|
2896
|
-
/*
|
|
2897
|
-
* Public API Surface of limble-tree
|
|
2898
|
-
*/
|
|
2899
|
-
|
|
2900
|
-
/**
|
|
2901
|
-
* Generated bundle index. Do not edit.
|
|
2902
|
-
*/
|
|
2903
|
-
|
|
2904
|
-
exports.LimbleTreeModule = LimbleTreeModule;
|
|
2905
|
-
exports.LimbleTreeRootComponent = LimbleTreeRootComponent;
|
|
2906
|
-
|
|
2907
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2908
|
-
|
|
2909
|
-
})));
|
|
2910
|
-
//# sourceMappingURL=limble-limble-tree.umd.js.map
|