jqtree 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- JqTree 1.9.0
2
+ JqTree 1.9.1
3
3
 
4
4
  Copyright 2026 Marco Braak
5
5
 
@@ -1915,7 +1915,7 @@ var jqtree = (function (exports) {
1915
1915
  this.init(node);
1916
1916
  }
1917
1917
  addDropHint(position) {
1918
- if (this.mustShowBorderDropHint(position)) {
1918
+ if (this._mustShowBorderDropHint(position)) {
1919
1919
  return new BorderDropHint(this.element, this._getScrollLeft());
1920
1920
  } else {
1921
1921
  return new GhostDropHint(this.node, this.element, position);
@@ -1923,7 +1923,7 @@ var jqtree = (function (exports) {
1923
1923
  }
1924
1924
  deselect() {
1925
1925
  this.element.classList.remove("jqtree-selected");
1926
- const titleSpan = this.getTitleSpan();
1926
+ const titleSpan = this._getTitleSpan();
1927
1927
  titleSpan.removeAttribute("tabindex");
1928
1928
  titleSpan.setAttribute("aria-selected", "false");
1929
1929
  titleSpan.blur();
@@ -1935,7 +1935,7 @@ var jqtree = (function (exports) {
1935
1935
  }
1936
1936
  select(mustSetFocus) {
1937
1937
  this.element.classList.add("jqtree-selected");
1938
- const titleSpan = this.getTitleSpan();
1938
+ const titleSpan = this._getTitleSpan();
1939
1939
  const tabIndex = this._tabIndex;
1940
1940
 
1941
1941
  // Check for null or undefined
@@ -1947,13 +1947,13 @@ var jqtree = (function (exports) {
1947
1947
  titleSpan.focus();
1948
1948
  }
1949
1949
  }
1950
- getTitleSpan() {
1950
+ _getTitleSpan() {
1951
1951
  return this.element.querySelector(":scope > .jqtree-element > span.jqtree-title");
1952
1952
  }
1953
- getUl() {
1953
+ _getUl() {
1954
1954
  return this.element.querySelector(":scope > ul");
1955
1955
  }
1956
- mustShowBorderDropHint(position) {
1956
+ _mustShowBorderDropHint(position) {
1957
1957
  return position === "inside";
1958
1958
  }
1959
1959
  }
@@ -2033,13 +2033,13 @@ var jqtree = (function (exports) {
2033
2033
  }
2034
2034
  const doClose = () => {
2035
2035
  this.element.classList.add("jqtree-closed");
2036
- const titleSpan = this.getTitleSpan();
2036
+ const titleSpan = this._getTitleSpan();
2037
2037
  titleSpan.setAttribute("aria-expanded", "false");
2038
2038
  this._triggerEvent("tree.close", {
2039
2039
  node: this.node
2040
2040
  });
2041
2041
  };
2042
- const ul = this.getUl();
2042
+ const ul = this._getUl();
2043
2043
  if (slide) {
2044
2044
  slideUp(ul, animationSpeed, doClose);
2045
2045
  } else {
@@ -2062,7 +2062,7 @@ var jqtree = (function (exports) {
2062
2062
  }
2063
2063
  const doOpen = () => {
2064
2064
  this.element.classList.remove("jqtree-closed");
2065
- const titleSpan = this.getTitleSpan();
2065
+ const titleSpan = this._getTitleSpan();
2066
2066
  titleSpan.setAttribute("aria-expanded", "true");
2067
2067
  if (onFinished) {
2068
2068
  onFinished(this.node);
@@ -2071,7 +2071,7 @@ var jqtree = (function (exports) {
2071
2071
  node: this.node
2072
2072
  });
2073
2073
  };
2074
- const ul = this.getUl();
2074
+ const ul = this._getUl();
2075
2075
  if (slide) {
2076
2076
  slideDown(ul, animationSpeed, doOpen);
2077
2077
  } else {
@@ -2079,7 +2079,7 @@ var jqtree = (function (exports) {
2079
2079
  doOpen();
2080
2080
  }
2081
2081
  }
2082
- mustShowBorderDropHint(position) {
2082
+ _mustShowBorderDropHint(position) {
2083
2083
  return !this.node.is_open && position === "inside";
2084
2084
  }
2085
2085
  _getButton() {
@@ -2286,79 +2286,79 @@ var jqtree = (function (exports) {
2286
2286
  }
2287
2287
 
2288
2288
  class ScrollParent {
2289
- container;
2290
- horizontalScrollDirection;
2291
- horizontalScrollTimeout;
2292
- refreshHitAreas;
2293
- verticalScrollDirection;
2294
- verticalScrollTimeout;
2289
+ _container;
2290
+ _horizontalScrollDirection;
2291
+ _horizontalScrollTimeout;
2292
+ _refreshHitAreas;
2293
+ _verticalScrollDirection;
2294
+ _verticalScrollTimeout;
2295
2295
  constructor({
2296
2296
  container,
2297
2297
  refreshHitAreas
2298
2298
  }) {
2299
- this.container = container;
2300
- this.refreshHitAreas = refreshHitAreas;
2299
+ this._container = container;
2300
+ this._refreshHitAreas = refreshHitAreas;
2301
2301
  }
2302
2302
  checkHorizontalScrolling(pageX) {
2303
- const newHorizontalScrollDirection = this.getNewHorizontalScrollDirection(pageX);
2304
- if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {
2305
- this.horizontalScrollDirection = newHorizontalScrollDirection;
2306
- if (this.horizontalScrollTimeout != null) {
2307
- window.clearTimeout(this.horizontalScrollTimeout);
2303
+ const newHorizontalScrollDirection = this._getNewHorizontalScrollDirection(pageX);
2304
+ if (this._horizontalScrollDirection !== newHorizontalScrollDirection) {
2305
+ this._horizontalScrollDirection = newHorizontalScrollDirection;
2306
+ if (this._horizontalScrollTimeout != null) {
2307
+ window.clearTimeout(this._horizontalScrollTimeout);
2308
2308
  }
2309
2309
  if (newHorizontalScrollDirection) {
2310
- this.horizontalScrollTimeout = window.setTimeout(this.scrollHorizontally.bind(this), 40);
2310
+ this._horizontalScrollTimeout = window.setTimeout(this._scrollHorizontally.bind(this), 40);
2311
2311
  }
2312
2312
  }
2313
2313
  }
2314
2314
  checkVerticalScrolling(pageY) {
2315
- const newVerticalScrollDirection = this.getNewVerticalScrollDirection(pageY);
2316
- if (this.verticalScrollDirection !== newVerticalScrollDirection) {
2317
- this.verticalScrollDirection = newVerticalScrollDirection;
2318
- if (this.verticalScrollTimeout != null) {
2319
- window.clearTimeout(this.verticalScrollTimeout);
2320
- this.verticalScrollTimeout = undefined;
2315
+ const newVerticalScrollDirection = this._getNewVerticalScrollDirection(pageY);
2316
+ if (this._verticalScrollDirection !== newVerticalScrollDirection) {
2317
+ this._verticalScrollDirection = newVerticalScrollDirection;
2318
+ if (this._verticalScrollTimeout != null) {
2319
+ window.clearTimeout(this._verticalScrollTimeout);
2320
+ this._verticalScrollTimeout = undefined;
2321
2321
  }
2322
2322
  if (newVerticalScrollDirection) {
2323
- this.verticalScrollTimeout = window.setTimeout(this.scrollVertically.bind(this), 40);
2323
+ this._verticalScrollTimeout = window.setTimeout(this._scrollVertically.bind(this), 40);
2324
2324
  }
2325
2325
  }
2326
2326
  }
2327
2327
  getScrollLeft() {
2328
- return this.container.scrollLeft;
2328
+ return this._container.scrollLeft;
2329
2329
  }
2330
2330
  scrollToY(top) {
2331
- this.container.scrollTop = top;
2331
+ this._container.scrollTop = top;
2332
2332
  }
2333
2333
  stopScrolling() {
2334
- this.horizontalScrollDirection = undefined;
2335
- this.verticalScrollDirection = undefined;
2334
+ this._horizontalScrollDirection = undefined;
2335
+ this._verticalScrollDirection = undefined;
2336
2336
  }
2337
- scrollHorizontally() {
2338
- if (!this.horizontalScrollDirection) {
2337
+ _scrollHorizontally() {
2338
+ if (!this._horizontalScrollDirection) {
2339
2339
  return;
2340
2340
  }
2341
- const distance = this.horizontalScrollDirection === "left" ? -20 : 20;
2342
- this.container.scrollBy({
2341
+ const distance = this._horizontalScrollDirection === "left" ? -20 : 20;
2342
+ this._container.scrollBy({
2343
2343
  behavior: "instant",
2344
2344
  left: distance,
2345
2345
  top: 0
2346
2346
  });
2347
- this.refreshHitAreas();
2348
- setTimeout(this.scrollHorizontally.bind(this), 40);
2347
+ this._refreshHitAreas();
2348
+ setTimeout(this._scrollHorizontally.bind(this), 40);
2349
2349
  }
2350
- scrollVertically() {
2351
- if (!this.verticalScrollDirection) {
2350
+ _scrollVertically() {
2351
+ if (!this._verticalScrollDirection) {
2352
2352
  return;
2353
2353
  }
2354
- const distance = this.verticalScrollDirection === "top" ? -20 : 20;
2355
- this.container.scrollBy({
2354
+ const distance = this._verticalScrollDirection === "top" ? -20 : 20;
2355
+ this._container.scrollBy({
2356
2356
  behavior: "instant",
2357
2357
  left: 0,
2358
2358
  top: distance
2359
2359
  });
2360
- this.refreshHitAreas();
2361
- setTimeout(this.scrollVertically.bind(this), 40);
2360
+ this._refreshHitAreas();
2361
+ setTimeout(this._scrollVertically.bind(this), 40);
2362
2362
  }
2363
2363
  }
2364
2364
 
@@ -2367,12 +2367,12 @@ var jqtree = (function (exports) {
2367
2367
  _scrollParentTop;
2368
2368
  stopScrolling() {
2369
2369
  super.stopScrolling();
2370
- this.horizontalScrollDirection = undefined;
2371
- this.verticalScrollDirection = undefined;
2370
+ this._horizontalScrollDirection = undefined;
2371
+ this._verticalScrollDirection = undefined;
2372
2372
  }
2373
- getNewHorizontalScrollDirection(pageX) {
2374
- const scrollParentOffset = getElementPosition(this.container);
2375
- const containerWidth = this.container.getBoundingClientRect().width;
2373
+ _getNewHorizontalScrollDirection(pageX) {
2374
+ const scrollParentOffset = getElementPosition(this._container);
2375
+ const containerWidth = this._container.getBoundingClientRect().width;
2376
2376
  const rightEdge = scrollParentOffset.left + containerWidth;
2377
2377
  const leftEdge = scrollParentOffset.left;
2378
2378
  const isNearRightEdge = pageX > rightEdge - 20;
@@ -2384,7 +2384,7 @@ var jqtree = (function (exports) {
2384
2384
  }
2385
2385
  return undefined;
2386
2386
  }
2387
- getNewVerticalScrollDirection(pageY) {
2387
+ _getNewVerticalScrollDirection(pageY) {
2388
2388
  if (pageY < this._getScrollParentTop()) {
2389
2389
  return "top";
2390
2390
  }
@@ -2395,13 +2395,13 @@ var jqtree = (function (exports) {
2395
2395
  }
2396
2396
  _getScrollParentBottom() {
2397
2397
  if (this._scrollParentBottom == null) {
2398
- const containerHeight = this.container.getBoundingClientRect().height;
2398
+ const containerHeight = this._container.getBoundingClientRect().height;
2399
2399
  this._scrollParentBottom = this._getScrollParentTop() + containerHeight;
2400
2400
  }
2401
2401
  return this._scrollParentBottom;
2402
2402
  }
2403
2403
  _getScrollParentTop() {
2404
- this._scrollParentTop ??= getOffsetTop(this.container);
2404
+ this._scrollParentTop ??= getOffsetTop(this._container);
2405
2405
  return this._scrollParentTop;
2406
2406
  }
2407
2407
  }
@@ -2429,8 +2429,8 @@ var jqtree = (function (exports) {
2429
2429
  this._documentScrollHeight = undefined;
2430
2430
  this._documentScrollWidth = undefined;
2431
2431
  }
2432
- getNewHorizontalScrollDirection(pageX) {
2433
- const scrollLeft = this.container.scrollLeft;
2432
+ _getNewHorizontalScrollDirection(pageX) {
2433
+ const scrollLeft = this._container.scrollLeft;
2434
2434
  const windowWidth = window.innerWidth;
2435
2435
  const isNearRightEdge = pageX > windowWidth - 20;
2436
2436
  const isNearLeftEdge = pageX - scrollLeft < 20;
@@ -2442,8 +2442,8 @@ var jqtree = (function (exports) {
2442
2442
  }
2443
2443
  return undefined;
2444
2444
  }
2445
- getNewVerticalScrollDirection(pageY) {
2446
- const scrollTop = this.container.scrollTop;
2445
+ _getNewVerticalScrollDirection(pageY) {
2446
+ const scrollTop = this._container.scrollTop;
2447
2447
  const distanceTop = pageY - scrollTop;
2448
2448
  if (distanceTop < 20) {
2449
2449
  return "top";
@@ -2455,19 +2455,19 @@ var jqtree = (function (exports) {
2455
2455
  return undefined;
2456
2456
  }
2457
2457
  _canScrollDown() {
2458
- return this.container.scrollTop + this.container.clientHeight < this._getDocumentScrollHeight();
2458
+ return this._container.scrollTop + this._container.clientHeight < this._getDocumentScrollHeight();
2459
2459
  }
2460
2460
  _canScrollRight() {
2461
- return this.container.scrollLeft + this.container.clientWidth < this._getDocumentScrollWidth();
2461
+ return this._container.scrollLeft + this._container.clientWidth < this._getDocumentScrollWidth();
2462
2462
  }
2463
2463
  _getDocumentScrollHeight() {
2464
2464
  // Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.
2465
- this._documentScrollHeight ??= this.container.scrollHeight;
2465
+ this._documentScrollHeight ??= this._container.scrollHeight;
2466
2466
  return this._documentScrollHeight;
2467
2467
  }
2468
2468
  _getDocumentScrollWidth() {
2469
2469
  // Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.
2470
- this._documentScrollWidth ??= this.container.scrollWidth;
2470
+ this._documentScrollWidth ??= this._container.scrollWidth;
2471
2471
  return this._documentScrollWidth;
2472
2472
  }
2473
2473
  }
@@ -2632,157 +2632,57 @@ var jqtree = (function (exports) {
2632
2632
  }
2633
2633
  }
2634
2634
 
2635
- const register = (widgetClass, widgetName) => {
2636
- const getDataKey = () => `simple_widget_${widgetName}`;
2637
- const getWidgetData = (el, dataKey) => {
2638
- const widget = jQuery.data(el, dataKey);
2639
- if (widget && widget instanceof SimpleWidget) {
2640
- return widget;
2641
- } else {
2642
- return null;
2643
- }
2644
- };
2645
- const createWidget = ($el, options) => {
2646
- const dataKey = getDataKey();
2647
- for (const el of $el.get()) {
2648
- const existingWidget = getWidgetData(el, dataKey);
2649
- if (!existingWidget) {
2650
- const simpleWidgetClass = widgetClass;
2651
- const widget = new simpleWidgetClass(el, options);
2652
- if (!jQuery.data(el, dataKey)) {
2653
- jQuery.data(el, dataKey, widget);
2654
- }
2655
-
2656
- // Call init after setting data, so we can call methods
2657
- widget.init();
2658
- }
2659
- }
2660
- return $el;
2661
- };
2662
- const destroyWidget = $el => {
2663
- const dataKey = getDataKey();
2664
- for (const el of $el.get()) {
2665
- const widget = getWidgetData(el, dataKey);
2666
- if (widget) {
2667
- widget.destroy();
2668
- }
2669
- jQuery.removeData(el, dataKey);
2670
- }
2671
- };
2672
- const callFunction = ($el, functionName, args) => {
2673
- let result = null;
2674
- for (const el of $el.get()) {
2675
- const widget = jQuery.data(el, getDataKey());
2676
- if (widget && widget instanceof SimpleWidget) {
2677
- const simpleWidget = widget;
2678
- const widgetFunction = simpleWidget[functionName];
2679
- if (widgetFunction && typeof widgetFunction === "function") {
2680
- result = widgetFunction.apply(widget, args);
2681
- }
2682
- }
2683
- }
2684
- return result;
2685
- };
2686
-
2687
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2688
- jQuery.fn[widgetName] = function (argument1, ...args) {
2689
- if (!argument1) {
2690
- return createWidget(this, null);
2691
- } else if (typeof argument1 === "object") {
2692
- const options = argument1;
2693
- return createWidget(this, options);
2694
- } else if (typeof argument1 === "string" && argument1[0] !== "_") {
2695
- const functionName = argument1;
2696
- if (argument1 === "destroy") {
2697
- destroyWidget(this);
2698
- return undefined;
2699
- } else {
2700
- return callFunction(this, functionName, args);
2701
- }
2702
- } else {
2703
- return undefined;
2704
- }
2705
- };
2635
+ const version = "1.9.1";
2636
+
2637
+ const defaults = {
2638
+ animationSpeed: "fast",
2639
+ autoEscape: true,
2640
+ autoOpen: false,
2641
+ // true / false / int (open n levels starting at 0)
2642
+ buttonLeft: true,
2643
+ // The symbol to use for a closed node - ► BLACK RIGHT-POINTING POINTER
2644
+ // http://www.fileformat.info/info/unicode/char/25ba/index.htm
2645
+ closedIcon: undefined,
2646
+ data: undefined,
2647
+ dataFilter: undefined,
2648
+ dataUrl: undefined,
2649
+ dragAndDrop: false,
2650
+ keyboardSupport: true,
2651
+ nodeClass: Node,
2652
+ onCanMove: undefined,
2653
+ // Can this node be moved?
2654
+ onCanMoveTo: undefined,
2655
+ // Can this node be moved to this position? function(moved_node, target_node, position)
2656
+ onCanSelectNode: undefined,
2657
+ onCreateLi: undefined,
2658
+ onDragMove: undefined,
2659
+ onDragStop: undefined,
2660
+ onGetStateFromStorage: undefined,
2661
+ onIsMoveHandle: undefined,
2662
+ onLoadFailed: undefined,
2663
+ onLoading: undefined,
2664
+ onSetStateFromStorage: undefined,
2665
+ openedIcon: "&#x25bc;",
2666
+ openFolderDelay: 500,
2667
+ // The delay for opening a folder during drag and drop; the value is in milliseconds
2668
+ // The symbol to use for an open node - ▼ BLACK DOWN-POINTING TRIANGLE
2669
+ // http://www.fileformat.info/info/unicode/char/25bc/index.htm
2670
+ rtl: undefined,
2671
+ // right-to-left support; true / false (default)
2672
+ saveState: false,
2673
+ // true / false / string (cookie name)
2674
+ selectable: true,
2675
+ showEmptyFolder: false,
2676
+ slide: true,
2677
+ // must display slide animation?
2678
+ startDndDelay: 300,
2679
+ // The delay for starting dnd (in milliseconds)
2680
+ tabIndex: 0,
2681
+ useContextMenu: true
2706
2682
  };
2707
- class SimpleWidget {
2708
- static defaults = {};
2709
- $el;
2710
- options;
2711
- constructor(el, options) {
2712
- this.$el = jQuery(el);
2713
-
2714
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2715
- const defaults = this.constructor.defaults;
2716
- this.options = {
2717
- ...defaults,
2718
- ...options
2719
- };
2720
- }
2721
- static register(widgetClass, widgetName) {
2722
- register(widgetClass, widgetName);
2723
- }
2724
- deinit() {
2725
- //
2726
- }
2727
- destroy() {
2728
- this.deinit();
2729
- }
2730
- init() {
2731
- //
2732
- }
2733
- }
2734
-
2735
- const version = "1.9.0";
2736
-
2737
2683
  const NODE_PARAM_IS_EMPTY = "Node parameter is empty";
2738
2684
  const PARAM_IS_EMPTY = "Parameter is empty: ";
2739
- class JqTreeWidget extends SimpleWidget {
2740
- static defaults = {
2741
- animationSpeed: "fast",
2742
- autoEscape: true,
2743
- autoOpen: false,
2744
- // true / false / int (open n levels starting at 0)
2745
- buttonLeft: true,
2746
- // The symbol to use for a closed node - ► BLACK RIGHT-POINTING POINTER
2747
- // http://www.fileformat.info/info/unicode/char/25ba/index.htm
2748
- closedIcon: undefined,
2749
- data: undefined,
2750
- dataFilter: undefined,
2751
- dataUrl: undefined,
2752
- dragAndDrop: false,
2753
- keyboardSupport: true,
2754
- nodeClass: Node,
2755
- onCanMove: undefined,
2756
- // Can this node be moved?
2757
- onCanMoveTo: undefined,
2758
- // Can this node be moved to this position? function(moved_node, target_node, position)
2759
- onCanSelectNode: undefined,
2760
- onCreateLi: undefined,
2761
- onDragMove: undefined,
2762
- onDragStop: undefined,
2763
- onGetStateFromStorage: undefined,
2764
- onIsMoveHandle: undefined,
2765
- onLoadFailed: undefined,
2766
- onLoading: undefined,
2767
- onSetStateFromStorage: undefined,
2768
- openedIcon: "&#x25bc;",
2769
- openFolderDelay: 500,
2770
- // The delay for opening a folder during drag and drop; the value is in milliseconds
2771
- // The symbol to use for an open node - ▼ BLACK DOWN-POINTING TRIANGLE
2772
- // http://www.fileformat.info/info/unicode/char/25bc/index.htm
2773
- rtl: undefined,
2774
- // right-to-left support; true / false (default)
2775
- saveState: false,
2776
- // true / false / string (cookie name)
2777
- selectable: true,
2778
- showEmptyFolder: false,
2779
- slide: true,
2780
- // must display slide animation?
2781
- startDndDelay: 300,
2782
- // The delay for starting dnd (in milliseconds)
2783
- tabIndex: 0,
2784
- useContextMenu: true
2785
- };
2685
+ class JqTreeWidget {
2786
2686
  _dataLoader;
2787
2687
  _dndHandler;
2788
2688
  _element;
@@ -2790,11 +2690,20 @@ var jqtree = (function (exports) {
2790
2690
  _isInitialized;
2791
2691
  _keyHandler;
2792
2692
  _mouseHandler;
2693
+ _options;
2793
2694
  _renderer;
2794
2695
  _saveStateHandler;
2795
2696
  _scrollHandler;
2796
2697
  _selectNodeHandler;
2797
2698
  _tree;
2699
+ constructor(el, options) {
2700
+ this._htmlElement = el;
2701
+ this._element = jQuery(el);
2702
+ this._options = {
2703
+ ...defaults,
2704
+ ...options
2705
+ };
2706
+ }
2798
2707
  addNodeAfter(newNodeInfo, existingNode) {
2799
2708
  const newNode = existingNode.addAfter(newNodeInfo);
2800
2709
  if (newNode) {
@@ -2842,9 +2751,9 @@ var jqtree = (function (exports) {
2842
2751
  if (!node) {
2843
2752
  throw Error(NODE_PARAM_IS_EMPTY);
2844
2753
  }
2845
- const slide = slideParam ?? this.options.slide;
2754
+ const slide = slideParam ?? this._options.slide;
2846
2755
  if (node.isFolder() || node.isEmptyFolder) {
2847
- this._createFolderElement(node).close(slide, this.options.animationSpeed);
2756
+ this._createFolderElement(node).close(slide, this._options.animationSpeed);
2848
2757
  this._saveState();
2849
2758
  }
2850
2759
  return this._element;
@@ -2855,7 +2764,9 @@ var jqtree = (function (exports) {
2855
2764
  this._keyHandler.deinit();
2856
2765
  this._mouseHandler.deinit();
2857
2766
  this._tree = new Node({}, true);
2858
- super.deinit();
2767
+ }
2768
+ destroy() {
2769
+ this.deinit();
2859
2770
  }
2860
2771
  getNodeByCallback(callback) {
2861
2772
  return this._tree.getNodeByCallback(callback);
@@ -2898,14 +2809,13 @@ var jqtree = (function (exports) {
2898
2809
  return version;
2899
2810
  }
2900
2811
  init() {
2901
- super.init();
2902
- this._element = this.$el;
2903
- this._htmlElement = this._element.get(0);
2812
+ const htmlElement = this._element.get(0);
2813
+ this._htmlElement = htmlElement;
2904
2814
  this._isInitialized = false;
2905
- this.options.dataUrl ??= this._element.data("url");
2815
+ this._options.dataUrl ??= this._element.data("url");
2906
2816
  const dataRtl = this._element.data("rtl");
2907
- this.options.rtl ??= dataRtl === '' ? true : Boolean(dataRtl);
2908
- this.options.closedIcon ??= this._getDefaultClosedIcon();
2817
+ this._options.rtl ??= dataRtl === '' ? true : Boolean(dataRtl);
2818
+ this._options.closedIcon ??= this._getDefaultClosedIcon();
2909
2819
  this._connectHandlers();
2910
2820
  this._initData();
2911
2821
  }
@@ -2988,7 +2898,7 @@ var jqtree = (function (exports) {
2988
2898
  slide = param1;
2989
2899
  onFinished = param2;
2990
2900
  }
2991
- slide ??= this.options.slide;
2901
+ slide ??= this._options.slide;
2992
2902
  return [slide, onFinished];
2993
2903
  };
2994
2904
  const [slide, onFinished] = parseParams();
@@ -3048,7 +2958,7 @@ var jqtree = (function (exports) {
3048
2958
  return this._element;
3049
2959
  }
3050
2960
  setOption(option, value) {
3051
- this.options[option] = value;
2961
+ this._options[option] = value;
3052
2962
  return this._element;
3053
2963
  }
3054
2964
  setState(state) {
@@ -3062,7 +2972,7 @@ var jqtree = (function (exports) {
3062
2972
  if (!node) {
3063
2973
  throw Error(NODE_PARAM_IS_EMPTY);
3064
2974
  }
3065
- const slide = slideParam ?? this.options.slide;
2975
+ const slide = slideParam ?? this._options.slide;
3066
2976
  if (node.is_open) {
3067
2977
  this.closeNode(node, slide);
3068
2978
  } else {
@@ -3122,7 +3032,7 @@ var jqtree = (function (exports) {
3122
3032
  showEmptyFolder,
3123
3033
  slide,
3124
3034
  tabIndex
3125
- } = this.options;
3035
+ } = this._options;
3126
3036
  const closeNode = this.closeNode.bind(this);
3127
3037
  const getNodeElement = this._getNodeElement.bind(this);
3128
3038
  const getNodeElementForNode = this._getNodeElementForNode.bind(this);
@@ -3143,7 +3053,7 @@ var jqtree = (function (exports) {
3143
3053
  const getSelectedNodes = selectNodeHandler.getSelectedNodes.bind(selectNodeHandler);
3144
3054
  const isNodeSelected = selectNodeHandler.isNodeSelected.bind(selectNodeHandler);
3145
3055
  const removeFromSelection = selectNodeHandler.removeFromSelection.bind(selectNodeHandler);
3146
- const getMouseDelay = () => this.options.startDndDelay ?? 0;
3056
+ const getMouseDelay = () => this._options.startDndDelay ?? 0;
3147
3057
  const refreshHitAreas = () => {
3148
3058
  dndHandler.refresh();
3149
3059
  };
@@ -3228,7 +3138,7 @@ var jqtree = (function (exports) {
3228
3138
  onMouseStart,
3229
3139
  onMouseStop,
3230
3140
  triggerEvent,
3231
- useContextMenu: this.options.useContextMenu
3141
+ useContextMenu: this._options.useContextMenu
3232
3142
  });
3233
3143
  this._dataLoader = dataLoader;
3234
3144
  this._dndHandler = dndHandler;
@@ -3239,15 +3149,11 @@ var jqtree = (function (exports) {
3239
3149
  this._scrollHandler = scrollHandler;
3240
3150
  this._selectNodeHandler = selectNodeHandler;
3241
3151
  }
3242
- _containsElement(element) {
3243
- const node = this._getNode(element);
3244
- return node?.tree === this._tree;
3245
- }
3246
3152
  _createFolderElement(node) {
3247
3153
  const closedIconElement = this._renderer.closedIconElement;
3248
3154
  const getScrollLeft = this._scrollHandler.getScrollLeft.bind(this._scrollHandler);
3249
3155
  const openedIconElement = this._renderer.openedIconElement;
3250
- const tabIndex = this.options.tabIndex;
3156
+ const tabIndex = this._options.tabIndex;
3251
3157
  const triggerEvent = this._triggerEvent.bind(this);
3252
3158
  return new FolderElement({
3253
3159
  closedIconElement,
@@ -3261,7 +3167,7 @@ var jqtree = (function (exports) {
3261
3167
  }
3262
3168
  _createNodeElement(node) {
3263
3169
  const getScrollLeft = this._scrollHandler.getScrollLeft.bind(this._scrollHandler);
3264
- const tabIndex = this.options.tabIndex;
3170
+ const tabIndex = this._options.tabIndex;
3265
3171
  return new NodeElement({
3266
3172
  getScrollLeft,
3267
3173
  node,
@@ -3304,7 +3210,7 @@ var jqtree = (function (exports) {
3304
3210
  }
3305
3211
  _doSelectNode(node, optionsParam) {
3306
3212
  const saveState = () => {
3307
- if (this.options.saveState) {
3213
+ if (this._options.saveState) {
3308
3214
  this._saveStateHandler.saveState();
3309
3215
  }
3310
3216
  };
@@ -3323,10 +3229,10 @@ var jqtree = (function (exports) {
3323
3229
  ...(optionsParam ?? {})
3324
3230
  };
3325
3231
  const canSelect = () => {
3326
- if (this.options.onCanSelectNode) {
3327
- return this.options.selectable && this.options.onCanSelectNode(node);
3232
+ if (this._options.onCanSelectNode) {
3233
+ return this._options.selectable && this._options.onCanSelectNode(node);
3328
3234
  } else {
3329
- return this.options.selectable;
3235
+ return this._options.selectable;
3330
3236
  }
3331
3237
  };
3332
3238
  if (!canSelect()) {
@@ -3353,12 +3259,12 @@ var jqtree = (function (exports) {
3353
3259
  saveState();
3354
3260
  }
3355
3261
  _getAutoOpenMaxLevel() {
3356
- if (this.options.autoOpen === true) {
3262
+ if (this._options.autoOpen === true) {
3357
3263
  return -1;
3358
- } else if (typeof this.options.autoOpen === "number") {
3359
- return this.options.autoOpen;
3360
- } else if (typeof this.options.autoOpen === "string") {
3361
- return parseInt(this.options.autoOpen, 10);
3264
+ } else if (typeof this._options.autoOpen === "number") {
3265
+ return this._options.autoOpen;
3266
+ } else if (typeof this._options.autoOpen === "string") {
3267
+ return parseInt(this._options.autoOpen, 10);
3362
3268
  } else {
3363
3269
  return 0;
3364
3270
  }
@@ -3389,7 +3295,7 @@ var jqtree = (function (exports) {
3389
3295
  }
3390
3296
  }
3391
3297
  };
3392
- const dataUrl = this.options.dataUrl;
3298
+ const dataUrl = this._options.dataUrl;
3393
3299
  if (typeof dataUrl === "function") {
3394
3300
  return dataUrl(node);
3395
3301
  } else if (typeof dataUrl === "string") {
@@ -3402,7 +3308,7 @@ var jqtree = (function (exports) {
3402
3308
  }
3403
3309
  }
3404
3310
  _getDefaultClosedIcon() {
3405
- if (this.options.rtl) {
3311
+ if (this._options.rtl) {
3406
3312
  // triangle to the left
3407
3313
  return "&#x25c0;";
3408
3314
  } else {
@@ -3434,15 +3340,15 @@ var jqtree = (function (exports) {
3434
3340
  }
3435
3341
  }
3436
3342
  _getNodeIdToBeSelected() {
3437
- if (this.options.saveState) {
3343
+ if (this._options.saveState) {
3438
3344
  return this._saveStateHandler.getNodeIdToBeSelected();
3439
3345
  } else {
3440
3346
  return null;
3441
3347
  }
3442
3348
  }
3443
3349
  _initData() {
3444
- if (this.options.data) {
3445
- this._doLoadData(this.options.data, null);
3350
+ if (this._options.data) {
3351
+ this._doLoadData(this._options.data, null);
3446
3352
  } else {
3447
3353
  const dataUrl = this._getDataUrlInfo(null);
3448
3354
  if (dataUrl) {
@@ -3459,21 +3365,35 @@ var jqtree = (function (exports) {
3459
3365
  this._triggerEvent("tree.init");
3460
3366
  }
3461
3367
  };
3462
- this._tree = new this.options.nodeClass(null, true, this.options.nodeClass);
3368
+ this._tree = new this._options.nodeClass(null, true, this._options.nodeClass);
3463
3369
  this._selectNodeHandler.clear();
3464
3370
  this._tree.loadFromData(data);
3465
3371
  const mustLoadOnDemand = this._setInitialState();
3466
3372
  this._refreshElements(null);
3467
- if (!mustLoadOnDemand) {
3468
- doInit();
3469
- } else {
3373
+ if (mustLoadOnDemand) {
3470
3374
  // Load data on demand and then init the tree
3471
3375
  this._setInitialStateOnDemand(doInit);
3376
+ } else {
3377
+ doInit();
3472
3378
  }
3473
3379
  }
3380
+
3381
+ // Does an element in the tree have the focus?
3474
3382
  _isFocusOnTree() {
3475
3383
  const activeElement = document.activeElement;
3476
- return activeElement?.tagName === "SPAN" && this._containsElement(activeElement);
3384
+
3385
+ /* istanbul ignore if */
3386
+ if (!activeElement) {
3387
+ return false;
3388
+ }
3389
+
3390
+ // The keyboard must still work for input elements.
3391
+ const tagName = activeElement.tagName;
3392
+ if (tagName !== "A" && tagName !== "SPAN") {
3393
+ return false;
3394
+ }
3395
+ const node = this._getNode(activeElement);
3396
+ return node?.tree === this._tree;
3477
3397
  }
3478
3398
  _isSelectedNodeInSubtree(subtree) {
3479
3399
  const selectedNode = this.getSelectedNode();
@@ -3496,35 +3416,34 @@ var jqtree = (function (exports) {
3496
3416
  this._refreshElements(parentNode);
3497
3417
  }
3498
3418
  _mouseCapture(positionInfo) {
3499
- if (this.options.dragAndDrop) {
3500
- return this._dndHandler.mouseCapture(positionInfo);
3501
- } else {
3419
+ if (!this._options.dragAndDrop) {
3502
3420
  return false;
3503
3421
  }
3422
+ return this._dndHandler.mouseCapture(positionInfo);
3504
3423
  }
3505
3424
  _mouseDrag(positionInfo) {
3506
- if (this.options.dragAndDrop) {
3507
- const result = this._dndHandler.mouseDrag(positionInfo);
3508
- this._scrollHandler.checkScrolling(positionInfo);
3509
- return result;
3510
- } else {
3425
+ /* istanbul ignore if */
3426
+ if (!this._options.dragAndDrop) {
3511
3427
  return false;
3512
3428
  }
3429
+ const result = this._dndHandler.mouseDrag(positionInfo);
3430
+ this._scrollHandler.checkScrolling(positionInfo);
3431
+ return result;
3513
3432
  }
3514
3433
  _mouseStart(positionInfo) {
3515
- if (this.options.dragAndDrop) {
3516
- return this._dndHandler.mouseStart(positionInfo);
3517
- } else {
3434
+ /* istanbul ignore if */
3435
+ if (!this._options.dragAndDrop) {
3518
3436
  return false;
3519
3437
  }
3438
+ return this._dndHandler.mouseStart(positionInfo);
3520
3439
  }
3521
3440
  _mouseStop(positionInfo) {
3522
- if (this.options.dragAndDrop) {
3523
- this._scrollHandler.stopScrolling();
3524
- return this._dndHandler.mouseStop(positionInfo);
3525
- } else {
3441
+ /* istanbul ignore if */
3442
+ if (!this._options.dragAndDrop) {
3526
3443
  return false;
3527
3444
  }
3445
+ this._scrollHandler.stopScrolling();
3446
+ return this._dndHandler.mouseStop(positionInfo);
3528
3447
  }
3529
3448
  _openNodeInternal(node, slide = true, onFinished) {
3530
3449
  const doOpenNode = (_node, _slide, _onFinished) => {
@@ -3532,7 +3451,7 @@ var jqtree = (function (exports) {
3532
3451
  return;
3533
3452
  }
3534
3453
  const folderElement = this._createFolderElement(_node);
3535
- folderElement.open(_onFinished, _slide, this.options.animationSpeed);
3454
+ folderElement.open(_onFinished, _slide, this._options.animationSpeed);
3536
3455
  };
3537
3456
  if (node.isFolder() || node.isEmptyFolder) {
3538
3457
  if (node.load_on_demand) {
@@ -3572,7 +3491,7 @@ var jqtree = (function (exports) {
3572
3491
  this._triggerEvent("tree.refresh");
3573
3492
  }
3574
3493
  _saveState() {
3575
- if (this.options.saveState) {
3494
+ if (this._options.saveState) {
3576
3495
  this._saveStateHandler.saveState();
3577
3496
  }
3578
3497
  }
@@ -3589,7 +3508,7 @@ var jqtree = (function (exports) {
3589
3508
  _setInitialState() {
3590
3509
  const restoreState = () => {
3591
3510
  // result: is state restored, must load on demand?
3592
- if (!this.options.saveState) {
3511
+ if (!this._options.saveState) {
3593
3512
  return [false, false];
3594
3513
  } else {
3595
3514
  const state = this._saveStateHandler.getStateFromStorage();
@@ -3605,7 +3524,7 @@ var jqtree = (function (exports) {
3605
3524
  };
3606
3525
  const autoOpenNodes = () => {
3607
3526
  // result: must load on demand?
3608
- if (this.options.autoOpen === false) {
3527
+ if (this._options.autoOpen === false) {
3609
3528
  return false;
3610
3529
  }
3611
3530
  const maxLevel = this._getAutoOpenMaxLevel();
@@ -3635,16 +3554,12 @@ var jqtree = (function (exports) {
3635
3554
  // Call cb_finished when done
3636
3555
  _setInitialStateOnDemand(cbFinished) {
3637
3556
  const restoreState = () => {
3638
- if (!this.options.saveState) {
3557
+ const state = this._saveStateHandler.getStateFromStorage();
3558
+ if (!state) {
3639
3559
  return false;
3640
3560
  } else {
3641
- const state = this._saveStateHandler.getStateFromStorage();
3642
- if (!state) {
3643
- return false;
3644
- } else {
3645
- this._saveStateHandler.setInitialStateOnDemand(state, cbFinished);
3646
- return true;
3647
- }
3561
+ this._saveStateHandler.setInitialStateOnDemand(state, cbFinished);
3562
+ return true;
3648
3563
  }
3649
3564
  };
3650
3565
  const autoOpenNodes = () => {
@@ -3685,7 +3600,74 @@ var jqtree = (function (exports) {
3685
3600
  return !event.isDefaultPrevented();
3686
3601
  }
3687
3602
  }
3688
- SimpleWidget.register(JqTreeWidget, "tree");
3603
+ const register = () => {
3604
+ const getWidgetData = (el, dataKey) => {
3605
+ const widget = jQuery.data(el, dataKey);
3606
+ if (widget && widget instanceof JqTreeWidget) {
3607
+ return widget;
3608
+ } else {
3609
+ return null;
3610
+ }
3611
+ };
3612
+ const createWidget = ($el, options) => {
3613
+ for (const el of $el.get()) {
3614
+ const existingWidget = getWidgetData(el, "jqtree");
3615
+ if (!existingWidget) {
3616
+ const widget = new JqTreeWidget(el, options ?? {});
3617
+ if (!jQuery.data(el, "jqtree")) {
3618
+ jQuery.data(el, "jqtree", widget);
3619
+ }
3620
+
3621
+ // Call init after setting data, so we can call methods
3622
+ widget.init();
3623
+ }
3624
+ }
3625
+ return $el;
3626
+ };
3627
+ const destroyWidget = $el => {
3628
+ for (const el of $el.get()) {
3629
+ const widget = getWidgetData(el, "jqtree");
3630
+ if (widget) {
3631
+ widget.destroy();
3632
+ }
3633
+ jQuery.removeData(el, "jqtree");
3634
+ }
3635
+ };
3636
+ const callFunction = ($el, functionName, args) => {
3637
+ let result = null;
3638
+ for (const el of $el.get()) {
3639
+ const widget = jQuery.data(el, "jqtree");
3640
+ if (widget && widget instanceof JqTreeWidget) {
3641
+ const widgetFunction = widget[functionName];
3642
+ if (widgetFunction && typeof widgetFunction === "function") {
3643
+ result = widgetFunction.apply(widget, args);
3644
+ }
3645
+ }
3646
+ }
3647
+ return result;
3648
+ };
3649
+
3650
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3651
+ jQuery.fn.tree = function (argument1, ...args) {
3652
+ if (!argument1) {
3653
+ return createWidget(this, null);
3654
+ } else if (typeof argument1 === "object") {
3655
+ const options = argument1;
3656
+ return createWidget(this, options);
3657
+ } else if (typeof argument1 === "string" && argument1[0] !== "_") {
3658
+ const functionName = argument1;
3659
+ if (argument1 === "destroy") {
3660
+ destroyWidget(this);
3661
+ return undefined;
3662
+ } else {
3663
+ return callFunction(this, functionName, args);
3664
+ }
3665
+ } else {
3666
+ return undefined;
3667
+ }
3668
+ };
3669
+ };
3670
+ register();
3689
3671
 
3690
3672
  exports.JqTreeWidget = JqTreeWidget;
3691
3673