jqtree 1.6.0 → 1.6.3
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/.eslintrc +3 -11
- package/.github/workflows/ci.yml +48 -23
- package/.github/workflows/codeql-analysis.yml +9 -5
- package/.prettier +3 -0
- package/README.md +11 -8
- package/bower.json +1 -1
- package/{.postcssrc → config/.postcssrc} +0 -0
- package/config/babel.config.json +11 -0
- package/config/babel.coverage.config.json +4 -0
- package/{jest-jsdom.config.js → config/jest.config.js} +9 -5
- package/config/playwright.config.js +18 -0
- package/config/production +4 -0
- package/{rollup.config.js → config/rollup.config.js} +19 -14
- package/{jqtree.postcss → css/jqtree.postcss} +3 -0
- package/devserver/index.html +1 -9
- package/docs/Gemfile +2 -0
- package/docs/Gemfile.lock +263 -0
- package/{_config.yml → docs/_config.yml} +8 -1
- package/{_entries → docs/_entries}/01_general.md +0 -0
- package/{_entries → docs/_entries}/02_introduction.md +0 -0
- package/{_entries → docs/_entries}/03_features.md +1 -1
- package/{_entries → docs/_entries}/04_demo.html +1 -7
- package/{_entries → docs/_entries}/05_requirements.md +0 -0
- package/{_entries → docs/_entries}/06_downloads.md +0 -0
- package/{_entries → docs/_entries}/07_tutorial.md +0 -0
- package/{_entries → docs/_entries}/08_examples.md +0 -0
- package/{_entries → docs/_entries}/09_usecases.md +0 -0
- package/{_entries → docs/_entries}/10_changelog.md +14 -0
- package/{_entries → docs/_entries}/11_options.md +0 -0
- package/{_entries → docs/_entries}/12_animationspeed.md +0 -0
- package/{_entries → docs/_entries}/13_autoescape.md +0 -0
- package/{_entries → docs/_entries}/14_autoopen.md +0 -0
- package/{_entries → docs/_entries}/15_buttonleft.md +0 -0
- package/{_entries → docs/_entries}/16_closedicon.md +0 -0
- package/{_entries → docs/_entries}/17_data.md +0 -0
- package/{_entries → docs/_entries}/18_datafilter.md +0 -0
- package/{_entries → docs/_entries}/19_data-url.md +0 -0
- package/{_entries → docs/_entries}/20_draganddrop.md +0 -0
- package/{_entries → docs/_entries}/21_keyboardsupport.md +0 -0
- package/{_entries → docs/_entries}/22_oncanmove.md +0 -0
- package/{_entries → docs/_entries}/23_oncanmoveto.md +2 -2
- package/{_entries → docs/_entries}/24_oncanselectnode.md +0 -0
- package/{_entries → docs/_entries}/25_oncreateli.md +2 -2
- package/{_entries → docs/_entries}/26_ondragmove.md +0 -0
- package/{_entries → docs/_entries}/27_ondragstop.md +0 -0
- package/{_entries → docs/_entries}/28_onismovehandle.md +0 -0
- package/{_entries → docs/_entries}/29_onloadfailed.md +0 -0
- package/{_entries → docs/_entries}/30_onloading.md +2 -2
- package/{_entries → docs/_entries}/31_openedicon.md +0 -0
- package/{_entries → docs/_entries}/32_openfolderdelay.md +2 -0
- package/{_entries → docs/_entries}/33_rtl.md +0 -0
- package/{_entries → docs/_entries}/34_savestate.md +0 -0
- package/{_entries → docs/_entries}/35_selectable.md +0 -0
- package/{_entries → docs/_entries}/36_showemptyfolder.md +0 -0
- package/{_entries → docs/_entries}/37_slide.md +0 -0
- package/{_entries → docs/_entries}/38_start_dnd_delay.md +0 -0
- package/{_entries → docs/_entries}/39_tabindex.md +0 -0
- package/{_entries → docs/_entries}/40_usecontextmenu.md +0 -0
- package/{_entries → docs/_entries}/41_functions.md +0 -0
- package/{_entries → docs/_entries}/42_addparentnode.md +1 -1
- package/{_entries → docs/_entries}/43_addnodeafter.md +1 -1
- package/{_entries → docs/_entries}/44_addnodebefore.md +1 -1
- package/{_entries → docs/_entries}/45_appendnode.md +5 -5
- package/{_entries → docs/_entries}/46_closenode.md +0 -0
- package/{_entries → docs/_entries}/47_destroy.md +0 -0
- package/{_entries → docs/_entries}/48_getnodebycallback.md +0 -0
- package/{_entries → docs/_entries}/49_getnodebyid.md +0 -0
- package/{_entries → docs/_entries}/50_getnodebyhtmlelement.md +2 -2
- package/{_entries → docs/_entries}/51_getselectednode.md +0 -0
- package/{_entries → docs/_entries}/52_getstate.md +0 -0
- package/{_entries → docs/_entries}/53_gettree.md +1 -1
- package/{_entries → docs/_entries}/54_isdragging.md +1 -1
- package/{_entries → docs/_entries}/55_loaddata.md +3 -3
- package/{_entries → docs/_entries}/56_loaddatafromurl.md +4 -4
- package/{_entries → docs/_entries}/57_movedown.md +0 -0
- package/{_entries → docs/_entries}/58_movenode.md +3 -3
- package/{_entries → docs/_entries}/59_moveup.md +0 -0
- package/{_entries → docs/_entries}/60_opennode.md +3 -3
- package/docs/_entries/61_prependnode.md +21 -0
- package/docs/_entries/62_refresh.md +12 -0
- package/{_entries/62_reload.md → docs/_entries/63_reload.md} +2 -2
- package/{_entries/63_removenode.md → docs/_entries/64_removenode.md} +0 -0
- package/{_entries/64_selectnode.md → docs/_entries/65_selectnode.md} +0 -0
- package/{_entries/65_scrolltonode.md → docs/_entries/66_scrolltonode.md} +0 -0
- package/{_entries/66_setoption.md → docs/_entries/67_setoption.md} +0 -0
- package/{_entries/67_setstate.md → docs/_entries/68_setstate.md} +0 -0
- package/{_entries/68_toggle.md → docs/_entries/69_toggle.md} +0 -0
- package/{_entries/69_tojson.md → docs/_entries/70_tojson.md} +0 -0
- package/{_entries/70_updatenode.md → docs/_entries/71_updatenode.md} +1 -1
- package/{_entries/71_events.md → docs/_entries/72_events.md} +0 -0
- package/{_entries/72_tree-click.md → docs/_entries/73_tree-click.md} +0 -0
- package/{_entries/73_tree-close.md → docs/_entries/74_tree-close.md} +0 -0
- package/{_entries/74_tree-contextmenu.md → docs/_entries/75_tree-contextmenu.md} +0 -0
- package/{_entries/75_tree-dblclick.md → docs/_entries/76_tree-dblclick.md} +0 -0
- package/{_entries/76_tree-init.md → docs/_entries/77_tree-init.md} +0 -0
- package/{_entries/77_tree-load-data.md → docs/_entries/78_tree-load-data.md} +0 -0
- package/{_entries/78_tree-loading-data.md → docs/_entries/79_tree-loading-data.md} +0 -0
- package/{_entries/79_tree-move.md → docs/_entries/80_tree-move.md} +0 -0
- package/{_entries/80_tree-refresh.md → docs/_entries/81_tree-refresh.md} +0 -0
- package/{_entries/81_tree-open.md → docs/_entries/82_tree-open.md} +0 -0
- package/{_entries/82_tree-select.md → docs/_entries/83_tree-select.md} +0 -0
- package/{_entries/83_multiple-selection.md → docs/_entries/84_multiple-selection.md} +0 -0
- package/{_entries/84_add-to-selection.md → docs/_entries/85_add-to-selection.md} +0 -0
- package/{_entries/85_get-selected-nodes.md → docs/_entries/86_get-selected-nodes.md} +0 -0
- package/{_entries/86_is-node-selected.md → docs/_entries/87_is-node-selected.md} +1 -1
- package/{_entries/87_remove-from-selection.md → docs/_entries/88_remove-from-selection.md} +0 -0
- package/{_entries/88_node-functions.md → docs/_entries/89_node-functions.md} +0 -0
- package/{_entries/89_children.md → docs/_entries/90_children.md} +0 -0
- package/{_entries/90_getdata.md → docs/_entries/91_getdata.md} +2 -2
- package/{_entries/91_getlevel.md → docs/_entries/92_getlevel.md} +0 -0
- package/{_entries/92_getnextnode.md → docs/_entries/93_getnextnode.md} +0 -0
- package/{_entries/93_getnextsibling.md → docs/_entries/94_getnextsibling.md} +0 -0
- package/{_entries/94_getpreviousnode.md → docs/_entries/95_getpreviousnode.md} +0 -0
- package/{_entries/95_getprevioussibling.md → docs/_entries/96_getprevioussibling.md} +0 -0
- package/{_entries/96_parent.md → docs/_entries/97_parent.md} +1 -1
- package/{_entries → docs/_entries}/insert.py +0 -0
- package/{_entries → docs/_entries}/renumber.py +0 -0
- package/{_examples → docs/_examples}/01_load_json_data.html +3 -5
- package/{_examples → docs/_examples}/02_load_json_data_from_server.html +3 -5
- package/{_examples → docs/_examples}/03_drag_and_drop.html +3 -5
- package/{_examples → docs/_examples}/04_save_state.html +3 -5
- package/{_examples → docs/_examples}/05_load_on_demand.html +3 -5
- package/{_examples → docs/_examples}/06_autoescape.html +3 -5
- package/{_examples → docs/_examples}/07_autoscroll.html +3 -5
- package/{_examples → docs/_examples}/08_multiple_select.html +3 -5
- package/{_examples → docs/_examples}/09_custom_html.html +3 -5
- package/{_examples → docs/_examples}/10_icon_buttons.html +3 -5
- package/{_examples → docs/_examples}/11_right-to-left.html +3 -5
- package/{_examples → docs/_examples}/12_button_on_right.html +3 -5
- package/docs/_examples/13_drag_outside.html +48 -0
- package/docs/_examples/14_filter.html +111 -0
- package/docs/_layouts/example.html +7 -0
- package/docs/_layouts/page.html +26 -0
- package/docs/documentation.css +3 -0
- package/docs/index.html +65 -0
- package/docs/jqtree.css +189 -0
- package/docs/package.json +22 -0
- package/docs/pnpm-lock.yaml +768 -0
- package/docs/postcss.config.js +7 -0
- package/docs/static/bower.json +8 -0
- package/docs/static/bower_components/fontawesome/css/all.min.css +5 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.svg +774 -627
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.svg +93 -95
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.svg +1164 -1074
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/{static → docs/static}/bower_components/jquery/dist/jquery.js +118 -109
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -0
- package/{static → docs/static}/bower_components/jquery-mockjax/dist/jquery.mockjax.js +15 -9
- package/docs/static/documentation.css +1313 -0
- package/docs/static/documentation.js +26 -0
- package/{static → docs/static}/example.css +14 -33
- package/{static → docs/static}/example.postcss +15 -32
- package/{static → docs/static}/example_data.js +33 -36
- package/{static → docs/static}/examples/autoescape.js +0 -0
- package/{static → docs/static}/examples/autoscroll.js +0 -0
- package/{static → docs/static}/examples/button-on-right.js +0 -0
- package/{static → docs/static}/examples/custom_html.js +5 -9
- package/{static → docs/static}/examples/drag-outside.js +0 -0
- package/{static → docs/static}/examples/drag_and_drop.js +0 -0
- package/docs/static/examples/filter.js +63 -0
- package/{static → docs/static}/examples/icon_buttons.js +0 -0
- package/{static → docs/static}/examples/load_json_data.js +0 -0
- package/{static → docs/static}/examples/load_json_data_from_server.js +0 -0
- package/{static → docs/static}/examples/load_on_demand.js +0 -0
- package/{static → docs/static}/examples/multiple_select.js +0 -0
- package/{static → docs/static}/examples/right-to-left.js +0 -0
- package/{static → docs/static}/examples/save_state.js +0 -0
- package/{static → docs/static}/monokai.css +0 -0
- package/{static → docs/static}/spinner.gif +0 -0
- package/docs/tailwind.config.js +16 -0
- package/docs/tree.jquery.js +21 -0
- package/jqtree.css +4 -1
- package/lib/dataLoader.js +146 -98
- package/lib/dragAndDropHandler.js +672 -470
- package/lib/elementsRenderer.js +282 -197
- package/lib/jqtreeOptions.js +1 -2
- package/lib/keyHandler.js +134 -87
- package/lib/mouse.widget.js +285 -184
- package/lib/node.js +691 -505
- package/lib/nodeElement.js +329 -205
- package/lib/playwright/coverage.js +140 -0
- package/lib/playwright/playwright.test.js +298 -179
- package/lib/playwright/testUtils.js +267 -0
- package/lib/saveStateHandler.js +311 -204
- package/lib/scrollHandler.js +293 -199
- package/lib/selectNodeHandler.js +140 -100
- package/lib/simple.widget.js +184 -109
- package/lib/test/global.d.js +3 -0
- package/lib/test/jqTree/create.test.js +44 -40
- package/lib/test/jqTree/events.test.js +186 -138
- package/lib/test/jqTree/keyboard.test.js +216 -199
- package/lib/test/jqTree/loadOnDemand.test.js +238 -157
- package/lib/test/jqTree/methods.test.js +1289 -1019
- package/lib/test/jqTree/options.test.js +491 -410
- package/lib/test/node.test.js +1036 -873
- package/lib/test/nodeUtil.test.js +21 -20
- package/lib/test/support/exampleData.js +35 -23
- package/lib/test/support/jqTreeMatchers.js +72 -54
- package/lib/test/support/matchers.d.js +1 -0
- package/lib/test/support/setupTests.js +9 -3
- package/lib/test/support/testUtil.js +35 -15
- package/lib/test/support/treeStructure.js +41 -32
- package/lib/test/util.test.js +21 -20
- package/lib/tree.jquery.d.js +1 -0
- package/lib/tree.jquery.js +1264 -886
- package/lib/types.js +1 -2
- package/lib/typings.d.js +2 -0
- package/lib/util.js +19 -8
- package/lib/version.js +8 -3
- package/package.json +54 -47
- package/src/dataLoader.ts +6 -6
- package/src/dragAndDropHandler.ts +8 -8
- package/src/elementsRenderer.ts +4 -0
- package/src/jqtreeOptions.ts +2 -2
- package/src/mouse.widget.ts +19 -15
- package/src/node.ts +27 -41
- package/src/nodeElement.ts +17 -9
- package/src/playwright/.eslintrc +5 -0
- package/src/playwright/coverage.ts +41 -0
- package/src/playwright/playwright.test.ts +75 -77
- package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-linux.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-linux.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-linux.png +0 -0
- package/src/playwright/testUtils.ts +122 -0
- package/src/saveStateHandler.ts +11 -6
- package/src/selectNodeHandler.ts +1 -1
- package/src/simple.widget.ts +1 -1
- package/src/test/.eslintrc +14 -0
- package/src/test/jqTree/create.test.ts +0 -1
- package/src/test/jqTree/events.test.ts +10 -10
- package/src/test/jqTree/keyboard.test.ts +0 -1
- package/src/test/jqTree/loadOnDemand.test.ts +56 -11
- package/src/test/jqTree/methods.test.ts +72 -55
- package/src/test/jqTree/options.test.ts +30 -33
- package/src/test/node.test.ts +2 -2
- package/src/test/support/jqTreeMatchers.ts +8 -9
- package/src/test/support/matchers.d.ts +2 -4
- package/src/test/support/setupTests.ts +2 -1
- package/src/tree.jquery.d.ts +19 -13
- package/src/tree.jquery.ts +35 -28
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +4810 -3325
- 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/_entries/61_prependnode.md +0 -21
- package/_examples/13_drag_outside.html +0 -25
- package/_layouts/base.html +0 -55
- package/_layouts/frontpage.html +0 -20
- package/_layouts/page.html +0 -7
- package/index.html +0 -48
- package/jest-browser.config.js +0 -18
- package/jest-playwright.config.js +0 -21
- package/jest.config.js +0 -8
- package/lib/playwright/testUtil.js +0 -223
- package/lib/playwright/visualRegression.js +0 -128
- package/production +0 -5
- package/src/playwright/screenshots/displays_a_tree_Desktop.png +0 -0
- package/src/playwright/screenshots/displays_a_tree_iPhone 6.png +0 -0
- package/src/playwright/screenshots/moves_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/moves_a_node_iPhone 6.png +0 -0
- package/src/playwright/screenshots/opens_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/opens_a_node_iPhone 6.png +0 -0
- package/src/playwright/screenshots/selects_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/selects_a_node_iPhone 6.png +0 -0
- package/src/playwright/testUtil.ts +0 -171
- package/src/playwright/visualRegression.ts +0 -88
- package/static/bower.json +0 -9
- package/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +0 -6
- package/static/bower_components/bootstrap/dist/css/bootstrap.min.css +0 -6
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +0 -288
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/static/bower_components/bootstrap/dist/js/bootstrap.min.js +0 -6
- package/static/bower_components/fontawesome/css/all.min.css +0 -5
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- package/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/static/bower_components/jquery/dist/jquery.min.js +0 -2
- package/static/documentation.css +0 -171
- package/static/documentation.js +0 -48
package/lib/node.js
CHANGED
|
@@ -1,96 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPositionName = exports.getPosition = exports.Position = exports.Node = void 0;
|
|
7
|
+
|
|
8
|
+
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
|
+
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
|
+
|
|
14
|
+
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
|
+
|
|
18
|
+
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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
|
|
22
|
+
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
|
+
|
|
4
24
|
var Position;
|
|
25
|
+
exports.Position = Position;
|
|
26
|
+
|
|
5
27
|
(function (Position) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(Position
|
|
28
|
+
Position[Position["Before"] = 1] = "Before";
|
|
29
|
+
Position[Position["After"] = 2] = "After";
|
|
30
|
+
Position[Position["Inside"] = 3] = "Inside";
|
|
31
|
+
Position[Position["None"] = 4] = "None";
|
|
32
|
+
})(Position || (exports.Position = Position = {}));
|
|
33
|
+
|
|
11
34
|
var positionNames = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
35
|
+
before: Position.Before,
|
|
36
|
+
after: Position.After,
|
|
37
|
+
inside: Position.Inside,
|
|
38
|
+
none: Position.None
|
|
16
39
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
|
|
41
|
+
var getPositionName = function getPositionName(position) {
|
|
42
|
+
for (var name in positionNames) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(positionNames, name)) {
|
|
44
|
+
if (positionNames[name] === position) {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
24
47
|
}
|
|
25
|
-
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return "";
|
|
26
51
|
};
|
|
52
|
+
|
|
27
53
|
exports.getPositionName = getPositionName;
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
|
|
55
|
+
var getPosition = function getPosition(name) {
|
|
56
|
+
return positionNames[name];
|
|
30
57
|
};
|
|
58
|
+
|
|
31
59
|
exports.getPosition = getPosition;
|
|
32
|
-
var Node = /** @class */ (function () {
|
|
33
|
-
function Node(o, isRoot, nodeClass) {
|
|
34
|
-
if (o === void 0) { o = null; }
|
|
35
|
-
if (isRoot === void 0) { isRoot = false; }
|
|
36
|
-
if (nodeClass === void 0) { nodeClass = Node; }
|
|
37
|
-
this.name = "";
|
|
38
|
-
this.isEmptyFolder = false;
|
|
39
|
-
this.load_on_demand = false;
|
|
40
|
-
this.setData(o);
|
|
41
|
-
this.children = [];
|
|
42
|
-
this.parent = null;
|
|
43
|
-
if (isRoot) {
|
|
44
|
-
this.idMapping = new Map();
|
|
45
|
-
this.tree = this;
|
|
46
|
-
this.nodeClass = nodeClass;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/*
|
|
50
|
-
Set the data of this node.
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
var isNodeRecordWithChildren = function isNodeRecordWithChildren(data) {
|
|
62
|
+
return _typeof(data) === "object" && "children" in data && data["children"] instanceof Array;
|
|
63
|
+
};
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
var Node = /*#__PURE__*/function () {
|
|
66
|
+
function Node() {
|
|
67
|
+
var o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
68
|
+
var isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
69
|
+
var nodeClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Node;
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
_classCallCheck(this, Node);
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
_defineProperty(this, "id", void 0);
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
_defineProperty(this, "name", void 0);
|
|
76
|
+
|
|
77
|
+
_defineProperty(this, "children", void 0);
|
|
78
|
+
|
|
79
|
+
_defineProperty(this, "parent", void 0);
|
|
80
|
+
|
|
81
|
+
_defineProperty(this, "idMapping", void 0);
|
|
82
|
+
|
|
83
|
+
_defineProperty(this, "tree", void 0);
|
|
84
|
+
|
|
85
|
+
_defineProperty(this, "nodeClass", void 0);
|
|
86
|
+
|
|
87
|
+
_defineProperty(this, "load_on_demand", void 0);
|
|
88
|
+
|
|
89
|
+
_defineProperty(this, "is_open", void 0);
|
|
90
|
+
|
|
91
|
+
_defineProperty(this, "element", void 0);
|
|
92
|
+
|
|
93
|
+
_defineProperty(this, "is_loading", void 0);
|
|
94
|
+
|
|
95
|
+
_defineProperty(this, "isEmptyFolder", void 0);
|
|
96
|
+
|
|
97
|
+
this.name = "";
|
|
98
|
+
this.isEmptyFolder = false;
|
|
99
|
+
this.load_on_demand = false;
|
|
100
|
+
this.setData(o);
|
|
101
|
+
this.children = [];
|
|
102
|
+
this.parent = null;
|
|
103
|
+
|
|
104
|
+
if (isRoot) {
|
|
105
|
+
this.idMapping = new Map();
|
|
106
|
+
this.tree = this;
|
|
107
|
+
this.nodeClass = nodeClass;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/*
|
|
111
|
+
Set the data of this node.
|
|
112
|
+
setData(string): set the name of the node
|
|
113
|
+
setdata(object): set attributes of the node
|
|
114
|
+
Examples:
|
|
115
|
+
setdata('node1')
|
|
116
|
+
setData({ name: 'node1', id: 1});
|
|
117
|
+
setData({ name: 'node2', id: 2, color: 'green'});
|
|
118
|
+
* This is an internal function; it is not in the docs
|
|
119
|
+
* Does not remove existing node values
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
_createClass(Node, [{
|
|
124
|
+
key: "setData",
|
|
125
|
+
value: function setData(o) {
|
|
126
|
+
if (!o) {
|
|
127
|
+
return;
|
|
128
|
+
} else if (typeof o === "string") {
|
|
129
|
+
this.name = o;
|
|
130
|
+
} else if (_typeof(o) === "object") {
|
|
131
|
+
for (var _key in o) {
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(o, _key)) {
|
|
133
|
+
var value = o[_key];
|
|
134
|
+
|
|
135
|
+
if (_key === "label" || _key === "name") {
|
|
136
|
+
// You can use the 'label' key instead of 'name'; this is a legacy feature
|
|
137
|
+
if (typeof value === "string") {
|
|
138
|
+
this.name = value;
|
|
139
|
+
}
|
|
140
|
+
} else if (_key !== "children" && _key !== "parent") {
|
|
141
|
+
// You can't update the children or the parent using this function
|
|
142
|
+
this[_key] = value;
|
|
87
143
|
}
|
|
144
|
+
}
|
|
88
145
|
}
|
|
89
|
-
|
|
146
|
+
}
|
|
147
|
+
}
|
|
90
148
|
/*
|
|
91
149
|
Create tree from data.
|
|
92
|
-
|
|
93
|
-
Structure of data is:
|
|
150
|
+
Structure of data is:
|
|
94
151
|
[
|
|
95
152
|
{
|
|
96
153
|
name: 'node1',
|
|
@@ -104,490 +161,619 @@ var Node = /** @class */ (function () {
|
|
|
104
161
|
}
|
|
105
162
|
]
|
|
106
163
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
164
|
+
|
|
165
|
+
}, {
|
|
166
|
+
key: "loadFromData",
|
|
167
|
+
value: function loadFromData(data) {
|
|
168
|
+
this.removeChildren();
|
|
169
|
+
|
|
170
|
+
var _iterator = _createForOfIteratorHelper(data),
|
|
171
|
+
_step;
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
175
|
+
var o = _step.value;
|
|
176
|
+
|
|
177
|
+
var _node = this.createNode(o);
|
|
178
|
+
|
|
179
|
+
this.addChild(_node);
|
|
180
|
+
|
|
181
|
+
if (isNodeRecordWithChildren(o)) {
|
|
182
|
+
if (o.children.length === 0) {
|
|
183
|
+
_node.isEmptyFolder = true;
|
|
184
|
+
} else {
|
|
185
|
+
_node.loadFromData(o.children);
|
|
122
186
|
}
|
|
187
|
+
}
|
|
123
188
|
}
|
|
124
|
-
|
|
125
|
-
|
|
189
|
+
} catch (err) {
|
|
190
|
+
_iterator.e(err);
|
|
191
|
+
} finally {
|
|
192
|
+
_iterator.f();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
126
197
|
/*
|
|
127
198
|
Add child.
|
|
128
|
-
|
|
129
|
-
tree.addChild(
|
|
199
|
+
tree.addChild(
|
|
130
200
|
new Node('child1')
|
|
131
201
|
);
|
|
132
202
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
203
|
+
|
|
204
|
+
}, {
|
|
205
|
+
key: "addChild",
|
|
206
|
+
value: function addChild(node) {
|
|
207
|
+
this.children.push(node);
|
|
208
|
+
node.setParent(this);
|
|
209
|
+
}
|
|
137
210
|
/*
|
|
138
211
|
Add child at position. Index starts at 0.
|
|
139
|
-
|
|
140
|
-
tree.addChildAtPosition(
|
|
212
|
+
tree.addChildAtPosition(
|
|
141
213
|
new Node('abc'),
|
|
142
214
|
1
|
|
143
215
|
);
|
|
144
216
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
217
|
+
|
|
218
|
+
}, {
|
|
219
|
+
key: "addChildAtPosition",
|
|
220
|
+
value: function addChildAtPosition(node, index) {
|
|
221
|
+
this.children.splice(index, 0, node);
|
|
222
|
+
node.setParent(this);
|
|
223
|
+
}
|
|
149
224
|
/*
|
|
150
225
|
Remove child. This also removes the children of the node.
|
|
151
|
-
|
|
152
|
-
tree.removeChild(tree.children[0]);
|
|
226
|
+
tree.removeChild(tree.children[0]);
|
|
153
227
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
228
|
+
|
|
229
|
+
}, {
|
|
230
|
+
key: "removeChild",
|
|
231
|
+
value: function removeChild(node) {
|
|
232
|
+
// remove children from the index
|
|
233
|
+
node.removeChildren();
|
|
234
|
+
this.doRemoveChild(node);
|
|
235
|
+
}
|
|
159
236
|
/*
|
|
160
237
|
Get child index.
|
|
161
|
-
|
|
162
|
-
var index = getChildIndex(node);
|
|
238
|
+
var index = getChildIndex(node);
|
|
163
239
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
240
|
+
|
|
241
|
+
}, {
|
|
242
|
+
key: "getChildIndex",
|
|
243
|
+
value: function getChildIndex(node) {
|
|
244
|
+
return this.children.indexOf(node);
|
|
245
|
+
}
|
|
167
246
|
/*
|
|
168
247
|
Does the tree have children?
|
|
169
|
-
|
|
170
|
-
if (tree.hasChildren()) {
|
|
248
|
+
if (tree.hasChildren()) {
|
|
171
249
|
//
|
|
172
250
|
}
|
|
173
251
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
252
|
+
|
|
253
|
+
}, {
|
|
254
|
+
key: "hasChildren",
|
|
255
|
+
value: function hasChildren() {
|
|
256
|
+
return this.children.length !== 0;
|
|
257
|
+
}
|
|
258
|
+
}, {
|
|
259
|
+
key: "isFolder",
|
|
260
|
+
value: function isFolder() {
|
|
261
|
+
return this.hasChildren() || this.load_on_demand;
|
|
262
|
+
}
|
|
180
263
|
/*
|
|
181
264
|
Iterate over all the nodes in the tree.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
The callback must return true to continue the iteration on current node.
|
|
186
|
-
|
|
187
|
-
tree.iterate(
|
|
265
|
+
Calls callback with (node, level).
|
|
266
|
+
The callback must return true to continue the iteration on current node.
|
|
267
|
+
tree.iterate(
|
|
188
268
|
function(node, level) {
|
|
189
269
|
console.log(node.name);
|
|
190
|
-
|
|
191
|
-
// stop iteration after level 2
|
|
270
|
+
// stop iteration after level 2
|
|
192
271
|
return (level <= 2);
|
|
193
272
|
}
|
|
194
273
|
);
|
|
274
|
+
*/
|
|
195
275
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (result && child.hasChildren()) {
|
|
204
|
-
_iterate(child, level + 1);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
_iterate(this, 0);
|
|
210
|
-
};
|
|
211
|
-
/*
|
|
212
|
-
Move node relative to another node.
|
|
276
|
+
}, {
|
|
277
|
+
key: "iterate",
|
|
278
|
+
value: function iterate(callback) {
|
|
279
|
+
var _iterate = function _iterate(node, level) {
|
|
280
|
+
if (node.children) {
|
|
281
|
+
var _iterator2 = _createForOfIteratorHelper(node.children),
|
|
282
|
+
_step2;
|
|
213
283
|
|
|
214
|
-
|
|
284
|
+
try {
|
|
285
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
286
|
+
var child = _step2.value;
|
|
287
|
+
var result = callback(child, level);
|
|
215
288
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Node.prototype.moveNode = function (movedNode, targetNode, position) {
|
|
220
|
-
if (!movedNode.parent || movedNode.isParentOf(targetNode)) {
|
|
221
|
-
// - Node is parent of target node
|
|
222
|
-
// - Or, parent is empty
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
movedNode.parent.doRemoveChild(movedNode);
|
|
227
|
-
switch (position) {
|
|
228
|
-
case Position.After: {
|
|
229
|
-
if (targetNode.parent) {
|
|
230
|
-
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode) + 1);
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
case Position.Before: {
|
|
236
|
-
if (targetNode.parent) {
|
|
237
|
-
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode));
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
case Position.Inside: {
|
|
243
|
-
// move inside as first child
|
|
244
|
-
targetNode.addChildAtPosition(movedNode, 0);
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
default:
|
|
248
|
-
return false;
|
|
289
|
+
if (result && child.hasChildren()) {
|
|
290
|
+
_iterate(child, level + 1);
|
|
291
|
+
}
|
|
249
292
|
}
|
|
293
|
+
} catch (err) {
|
|
294
|
+
_iterator2.e(err);
|
|
295
|
+
} finally {
|
|
296
|
+
_iterator2.f();
|
|
297
|
+
}
|
|
250
298
|
}
|
|
251
|
-
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
_iterate(this, 0);
|
|
302
|
+
}
|
|
252
303
|
/*
|
|
253
|
-
|
|
304
|
+
Move node relative to another node.
|
|
305
|
+
Argument position: Position.BEFORE, Position.AFTER or Position.Inside
|
|
306
|
+
// move node1 after node2
|
|
307
|
+
tree.moveNode(node1, node2, Position.AFTER);
|
|
254
308
|
*/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
Object.prototype.hasOwnProperty.call(node, k)) {
|
|
272
|
-
var v = node[k];
|
|
273
|
-
tmpNode[k] = v;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (node.hasChildren()) {
|
|
277
|
-
tmpNode["children"] = getDataFromNodes(node.children);
|
|
278
|
-
}
|
|
279
|
-
return tmpNode;
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
if (includeParent) {
|
|
283
|
-
return getDataFromNodes([this]);
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
return getDataFromNodes(this.children);
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
Node.prototype.getNodeByName = function (name) {
|
|
290
|
-
return this.getNodeByCallback(function (node) { return node.name === name; });
|
|
291
|
-
};
|
|
292
|
-
Node.prototype.getNodeByNameMustExist = function (name) {
|
|
293
|
-
var node = this.getNodeByCallback(function (n) { return n.name === name; });
|
|
294
|
-
if (!node) {
|
|
295
|
-
throw "Node with name " + name + " not found";
|
|
296
|
-
}
|
|
297
|
-
return node;
|
|
298
|
-
};
|
|
299
|
-
Node.prototype.getNodeByCallback = function (callback) {
|
|
300
|
-
var result = null;
|
|
301
|
-
this.iterate(function (node) {
|
|
302
|
-
if (result) {
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
|
-
else if (callback(node)) {
|
|
306
|
-
result = node;
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
309
|
+
|
|
310
|
+
}, {
|
|
311
|
+
key: "moveNode",
|
|
312
|
+
value: function moveNode(movedNode, targetNode, position) {
|
|
313
|
+
if (!movedNode.parent || movedNode.isParentOf(targetNode)) {
|
|
314
|
+
// - Node is parent of target node
|
|
315
|
+
// - Or, parent is empty
|
|
316
|
+
return false;
|
|
317
|
+
} else {
|
|
318
|
+
movedNode.parent.doRemoveChild(movedNode);
|
|
319
|
+
|
|
320
|
+
switch (position) {
|
|
321
|
+
case Position.After:
|
|
322
|
+
{
|
|
323
|
+
if (targetNode.parent) {
|
|
324
|
+
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode) + 1);
|
|
310
325
|
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return false;
|
|
311
329
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var childIndex = this.parent.getChildIndex(this);
|
|
322
|
-
this.parent.addChildAtPosition(node, childIndex + 1);
|
|
323
|
-
if (typeof nodeInfo === "object" &&
|
|
324
|
-
nodeInfo["children"] &&
|
|
325
|
-
nodeInfo["children"] instanceof Array &&
|
|
326
|
-
nodeInfo["children"].length) {
|
|
327
|
-
node.loadFromData(nodeInfo["children"]);
|
|
328
|
-
}
|
|
329
|
-
return node;
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
Node.prototype.addBefore = function (nodeInfo) {
|
|
333
|
-
if (!this.parent) {
|
|
334
|
-
return null;
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
var node = this.createNode(nodeInfo);
|
|
338
|
-
var childIndex = this.parent.getChildIndex(this);
|
|
339
|
-
this.parent.addChildAtPosition(node, childIndex);
|
|
340
|
-
if (typeof nodeInfo === "object" &&
|
|
341
|
-
nodeInfo["children"] &&
|
|
342
|
-
nodeInfo["children"] instanceof Array &&
|
|
343
|
-
nodeInfo["children"].length) {
|
|
344
|
-
node.loadFromData(nodeInfo["children"]);
|
|
345
|
-
}
|
|
346
|
-
return node;
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
Node.prototype.addParent = function (nodeInfo) {
|
|
350
|
-
if (!this.parent) {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
var newParent = this.createNode(nodeInfo);
|
|
355
|
-
if (this.tree) {
|
|
356
|
-
newParent.setParent(this.tree);
|
|
330
|
+
|
|
331
|
+
case Position.Before:
|
|
332
|
+
{
|
|
333
|
+
if (targetNode.parent) {
|
|
334
|
+
targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode));
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return false;
|
|
357
339
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
340
|
+
|
|
341
|
+
case Position.Inside:
|
|
342
|
+
{
|
|
343
|
+
// move inside as first child
|
|
344
|
+
targetNode.addChildAtPosition(movedNode, 0);
|
|
345
|
+
return true;
|
|
362
346
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
Node.prototype.remove = function () {
|
|
369
|
-
if (this.parent) {
|
|
370
|
-
this.parent.removeChild(this);
|
|
371
|
-
this.parent = null;
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
Node.prototype.append = function (nodeInfo) {
|
|
375
|
-
var node = this.createNode(nodeInfo);
|
|
376
|
-
this.addChild(node);
|
|
377
|
-
if (typeof nodeInfo === "object" &&
|
|
378
|
-
nodeInfo["children"] &&
|
|
379
|
-
nodeInfo["children"] instanceof Array &&
|
|
380
|
-
nodeInfo["children"].length) {
|
|
381
|
-
node.loadFromData(nodeInfo["children"]);
|
|
382
|
-
}
|
|
383
|
-
return node;
|
|
384
|
-
};
|
|
385
|
-
Node.prototype.prepend = function (nodeInfo) {
|
|
386
|
-
var node = this.createNode(nodeInfo);
|
|
387
|
-
this.addChildAtPosition(node, 0);
|
|
388
|
-
if (typeof nodeInfo === "object" &&
|
|
389
|
-
nodeInfo["children"] &&
|
|
390
|
-
nodeInfo["children"] instanceof Array &&
|
|
391
|
-
nodeInfo["children"].length) {
|
|
392
|
-
node.loadFromData(nodeInfo["children"]);
|
|
347
|
+
|
|
348
|
+
default:
|
|
349
|
+
return false;
|
|
393
350
|
}
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/*
|
|
354
|
+
Get the tree as data.
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
}, {
|
|
358
|
+
key: "getData",
|
|
359
|
+
value: function getData() {
|
|
360
|
+
var includeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
361
|
+
|
|
362
|
+
var getDataFromNodes = function getDataFromNodes(nodes) {
|
|
363
|
+
return nodes.map(function (node) {
|
|
364
|
+
var tmpNode = {};
|
|
365
|
+
|
|
366
|
+
for (var k in node) {
|
|
367
|
+
if (["parent", "children", "element", "idMapping", "load_on_demand", "nodeClass", "tree", "isEmptyFolder"].indexOf(k) === -1 && Object.prototype.hasOwnProperty.call(node, k)) {
|
|
368
|
+
var v = node[k];
|
|
369
|
+
tmpNode[k] = v;
|
|
401
370
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
while (node.parent) {
|
|
410
|
-
level += 1;
|
|
411
|
-
node = node.parent;
|
|
412
|
-
}
|
|
413
|
-
return level;
|
|
414
|
-
};
|
|
415
|
-
Node.prototype.getNodeById = function (nodeId) {
|
|
416
|
-
return this.idMapping.get(nodeId) || null;
|
|
417
|
-
};
|
|
418
|
-
Node.prototype.addNodeToIndex = function (node) {
|
|
419
|
-
if (node.id != null) {
|
|
420
|
-
this.idMapping.set(node.id, node);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
Node.prototype.removeNodeFromIndex = function (node) {
|
|
424
|
-
if (node.id != null) {
|
|
425
|
-
this.idMapping["delete"](node.id);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
Node.prototype.removeChildren = function () {
|
|
429
|
-
var _this = this;
|
|
430
|
-
this.iterate(function (child) {
|
|
431
|
-
var _a;
|
|
432
|
-
(_a = _this.tree) === null || _a === void 0 ? void 0 : _a.removeNodeFromIndex(child);
|
|
433
|
-
return true;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (node.hasChildren()) {
|
|
374
|
+
tmpNode["children"] = getDataFromNodes(node.children);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return tmpNode;
|
|
434
378
|
});
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
if (includeParent) {
|
|
382
|
+
return getDataFromNodes([this]);
|
|
383
|
+
} else {
|
|
384
|
+
return getDataFromNodes(this.children);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}, {
|
|
388
|
+
key: "getNodeByName",
|
|
389
|
+
value: function getNodeByName(name) {
|
|
390
|
+
return this.getNodeByCallback(function (node) {
|
|
391
|
+
return node.name === name;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}, {
|
|
395
|
+
key: "getNodeByNameMustExist",
|
|
396
|
+
value: function getNodeByNameMustExist(name) {
|
|
397
|
+
var node = this.getNodeByCallback(function (n) {
|
|
398
|
+
return n.name === name;
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
if (!node) {
|
|
402
|
+
throw "Node with name ".concat(name, " not found");
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return node;
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: "getNodeByCallback",
|
|
409
|
+
value: function getNodeByCallback(callback) {
|
|
410
|
+
var result = null;
|
|
411
|
+
this.iterate(function (node) {
|
|
412
|
+
if (result) {
|
|
413
|
+
return false;
|
|
414
|
+
} else if (callback(node)) {
|
|
415
|
+
result = node;
|
|
416
|
+
return false;
|
|
417
|
+
} else {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "addAfter",
|
|
425
|
+
value: function addAfter(nodeInfo) {
|
|
426
|
+
if (!this.parent) {
|
|
427
|
+
return null;
|
|
428
|
+
} else {
|
|
429
|
+
var _node2 = this.createNode(nodeInfo);
|
|
430
|
+
|
|
431
|
+
var childIndex = this.parent.getChildIndex(this);
|
|
432
|
+
this.parent.addChildAtPosition(_node2, childIndex + 1);
|
|
433
|
+
|
|
434
|
+
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
435
|
+
_node2.loadFromData(nodeInfo.children);
|
|
440
436
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
437
|
+
|
|
438
|
+
return _node2;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "addBefore",
|
|
443
|
+
value: function addBefore(nodeInfo) {
|
|
444
|
+
if (!this.parent) {
|
|
445
|
+
return null;
|
|
446
|
+
} else {
|
|
447
|
+
var _node3 = this.createNode(nodeInfo);
|
|
448
|
+
|
|
449
|
+
var childIndex = this.parent.getChildIndex(this);
|
|
450
|
+
this.parent.addChildAtPosition(_node3, childIndex);
|
|
451
|
+
|
|
452
|
+
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
453
|
+
_node3.loadFromData(nodeInfo.children);
|
|
449
454
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
455
|
+
|
|
456
|
+
return _node3;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "addParent",
|
|
461
|
+
value: function addParent(nodeInfo) {
|
|
462
|
+
if (!this.parent) {
|
|
463
|
+
return null;
|
|
464
|
+
} else {
|
|
465
|
+
var newParent = this.createNode(nodeInfo);
|
|
466
|
+
|
|
467
|
+
if (this.tree) {
|
|
468
|
+
newParent.setParent(this.tree);
|
|
454
469
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
470
|
+
|
|
471
|
+
var originalParent = this.parent;
|
|
472
|
+
|
|
473
|
+
var _iterator3 = _createForOfIteratorHelper(originalParent.children),
|
|
474
|
+
_step3;
|
|
475
|
+
|
|
476
|
+
try {
|
|
477
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
478
|
+
var child = _step3.value;
|
|
479
|
+
newParent.addChild(child);
|
|
480
|
+
}
|
|
481
|
+
} catch (err) {
|
|
482
|
+
_iterator3.e(err);
|
|
483
|
+
} finally {
|
|
484
|
+
_iterator3.f();
|
|
463
485
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
486
|
+
|
|
487
|
+
originalParent.children = [];
|
|
488
|
+
originalParent.addChild(newParent);
|
|
489
|
+
return newParent;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}, {
|
|
493
|
+
key: "remove",
|
|
494
|
+
value: function remove() {
|
|
495
|
+
if (this.parent) {
|
|
496
|
+
this.parent.removeChild(this);
|
|
497
|
+
this.parent = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}, {
|
|
501
|
+
key: "append",
|
|
502
|
+
value: function append(nodeInfo) {
|
|
503
|
+
var node = this.createNode(nodeInfo);
|
|
504
|
+
this.addChild(node);
|
|
505
|
+
|
|
506
|
+
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
507
|
+
node.loadFromData(nodeInfo.children);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return node;
|
|
511
|
+
}
|
|
512
|
+
}, {
|
|
513
|
+
key: "prepend",
|
|
514
|
+
value: function prepend(nodeInfo) {
|
|
515
|
+
var node = this.createNode(nodeInfo);
|
|
516
|
+
this.addChildAtPosition(node, 0);
|
|
517
|
+
|
|
518
|
+
if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
|
|
519
|
+
node.loadFromData(nodeInfo.children);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return node;
|
|
523
|
+
}
|
|
524
|
+
}, {
|
|
525
|
+
key: "isParentOf",
|
|
526
|
+
value: function isParentOf(node) {
|
|
527
|
+
var parent = node.parent;
|
|
528
|
+
|
|
529
|
+
while (parent) {
|
|
530
|
+
if (parent === this) {
|
|
531
|
+
return true;
|
|
483
532
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
533
|
+
|
|
534
|
+
parent = parent.parent;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}, {
|
|
540
|
+
key: "getLevel",
|
|
541
|
+
value: function getLevel() {
|
|
542
|
+
var level = 0;
|
|
543
|
+
var node = this; // eslint-disable-line @typescript-eslint/no-this-alias
|
|
544
|
+
|
|
545
|
+
while (node.parent) {
|
|
546
|
+
level += 1;
|
|
547
|
+
node = node.parent;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return level;
|
|
551
|
+
}
|
|
552
|
+
}, {
|
|
553
|
+
key: "getNodeById",
|
|
554
|
+
value: function getNodeById(nodeId) {
|
|
555
|
+
return this.idMapping.get(nodeId) || null;
|
|
556
|
+
}
|
|
557
|
+
}, {
|
|
558
|
+
key: "addNodeToIndex",
|
|
559
|
+
value: function addNodeToIndex(node) {
|
|
560
|
+
if (node.id != null) {
|
|
561
|
+
this.idMapping.set(node.id, node);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}, {
|
|
565
|
+
key: "removeNodeFromIndex",
|
|
566
|
+
value: function removeNodeFromIndex(node) {
|
|
567
|
+
if (node.id != null) {
|
|
568
|
+
this.idMapping["delete"](node.id);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}, {
|
|
572
|
+
key: "removeChildren",
|
|
573
|
+
value: function removeChildren() {
|
|
574
|
+
var _this = this;
|
|
575
|
+
|
|
576
|
+
this.iterate(function (child) {
|
|
577
|
+
var _this$tree;
|
|
578
|
+
|
|
579
|
+
(_this$tree = _this.tree) === null || _this$tree === void 0 ? void 0 : _this$tree.removeNodeFromIndex(child);
|
|
580
|
+
return true;
|
|
581
|
+
});
|
|
582
|
+
this.children = [];
|
|
583
|
+
}
|
|
584
|
+
}, {
|
|
585
|
+
key: "getPreviousSibling",
|
|
586
|
+
value: function getPreviousSibling() {
|
|
587
|
+
if (!this.parent) {
|
|
588
|
+
return null;
|
|
589
|
+
} else {
|
|
590
|
+
var previousIndex = this.parent.getChildIndex(this) - 1;
|
|
591
|
+
|
|
592
|
+
if (previousIndex >= 0) {
|
|
593
|
+
return this.parent.children[previousIndex];
|
|
594
|
+
} else {
|
|
595
|
+
return null;
|
|
499
596
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}, {
|
|
600
|
+
key: "getNextSibling",
|
|
601
|
+
value: function getNextSibling() {
|
|
602
|
+
if (!this.parent) {
|
|
603
|
+
return null;
|
|
604
|
+
} else {
|
|
605
|
+
var nextIndex = this.parent.getChildIndex(this) + 1;
|
|
606
|
+
|
|
607
|
+
if (nextIndex < this.parent.children.length) {
|
|
608
|
+
return this.parent.children[nextIndex];
|
|
609
|
+
} else {
|
|
610
|
+
return null;
|
|
504
611
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}, {
|
|
615
|
+
key: "getNodesByProperty",
|
|
616
|
+
value: function getNodesByProperty(key, value) {
|
|
617
|
+
return this.filter(function (node) {
|
|
618
|
+
return node[key] === value;
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}, {
|
|
622
|
+
key: "filter",
|
|
623
|
+
value: function filter(f) {
|
|
624
|
+
var result = [];
|
|
625
|
+
this.iterate(function (node) {
|
|
626
|
+
if (f(node)) {
|
|
627
|
+
result.push(node);
|
|
521
628
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
629
|
+
|
|
630
|
+
return true;
|
|
631
|
+
});
|
|
632
|
+
return result;
|
|
633
|
+
}
|
|
634
|
+
}, {
|
|
635
|
+
key: "getNextNode",
|
|
636
|
+
value: function getNextNode() {
|
|
637
|
+
var includeChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
638
|
+
|
|
639
|
+
if (includeChildren && this.hasChildren() && this.is_open) {
|
|
640
|
+
// First child
|
|
641
|
+
return this.children[0];
|
|
642
|
+
} else {
|
|
525
643
|
if (!this.parent) {
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
644
|
+
return null;
|
|
645
|
+
} else {
|
|
646
|
+
var nextSibling = this.getNextSibling();
|
|
647
|
+
|
|
648
|
+
if (nextSibling) {
|
|
649
|
+
// Next sibling
|
|
650
|
+
return nextSibling;
|
|
651
|
+
} else {
|
|
652
|
+
// Next node of parent
|
|
653
|
+
return this.parent.getNextNode(false);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}, {
|
|
659
|
+
key: "getPreviousNode",
|
|
660
|
+
value: function getPreviousNode() {
|
|
661
|
+
if (!this.parent) {
|
|
662
|
+
return null;
|
|
663
|
+
} else {
|
|
664
|
+
var previousSibling = this.getPreviousSibling();
|
|
665
|
+
|
|
666
|
+
if (previousSibling) {
|
|
667
|
+
if (!previousSibling.hasChildren() || !previousSibling.is_open) {
|
|
668
|
+
// Previous sibling
|
|
669
|
+
return previousSibling;
|
|
670
|
+
} else {
|
|
671
|
+
// Last child of previous sibling
|
|
672
|
+
return previousSibling.getLastChild();
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
return this.getParent();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
key: "getParent",
|
|
681
|
+
value: function getParent() {
|
|
682
|
+
// Return parent except if it is the root node
|
|
683
|
+
if (!this.parent) {
|
|
684
|
+
return null;
|
|
685
|
+
} else if (!this.parent.parent) {
|
|
686
|
+
// Root node -> null
|
|
687
|
+
return null;
|
|
688
|
+
} else {
|
|
689
|
+
return this.parent;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}, {
|
|
693
|
+
key: "getLastChild",
|
|
694
|
+
value: function getLastChild() {
|
|
695
|
+
if (!this.hasChildren()) {
|
|
696
|
+
return null;
|
|
697
|
+
} else {
|
|
698
|
+
var lastChild = this.children[this.children.length - 1];
|
|
699
|
+
|
|
700
|
+
if (!(lastChild.hasChildren() && lastChild.is_open)) {
|
|
701
|
+
return lastChild;
|
|
702
|
+
} else {
|
|
703
|
+
return lastChild.getLastChild();
|
|
539
704
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
705
|
+
}
|
|
706
|
+
} // Init Node from data without making it the root of the tree
|
|
707
|
+
|
|
708
|
+
}, {
|
|
709
|
+
key: "initFromData",
|
|
710
|
+
value: function initFromData(data) {
|
|
711
|
+
var _this2 = this;
|
|
712
|
+
|
|
713
|
+
var addNode = function addNode(nodeData) {
|
|
714
|
+
_this2.setData(nodeData);
|
|
715
|
+
|
|
716
|
+
if (isNodeRecordWithChildren(nodeData) && nodeData.children.length) {
|
|
717
|
+
addChildren(nodeData.children);
|
|
548
718
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
var
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
var addChildren = function addChildren(childrenData) {
|
|
722
|
+
var _iterator4 = _createForOfIteratorHelper(childrenData),
|
|
723
|
+
_step4;
|
|
724
|
+
|
|
725
|
+
try {
|
|
726
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
727
|
+
var child = _step4.value;
|
|
728
|
+
|
|
729
|
+
var _node4 = _this2.createNode();
|
|
730
|
+
|
|
731
|
+
_node4.initFromData(child);
|
|
732
|
+
|
|
733
|
+
_this2.addChild(_node4);
|
|
734
|
+
}
|
|
735
|
+
} catch (err) {
|
|
736
|
+
_iterator4.e(err);
|
|
737
|
+
} finally {
|
|
738
|
+
_iterator4.f();
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
addNode(data);
|
|
743
|
+
}
|
|
744
|
+
}, {
|
|
745
|
+
key: "setParent",
|
|
746
|
+
value: function setParent(parent) {
|
|
747
|
+
var _this$tree2;
|
|
748
|
+
|
|
749
|
+
this.parent = parent;
|
|
750
|
+
this.tree = parent.tree;
|
|
751
|
+
(_this$tree2 = this.tree) === null || _this$tree2 === void 0 ? void 0 : _this$tree2.addNodeToIndex(this);
|
|
752
|
+
}
|
|
753
|
+
}, {
|
|
754
|
+
key: "doRemoveChild",
|
|
755
|
+
value: function doRemoveChild(node) {
|
|
756
|
+
var _this$tree3;
|
|
757
|
+
|
|
758
|
+
this.children.splice(this.getChildIndex(node), 1);
|
|
759
|
+
(_this$tree3 = this.tree) === null || _this$tree3 === void 0 ? void 0 : _this$tree3.removeNodeFromIndex(node);
|
|
760
|
+
}
|
|
761
|
+
}, {
|
|
762
|
+
key: "getNodeClass",
|
|
763
|
+
value: function getNodeClass() {
|
|
764
|
+
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;
|
|
767
|
+
}
|
|
768
|
+
}, {
|
|
769
|
+
key: "createNode",
|
|
770
|
+
value: function createNode(nodeData) {
|
|
771
|
+
var nodeClass = this.getNodeClass();
|
|
772
|
+
return new nodeClass(nodeData);
|
|
773
|
+
}
|
|
774
|
+
}]);
|
|
775
|
+
|
|
776
|
+
return Node;
|
|
777
|
+
}();
|
|
778
|
+
|
|
779
|
+
exports.Node = Node;
|