jqtree 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/.eslintrc +3 -12
  2. package/.github/workflows/ci.yml +57 -30
  3. package/.github/workflows/codeql-analysis.yml +9 -5
  4. package/.prettier +3 -0
  5. package/.tool-versions +1 -0
  6. package/README.md +12 -9
  7. package/bower.json +10 -3
  8. package/{.postcssrc → config/.postcssrc} +0 -0
  9. package/{babel.config.json → config/babel.config.json} +0 -0
  10. package/{babel.coverage.config.json → config/babel.coverage.config.json} +0 -0
  11. package/{jest-jsdom.config.js → config/jest.config.js} +8 -3
  12. package/config/playwright.config.js +18 -0
  13. package/config/production +4 -0
  14. package/{rollup.config.js → config/rollup.config.mjs} +3 -8
  15. package/{jqtree.postcss → css/jqtree.postcss} +0 -0
  16. package/devserver/index.html +1 -9
  17. package/docs/Gemfile +2 -0
  18. package/docs/Gemfile.lock +263 -0
  19. package/{_config.yml → docs/_config.yml} +8 -1
  20. package/{_entries → docs/_entries}/01_general.md +0 -0
  21. package/{_entries → docs/_entries}/02_introduction.md +0 -0
  22. package/{_entries → docs/_entries}/03_features.md +1 -1
  23. package/{_entries → docs/_entries}/04_demo.html +1 -7
  24. package/{_entries → docs/_entries}/05_requirements.md +0 -0
  25. package/{_entries → docs/_entries}/06_downloads.md +0 -0
  26. package/{_entries → docs/_entries}/07_tutorial.md +0 -0
  27. package/{_entries → docs/_entries}/08_examples.md +0 -0
  28. package/{_entries → docs/_entries}/09_usecases.md +0 -0
  29. package/{_entries → docs/_entries}/10_changelog.md +13 -0
  30. package/{_entries → docs/_entries}/11_options.md +0 -0
  31. package/{_entries → docs/_entries}/12_animationspeed.md +0 -0
  32. package/{_entries → docs/_entries}/13_autoescape.md +0 -0
  33. package/{_entries → docs/_entries}/14_autoopen.md +0 -0
  34. package/{_entries → docs/_entries}/15_buttonleft.md +0 -0
  35. package/{_entries → docs/_entries}/16_closedicon.md +0 -0
  36. package/{_entries → docs/_entries}/17_data.md +0 -0
  37. package/{_entries → docs/_entries}/18_datafilter.md +0 -0
  38. package/{_entries → docs/_entries}/19_data-url.md +0 -0
  39. package/{_entries → docs/_entries}/20_draganddrop.md +0 -0
  40. package/{_entries → docs/_entries}/21_keyboardsupport.md +0 -0
  41. package/{_entries → docs/_entries}/22_oncanmove.md +0 -0
  42. package/{_entries → docs/_entries}/23_oncanmoveto.md +2 -2
  43. package/{_entries → docs/_entries}/24_oncanselectnode.md +0 -0
  44. package/{_entries → docs/_entries}/25_oncreateli.md +2 -2
  45. package/{_entries → docs/_entries}/26_ondragmove.md +0 -0
  46. package/{_entries → docs/_entries}/27_ondragstop.md +0 -0
  47. package/{_entries → docs/_entries}/28_onismovehandle.md +0 -0
  48. package/{_entries → docs/_entries}/29_onloadfailed.md +0 -0
  49. package/{_entries → docs/_entries}/30_onloading.md +2 -2
  50. package/{_entries → docs/_entries}/31_openedicon.md +0 -0
  51. package/{_entries → docs/_entries}/32_openfolderdelay.md +2 -0
  52. package/{_entries → docs/_entries}/33_rtl.md +0 -0
  53. package/{_entries → docs/_entries}/34_savestate.md +0 -0
  54. package/{_entries → docs/_entries}/35_selectable.md +0 -0
  55. package/{_entries → docs/_entries}/36_showemptyfolder.md +0 -0
  56. package/{_entries → docs/_entries}/37_slide.md +0 -0
  57. package/{_entries → docs/_entries}/38_start_dnd_delay.md +0 -0
  58. package/{_entries → docs/_entries}/39_tabindex.md +0 -0
  59. package/{_entries → docs/_entries}/40_usecontextmenu.md +0 -0
  60. package/{_entries → docs/_entries}/41_functions.md +0 -0
  61. package/{_entries → docs/_entries}/42_addparentnode.md +1 -1
  62. package/{_entries → docs/_entries}/43_addnodeafter.md +1 -1
  63. package/{_entries → docs/_entries}/44_addnodebefore.md +1 -1
  64. package/{_entries → docs/_entries}/45_appendnode.md +5 -5
  65. package/{_entries → docs/_entries}/46_closenode.md +0 -0
  66. package/{_entries → docs/_entries}/47_destroy.md +0 -0
  67. package/{_entries → docs/_entries}/48_getnodebycallback.md +0 -0
  68. package/{_entries → docs/_entries}/49_getnodebyid.md +0 -0
  69. package/{_entries → docs/_entries}/50_getnodebyhtmlelement.md +2 -2
  70. package/{_entries → docs/_entries}/51_getselectednode.md +0 -0
  71. package/{_entries → docs/_entries}/52_getstate.md +0 -0
  72. package/{_entries → docs/_entries}/53_gettree.md +1 -1
  73. package/{_entries → docs/_entries}/54_isdragging.md +1 -1
  74. package/{_entries → docs/_entries}/55_loaddata.md +3 -3
  75. package/{_entries → docs/_entries}/56_loaddatafromurl.md +4 -4
  76. package/{_entries → docs/_entries}/57_movedown.md +0 -0
  77. package/{_entries → docs/_entries}/58_movenode.md +3 -3
  78. package/{_entries → docs/_entries}/59_moveup.md +0 -0
  79. package/{_entries → docs/_entries}/60_opennode.md +3 -3
  80. package/docs/_entries/61_prependnode.md +21 -0
  81. package/{_entries → docs/_entries}/62_refresh.md +0 -0
  82. package/{_entries → docs/_entries}/63_reload.md +2 -2
  83. package/{_entries → docs/_entries}/64_removenode.md +0 -0
  84. package/{_entries → docs/_entries}/65_selectnode.md +0 -0
  85. package/{_entries → docs/_entries}/66_scrolltonode.md +0 -0
  86. package/{_entries → docs/_entries}/67_setoption.md +0 -0
  87. package/{_entries → docs/_entries}/68_setstate.md +0 -0
  88. package/{_entries → docs/_entries}/69_toggle.md +0 -0
  89. package/{_entries → docs/_entries}/70_tojson.md +0 -0
  90. package/{_entries → docs/_entries}/71_updatenode.md +1 -1
  91. package/{_entries → docs/_entries}/72_events.md +0 -0
  92. package/{_entries → docs/_entries}/73_tree-click.md +0 -0
  93. package/{_entries → docs/_entries}/74_tree-close.md +0 -0
  94. package/{_entries → docs/_entries}/75_tree-contextmenu.md +0 -0
  95. package/{_entries → docs/_entries}/76_tree-dblclick.md +0 -0
  96. package/{_entries → docs/_entries}/77_tree-init.md +0 -0
  97. package/{_entries → docs/_entries}/78_tree-load-data.md +0 -0
  98. package/{_entries → docs/_entries}/79_tree-loading-data.md +0 -0
  99. package/{_entries → docs/_entries}/80_tree-move.md +0 -0
  100. package/{_entries → docs/_entries}/81_tree-refresh.md +0 -0
  101. package/{_entries → docs/_entries}/82_tree-open.md +0 -0
  102. package/{_entries → docs/_entries}/83_tree-select.md +0 -0
  103. package/{_entries → docs/_entries}/84_multiple-selection.md +0 -0
  104. package/{_entries → docs/_entries}/85_add-to-selection.md +0 -0
  105. package/{_entries → docs/_entries}/86_get-selected-nodes.md +0 -0
  106. package/{_entries → docs/_entries}/87_is-node-selected.md +1 -1
  107. package/{_entries → docs/_entries}/88_remove-from-selection.md +0 -0
  108. package/{_entries → docs/_entries}/89_node-functions.md +0 -0
  109. package/{_entries → docs/_entries}/90_children.md +0 -0
  110. package/{_entries → docs/_entries}/91_getdata.md +2 -2
  111. package/{_entries → docs/_entries}/92_getlevel.md +0 -0
  112. package/docs/_entries/93_getnextnode.md +15 -0
  113. package/{_entries → docs/_entries}/94_getnextsibling.md +0 -0
  114. package/{_entries/95_getpreviousnode.md → docs/_entries/95_getnextvisiblenode.md} +1 -1
  115. package/docs/_entries/96_getpreviousnode.md +0 -0
  116. package/{_entries/96_getprevioussibling.md → docs/_entries/97_getprevioussibling.md} +0 -0
  117. package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
  118. package/{_entries/97_parent.md → docs/_entries/99_parent.md} +1 -1
  119. package/{_entries → docs/_entries}/insert.py +0 -0
  120. package/{_entries → docs/_entries}/renumber.py +0 -0
  121. package/{_examples → docs/_examples}/01_load_json_data.html +3 -5
  122. package/{_examples → docs/_examples}/02_load_json_data_from_server.html +3 -5
  123. package/{_examples → docs/_examples}/03_drag_and_drop.html +3 -5
  124. package/{_examples → docs/_examples}/04_save_state.html +3 -5
  125. package/{_examples → docs/_examples}/05_load_on_demand.html +3 -5
  126. package/{_examples → docs/_examples}/06_autoescape.html +3 -5
  127. package/{_examples → docs/_examples}/07_autoscroll.html +3 -5
  128. package/{_examples → docs/_examples}/08_multiple_select.html +3 -5
  129. package/{_examples → docs/_examples}/09_custom_html.html +3 -5
  130. package/{_examples → docs/_examples}/10_icon_buttons.html +3 -5
  131. package/{_examples → docs/_examples}/11_right-to-left.html +3 -5
  132. package/{_examples → docs/_examples}/12_button_on_right.html +3 -5
  133. package/docs/_examples/13_drag_outside.html +48 -0
  134. package/{_examples → docs/_examples}/14_filter.html +7 -9
  135. package/docs/_layouts/example.html +7 -0
  136. package/{_layouts/base.html → docs/_layouts/page.html} +4 -11
  137. package/docs/documentation.css +3 -0
  138. package/docs/index.html +65 -0
  139. package/docs/jqtree.css +189 -0
  140. package/docs/package.json +22 -0
  141. package/docs/pnpm-lock.yaml +798 -0
  142. package/docs/postcss.config.js +7 -0
  143. package/{static → docs/static}/bower.json +1 -2
  144. package/{static → docs/static}/bower_components/fontawesome/css/all.min.css +0 -0
  145. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
  146. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -0
  147. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  148. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
  149. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  150. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
  151. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -0
  152. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  153. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
  154. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  155. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
  156. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -0
  157. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  158. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
  159. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  160. package/{static → docs/static}/bower_components/jquery/dist/jquery.js +209 -97
  161. package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -0
  162. package/{static → docs/static}/bower_components/jquery-mockjax/dist/jquery.mockjax.js +0 -0
  163. package/docs/static/documentation.css +1453 -0
  164. package/docs/static/documentation.js +26 -0
  165. package/{static → docs/static}/example.css +5 -38
  166. package/{static → docs/static}/example.postcss +5 -35
  167. package/{static → docs/static}/example_data.js +0 -0
  168. package/{static → docs/static}/examples/autoescape.js +0 -0
  169. package/{static → docs/static}/examples/autoscroll.js +0 -0
  170. package/{static → docs/static}/examples/button-on-right.js +0 -0
  171. package/{static → docs/static}/examples/custom_html.js +5 -9
  172. package/{static → docs/static}/examples/drag-outside.js +0 -0
  173. package/{static → docs/static}/examples/drag_and_drop.js +0 -0
  174. package/{static → docs/static}/examples/filter.js +2 -2
  175. package/{static → docs/static}/examples/icon_buttons.js +0 -0
  176. package/{static → docs/static}/examples/load_json_data.js +0 -0
  177. package/{static → docs/static}/examples/load_json_data_from_server.js +0 -0
  178. package/{static → docs/static}/examples/load_on_demand.js +0 -0
  179. package/{static → docs/static}/examples/multiple_select.js +0 -0
  180. package/{static → docs/static}/examples/right-to-left.js +0 -0
  181. package/{static → docs/static}/examples/save_state.js +0 -0
  182. package/{static → docs/static}/monokai.css +0 -0
  183. package/{static → docs/static}/spinner.gif +0 -0
  184. package/docs/tailwind.config.js +16 -0
  185. package/docs/tree.jquery.js +21 -0
  186. package/lib/dataLoader.js +5 -31
  187. package/lib/dragAndDropHandler.js +26 -135
  188. package/lib/elementsRenderer.js +29 -59
  189. package/lib/keyHandler.js +8 -32
  190. package/lib/mouse.widget.js +16 -77
  191. package/lib/node.js +60 -125
  192. package/lib/nodeElement.js +8 -75
  193. package/lib/playwright/coverage.js +101 -0
  194. package/lib/playwright/playwright.test.js +212 -182
  195. package/lib/playwright/testUtils.js +201 -0
  196. package/lib/saveStateHandler.js +12 -61
  197. package/lib/scrollHandler.js +17 -74
  198. package/lib/selectNodeHandler.js +5 -24
  199. package/lib/simple.widget.js +18 -53
  200. package/lib/test/jqTree/create.test.js +0 -4
  201. package/lib/test/jqTree/events.test.js +10 -16
  202. package/lib/test/jqTree/keyboard.test.js +0 -6
  203. package/lib/test/jqTree/loadOnDemand.test.js +107 -139
  204. package/lib/test/jqTree/methods.test.js +136 -159
  205. package/lib/test/jqTree/options.test.js +53 -63
  206. package/lib/test/node.test.js +127 -72
  207. package/lib/test/nodeUtil.test.js +0 -1
  208. package/lib/test/support/jqTreeMatchers.js +4 -9
  209. package/lib/test/support/setupTests.js +0 -4
  210. package/lib/test/support/testUtil.js +2 -11
  211. package/lib/test/support/treeStructure.js +0 -6
  212. package/lib/test/util.test.js +0 -1
  213. package/lib/tree.jquery.js +32 -243
  214. package/lib/util.js +0 -6
  215. package/lib/version.js +1 -1
  216. package/package.json +54 -54
  217. package/src/dragAndDropHandler.ts +8 -4
  218. package/src/jqtreeOptions.ts +1 -1
  219. package/src/keyHandler.ts +3 -3
  220. package/src/node.ts +43 -12
  221. package/src/playwright/.eslintrc +2 -2
  222. package/src/playwright/coverage.ts +41 -0
  223. package/src/playwright/playwright.test.ts +50 -52
  224. package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-darwin.png +0 -0
  225. package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-linux.png +0 -0
  226. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-darwin.png +0 -0
  227. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-linux.png +0 -0
  228. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-darwin.png +0 -0
  229. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-linux.png +0 -0
  230. package/src/playwright/testUtils.ts +122 -0
  231. package/src/test/.eslintrc +15 -3
  232. package/src/test/jqTree/events.test.ts +10 -9
  233. package/src/test/jqTree/loadOnDemand.test.ts +10 -10
  234. package/src/test/jqTree/methods.test.ts +37 -45
  235. package/src/test/jqTree/options.test.ts +26 -28
  236. package/src/test/node.test.ts +146 -54
  237. package/src/tree.jquery.d.ts +1 -1
  238. package/src/tree.jquery.ts +6 -5
  239. package/src/version.ts +1 -1
  240. package/tree.jquery.debug.js +217 -867
  241. package/tree.jquery.debug.js.map +1 -1
  242. package/tree.jquery.js +3 -3
  243. package/tree.jquery.js.map +1 -1
  244. package/_entries/61_prependnode.md +0 -21
  245. package/_entries/93_getnextnode.md +0 -12
  246. package/_examples/13_drag_outside.html +0 -26
  247. package/_layouts/frontpage.html +0 -20
  248. package/_layouts/page.html +0 -7
  249. package/index.html +0 -48
  250. package/jest-browser.config.js +0 -15
  251. package/jest-playwright.config.js +0 -21
  252. package/jest.config.js +0 -8
  253. package/lib/playwright/testUtil.js +0 -459
  254. package/lib/playwright/visualRegression.js +0 -193
  255. package/production +0 -5
  256. package/src/playwright/screenshots/displays_a_tree_Desktop.png +0 -0
  257. package/src/playwright/screenshots/displays_a_tree_iPhone 6.png +0 -0
  258. package/src/playwright/screenshots/moves_a_node_Desktop.png +0 -0
  259. package/src/playwright/screenshots/moves_a_node_iPhone 6.png +0 -0
  260. package/src/playwright/screenshots/opens_a_node_Desktop.png +0 -0
  261. package/src/playwright/screenshots/opens_a_node_iPhone 6.png +0 -0
  262. package/src/playwright/screenshots/selects_a_node_Desktop.png +0 -0
  263. package/src/playwright/screenshots/selects_a_node_iPhone 6.png +0 -0
  264. package/src/playwright/testUtil.ts +0 -170
  265. package/src/playwright/visualRegression.ts +0 -88
  266. package/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +0 -6
  267. package/static/bower_components/bootstrap/dist/css/bootstrap.min.css +0 -6
  268. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  269. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +0 -288
  270. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  271. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  272. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
  273. package/static/bower_components/bootstrap/dist/js/bootstrap.min.js +0 -6
  274. package/static/bower_components/jquery/dist/jquery.min.js +0 -2
  275. package/static/documentation.css +0 -171
  276. package/static/documentation.js +0 -48
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 _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
-
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
17
  var Position;
25
18
  exports.Position = Position;
26
-
27
19
  (function (Position) {
28
20
  Position[Position["Before"] = 1] = "Before";
29
21
  Position[Position["After"] = 2] = "After";
30
22
  Position[Position["Inside"] = 3] = "Inside";
31
23
  Position[Position["None"] = 4] = "None";
32
24
  })(Position || (exports.Position = Position = {}));
33
-
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
- _step;
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
- _step2;
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
- _step3;
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,7 +512,6 @@ 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
516
  return this.parent.children[previousIndex];
594
517
  } else {
@@ -603,7 +526,6 @@ 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
530
  return this.parent.children[nextIndex];
609
531
  } else {
@@ -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,8 +556,23 @@ 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
- if (includeChildren && this.hasChildren() && this.is_open) {
559
+ if (includeChildren && this.hasChildren()) {
560
+ return this.children[0];
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
577
  return this.children[0];
642
578
  } else {
@@ -644,7 +580,6 @@ var Node = /*#__PURE__*/function () {
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
- 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
- }
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,33 @@ var Node = /*#__PURE__*/function () {
696
644
  return null;
697
645
  } else {
698
646
  var lastChild = this.children[this.children.length - 1];
699
-
700
647
  if (!(lastChild.hasChildren() && lastChild.is_open)) {
701
648
  return lastChild;
702
649
  } else {
703
650
  return lastChild.getLastChild();
704
651
  }
705
652
  }
706
- } // Init Node from data without making it the root of the tree
653
+ }
707
654
 
655
+ // Init Node from data without making it the root of the tree
708
656
  }, {
709
657
  key: "initFromData",
710
658
  value: function initFromData(data) {
711
659
  var _this2 = this;
712
-
713
660
  var addNode = function addNode(nodeData) {
714
661
  _this2.setData(nodeData);
715
-
716
662
  if (isNodeRecordWithChildren(nodeData) && nodeData.children.length) {
717
663
  addChildren(nodeData.children);
718
664
  }
719
665
  };
720
-
721
666
  var addChildren = function addChildren(childrenData) {
722
667
  var _iterator4 = _createForOfIteratorHelper(childrenData),
723
- _step4;
724
-
668
+ _step4;
725
669
  try {
726
670
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
727
671
  var child = _step4.value;
728
-
729
672
  var _node4 = _this2.createNode();
730
-
731
673
  _node4.initFromData(child);
732
-
733
674
  _this2.addChild(_node4);
734
675
  }
735
676
  } catch (err) {
@@ -738,14 +679,12 @@ var Node = /*#__PURE__*/function () {
738
679
  _iterator4.f();
739
680
  }
740
681
  };
741
-
742
682
  addNode(data);
743
683
  }
744
684
  }, {
745
685
  key: "setParent",
746
686
  value: function setParent(parent) {
747
687
  var _this$tree2;
748
-
749
688
  this.parent = parent;
750
689
  this.tree = parent.tree;
751
690
  (_this$tree2 = this.tree) === null || _this$tree2 === void 0 ? void 0 : _this$tree2.addNodeToIndex(this);
@@ -754,7 +693,6 @@ var Node = /*#__PURE__*/function () {
754
693
  key: "doRemoveChild",
755
694
  value: function doRemoveChild(node) {
756
695
  var _this$tree3;
757
-
758
696
  this.children.splice(this.getChildIndex(node), 1);
759
697
  (_this$tree3 = this.tree) === null || _this$tree3 === void 0 ? void 0 : _this$tree3.removeNodeFromIndex(node);
760
698
  }
@@ -762,7 +700,6 @@ var Node = /*#__PURE__*/function () {
762
700
  key: "getNodeClass",
763
701
  value: function getNodeClass() {
764
702
  var _this$tree4;
765
-
766
703
  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
704
  }
768
705
  }, {
@@ -772,8 +709,6 @@ var Node = /*#__PURE__*/function () {
772
709
  return new nodeClass(nodeData);
773
710
  }
774
711
  }]);
775
-
776
712
  return Node;
777
713
  }();
778
-
779
714
  exports.Node = Node;