jqtree 1.8.9 → 1.8.11

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
- JqTree 1.8.8
2
+ JqTree 1.8.11
3
3
 
4
- Copyright 2024 Marco Braak
4
+ Copyright 2026 Marco Braak
5
5
 
6
6
  Licensed under the Apache License, Version 2.0 (the "License");
7
7
  you may not use this file except in compliance with the License.
@@ -21,15 +21,14 @@ var jqtree = (function (exports) {
21
21
  'use strict';
22
22
 
23
23
  class DataLoader {
24
- constructor(_ref) {
25
- let {
26
- dataFilter,
27
- loadData,
28
- onLoadFailed,
29
- onLoading,
30
- treeElement,
31
- triggerEvent
32
- } = _ref;
24
+ constructor({
25
+ dataFilter,
26
+ loadData,
27
+ onLoadFailed,
28
+ onLoading,
29
+ treeElement,
30
+ triggerEvent
31
+ }) {
33
32
  this.dataFilter = dataFilter;
34
33
  this.loadData = loadData;
35
34
  this.onLoadFailed = onLoadFailed;
@@ -119,31 +118,6 @@ var jqtree = (function (exports) {
119
118
  }
120
119
  }
121
120
 
122
- let Position = /*#__PURE__*/function (Position) {
123
- Position[Position["Before"] = 1] = "Before";
124
- Position[Position["After"] = 2] = "After";
125
- Position[Position["Inside"] = 3] = "Inside";
126
- Position[Position["None"] = 4] = "None";
127
- return Position;
128
- }({});
129
- const positionNames = {
130
- after: Position.After,
131
- before: Position.Before,
132
- inside: Position.Inside,
133
- none: Position.None
134
- };
135
- const getPositionName = position => {
136
- for (const name in positionNames) {
137
- if (Object.prototype.hasOwnProperty.call(positionNames, name)) {
138
- if (positionNames[name] === position) {
139
- return name;
140
- }
141
- }
142
- }
143
- return "";
144
- };
145
- const getPosition = name => positionNames[name];
146
-
147
121
  const isInt = n => typeof n === "number" && n % 1 === 0;
148
122
  const isFunction = v => typeof v === "function";
149
123
  const getBoolString = value => value ? "true" : "false";
@@ -178,14 +152,13 @@ var jqtree = (function (exports) {
178
152
  }
179
153
 
180
154
  class DragElement {
181
- constructor(_ref) {
182
- let {
183
- autoEscape,
184
- nodeName,
185
- offsetX,
186
- offsetY,
187
- treeElement
188
- } = _ref;
155
+ constructor({
156
+ autoEscape,
157
+ nodeName,
158
+ offsetX,
159
+ offsetY,
160
+ treeElement
161
+ }) {
189
162
  this.offsetX = offsetX;
190
163
  this.offsetY = offsetY;
191
164
  this.element = this.createElement(nodeName, autoEscape);
@@ -211,14 +184,13 @@ var jqtree = (function (exports) {
211
184
  }
212
185
  }
213
186
 
214
- const iterateVisibleNodes = (tree, _ref) => {
215
- let {
216
- handleAfterOpenFolder,
217
- handleClosedFolder,
218
- handleFirstNode,
219
- handleNode,
220
- handleOpenFolder
221
- } = _ref;
187
+ const iterateVisibleNodes = (tree, {
188
+ handleAfterOpenFolder,
189
+ handleClosedFolder,
190
+ handleFirstNode,
191
+ handleNode,
192
+ handleOpenFolder
193
+ }) => {
222
194
  let isFirstNode = true;
223
195
  const iterate = (node, nextNode) => {
224
196
  let mustIterateInside = (node.is_open || !node.element) && node.hasChildren();
@@ -278,43 +250,43 @@ var jqtree = (function (exports) {
278
250
  const handleAfterOpenFolder = (node, nextNode) => {
279
251
  if (node === currentNode || nextNode === currentNode) {
280
252
  // Cannot move before or after current item
281
- addHitPosition(node, Position.None, lastTop);
253
+ addHitPosition(node, null, lastTop);
282
254
  } else {
283
- addHitPosition(node, Position.After, lastTop);
255
+ addHitPosition(node, "after", lastTop);
284
256
  }
285
257
  };
286
258
  const handleClosedFolder = (node, nextNode, element) => {
287
259
  const top = getOffsetTop(element);
288
260
  if (node === currentNode) {
289
261
  // Cannot move after current item
290
- addHitPosition(node, Position.None, top);
262
+ addHitPosition(node, null, top);
291
263
  } else {
292
- addHitPosition(node, Position.Inside, top);
264
+ addHitPosition(node, "inside", top);
293
265
 
294
266
  // Cannot move before current item
295
267
  if (nextNode !== currentNode) {
296
- addHitPosition(node, Position.After, top);
268
+ addHitPosition(node, "after", top);
297
269
  }
298
270
  }
299
271
  };
300
272
  const handleFirstNode = node => {
301
273
  if (node !== currentNode && node.element) {
302
- addHitPosition(node, Position.Before, getOffsetTop(node.element));
274
+ addHitPosition(node, "before", getOffsetTop(node.element));
303
275
  }
304
276
  };
305
277
  const handleNode = (node, nextNode, element) => {
306
278
  const top = getOffsetTop(element);
307
279
  if (node === currentNode) {
308
280
  // Cannot move inside current item
309
- addHitPosition(node, Position.None, top);
281
+ addHitPosition(node, null, top);
310
282
  } else {
311
- addHitPosition(node, Position.Inside, top);
283
+ addHitPosition(node, "inside", top);
312
284
  }
313
285
  if (nextNode === currentNode || node === currentNode) {
314
286
  // Cannot move before or after current item
315
- addHitPosition(node, Position.None, top);
287
+ addHitPosition(node, null, top);
316
288
  } else {
317
- addHitPosition(node, Position.After, top);
289
+ addHitPosition(node, "after", top);
318
290
  }
319
291
  };
320
292
  const handleOpenFolder = (node, element) => {
@@ -324,10 +296,10 @@ var jqtree = (function (exports) {
324
296
  // Dnd over the current element is not possible: add a position with type None for the top and the bottom.
325
297
  const top = getOffsetTop(element);
326
298
  const height = element.clientHeight;
327
- addHitPosition(node, Position.None, top);
299
+ addHitPosition(node, null, top);
328
300
  if (height > 5) {
329
301
  // Subtract 5 pixels to allow more space for the next element.
330
- addHitPosition(node, Position.None, top + height - 5);
302
+ addHitPosition(node, null, top + height - 5);
331
303
  }
332
304
 
333
305
  // Stop iterating
@@ -336,7 +308,7 @@ var jqtree = (function (exports) {
336
308
 
337
309
  // Cannot move before current item
338
310
  if (node.children[0] !== currentNode) {
339
- addHitPosition(node, Position.Inside, getOffsetTop(element));
311
+ addHitPosition(node, "inside", getOffsetTop(element));
340
312
  }
341
313
 
342
314
  // Continue iterating
@@ -358,7 +330,7 @@ var jqtree = (function (exports) {
358
330
  let areaTop = top;
359
331
  for (let i = 0; i < positionCount; i++) {
360
332
  const position = positionsInGroup[i];
361
- if (position.position !== Position.None) {
333
+ if (position.position) {
362
334
  hitAreas.push({
363
335
  bottom: areaTop + areaHeight,
364
336
  node: position.node,
@@ -390,24 +362,24 @@ var jqtree = (function (exports) {
390
362
  const generateHitAreas = (tree, currentNode, treeBottom) => generateHitAreasFromPositions(generateHitPositions(tree, currentNode), treeBottom);
391
363
 
392
364
  class DragAndDropHandler {
393
- constructor(_ref) {
394
- let {
395
- autoEscape,
396
- getNodeElement,
397
- getNodeElementForNode,
398
- getScrollLeft,
399
- getTree,
400
- onCanMove,
401
- onCanMoveTo,
402
- onDragMove,
403
- onDragStop,
404
- onIsMoveHandle,
405
- openNode,
406
- refreshElements,
407
- slide,
408
- treeElement,
409
- triggerEvent
410
- } = _ref;
365
+ constructor({
366
+ autoEscape,
367
+ getNodeElement,
368
+ getNodeElementForNode,
369
+ getScrollLeft,
370
+ getTree,
371
+ onCanMove,
372
+ onCanMoveTo,
373
+ onDragMove,
374
+ onDragStop,
375
+ onIsMoveHandle,
376
+ openFolderDelay,
377
+ openNode,
378
+ refreshElements,
379
+ slide,
380
+ treeElement,
381
+ triggerEvent
382
+ }) {
411
383
  this.autoEscape = autoEscape;
412
384
  this.getNodeElement = getNodeElement;
413
385
  this.getNodeElementForNode = getNodeElementForNode;
@@ -418,6 +390,7 @@ var jqtree = (function (exports) {
418
390
  this.onDragMove = onDragMove;
419
391
  this.onDragStop = onDragStop;
420
392
  this.onIsMoveHandle = onIsMoveHandle;
393
+ this.openFolderDelay = openFolderDelay;
421
394
  this.openNode = openNode;
422
395
  this.refreshElements = refreshElements;
423
396
  this.slide = slide;
@@ -533,8 +506,7 @@ var jqtree = (function (exports) {
533
506
  if (!this.onCanMoveTo) {
534
507
  return true;
535
508
  }
536
- const positionName = getPositionName(area.position);
537
- return this.onCanMoveTo(currentItem.node, area.node, positionName);
509
+ return this.onCanMoveTo(currentItem.node, area.node, area.position);
538
510
  }
539
511
  clear() {
540
512
  if (this.dragElement) {
@@ -581,12 +553,12 @@ var jqtree = (function (exports) {
581
553
 
582
554
  /* Move the dragged node to the selected position in the tree. */
583
555
  moveItem(positionInfo) {
584
- if (this.currentItem && this.hoveredArea && this.hoveredArea.position !== Position.None && this.canMoveToArea(this.hoveredArea, this.currentItem)) {
556
+ if (this.currentItem && this.hoveredArea?.position && this.canMoveToArea(this.hoveredArea, this.currentItem)) {
585
557
  const movedNode = this.currentItem.node;
586
558
  const targetNode = this.hoveredArea.node;
587
559
  const position = this.hoveredArea.position;
588
560
  const previousParent = movedNode.parent;
589
- if (position === Position.Inside) {
561
+ if (position === "inside") {
590
562
  this.hoveredArea.node.is_open = true;
591
563
  }
592
564
  const doMove = () => {
@@ -602,7 +574,7 @@ var jqtree = (function (exports) {
602
574
  do_move: doMove,
603
575
  moved_node: movedNode,
604
576
  original_event: positionInfo.originalEvent,
605
- position: getPositionName(position),
577
+ position,
606
578
  previous_parent: previousParent,
607
579
  target_node: targetNode
608
580
  }
@@ -618,7 +590,7 @@ var jqtree = (function (exports) {
618
590
  }
619
591
  mustOpenFolderTimer(area) {
620
592
  const node = area.node;
621
- return node.isFolder() && !node.is_open && area.position === Position.Inside;
593
+ return node.isFolder() && !node.is_open && area.position === "inside";
622
594
  }
623
595
  removeDropHint() {
624
596
  if (this.previousGhost) {
@@ -665,21 +637,20 @@ var jqtree = (function (exports) {
665
637
  }
666
638
 
667
639
  class ElementsRenderer {
668
- constructor(_ref) {
669
- let {
670
- $element,
671
- autoEscape,
672
- buttonLeft,
673
- closedIcon,
674
- dragAndDrop,
675
- getTree,
676
- isNodeSelected,
677
- onCreateLi,
678
- openedIcon,
679
- rtl,
680
- showEmptyFolder,
681
- tabIndex
682
- } = _ref;
640
+ constructor({
641
+ $element,
642
+ autoEscape,
643
+ buttonLeft,
644
+ closedIcon,
645
+ dragAndDrop,
646
+ getTree,
647
+ isNodeSelected,
648
+ onCreateLi,
649
+ openedIcon,
650
+ rtl,
651
+ showEmptyFolder,
652
+ tabIndex
653
+ }) {
683
654
  this.autoEscape = autoEscape;
684
655
  this.buttonLeft = buttonLeft;
685
656
  this.dragAndDrop = dragAndDrop;
@@ -795,7 +766,7 @@ var jqtree = (function (exports) {
795
766
  * Call onCreateLi
796
767
  */
797
768
  createLi(node, level) {
798
- const isSelected = Boolean(this.isNodeSelected(node));
769
+ const isSelected = this.isNodeSelected(node);
799
770
  const mustShowFolder = node.isFolder() || node.isEmptyFolder && this.showEmptyFolder;
800
771
  const li = mustShowFolder ? this.createFolderLi(node, level, isSelected) : this.createNodeLi(node, level, isSelected);
801
772
  this.attachNodeData(node, li);
@@ -904,15 +875,14 @@ var jqtree = (function (exports) {
904
875
  }
905
876
 
906
877
  class KeyHandler {
907
- constructor(_ref) {
908
- let {
909
- closeNode,
910
- getSelectedNode,
911
- isFocusOnTree,
912
- keyboardSupport,
913
- openNode,
914
- selectNode
915
- } = _ref;
878
+ constructor({
879
+ closeNode,
880
+ getSelectedNode,
881
+ isFocusOnTree,
882
+ keyboardSupport,
883
+ openNode,
884
+ selectNode
885
+ }) {
916
886
  this.closeNode = closeNode;
917
887
  this.getSelectedNode = getSelectedNode;
918
888
  this.isFocusOnTree = isFocusOnTree;
@@ -1017,20 +987,19 @@ var jqtree = (function (exports) {
1017
987
  });
1018
988
 
1019
989
  class MouseHandler {
1020
- constructor(_ref) {
1021
- let {
1022
- element,
1023
- getMouseDelay,
1024
- getNode,
1025
- onClickButton,
1026
- onClickTitle,
1027
- onMouseCapture,
1028
- onMouseDrag,
1029
- onMouseStart,
1030
- onMouseStop,
1031
- triggerEvent,
1032
- useContextMenu
1033
- } = _ref;
990
+ constructor({
991
+ element,
992
+ getMouseDelay,
993
+ getNode,
994
+ onClickButton,
995
+ onClickTitle,
996
+ onMouseCapture,
997
+ onMouseDrag,
998
+ onMouseStart,
999
+ onMouseStop,
1000
+ triggerEvent,
1001
+ useContextMenu
1002
+ }) {
1034
1003
  this.element = element;
1035
1004
  this.getMouseDelay = getMouseDelay;
1036
1005
  this.getNode = getNode;
@@ -1282,10 +1251,7 @@ var jqtree = (function (exports) {
1282
1251
  const isNodeRecordWithChildren = data => typeof data === "object" && "children" in data && data.children instanceof Array;
1283
1252
 
1284
1253
  class Node {
1285
- constructor() {
1286
- let nodeData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1287
- let isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1288
- let nodeClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Node;
1254
+ constructor(nodeData = null, isRoot = false, nodeClass = Node) {
1289
1255
  this.name = "";
1290
1256
  this.load_on_demand = false;
1291
1257
  this.isEmptyFolder = nodeData != null && isNodeRecordWithChildren(nodeData) && nodeData.children.length === 0;
@@ -1393,8 +1359,7 @@ var jqtree = (function (exports) {
1393
1359
  /*
1394
1360
  Get the tree as data.
1395
1361
  */
1396
- getData() {
1397
- let includeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1362
+ getData(includeParent = false) {
1398
1363
  const getDataFromNodes = nodes => {
1399
1364
  return nodes.map(node => {
1400
1365
  const tmpNode = {};
@@ -1421,9 +1386,6 @@ var jqtree = (function (exports) {
1421
1386
  return null;
1422
1387
  } else {
1423
1388
  const lastChild = this.children[this.children.length - 1];
1424
- if (!lastChild) {
1425
- return null;
1426
- }
1427
1389
  if (!(lastChild.hasChildren() && lastChild.is_open)) {
1428
1390
  return lastChild;
1429
1391
  } else {
@@ -1441,8 +1403,7 @@ var jqtree = (function (exports) {
1441
1403
  }
1442
1404
  return level;
1443
1405
  }
1444
- getNextNode() {
1445
- let includeChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1406
+ getNextNode(includeChildren = true) {
1446
1407
  if (includeChildren && this.hasChildren()) {
1447
1408
  return this.children[0] ?? null;
1448
1409
  } else if (!this.parent) {
@@ -1678,7 +1639,7 @@ var jqtree = (function (exports) {
1678
1639
  } else {
1679
1640
  movedNode.parent.doRemoveChild(movedNode);
1680
1641
  switch (position) {
1681
- case Position.After:
1642
+ case "after":
1682
1643
  {
1683
1644
  if (targetNode.parent) {
1684
1645
  targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode) + 1);
@@ -1686,7 +1647,7 @@ var jqtree = (function (exports) {
1686
1647
  }
1687
1648
  return false;
1688
1649
  }
1689
- case Position.Before:
1650
+ case "before":
1690
1651
  {
1691
1652
  if (targetNode.parent) {
1692
1653
  targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode));
@@ -1694,14 +1655,12 @@ var jqtree = (function (exports) {
1694
1655
  }
1695
1656
  return false;
1696
1657
  }
1697
- case Position.Inside:
1658
+ case "inside":
1698
1659
  {
1699
1660
  // move inside as first child
1700
1661
  targetNode.addChildAtPosition(movedNode, 0);
1701
1662
  return true;
1702
1663
  }
1703
- default:
1704
- return false;
1705
1664
  }
1706
1665
  }
1707
1666
  }
@@ -1825,13 +1784,13 @@ var jqtree = (function (exports) {
1825
1784
  this.node = node;
1826
1785
  this.ghost = this.createGhostElement();
1827
1786
  switch (position) {
1828
- case Position.After:
1787
+ case "after":
1829
1788
  this.moveAfter();
1830
1789
  break;
1831
- case Position.Before:
1790
+ case "before":
1832
1791
  this.moveBefore();
1833
1792
  break;
1834
- case Position.Inside:
1793
+ case "inside":
1835
1794
  {
1836
1795
  if (node.isFolder() && node.is_open) {
1837
1796
  this.moveInsideOpenFolder();
@@ -1874,13 +1833,12 @@ var jqtree = (function (exports) {
1874
1833
  }
1875
1834
 
1876
1835
  class NodeElement {
1877
- constructor(_ref) {
1878
- let {
1879
- getScrollLeft,
1880
- node,
1881
- tabIndex,
1882
- treeElement
1883
- } = _ref;
1836
+ constructor({
1837
+ getScrollLeft,
1838
+ node,
1839
+ tabIndex,
1840
+ treeElement
1841
+ }) {
1884
1842
  this.getScrollLeft = getScrollLeft;
1885
1843
  this.tabIndex = tabIndex;
1886
1844
  this.treeElement = treeElement;
@@ -1902,9 +1860,7 @@ var jqtree = (function (exports) {
1902
1860
  }
1903
1861
  init(node) {
1904
1862
  this.node = node;
1905
- if (!node.element) {
1906
- node.element = this.treeElement;
1907
- }
1863
+ node.element ??= this.treeElement;
1908
1864
  this.element = node.element;
1909
1865
  }
1910
1866
  select(mustSetFocus) {
@@ -1928,21 +1884,20 @@ var jqtree = (function (exports) {
1928
1884
  return this.element.querySelector(":scope > ul");
1929
1885
  }
1930
1886
  mustShowBorderDropHint(position) {
1931
- return position === Position.Inside;
1887
+ return position === "inside";
1932
1888
  }
1933
1889
  }
1934
1890
 
1935
1891
  class FolderElement extends NodeElement {
1936
- constructor(_ref) {
1937
- let {
1938
- closedIconElement,
1939
- getScrollLeft,
1940
- node,
1941
- openedIconElement,
1942
- tabIndex,
1943
- treeElement,
1944
- triggerEvent
1945
- } = _ref;
1892
+ constructor({
1893
+ closedIconElement,
1894
+ getScrollLeft,
1895
+ node,
1896
+ openedIconElement,
1897
+ tabIndex,
1898
+ treeElement,
1899
+ triggerEvent
1900
+ }) {
1946
1901
  super({
1947
1902
  getScrollLeft,
1948
1903
  node,
@@ -2013,7 +1968,7 @@ var jqtree = (function (exports) {
2013
1968
  }
2014
1969
  }
2015
1970
  mustShowBorderDropHint(position) {
2016
- return !this.node.is_open && position === Position.Inside;
1971
+ return !this.node.is_open && position === "inside";
2017
1972
  }
2018
1973
  getButton() {
2019
1974
  return this.element.querySelector(":scope > .jqtree-element > a.jqtree-toggler");
@@ -2021,19 +1976,18 @@ var jqtree = (function (exports) {
2021
1976
  }
2022
1977
 
2023
1978
  class SaveStateHandler {
2024
- constructor(_ref) {
2025
- let {
2026
- addToSelection,
2027
- getNodeById,
2028
- getSelectedNodes,
2029
- getTree,
2030
- onGetStateFromStorage,
2031
- onSetStateFromStorage,
2032
- openNode,
2033
- refreshElements,
2034
- removeFromSelection,
2035
- saveState
2036
- } = _ref;
1979
+ constructor({
1980
+ addToSelection,
1981
+ getNodeById,
1982
+ getSelectedNodes,
1983
+ getTree,
1984
+ onGetStateFromStorage,
1985
+ onSetStateFromStorage,
1986
+ openNode,
1987
+ refreshElements,
1988
+ removeFromSelection,
1989
+ saveState
1990
+ }) {
2037
1991
  this.addToSelection = addToSelection;
2038
1992
  this.getNodeById = getNodeById;
2039
1993
  this.getSelectedNodes = getSelectedNodes;
@@ -2209,12 +2163,11 @@ var jqtree = (function (exports) {
2209
2163
  }
2210
2164
  }
2211
2165
 
2212
- class ContainerScrollParent {
2213
- constructor(_ref) {
2214
- let {
2215
- container,
2216
- refreshHitAreas
2217
- } = _ref;
2166
+ class ScrollParent {
2167
+ constructor({
2168
+ container,
2169
+ refreshHitAreas
2170
+ }) {
2218
2171
  this.container = container;
2219
2172
  this.refreshHitAreas = refreshHitAreas;
2220
2173
  }
@@ -2223,7 +2176,7 @@ var jqtree = (function (exports) {
2223
2176
  if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {
2224
2177
  this.horizontalScrollDirection = newHorizontalScrollDirection;
2225
2178
  if (this.horizontalScrollTimeout != null) {
2226
- window.clearTimeout(this.verticalScrollTimeout);
2179
+ window.clearTimeout(this.horizontalScrollTimeout);
2227
2180
  }
2228
2181
  if (newHorizontalScrollDirection) {
2229
2182
  this.horizontalScrollTimeout = window.setTimeout(this.scrollHorizontally.bind(this), 40);
@@ -2252,42 +2205,6 @@ var jqtree = (function (exports) {
2252
2205
  stopScrolling() {
2253
2206
  this.horizontalScrollDirection = undefined;
2254
2207
  this.verticalScrollDirection = undefined;
2255
- this.scrollParentTop = undefined;
2256
- this.scrollParentBottom = undefined;
2257
- }
2258
- getNewHorizontalScrollDirection(pageX) {
2259
- const scrollParentOffset = getElementPosition(this.container);
2260
- const rightEdge = scrollParentOffset.left + this.container.clientWidth;
2261
- const leftEdge = scrollParentOffset.left;
2262
- const isNearRightEdge = pageX > rightEdge - 20;
2263
- const isNearLeftEdge = pageX < leftEdge + 20;
2264
- if (isNearRightEdge) {
2265
- return "right";
2266
- } else if (isNearLeftEdge) {
2267
- return "left";
2268
- }
2269
- return undefined;
2270
- }
2271
- getNewVerticalScrollDirection(pageY) {
2272
- if (pageY < this.getScrollParentTop()) {
2273
- return "top";
2274
- }
2275
- if (pageY > this.getScrollParentBottom()) {
2276
- return "bottom";
2277
- }
2278
- return undefined;
2279
- }
2280
- getScrollParentBottom() {
2281
- if (this.scrollParentBottom == null) {
2282
- this.scrollParentBottom = this.getScrollParentTop() + this.container.clientHeight;
2283
- }
2284
- return this.scrollParentBottom;
2285
- }
2286
- getScrollParentTop() {
2287
- if (this.scrollParentTop == null) {
2288
- this.scrollParentTop = getOffsetTop(this.container);
2289
- }
2290
- return this.scrollParentTop;
2291
2208
  }
2292
2209
  scrollHorizontally() {
2293
2210
  if (!this.horizontalScrollDirection) {
@@ -2317,77 +2234,70 @@ var jqtree = (function (exports) {
2317
2234
  }
2318
2235
  }
2319
2236
 
2320
- class DocumentScrollParent {
2321
- constructor(_ref) {
2322
- let {
2323
- refreshHitAreas,
2324
- treeElement
2325
- } = _ref;
2326
- this.refreshHitAreas = refreshHitAreas;
2327
- this.treeElement = treeElement;
2237
+ class ContainerScrollParent extends ScrollParent {
2238
+ stopScrolling() {
2239
+ super.stopScrolling();
2240
+ this.horizontalScrollDirection = undefined;
2241
+ this.verticalScrollDirection = undefined;
2328
2242
  }
2329
- checkHorizontalScrolling(pageX) {
2330
- const newHorizontalScrollDirection = this.getNewHorizontalScrollDirection(pageX);
2331
- if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {
2332
- this.horizontalScrollDirection = newHorizontalScrollDirection;
2333
- if (this.horizontalScrollTimeout != null) {
2334
- window.clearTimeout(this.horizontalScrollTimeout);
2335
- }
2336
- if (newHorizontalScrollDirection) {
2337
- this.horizontalScrollTimeout = window.setTimeout(this.scrollHorizontally.bind(this), 40);
2338
- }
2243
+ getNewHorizontalScrollDirection(pageX) {
2244
+ const scrollParentOffset = getElementPosition(this.container);
2245
+ const containerWidth = this.container.getBoundingClientRect().width;
2246
+ const rightEdge = scrollParentOffset.left + containerWidth;
2247
+ const leftEdge = scrollParentOffset.left;
2248
+ const isNearRightEdge = pageX > rightEdge - 20;
2249
+ const isNearLeftEdge = pageX < leftEdge + 20;
2250
+ if (isNearRightEdge) {
2251
+ return "right";
2252
+ } else if (isNearLeftEdge) {
2253
+ return "left";
2339
2254
  }
2255
+ return undefined;
2340
2256
  }
2341
- checkVerticalScrolling(pageY) {
2342
- const newVerticalScrollDirection = this.getNewVerticalScrollDirection(pageY);
2343
- if (this.verticalScrollDirection !== newVerticalScrollDirection) {
2344
- this.verticalScrollDirection = newVerticalScrollDirection;
2345
- if (this.verticalScrollTimeout != null) {
2346
- window.clearTimeout(this.verticalScrollTimeout);
2347
- this.verticalScrollTimeout = undefined;
2348
- }
2349
- if (newVerticalScrollDirection) {
2350
- this.verticalScrollTimeout = window.setTimeout(this.scrollVertically.bind(this), 40);
2351
- }
2257
+ getNewVerticalScrollDirection(pageY) {
2258
+ if (pageY < this.getScrollParentTop()) {
2259
+ return "top";
2352
2260
  }
2261
+ if (pageY > this.getScrollParentBottom()) {
2262
+ return "bottom";
2263
+ }
2264
+ return undefined;
2353
2265
  }
2354
- getScrollLeft() {
2355
- return document.documentElement.scrollLeft;
2266
+ getScrollParentBottom() {
2267
+ if (this.scrollParentBottom == null) {
2268
+ const containerHeight = this.container.getBoundingClientRect().height;
2269
+ this.scrollParentBottom = this.getScrollParentTop() + containerHeight;
2270
+ }
2271
+ return this.scrollParentBottom;
2272
+ }
2273
+ getScrollParentTop() {
2274
+ this.scrollParentTop ??= getOffsetTop(this.container);
2275
+ return this.scrollParentTop;
2276
+ }
2277
+ }
2278
+
2279
+ class DocumentScrollParent extends ScrollParent {
2280
+ constructor({
2281
+ refreshHitAreas,
2282
+ treeElement
2283
+ }) {
2284
+ super({
2285
+ container: document.documentElement,
2286
+ refreshHitAreas
2287
+ });
2288
+ this.treeElement = treeElement;
2356
2289
  }
2357
2290
  scrollToY(top) {
2358
2291
  const treeTop = getOffsetTop(this.treeElement);
2359
- document.documentElement.scrollTop = top + treeTop;
2292
+ super.scrollToY(top + treeTop);
2360
2293
  }
2361
2294
  stopScrolling() {
2362
- this.horizontalScrollDirection = undefined;
2363
- this.verticalScrollDirection = undefined;
2295
+ super.stopScrolling();
2364
2296
  this.documentScrollHeight = undefined;
2365
2297
  this.documentScrollWidth = undefined;
2366
2298
  }
2367
- canScrollDown() {
2368
- const documentElement = document.documentElement;
2369
- return documentElement.scrollTop + documentElement.clientHeight < this.getDocumentScrollHeight();
2370
- }
2371
- canScrollRight() {
2372
- const documentElement = document.documentElement;
2373
- return documentElement.scrollLeft + documentElement.clientWidth < this.getDocumentScrollWidth();
2374
- }
2375
- getDocumentScrollHeight() {
2376
- // Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
2377
- if (this.documentScrollHeight == null) {
2378
- this.documentScrollHeight = document.documentElement.scrollHeight;
2379
- }
2380
- return this.documentScrollHeight;
2381
- }
2382
- getDocumentScrollWidth() {
2383
- // Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
2384
- if (this.documentScrollWidth == null) {
2385
- this.documentScrollWidth = document.documentElement.scrollWidth;
2386
- }
2387
- return this.documentScrollWidth;
2388
- }
2389
2299
  getNewHorizontalScrollDirection(pageX) {
2390
- const scrollLeft = document.documentElement.scrollLeft;
2300
+ const scrollLeft = this.container.scrollLeft;
2391
2301
  const windowWidth = window.innerWidth;
2392
2302
  const isNearRightEdge = pageX > windowWidth - 20;
2393
2303
  const isNearLeftEdge = pageX - scrollLeft < 20;
@@ -2400,7 +2310,7 @@ var jqtree = (function (exports) {
2400
2310
  return undefined;
2401
2311
  }
2402
2312
  getNewVerticalScrollDirection(pageY) {
2403
- const scrollTop = jQuery(document).scrollTop() ?? 0;
2313
+ const scrollTop = this.container.scrollTop;
2404
2314
  const distanceTop = pageY - scrollTop;
2405
2315
  if (distanceTop < 20) {
2406
2316
  return "top";
@@ -2411,31 +2321,21 @@ var jqtree = (function (exports) {
2411
2321
  }
2412
2322
  return undefined;
2413
2323
  }
2414
- scrollHorizontally() {
2415
- if (!this.horizontalScrollDirection) {
2416
- return;
2417
- }
2418
- const distance = this.horizontalScrollDirection === "left" ? -20 : 20;
2419
- window.scrollBy({
2420
- behavior: "instant",
2421
- left: distance,
2422
- top: 0
2423
- });
2424
- this.refreshHitAreas();
2425
- setTimeout(this.scrollHorizontally.bind(this), 40);
2324
+ canScrollDown() {
2325
+ return this.container.scrollTop + this.container.clientHeight < this.getDocumentScrollHeight();
2426
2326
  }
2427
- scrollVertically() {
2428
- if (!this.verticalScrollDirection) {
2429
- return;
2430
- }
2431
- const distance = this.verticalScrollDirection === "top" ? -20 : 20;
2432
- window.scrollBy({
2433
- behavior: "instant",
2434
- left: 0,
2435
- top: distance
2436
- });
2437
- this.refreshHitAreas();
2438
- setTimeout(this.scrollVertically.bind(this), 40);
2327
+ canScrollRight() {
2328
+ return this.container.scrollLeft + this.container.clientWidth < this.getDocumentScrollWidth();
2329
+ }
2330
+ getDocumentScrollHeight() {
2331
+ // Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
2332
+ this.documentScrollHeight ??= this.container.scrollHeight;
2333
+ return this.documentScrollHeight;
2334
+ }
2335
+ getDocumentScrollWidth() {
2336
+ // Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
2337
+ this.documentScrollWidth ??= this.container.scrollWidth;
2338
+ return this.documentScrollWidth;
2439
2339
  }
2440
2340
  }
2441
2341
 
@@ -2473,11 +2373,10 @@ var jqtree = (function (exports) {
2473
2373
  };
2474
2374
 
2475
2375
  class ScrollHandler {
2476
- constructor(_ref) {
2477
- let {
2478
- refreshHitAreas,
2479
- treeElement
2480
- } = _ref;
2376
+ constructor({
2377
+ refreshHitAreas,
2378
+ treeElement
2379
+ }) {
2481
2380
  this.refreshHitAreas = refreshHitAreas;
2482
2381
  this.scrollParent = undefined;
2483
2382
  this.treeElement = treeElement;
@@ -2502,18 +2401,15 @@ var jqtree = (function (exports) {
2502
2401
  this.getScrollParent().checkVerticalScrolling(positionInfo.pageY);
2503
2402
  }
2504
2403
  getScrollParent() {
2505
- if (!this.scrollParent) {
2506
- this.scrollParent = createScrollParent(this.treeElement, this.refreshHitAreas);
2507
- }
2404
+ this.scrollParent ??= createScrollParent(this.treeElement, this.refreshHitAreas);
2508
2405
  return this.scrollParent;
2509
2406
  }
2510
2407
  }
2511
2408
 
2512
2409
  class SelectNodeHandler {
2513
- constructor(_ref) {
2514
- let {
2515
- getNodeById
2516
- } = _ref;
2410
+ constructor({
2411
+ getNodeById
2412
+ }) {
2517
2413
  this.getNodeById = getNodeById;
2518
2414
  this.selectedNodes = new Set();
2519
2415
  this.clear();
@@ -2578,8 +2474,7 @@ var jqtree = (function (exports) {
2578
2474
  return false;
2579
2475
  }
2580
2476
  }
2581
- removeFromSelection(node) {
2582
- let includeChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2477
+ removeFromSelection(node, includeChildren = false) {
2583
2478
  if (node.id == null) {
2584
2479
  if (this.selectedSingleNode && node.element === this.selectedSingleNode.element) {
2585
2480
  this.selectedSingleNode = null;
@@ -2651,7 +2546,7 @@ var jqtree = (function (exports) {
2651
2546
  };
2652
2547
 
2653
2548
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2654
- jQuery.fn[widgetName] = function (argument1) {
2549
+ jQuery.fn[widgetName] = function (argument1, ...args) {
2655
2550
  if (!argument1) {
2656
2551
  return createWidget(this, null);
2657
2552
  } else if (typeof argument1 === "object") {
@@ -2659,15 +2554,10 @@ var jqtree = (function (exports) {
2659
2554
  return createWidget(this, options);
2660
2555
  } else if (typeof argument1 === "string" && argument1[0] !== "_") {
2661
2556
  const functionName = argument1;
2662
- if (functionName === "destroy") {
2557
+ if (argument1 === "destroy") {
2663
2558
  destroyWidget(this);
2664
2559
  return undefined;
2665
- } else if (functionName === "get_widget_class") {
2666
- return widgetClass;
2667
2560
  } else {
2668
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2669
- args[_key - 1] = arguments[_key];
2670
- }
2671
2561
  return callFunction(this, functionName, args);
2672
2562
  }
2673
2563
  } else {
@@ -2701,12 +2591,12 @@ var jqtree = (function (exports) {
2701
2591
  }
2702
2592
  }
2703
2593
 
2704
- const version = "1.8.8";
2594
+ const version = "1.8.11";
2705
2595
 
2706
2596
  const NODE_PARAM_IS_EMPTY = "Node parameter is empty";
2707
2597
  const PARAM_IS_EMPTY = "Parameter is empty: ";
2708
2598
  class JqTreeWidget extends SimpleWidget {
2709
- static defaults = (() => ({
2599
+ static defaults = {
2710
2600
  animationSpeed: "fast",
2711
2601
  autoEscape: true,
2712
2602
  autoOpen: false,
@@ -2751,7 +2641,7 @@ var jqtree = (function (exports) {
2751
2641
  // The delay for starting dnd (in milliseconds)
2752
2642
  tabIndex: 0,
2753
2643
  useContextMenu: true
2754
- }))();
2644
+ };
2755
2645
  addNodeAfter(newNodeInfo, existingNode) {
2756
2646
  const newNode = existingNode.addAfter(newNodeInfo);
2757
2647
  if (newNode) {
@@ -2818,7 +2708,7 @@ var jqtree = (function (exports) {
2818
2708
  return this.tree.getNodeByCallback(callback);
2819
2709
  }
2820
2710
  getNodeByHtmlElement(inputElement) {
2821
- const element = inputElement instanceof HTMLElement ? inputElement : inputElement[0];
2711
+ const element = inputElement instanceof HTMLElement ? inputElement : inputElement.get(0);
2822
2712
  if (!element) {
2823
2713
  return null;
2824
2714
  }
@@ -2859,9 +2749,7 @@ var jqtree = (function (exports) {
2859
2749
  this.element = this.$el;
2860
2750
  this.isInitialized = false;
2861
2751
  this.options.rtl = this.getRtlOption();
2862
- if (this.options.closedIcon == null) {
2863
- this.options.closedIcon = this.getDefaultClosedIcon();
2864
- }
2752
+ this.options.closedIcon ??= this.getDefaultClosedIcon();
2865
2753
  this.connectHandlers();
2866
2754
  this.initData();
2867
2755
  }
@@ -2919,11 +2807,8 @@ var jqtree = (function (exports) {
2919
2807
  if (!position) {
2920
2808
  throw Error(PARAM_IS_EMPTY + "position");
2921
2809
  }
2922
- const positionIndex = getPosition(position);
2923
- if (positionIndex !== undefined) {
2924
- this.tree.moveNode(node, targetNode, positionIndex);
2925
- this.refreshElements(null);
2926
- }
2810
+ this.tree.moveNode(node, targetNode, position);
2811
+ this.refreshElements(null);
2927
2812
  return this.element;
2928
2813
  }
2929
2814
  moveUp() {
@@ -2947,9 +2832,7 @@ var jqtree = (function (exports) {
2947
2832
  slide = param1;
2948
2833
  onFinished = param2;
2949
2834
  }
2950
- if (slide == null) {
2951
- slide = this.options.slide;
2952
- }
2835
+ slide ??= this.options.slide;
2953
2836
  return [slide, onFinished];
2954
2837
  };
2955
2838
  const [slide, onFinished] = parseParams();
@@ -3023,8 +2906,7 @@ var jqtree = (function (exports) {
3023
2906
  }
3024
2907
  return this.element;
3025
2908
  }
3026
- toggle(node) {
3027
- let slideParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2909
+ toggle(node, slideParam = null) {
3028
2910
  if (!node) {
3029
2911
  throw Error(NODE_PARAM_IS_EMPTY);
3030
2912
  }
@@ -3206,7 +3088,7 @@ var jqtree = (function (exports) {
3206
3088
  }
3207
3089
  containsElement(element) {
3208
3090
  const node = this.getNode(element);
3209
- return node != null && node.tree === this.tree;
3091
+ return node?.tree === this.tree;
3210
3092
  }
3211
3093
  createFolderElement(node) {
3212
3094
  const closedIconElement = this.renderer.closedIconElement;
@@ -3452,7 +3334,7 @@ var jqtree = (function (exports) {
3452
3334
  }
3453
3335
  isFocusOnTree() {
3454
3336
  const activeElement = document.activeElement;
3455
- return Boolean(activeElement && activeElement.tagName === "SPAN" && this.containsElement(activeElement));
3337
+ return activeElement?.tagName === "SPAN" && this.containsElement(activeElement);
3456
3338
  }
3457
3339
  isSelectedNodeInSubtree(subtree) {
3458
3340
  const selectedNode = this.getSelectedNode();
@@ -3462,9 +3344,7 @@ var jqtree = (function (exports) {
3462
3344
  return subtree === selectedNode || subtree.isParentOf(selectedNode);
3463
3345
  }
3464
3346
  }
3465
- loadFolderOnDemand(node) {
3466
- let slide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3467
- let onFinished = arguments.length > 2 ? arguments[2] : undefined;
3347
+ loadFolderOnDemand(node, slide = true, onFinished) {
3468
3348
  node.is_loading = true;
3469
3349
  this.doLoadDataFromUrl(null, node, () => {
3470
3350
  this.openNodeInternal(node, slide, onFinished);
@@ -3507,9 +3387,7 @@ var jqtree = (function (exports) {
3507
3387
  return false;
3508
3388
  }
3509
3389
  }
3510
- openNodeInternal(node) {
3511
- let slide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3512
- let onFinished = arguments.length > 2 ? arguments[2] : undefined;
3390
+ openNodeInternal(node, slide = true, onFinished) {
3513
3391
  const doOpenNode = (_node, _slide, _onFinished) => {
3514
3392
  if (!node.children.length) {
3515
3393
  return;