jqtree 1.6.3 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +15 -21
- package/.github/workflows/codeql-analysis.yml +2 -2
- package/README.md +1 -1
- package/bower.json +10 -3
- package/config/production +2 -2
- package/config/{rollup.config.js → rollup.config.mjs} +3 -8
- package/docs/Gemfile.lock +34 -37
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +13 -0
- package/docs/_entries/93_getnextnode.md +4 -1
- package/docs/_entries/{95_getpreviousnode.md → 95_getnextvisiblenode.md} +1 -1
- package/docs/_entries/96_getpreviousnode.md +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +413 -265
- package/docs/static/bower.json +2 -2
- package/docs/static/bower_components/fontawesome/css/all.min.css +6 -2
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/docs/static/bower_components/jquery/dist/jquery.js +944 -1121
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +181 -159
- package/docs/static/example.css +0 -1
- package/docs/tree.jquery.js +3 -3
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +40 -142
- package/lib/elementsRenderer.js +52 -72
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +24 -74
- package/lib/node.js +72 -134
- package/lib/nodeElement.js +24 -84
- package/lib/playwright/coverage.js +58 -97
- package/lib/playwright/playwright.test.js +148 -210
- package/lib/playwright/testUtils.js +116 -182
- package/lib/saveStateHandler.js +13 -62
- package/lib/scrollHandler.js +24 -77
- package/lib/selectNodeHandler.js +6 -25
- package/lib/simple.widget.js +20 -53
- package/lib/test/jqTree/accessibility.test.js +37 -0
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +73 -84
- package/lib/test/jqTree/keyboard.test.js +0 -6
- package/lib/test/jqTree/loadOnDemand.test.js +84 -121
- package/lib/test/jqTree/methods.test.js +107 -150
- package/lib/test/jqTree/options.test.js +32 -54
- package/lib/test/node.test.js +134 -76
- package/lib/test/nodeUtil.test.js +0 -1
- package/lib/test/support/jqTreeMatchers.js +4 -9
- package/lib/test/support/setupTests.js +0 -4
- package/lib/test/support/testUtil.js +2 -11
- package/lib/test/support/treeStructure.js +0 -6
- package/lib/test/util.test.js +0 -1
- package/lib/tree.jquery.js +28 -239
- package/lib/util.js +0 -6
- package/lib/version.js +1 -1
- package/package.json +44 -47
- package/src/dragAndDropHandler.ts +24 -10
- package/src/elementsRenderer.ts +49 -42
- package/src/jqtreeOptions.ts +3 -3
- package/src/keyHandler.ts +3 -3
- package/src/mouse.widget.ts +12 -0
- package/src/node.ts +52 -16
- package/src/nodeElement.ts +27 -21
- package/src/saveStateHandler.ts +1 -1
- package/src/scrollHandler.ts +6 -2
- package/src/selectNodeHandler.ts +1 -1
- package/src/simple.widget.ts +2 -0
- package/src/test/.eslintrc +3 -1
- package/src/test/jqTree/accessibility.test.ts +25 -0
- package/src/test/jqTree/events.test.ts +79 -93
- package/src/test/jqTree/methods.test.ts +1 -1
- package/src/test/node.test.ts +152 -58
- package/src/test/nodeUtil.test.ts +1 -1
- package/src/tree.jquery.ts +7 -6
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +297 -904
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/tsconfig.json +1 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -3717
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -801
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -5028
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- /package/docs/_entries/{96_getprevioussibling.md → 97_getprevioussibling.md} +0 -0
- /package/docs/_entries/{97_parent.md → 99_parent.md} +0 -0
package/lib/node.js
CHANGED
|
@@ -4,40 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPositionName = exports.getPosition = exports.Position = exports.Node = void 0;
|
|
7
|
-
|
|
8
7
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
9
|
-
|
|
10
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13
|
-
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
16
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
23
|
-
|
|
24
|
-
var Position;
|
|
25
|
-
exports.Position = Position;
|
|
26
|
-
|
|
27
|
-
(function (Position) {
|
|
17
|
+
var Position = /*#__PURE__*/function (Position) {
|
|
28
18
|
Position[Position["Before"] = 1] = "Before";
|
|
29
19
|
Position[Position["After"] = 2] = "After";
|
|
30
20
|
Position[Position["Inside"] = 3] = "Inside";
|
|
31
21
|
Position[Position["None"] = 4] = "None";
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
return Position;
|
|
23
|
+
}({});
|
|
24
|
+
exports.Position = Position;
|
|
34
25
|
var positionNames = {
|
|
35
26
|
before: Position.Before,
|
|
36
27
|
after: Position.After,
|
|
37
28
|
inside: Position.Inside,
|
|
38
29
|
none: Position.None
|
|
39
30
|
};
|
|
40
|
-
|
|
41
31
|
var getPositionName = function getPositionName(position) {
|
|
42
32
|
for (var name in positionNames) {
|
|
43
33
|
if (Object.prototype.hasOwnProperty.call(positionNames, name)) {
|
|
@@ -46,67 +36,47 @@ var getPositionName = function getPositionName(position) {
|
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
return "";
|
|
51
40
|
};
|
|
52
|
-
|
|
53
41
|
exports.getPositionName = getPositionName;
|
|
54
|
-
|
|
55
42
|
var getPosition = function getPosition(name) {
|
|
56
43
|
return positionNames[name];
|
|
57
44
|
};
|
|
58
|
-
|
|
59
45
|
exports.getPosition = getPosition;
|
|
60
|
-
|
|
61
46
|
var isNodeRecordWithChildren = function isNodeRecordWithChildren(data) {
|
|
62
47
|
return _typeof(data) === "object" && "children" in data && data["children"] instanceof Array;
|
|
63
48
|
};
|
|
64
|
-
|
|
65
49
|
var Node = /*#__PURE__*/function () {
|
|
66
50
|
function Node() {
|
|
67
51
|
var o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
68
52
|
var isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
69
53
|
var nodeClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Node;
|
|
70
|
-
|
|
71
54
|
_classCallCheck(this, Node);
|
|
72
|
-
|
|
73
55
|
_defineProperty(this, "id", void 0);
|
|
74
|
-
|
|
75
56
|
_defineProperty(this, "name", void 0);
|
|
76
|
-
|
|
77
57
|
_defineProperty(this, "children", void 0);
|
|
78
|
-
|
|
79
58
|
_defineProperty(this, "parent", void 0);
|
|
80
|
-
|
|
81
59
|
_defineProperty(this, "idMapping", void 0);
|
|
82
|
-
|
|
83
60
|
_defineProperty(this, "tree", void 0);
|
|
84
|
-
|
|
85
61
|
_defineProperty(this, "nodeClass", void 0);
|
|
86
|
-
|
|
87
62
|
_defineProperty(this, "load_on_demand", void 0);
|
|
88
|
-
|
|
89
63
|
_defineProperty(this, "is_open", void 0);
|
|
90
|
-
|
|
91
64
|
_defineProperty(this, "element", void 0);
|
|
92
|
-
|
|
93
65
|
_defineProperty(this, "is_loading", void 0);
|
|
94
|
-
|
|
95
66
|
_defineProperty(this, "isEmptyFolder", void 0);
|
|
96
|
-
|
|
97
67
|
this.name = "";
|
|
98
68
|
this.isEmptyFolder = false;
|
|
99
69
|
this.load_on_demand = false;
|
|
100
70
|
this.setData(o);
|
|
101
71
|
this.children = [];
|
|
102
72
|
this.parent = null;
|
|
103
|
-
|
|
104
73
|
if (isRoot) {
|
|
105
74
|
this.idMapping = new Map();
|
|
106
75
|
this.tree = this;
|
|
107
76
|
this.nodeClass = nodeClass;
|
|
108
77
|
}
|
|
109
78
|
}
|
|
79
|
+
|
|
110
80
|
/*
|
|
111
81
|
Set the data of this node.
|
|
112
82
|
setData(string): set the name of the node
|
|
@@ -118,8 +88,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
118
88
|
* This is an internal function; it is not in the docs
|
|
119
89
|
* Does not remove existing node values
|
|
120
90
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
91
|
_createClass(Node, [{
|
|
124
92
|
key: "setData",
|
|
125
93
|
value: function setData(o) {
|
|
@@ -131,7 +99,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
131
99
|
for (var _key in o) {
|
|
132
100
|
if (Object.prototype.hasOwnProperty.call(o, _key)) {
|
|
133
101
|
var value = o[_key];
|
|
134
|
-
|
|
135
102
|
if (_key === "label" || _key === "name") {
|
|
136
103
|
// You can use the 'label' key instead of 'name'; this is a legacy feature
|
|
137
104
|
if (typeof value === "string") {
|
|
@@ -145,6 +112,7 @@ var Node = /*#__PURE__*/function () {
|
|
|
145
112
|
}
|
|
146
113
|
}
|
|
147
114
|
}
|
|
115
|
+
|
|
148
116
|
/*
|
|
149
117
|
Create tree from data.
|
|
150
118
|
Structure of data is:
|
|
@@ -161,23 +129,17 @@ var Node = /*#__PURE__*/function () {
|
|
|
161
129
|
}
|
|
162
130
|
]
|
|
163
131
|
*/
|
|
164
|
-
|
|
165
132
|
}, {
|
|
166
133
|
key: "loadFromData",
|
|
167
134
|
value: function loadFromData(data) {
|
|
168
135
|
this.removeChildren();
|
|
169
|
-
|
|
170
136
|
var _iterator = _createForOfIteratorHelper(data),
|
|
171
|
-
|
|
172
|
-
|
|
137
|
+
_step;
|
|
173
138
|
try {
|
|
174
139
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
175
140
|
var o = _step.value;
|
|
176
|
-
|
|
177
141
|
var _node = this.createNode(o);
|
|
178
|
-
|
|
179
142
|
this.addChild(_node);
|
|
180
|
-
|
|
181
143
|
if (isNodeRecordWithChildren(o)) {
|
|
182
144
|
if (o.children.length === 0) {
|
|
183
145
|
_node.isEmptyFolder = true;
|
|
@@ -191,22 +153,22 @@ var Node = /*#__PURE__*/function () {
|
|
|
191
153
|
} finally {
|
|
192
154
|
_iterator.f();
|
|
193
155
|
}
|
|
194
|
-
|
|
195
156
|
return this;
|
|
196
157
|
}
|
|
158
|
+
|
|
197
159
|
/*
|
|
198
160
|
Add child.
|
|
199
161
|
tree.addChild(
|
|
200
162
|
new Node('child1')
|
|
201
163
|
);
|
|
202
164
|
*/
|
|
203
|
-
|
|
204
165
|
}, {
|
|
205
166
|
key: "addChild",
|
|
206
167
|
value: function addChild(node) {
|
|
207
168
|
this.children.push(node);
|
|
208
169
|
node.setParent(this);
|
|
209
170
|
}
|
|
171
|
+
|
|
210
172
|
/*
|
|
211
173
|
Add child at position. Index starts at 0.
|
|
212
174
|
tree.addChildAtPosition(
|
|
@@ -214,18 +176,17 @@ var Node = /*#__PURE__*/function () {
|
|
|
214
176
|
1
|
|
215
177
|
);
|
|
216
178
|
*/
|
|
217
|
-
|
|
218
179
|
}, {
|
|
219
180
|
key: "addChildAtPosition",
|
|
220
181
|
value: function addChildAtPosition(node, index) {
|
|
221
182
|
this.children.splice(index, 0, node);
|
|
222
183
|
node.setParent(this);
|
|
223
184
|
}
|
|
185
|
+
|
|
224
186
|
/*
|
|
225
187
|
Remove child. This also removes the children of the node.
|
|
226
188
|
tree.removeChild(tree.children[0]);
|
|
227
189
|
*/
|
|
228
|
-
|
|
229
190
|
}, {
|
|
230
191
|
key: "removeChild",
|
|
231
192
|
value: function removeChild(node) {
|
|
@@ -233,23 +194,23 @@ var Node = /*#__PURE__*/function () {
|
|
|
233
194
|
node.removeChildren();
|
|
234
195
|
this.doRemoveChild(node);
|
|
235
196
|
}
|
|
197
|
+
|
|
236
198
|
/*
|
|
237
199
|
Get child index.
|
|
238
200
|
var index = getChildIndex(node);
|
|
239
201
|
*/
|
|
240
|
-
|
|
241
202
|
}, {
|
|
242
203
|
key: "getChildIndex",
|
|
243
204
|
value: function getChildIndex(node) {
|
|
244
205
|
return this.children.indexOf(node);
|
|
245
206
|
}
|
|
207
|
+
|
|
246
208
|
/*
|
|
247
209
|
Does the tree have children?
|
|
248
210
|
if (tree.hasChildren()) {
|
|
249
211
|
//
|
|
250
212
|
}
|
|
251
213
|
*/
|
|
252
|
-
|
|
253
214
|
}, {
|
|
254
215
|
key: "hasChildren",
|
|
255
216
|
value: function hasChildren() {
|
|
@@ -260,6 +221,7 @@ var Node = /*#__PURE__*/function () {
|
|
|
260
221
|
value: function isFolder() {
|
|
261
222
|
return this.hasChildren() || this.load_on_demand;
|
|
262
223
|
}
|
|
224
|
+
|
|
263
225
|
/*
|
|
264
226
|
Iterate over all the nodes in the tree.
|
|
265
227
|
Calls callback with (node, level).
|
|
@@ -272,20 +234,17 @@ var Node = /*#__PURE__*/function () {
|
|
|
272
234
|
}
|
|
273
235
|
);
|
|
274
236
|
*/
|
|
275
|
-
|
|
276
237
|
}, {
|
|
277
238
|
key: "iterate",
|
|
278
239
|
value: function iterate(callback) {
|
|
279
240
|
var _iterate = function _iterate(node, level) {
|
|
280
241
|
if (node.children) {
|
|
281
242
|
var _iterator2 = _createForOfIteratorHelper(node.children),
|
|
282
|
-
|
|
283
|
-
|
|
243
|
+
_step2;
|
|
284
244
|
try {
|
|
285
245
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
286
246
|
var child = _step2.value;
|
|
287
247
|
var result = callback(child, level);
|
|
288
|
-
|
|
289
248
|
if (result && child.hasChildren()) {
|
|
290
249
|
_iterate(child, level + 1);
|
|
291
250
|
}
|
|
@@ -297,16 +256,15 @@ var Node = /*#__PURE__*/function () {
|
|
|
297
256
|
}
|
|
298
257
|
}
|
|
299
258
|
};
|
|
300
|
-
|
|
301
259
|
_iterate(this, 0);
|
|
302
260
|
}
|
|
261
|
+
|
|
303
262
|
/*
|
|
304
263
|
Move node relative to another node.
|
|
305
264
|
Argument position: Position.BEFORE, Position.AFTER or Position.Inside
|
|
306
265
|
// move node1 after node2
|
|
307
266
|
tree.moveNode(node1, node2, Position.AFTER);
|
|
308
267
|
*/
|
|
309
|
-
|
|
310
268
|
}, {
|
|
311
269
|
key: "moveNode",
|
|
312
270
|
value: function moveNode(movedNode, targetNode, position) {
|
|
@@ -316,7 +274,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
316
274
|
return false;
|
|
317
275
|
} else {
|
|
318
276
|
movedNode.parent.doRemoveChild(movedNode);
|
|
319
|
-
|
|
320
277
|
switch (position) {
|
|
321
278
|
case Position.After:
|
|
322
279
|
{
|
|
@@ -324,60 +281,50 @@ var Node = /*#__PURE__*/function () {
|
|
|
324
281
|
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode) + 1);
|
|
325
282
|
return true;
|
|
326
283
|
}
|
|
327
|
-
|
|
328
284
|
return false;
|
|
329
285
|
}
|
|
330
|
-
|
|
331
286
|
case Position.Before:
|
|
332
287
|
{
|
|
333
288
|
if (targetNode.parent) {
|
|
334
289
|
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode));
|
|
335
290
|
return true;
|
|
336
291
|
}
|
|
337
|
-
|
|
338
292
|
return false;
|
|
339
293
|
}
|
|
340
|
-
|
|
341
294
|
case Position.Inside:
|
|
342
295
|
{
|
|
343
296
|
// move inside as first child
|
|
344
297
|
targetNode.addChildAtPosition(movedNode, 0);
|
|
345
298
|
return true;
|
|
346
299
|
}
|
|
347
|
-
|
|
348
300
|
default:
|
|
349
301
|
return false;
|
|
350
302
|
}
|
|
351
303
|
}
|
|
352
304
|
}
|
|
305
|
+
|
|
353
306
|
/*
|
|
354
307
|
Get the tree as data.
|
|
355
308
|
*/
|
|
356
|
-
|
|
357
309
|
}, {
|
|
358
310
|
key: "getData",
|
|
359
311
|
value: function getData() {
|
|
360
312
|
var includeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
361
|
-
|
|
362
313
|
var getDataFromNodes = function getDataFromNodes(nodes) {
|
|
363
314
|
return nodes.map(function (node) {
|
|
364
315
|
var tmpNode = {};
|
|
365
|
-
|
|
366
316
|
for (var k in node) {
|
|
367
317
|
if (["parent", "children", "element", "idMapping", "load_on_demand", "nodeClass", "tree", "isEmptyFolder"].indexOf(k) === -1 && Object.prototype.hasOwnProperty.call(node, k)) {
|
|
368
318
|
var v = node[k];
|
|
369
319
|
tmpNode[k] = v;
|
|
370
320
|
}
|
|
371
321
|
}
|
|
372
|
-
|
|
373
322
|
if (node.hasChildren()) {
|
|
374
323
|
tmpNode["children"] = getDataFromNodes(node.children);
|
|
375
324
|
}
|
|
376
|
-
|
|
377
325
|
return tmpNode;
|
|
378
326
|
});
|
|
379
327
|
};
|
|
380
|
-
|
|
381
328
|
if (includeParent) {
|
|
382
329
|
return getDataFromNodes([this]);
|
|
383
330
|
} else {
|
|
@@ -397,11 +344,9 @@ var Node = /*#__PURE__*/function () {
|
|
|
397
344
|
var node = this.getNodeByCallback(function (n) {
|
|
398
345
|
return n.name === name;
|
|
399
346
|
});
|
|
400
|
-
|
|
401
347
|
if (!node) {
|
|
402
348
|
throw "Node with name ".concat(name, " not found");
|
|
403
349
|
}
|
|
404
|
-
|
|
405
350
|
return node;
|
|
406
351
|
}
|
|
407
352
|
}, {
|
|
@@ -427,14 +372,11 @@ var Node = /*#__PURE__*/function () {
|
|
|
427
372
|
return null;
|
|
428
373
|
} else {
|
|
429
374
|
var _node2 = this.createNode(nodeInfo);
|
|
430
|
-
|
|
431
375
|
var childIndex = this.parent.getChildIndex(this);
|
|
432
376
|
this.parent.addChildAtPosition(_node2, childIndex + 1);
|
|
433
|
-
|
|
434
377
|
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
435
378
|
_node2.loadFromData(nodeInfo.children);
|
|
436
379
|
}
|
|
437
|
-
|
|
438
380
|
return _node2;
|
|
439
381
|
}
|
|
440
382
|
}
|
|
@@ -445,14 +387,11 @@ var Node = /*#__PURE__*/function () {
|
|
|
445
387
|
return null;
|
|
446
388
|
} else {
|
|
447
389
|
var _node3 = this.createNode(nodeInfo);
|
|
448
|
-
|
|
449
390
|
var childIndex = this.parent.getChildIndex(this);
|
|
450
391
|
this.parent.addChildAtPosition(_node3, childIndex);
|
|
451
|
-
|
|
452
392
|
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
453
393
|
_node3.loadFromData(nodeInfo.children);
|
|
454
394
|
}
|
|
455
|
-
|
|
456
395
|
return _node3;
|
|
457
396
|
}
|
|
458
397
|
}
|
|
@@ -463,16 +402,12 @@ var Node = /*#__PURE__*/function () {
|
|
|
463
402
|
return null;
|
|
464
403
|
} else {
|
|
465
404
|
var newParent = this.createNode(nodeInfo);
|
|
466
|
-
|
|
467
405
|
if (this.tree) {
|
|
468
406
|
newParent.setParent(this.tree);
|
|
469
407
|
}
|
|
470
|
-
|
|
471
408
|
var originalParent = this.parent;
|
|
472
|
-
|
|
473
409
|
var _iterator3 = _createForOfIteratorHelper(originalParent.children),
|
|
474
|
-
|
|
475
|
-
|
|
410
|
+
_step3;
|
|
476
411
|
try {
|
|
477
412
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
478
413
|
var child = _step3.value;
|
|
@@ -483,7 +418,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
483
418
|
} finally {
|
|
484
419
|
_iterator3.f();
|
|
485
420
|
}
|
|
486
|
-
|
|
487
421
|
originalParent.children = [];
|
|
488
422
|
originalParent.addChild(newParent);
|
|
489
423
|
return newParent;
|
|
@@ -502,11 +436,9 @@ var Node = /*#__PURE__*/function () {
|
|
|
502
436
|
value: function append(nodeInfo) {
|
|
503
437
|
var node = this.createNode(nodeInfo);
|
|
504
438
|
this.addChild(node);
|
|
505
|
-
|
|
506
439
|
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
507
440
|
node.loadFromData(nodeInfo.children);
|
|
508
441
|
}
|
|
509
|
-
|
|
510
442
|
return node;
|
|
511
443
|
}
|
|
512
444
|
}, {
|
|
@@ -514,26 +446,21 @@ var Node = /*#__PURE__*/function () {
|
|
|
514
446
|
value: function prepend(nodeInfo) {
|
|
515
447
|
var node = this.createNode(nodeInfo);
|
|
516
448
|
this.addChildAtPosition(node, 0);
|
|
517
|
-
|
|
518
449
|
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
519
450
|
node.loadFromData(nodeInfo.children);
|
|
520
451
|
}
|
|
521
|
-
|
|
522
452
|
return node;
|
|
523
453
|
}
|
|
524
454
|
}, {
|
|
525
455
|
key: "isParentOf",
|
|
526
456
|
value: function isParentOf(node) {
|
|
527
457
|
var parent = node.parent;
|
|
528
|
-
|
|
529
458
|
while (parent) {
|
|
530
459
|
if (parent === this) {
|
|
531
460
|
return true;
|
|
532
461
|
}
|
|
533
|
-
|
|
534
462
|
parent = parent.parent;
|
|
535
463
|
}
|
|
536
|
-
|
|
537
464
|
return false;
|
|
538
465
|
}
|
|
539
466
|
}, {
|
|
@@ -546,7 +473,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
546
473
|
level += 1;
|
|
547
474
|
node = node.parent;
|
|
548
475
|
}
|
|
549
|
-
|
|
550
476
|
return level;
|
|
551
477
|
}
|
|
552
478
|
}, {
|
|
@@ -572,10 +498,8 @@ var Node = /*#__PURE__*/function () {
|
|
|
572
498
|
key: "removeChildren",
|
|
573
499
|
value: function removeChildren() {
|
|
574
500
|
var _this = this;
|
|
575
|
-
|
|
576
501
|
this.iterate(function (child) {
|
|
577
502
|
var _this$tree;
|
|
578
|
-
|
|
579
503
|
(_this$tree = _this.tree) === null || _this$tree === void 0 ? void 0 : _this$tree.removeNodeFromIndex(child);
|
|
580
504
|
return true;
|
|
581
505
|
});
|
|
@@ -588,9 +512,8 @@ var Node = /*#__PURE__*/function () {
|
|
|
588
512
|
return null;
|
|
589
513
|
} else {
|
|
590
514
|
var previousIndex = this.parent.getChildIndex(this) - 1;
|
|
591
|
-
|
|
592
515
|
if (previousIndex >= 0) {
|
|
593
|
-
return this.parent.children[previousIndex];
|
|
516
|
+
return this.parent.children[previousIndex] || null;
|
|
594
517
|
} else {
|
|
595
518
|
return null;
|
|
596
519
|
}
|
|
@@ -603,9 +526,8 @@ var Node = /*#__PURE__*/function () {
|
|
|
603
526
|
return null;
|
|
604
527
|
} else {
|
|
605
528
|
var nextIndex = this.parent.getChildIndex(this) + 1;
|
|
606
|
-
|
|
607
529
|
if (nextIndex < this.parent.children.length) {
|
|
608
|
-
return this.parent.children[nextIndex];
|
|
530
|
+
return this.parent.children[nextIndex] || null;
|
|
609
531
|
} else {
|
|
610
532
|
return null;
|
|
611
533
|
}
|
|
@@ -626,7 +548,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
626
548
|
if (f(node)) {
|
|
627
549
|
result.push(node);
|
|
628
550
|
}
|
|
629
|
-
|
|
630
551
|
return true;
|
|
631
552
|
});
|
|
632
553
|
return result;
|
|
@@ -635,16 +556,30 @@ var Node = /*#__PURE__*/function () {
|
|
|
635
556
|
key: "getNextNode",
|
|
636
557
|
value: function getNextNode() {
|
|
637
558
|
var includeChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
638
|
-
|
|
639
|
-
|
|
559
|
+
if (includeChildren && this.hasChildren()) {
|
|
560
|
+
return this.children[0] || null;
|
|
561
|
+
} else if (!this.parent) {
|
|
562
|
+
return null;
|
|
563
|
+
} else {
|
|
564
|
+
var nextSibling = this.getNextSibling();
|
|
565
|
+
if (nextSibling) {
|
|
566
|
+
return nextSibling;
|
|
567
|
+
} else {
|
|
568
|
+
return this.parent.getNextNode(false);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}, {
|
|
573
|
+
key: "getNextVisibleNode",
|
|
574
|
+
value: function getNextVisibleNode() {
|
|
575
|
+
if (this.hasChildren() && this.is_open) {
|
|
640
576
|
// First child
|
|
641
|
-
return this.children[0];
|
|
577
|
+
return this.children[0] || null;
|
|
642
578
|
} else {
|
|
643
579
|
if (!this.parent) {
|
|
644
580
|
return null;
|
|
645
581
|
} else {
|
|
646
582
|
var nextSibling = this.getNextSibling();
|
|
647
|
-
|
|
648
583
|
if (nextSibling) {
|
|
649
584
|
// Next sibling
|
|
650
585
|
return nextSibling;
|
|
@@ -662,17 +597,30 @@ var Node = /*#__PURE__*/function () {
|
|
|
662
597
|
return null;
|
|
663
598
|
} else {
|
|
664
599
|
var previousSibling = this.getPreviousSibling();
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return previousSibling;
|
|
670
|
-
} else {
|
|
671
|
-
// Last child of previous sibling
|
|
672
|
-
return previousSibling.getLastChild();
|
|
673
|
-
}
|
|
600
|
+
if (!previousSibling) {
|
|
601
|
+
return this.getParent();
|
|
602
|
+
} else if (previousSibling.hasChildren()) {
|
|
603
|
+
return previousSibling.getLastChild();
|
|
674
604
|
} else {
|
|
605
|
+
return previousSibling;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}, {
|
|
610
|
+
key: "getPreviousVisibleNode",
|
|
611
|
+
value: function getPreviousVisibleNode() {
|
|
612
|
+
if (!this.parent) {
|
|
613
|
+
return null;
|
|
614
|
+
} else {
|
|
615
|
+
var previousSibling = this.getPreviousSibling();
|
|
616
|
+
if (!previousSibling) {
|
|
675
617
|
return this.getParent();
|
|
618
|
+
} else if (!previousSibling.hasChildren() || !previousSibling.is_open) {
|
|
619
|
+
// Previous sibling
|
|
620
|
+
return previousSibling;
|
|
621
|
+
} else {
|
|
622
|
+
// Last child of previous sibling
|
|
623
|
+
return previousSibling.getLastChild();
|
|
676
624
|
}
|
|
677
625
|
}
|
|
678
626
|
}
|
|
@@ -696,40 +644,36 @@ var Node = /*#__PURE__*/function () {
|
|
|
696
644
|
return null;
|
|
697
645
|
} else {
|
|
698
646
|
var lastChild = this.children[this.children.length - 1];
|
|
699
|
-
|
|
647
|
+
if (!lastChild) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
700
650
|
if (!(lastChild.hasChildren() && lastChild.is_open)) {
|
|
701
651
|
return lastChild;
|
|
702
652
|
} else {
|
|
703
|
-
return lastChild.getLastChild();
|
|
653
|
+
return lastChild === null || lastChild === void 0 ? void 0 : lastChild.getLastChild();
|
|
704
654
|
}
|
|
705
655
|
}
|
|
706
|
-
}
|
|
656
|
+
}
|
|
707
657
|
|
|
658
|
+
// Init Node from data without making it the root of the tree
|
|
708
659
|
}, {
|
|
709
660
|
key: "initFromData",
|
|
710
661
|
value: function initFromData(data) {
|
|
711
662
|
var _this2 = this;
|
|
712
|
-
|
|
713
663
|
var addNode = function addNode(nodeData) {
|
|
714
664
|
_this2.setData(nodeData);
|
|
715
|
-
|
|
716
665
|
if (isNodeRecordWithChildren(nodeData) && nodeData.children.length) {
|
|
717
666
|
addChildren(nodeData.children);
|
|
718
667
|
}
|
|
719
668
|
};
|
|
720
|
-
|
|
721
669
|
var addChildren = function addChildren(childrenData) {
|
|
722
670
|
var _iterator4 = _createForOfIteratorHelper(childrenData),
|
|
723
|
-
|
|
724
|
-
|
|
671
|
+
_step4;
|
|
725
672
|
try {
|
|
726
673
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
727
674
|
var child = _step4.value;
|
|
728
|
-
|
|
729
675
|
var _node4 = _this2.createNode();
|
|
730
|
-
|
|
731
676
|
_node4.initFromData(child);
|
|
732
|
-
|
|
733
677
|
_this2.addChild(_node4);
|
|
734
678
|
}
|
|
735
679
|
} catch (err) {
|
|
@@ -738,14 +682,12 @@ var Node = /*#__PURE__*/function () {
|
|
|
738
682
|
_iterator4.f();
|
|
739
683
|
}
|
|
740
684
|
};
|
|
741
|
-
|
|
742
685
|
addNode(data);
|
|
743
686
|
}
|
|
744
687
|
}, {
|
|
745
688
|
key: "setParent",
|
|
746
689
|
value: function setParent(parent) {
|
|
747
690
|
var _this$tree2;
|
|
748
|
-
|
|
749
691
|
this.parent = parent;
|
|
750
692
|
this.tree = parent.tree;
|
|
751
693
|
(_this$tree2 = this.tree) === null || _this$tree2 === void 0 ? void 0 : _this$tree2.addNodeToIndex(this);
|
|
@@ -754,7 +696,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
754
696
|
key: "doRemoveChild",
|
|
755
697
|
value: function doRemoveChild(node) {
|
|
756
698
|
var _this$tree3;
|
|
757
|
-
|
|
758
699
|
this.children.splice(this.getChildIndex(node), 1);
|
|
759
700
|
(_this$tree3 = this.tree) === null || _this$tree3 === void 0 ? void 0 : _this$tree3.removeNodeFromIndex(node);
|
|
760
701
|
}
|
|
@@ -762,8 +703,7 @@ var Node = /*#__PURE__*/function () {
|
|
|
762
703
|
key: "getNodeClass",
|
|
763
704
|
value: function getNodeClass() {
|
|
764
705
|
var _this$tree4;
|
|
765
|
-
|
|
766
|
-
return this.nodeClass || (this === null || this === void 0 ? void 0 : (_this$tree4 = this.tree) === null || _this$tree4 === void 0 ? void 0 : _this$tree4.nodeClass) || Node;
|
|
706
|
+
return this.nodeClass || (this === null || this === void 0 || (_this$tree4 = this.tree) === null || _this$tree4 === void 0 ? void 0 : _this$tree4.nodeClass) || Node;
|
|
767
707
|
}
|
|
768
708
|
}, {
|
|
769
709
|
key: "createNode",
|
|
@@ -772,8 +712,6 @@ var Node = /*#__PURE__*/function () {
|
|
|
772
712
|
return new nodeClass(nodeData);
|
|
773
713
|
}
|
|
774
714
|
}]);
|
|
775
|
-
|
|
776
715
|
return Node;
|
|
777
716
|
}();
|
|
778
|
-
|
|
779
717
|
exports.Node = Node;
|