wunderbaum 0.8.0 → 0.8.2

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.
@@ -298,7 +298,7 @@ function throttle(func, wait = 0, options = {}) {
298
298
  /*!
299
299
  * Wunderbaum - util
300
300
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
301
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
301
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
302
302
  */
303
303
  /** @module util */
304
304
  /** Readable names for `MouseEvent.button` */
@@ -1096,7 +1096,7 @@ var util = /*#__PURE__*/Object.freeze({
1096
1096
  /*!
1097
1097
  * Wunderbaum - types
1098
1098
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1099
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1099
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1100
1100
  */
1101
1101
  /**
1102
1102
  * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
@@ -1160,7 +1160,7 @@ var NavModeEnum;
1160
1160
  /*!
1161
1161
  * Wunderbaum - wb_extension_base
1162
1162
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1163
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1163
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1164
1164
  */
1165
1165
  class WunderbaumExtension {
1166
1166
  constructor(tree, id, defaults) {
@@ -1219,7 +1219,7 @@ class WunderbaumExtension {
1219
1219
  /*!
1220
1220
  * Wunderbaum - ext-filter
1221
1221
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1222
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1222
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1223
1223
  */
1224
1224
  const START_MARKER = "\uFFF7";
1225
1225
  const END_MARKER = "\uFFF8";
@@ -1524,7 +1524,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
1524
1524
  /*!
1525
1525
  * Wunderbaum - ext-keynav
1526
1526
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1527
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1527
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1528
1528
  */
1529
1529
  const QUICKSEARCH_DELAY = 500;
1530
1530
  class KeynavExtension extends WunderbaumExtension {
@@ -1888,7 +1888,7 @@ class KeynavExtension extends WunderbaumExtension {
1888
1888
  /*!
1889
1889
  * Wunderbaum - ext-logger
1890
1890
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1891
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1891
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1892
1892
  */
1893
1893
  class LoggerExtension extends WunderbaumExtension {
1894
1894
  constructor(tree) {
@@ -1930,7 +1930,7 @@ class LoggerExtension extends WunderbaumExtension {
1930
1930
  /*!
1931
1931
  * Wunderbaum - common
1932
1932
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1933
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
1933
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
1934
1934
  */
1935
1935
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
1936
1936
  /**
@@ -2253,7 +2253,7 @@ function decompressSourceData(source) {
2253
2253
  /*!
2254
2254
  * Wunderbaum - ext-dnd
2255
2255
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2256
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
2256
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
2257
2257
  */
2258
2258
  const nodeMimeType = "application/x-wunderbaum-node";
2259
2259
  class DndExtension extends WunderbaumExtension {
@@ -2492,7 +2492,7 @@ class DndExtension extends WunderbaumExtension {
2492
2492
  const dndOpts = this.treeOpts.dnd;
2493
2493
  const srcNode = Wunderbaum.getNode(e);
2494
2494
  if (!srcNode) {
2495
- this.tree.logWarn(`onDragEvent.${e.type} no node`);
2495
+ this.tree.logWarn(`onDragEvent.${e.type}: no node`);
2496
2496
  return;
2497
2497
  }
2498
2498
  if (["dragstart", "dragend"].includes(e.type)) {
@@ -2567,6 +2567,13 @@ class DndExtension extends WunderbaumExtension {
2567
2567
  const dndOpts = this.treeOpts.dnd;
2568
2568
  const dt = e.dataTransfer;
2569
2569
  const dropRegion = this._calcDropRegion(e, this.lastAllowedDropRegions);
2570
+ /** Helper to log a message if predicate is false. */
2571
+ const _t = (pred, msg) => {
2572
+ if (pred) {
2573
+ this.tree.log(`Prevented drop operation (${msg}).`);
2574
+ }
2575
+ return pred;
2576
+ };
2570
2577
  if (!targetNode) {
2571
2578
  this._leaveNode();
2572
2579
  return;
@@ -2577,6 +2584,7 @@ class DndExtension extends WunderbaumExtension {
2577
2584
  }
2578
2585
  // --- dragenter ---
2579
2586
  if (e.type === "dragenter") {
2587
+ // this.tree.logWarn(` onDropEvent.${e.type} targetNode: ${targetNode}`, e);
2580
2588
  this.lastAllowedDropRegions = null;
2581
2589
  // `dragleave` is not reliable with event delegation, so we generate it
2582
2590
  // from dragenter:
@@ -2587,29 +2595,32 @@ class DndExtension extends WunderbaumExtension {
2587
2595
  this.lastEnterStamp = Date.now();
2588
2596
  if (
2589
2597
  // Don't drop on status node:
2590
- targetNode.isStatusNode() ||
2598
+ _t(targetNode.isStatusNode(), "is status node") ||
2591
2599
  // Prevent dropping nodes from different Wunderbaum trees:
2592
- (dndOpts.preventForeignNodes && targetNode.tree !== srcTree) ||
2600
+ _t(dndOpts.preventForeignNodes && targetNode.tree !== srcTree, "preventForeignNodes") ||
2593
2601
  // Prevent dropping items on unloaded lazy Wunderbaum tree nodes:
2594
- (dndOpts.preventLazyParents && !targetNode.isLoaded()) ||
2602
+ _t(dndOpts.preventLazyParents && !targetNode.isLoaded(), "preventLazyParents") ||
2595
2603
  // Prevent dropping items other than Wunderbaum tree nodes:
2596
- (dndOpts.preventNonNodes && !srcNode) ||
2604
+ _t(dndOpts.preventNonNodes && !srcNode, "preventNonNodes") ||
2597
2605
  // Prevent dropping nodes on own descendants:
2598
- (dndOpts.preventRecursion && (srcNode === null || srcNode === void 0 ? void 0 : srcNode.isAncestorOf(targetNode))) ||
2606
+ _t(dndOpts.preventRecursion && (srcNode === null || srcNode === void 0 ? void 0 : srcNode.isAncestorOf(targetNode)), "preventRecursion") ||
2599
2607
  // Prevent dropping nodes under same direct parent:
2600
- (dndOpts.preventSameParent &&
2608
+ _t(dndOpts.preventSameParent &&
2601
2609
  srcNode &&
2602
- targetNode.parent === srcNode.parent) ||
2610
+ targetNode.parent === srcNode.parent, "preventSameParent") ||
2603
2611
  // Don't allow void operation ('drop on self'): TODO: should be checked on move only
2604
- (dndOpts.preventVoidMoves && targetNode === srcNode)) {
2612
+ _t(dndOpts.preventVoidMoves && targetNode === srcNode, "preventVoidMoves")) {
2605
2613
  dt.dropEffect = "none";
2606
- this.tree.log("Prevented drop operation");
2614
+ // this.tree.log("Prevented drop operation");
2607
2615
  return true; // Prevent drop operation
2608
2616
  }
2609
2617
  // User may return a set of regions (or `false` to prevent drop)
2610
2618
  // Figure out a drop effect (copy/link/move) using opinated conventions.
2611
2619
  dt.dropEffect = this._guessDropEffect(e) || "none";
2612
- let regionSet = targetNode._callEvent("dnd.dragEnter", { event: e });
2620
+ let regionSet = targetNode._callEvent("dnd.dragEnter", {
2621
+ event: e,
2622
+ sourceNode: srcNode,
2623
+ });
2613
2624
  //
2614
2625
  regionSet = this.unifyDragover(regionSet);
2615
2626
  if (!regionSet) {
@@ -2627,7 +2638,7 @@ class DndExtension extends WunderbaumExtension {
2627
2638
  const viewportY = e.clientY - this.tree.element.offsetTop;
2628
2639
  this._autoScroll(viewportY);
2629
2640
  dt.dropEffect = this._guessDropEffect(e) || "none";
2630
- targetNode._callEvent("dnd.dragOver", { event: e });
2641
+ targetNode._callEvent("dnd.dragOver", { event: e, sourceNode: srcNode });
2631
2642
  const region = this._calcDropRegion(e, this.lastAllowedDropRegions);
2632
2643
  this.lastDropRegion = region;
2633
2644
  this.lastDropEffect = dt.dropEffect;
@@ -2635,7 +2646,10 @@ class DndExtension extends WunderbaumExtension {
2635
2646
  targetNode.isExpandable(true) &&
2636
2647
  !targetNode._isLoading &&
2637
2648
  Date.now() - this.lastEnterStamp > dndOpts.autoExpandMS &&
2638
- targetNode._callEvent("dnd.dragExpand", { event: e }) !== false) {
2649
+ targetNode._callEvent("dnd.dragExpand", {
2650
+ event: e,
2651
+ sourceNode: srcNode,
2652
+ }) !== false) {
2639
2653
  targetNode.setExpanded();
2640
2654
  }
2641
2655
  if (!region || this._isVoidDrop(targetNode, srcNode, region)) {
@@ -2651,7 +2665,7 @@ class DndExtension extends WunderbaumExtension {
2651
2665
  else if (e.type === "dragleave") {
2652
2666
  // NOTE: we cannot trust this event, since it is always fired,
2653
2667
  // Instead we remove the marker on dragenter
2654
- targetNode._callEvent("dnd.dragLeave", { event: e });
2668
+ targetNode._callEvent("dnd.dragLeave", { event: e, sourceNode: srcNode });
2655
2669
  // --- drop ---
2656
2670
  }
2657
2671
  else if (e.type === "drop") {
@@ -2684,7 +2698,7 @@ class DndExtension extends WunderbaumExtension {
2684
2698
  /*!
2685
2699
  * Wunderbaum - drag_observer
2686
2700
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2687
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
2701
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
2688
2702
  */
2689
2703
  /**
2690
2704
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2820,7 +2834,7 @@ class DragObserver {
2820
2834
  /*!
2821
2835
  * Wunderbaum - ext-grid
2822
2836
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2823
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
2837
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
2824
2838
  */
2825
2839
  class GridExtension extends WunderbaumExtension {
2826
2840
  constructor(tree) {
@@ -2857,7 +2871,7 @@ class GridExtension extends WunderbaumExtension {
2857
2871
  /*!
2858
2872
  * Wunderbaum - deferred
2859
2873
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2860
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
2874
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
2861
2875
  */
2862
2876
  /**
2863
2877
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -2910,7 +2924,7 @@ class Deferred {
2910
2924
  /*!
2911
2925
  * Wunderbaum - wunderbaum_node
2912
2926
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2913
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
2927
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
2914
2928
  */
2915
2929
  /** WunderbaumNode properties that can be passed with source data.
2916
2930
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -3870,13 +3884,20 @@ class WunderbaumNode {
3870
3884
  }
3871
3885
  }
3872
3886
  }
3873
- /**Load content of a lazy node. */
3887
+ /**
3888
+ * Load content of a lazy node.
3889
+ * If the node is already loaded, nothing happens.
3890
+ * @param [forceReload=false] If true, reload even if already loaded.
3891
+ */
3874
3892
  async loadLazy(forceReload = false) {
3875
3893
  const wasExpanded = this.expanded;
3876
3894
  assert(this.lazy, "load() requires a lazy node");
3877
- // _assert( forceReload || this.isUndefined(), "Pass forceReload=true to re-load a lazy node" );
3878
3895
  if (!forceReload && !this.isUnloaded()) {
3879
- return;
3896
+ return; // Already loaded: nothing to do
3897
+ }
3898
+ if (this.isLoading()) {
3899
+ this.logWarn("loadLazy() called while already loading: ignored.");
3900
+ return; // Already loading: prevent duplicate requests
3880
3901
  }
3881
3902
  if (this.isLoaded()) {
3882
3903
  this.resetLazy(); // Also collapses if currently expanded
@@ -3892,7 +3913,7 @@ class WunderbaumNode {
3892
3913
  }
3893
3914
  assert(isArray(source) || (source && source.url), "The lazyLoad event must return a node list, `{url: ...}`, or false.");
3894
3915
  await this.load(source);
3895
- this.setStatus(NodeStatusType.ok);
3916
+ this.setStatus(NodeStatusType.ok); // Also resets `this._isLoading`
3896
3917
  if (wasExpanded) {
3897
3918
  this.expanded = true;
3898
3919
  this.tree.update(ChangeType.structure);
@@ -3904,33 +3925,41 @@ class WunderbaumNode {
3904
3925
  catch (e) {
3905
3926
  this.logError("Error during loadLazy()", e);
3906
3927
  this._callEvent("error", { error: e });
3928
+ // Also resets `this._isLoading`:
3907
3929
  this.setStatus(NodeStatusType.error, { message: "" + e });
3908
3930
  }
3909
3931
  return;
3910
3932
  }
3911
- /** Alias for `logDebug` */
3933
+ /** Write to `console.log` with node name as prefix if opts.debugLevel >= 4.
3934
+ * @see {@link WunderbaumNode.logDebug}
3935
+ */
3912
3936
  log(...args) {
3913
- this.logDebug(...args);
3937
+ if (this.tree.options.debugLevel >= 4) {
3938
+ console.log(this.toString(), ...args); // eslint-disable-line no-console
3939
+ }
3914
3940
  }
3915
- /* Log to console if opts.debugLevel >= 4 */
3941
+ /** Write to `console.debug` with node name as prefix if opts.debugLevel >= 4
3942
+ * and browser console level includes debug/verbose messages.
3943
+ * @see {@link WunderbaumNode.log}
3944
+ */
3916
3945
  logDebug(...args) {
3917
3946
  if (this.tree.options.debugLevel >= 4) {
3918
- console.log(this.toString(), ...args); // eslint-disable-line no-console
3947
+ console.debug(this.toString(), ...args); // eslint-disable-line no-console
3919
3948
  }
3920
3949
  }
3921
- /* Log error to console. */
3950
+ /** Write to `console.error` with node name as prefix if opts.debugLevel >= 1. */
3922
3951
  logError(...args) {
3923
3952
  if (this.tree.options.debugLevel >= 1) {
3924
3953
  console.error(this.toString(), ...args); // eslint-disable-line no-console
3925
3954
  }
3926
3955
  }
3927
- /* Log to console if opts.debugLevel >= 3 */
3956
+ /** Write to `console.info` with node name as prefix if opts.debugLevel >= 3. */
3928
3957
  logInfo(...args) {
3929
3958
  if (this.tree.options.debugLevel >= 3) {
3930
3959
  console.info(this.toString(), ...args); // eslint-disable-line no-console
3931
3960
  }
3932
3961
  }
3933
- /* Log warning to console if opts.debugLevel >= 2 */
3962
+ /** Write to `console.warn` with node name as prefix if opts.debugLevel >= 2. */
3934
3963
  logWarn(...args) {
3935
3964
  if (this.tree.options.debugLevel >= 2) {
3936
3965
  console.warn(this.toString(), ...args); // eslint-disable-line no-console
@@ -4121,15 +4150,16 @@ class WunderbaumNode {
4121
4150
  }
4122
4151
  /** Remove all descendants of this node. */
4123
4152
  removeChildren() {
4153
+ var _a, _b;
4124
4154
  const tree = this.tree;
4125
4155
  if (!this.children) {
4126
4156
  return;
4127
4157
  }
4128
- if (tree.activeNode && tree.activeNode.isDescendantOf(this)) {
4158
+ if ((_a = tree.activeNode) === null || _a === void 0 ? void 0 : _a.isDescendantOf(this)) {
4129
4159
  tree.activeNode.setActive(false); // TODO: don't fire events
4130
4160
  }
4131
- if (tree.focusNode && tree.focusNode.isDescendantOf(this)) {
4132
- tree.focusNode = null;
4161
+ if ((_b = tree.focusNode) === null || _b === void 0 ? void 0 : _b.isDescendantOf(this)) {
4162
+ tree._setFocusNode(null);
4133
4163
  }
4134
4164
  // TODO: persist must take care to clear select and expand cookies
4135
4165
  // Unlink children to support GC
@@ -4728,7 +4758,7 @@ class WunderbaumNode {
4728
4758
  */
4729
4759
  async setActive(flag = true, options) {
4730
4760
  const tree = this.tree;
4731
- const prev = tree.activeNode;
4761
+ const prev = tree.getActiveNode();
4732
4762
  const retrigger = options === null || options === void 0 ? void 0 : options.retrigger; // Default: false
4733
4763
  const focusTree = options === null || options === void 0 ? void 0 : options.focusTree; // Default: false
4734
4764
  // const focusNode = options?.focusNode !== false; // Default: true
@@ -4751,7 +4781,7 @@ class WunderbaumNode {
4751
4781
  }) === false) {
4752
4782
  return;
4753
4783
  }
4754
- tree.activeNode = null;
4784
+ tree._setActiveNode(null);
4755
4785
  prev === null || prev === void 0 ? void 0 : prev.update(ChangeType.status);
4756
4786
  }
4757
4787
  }
@@ -4761,7 +4791,7 @@ class WunderbaumNode {
4761
4791
  }
4762
4792
  if (prev !== this) {
4763
4793
  if (flag) {
4764
- tree.activeNode = this;
4794
+ tree._setActiveNode(this);
4765
4795
  }
4766
4796
  prev === null || prev === void 0 ? void 0 : prev.update(ChangeType.status);
4767
4797
  this.update(ChangeType.status);
@@ -4770,7 +4800,7 @@ class WunderbaumNode {
4770
4800
  if (flag) {
4771
4801
  if (focusTree || edit) {
4772
4802
  tree.setFocus();
4773
- tree.focusNode = this;
4803
+ tree._setFocusNode(this);
4774
4804
  tree.focusNode.setFocus();
4775
4805
  }
4776
4806
  // if (focusNode || edit) {
@@ -4796,7 +4826,7 @@ class WunderbaumNode {
4796
4826
  this.isExpanded() &&
4797
4827
  this.getLevel() <= this.tree.getOption("minExpandLevel") &&
4798
4828
  !force) {
4799
- this.logDebug("Ignored collapse request below expandLevel.");
4829
+ this.logDebug("Ignored collapse request below minExpandLevel.");
4800
4830
  return;
4801
4831
  }
4802
4832
  if (!flag === !this.expanded) {
@@ -4835,7 +4865,7 @@ class WunderbaumNode {
4835
4865
  setFocus(flag = true) {
4836
4866
  assert(!!flag, "Blur is not yet implemented");
4837
4867
  const prev = this.tree.focusNode;
4838
- this.tree.focusNode = this;
4868
+ this.tree._setFocusNode(this);
4839
4869
  prev === null || prev === void 0 ? void 0 : prev.update();
4840
4870
  this.update();
4841
4871
  }
@@ -5288,7 +5318,7 @@ WunderbaumNode.sequence = 0;
5288
5318
  /*!
5289
5319
  * Wunderbaum - ext-edit
5290
5320
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
5291
- * v0.8.0, Thu, 11 Jan 2024 19:37:23 GMT (https://github.com/mar10/wunderbaum)
5321
+ * v0.8.2, Sat, 17 Feb 2024 07:32:06 GMT (https://github.com/mar10/wunderbaum)
5292
5322
  */
5293
5323
  // const START_MARKER = "\uFFF7";
5294
5324
  class EditExtension extends WunderbaumExtension {
@@ -5617,8 +5647,8 @@ class EditExtension extends WunderbaumExtension {
5617
5647
  * https://github.com/mar10/wunderbaum
5618
5648
  *
5619
5649
  * Released under the MIT license.
5620
- * @version v0.8.0
5621
- * @date Thu, 11 Jan 2024 19:37:23 GMT
5650
+ * @version v0.8.2
5651
+ * @date Sat, 17 Feb 2024 07:32:06 GMT
5622
5652
  */
5623
5653
  // import "./wunderbaum.scss";
5624
5654
  class WbSystemRoot extends WunderbaumNode {
@@ -5638,6 +5668,22 @@ class WbSystemRoot extends WunderbaumNode {
5638
5668
  * See also {@link WunderbaumOptions}.
5639
5669
  */
5640
5670
  class Wunderbaum {
5671
+ /** Currently active node if any.
5672
+ * Use @link {WunderbaumNode.setActive|setActive} to modify.
5673
+ */
5674
+ get activeNode() {
5675
+ var _a;
5676
+ // Check for deleted node, i.e. node.tree === null
5677
+ return ((_a = this._activeNode) === null || _a === void 0 ? void 0 : _a.tree) ? this._activeNode : null;
5678
+ }
5679
+ /** Current node hat has keyboard focus if any.
5680
+ * Use @link {WunderbaumNode.setFocus|setFocus()} to modify.
5681
+ */
5682
+ get focusNode() {
5683
+ var _a;
5684
+ // Check for deleted node, i.e. node.tree === null
5685
+ return ((_a = this._focusNode) === null || _a === void 0 ? void 0 : _a.tree) ? this._focusNode : null;
5686
+ }
5641
5687
  constructor(options) {
5642
5688
  this.enabled = true;
5643
5689
  /** Contains additional data that was sent as response to an Ajax source load request. */
@@ -5649,10 +5695,8 @@ class Wunderbaum {
5649
5695
  this.treeRowCount = 0;
5650
5696
  this._disableUpdateCount = 0;
5651
5697
  this._disableUpdateIgnoreCount = 0;
5652
- /** Currently active node if any. */
5653
- this.activeNode = null;
5654
- /** Current node hat has keyboard focus if any. */
5655
- this.focusNode = null;
5698
+ this._activeNode = null;
5699
+ this._focusNode = null;
5656
5700
  /** Shared properties, referenced by `node.type`. */
5657
5701
  this.types = {};
5658
5702
  /** List of column definitions. */
@@ -5678,10 +5722,6 @@ class Wunderbaum {
5678
5722
  this.lastQuicksearchTerm = "";
5679
5723
  // --- EDIT ---
5680
5724
  this.lastClickTime = 0;
5681
- /** Alias for {@link Wunderbaum.logDebug}.
5682
- * @alias Wunderbaum.logDebug
5683
- */
5684
- this.log = this.logDebug;
5685
5725
  const opts = (this.options = extend({
5686
5726
  id: null,
5687
5727
  source: null,
@@ -6071,7 +6111,8 @@ class Wunderbaum {
6071
6111
  /** Add node to tree's bookkeeping data structures. */
6072
6112
  _registerNode(node) {
6073
6113
  const key = node.key;
6074
- assert(key != null && !this.keyMap.has(key), `Missing or duplicate key: '${key}'.`);
6114
+ assert(key != null, `Missing key: '${node}'.`);
6115
+ assert(!this.keyMap.has(key), `Duplicate key: '${key}': ${node}.`);
6075
6116
  this.keyMap.set(key, node);
6076
6117
  const rk = node.refKey;
6077
6118
  if (rk != null) {
@@ -6352,8 +6393,8 @@ class Wunderbaum {
6352
6393
  this.keyMap.clear();
6353
6394
  this.refKeyMap.clear();
6354
6395
  this.treeRowCount = 0;
6355
- this.activeNode = null;
6356
- this.focusNode = null;
6396
+ this._activeNode = null;
6397
+ this._focusNode = null;
6357
6398
  // this.types = {};
6358
6399
  // this. columns =[];
6359
6400
  // this._columnsById = {};
@@ -6752,10 +6793,13 @@ class Wunderbaum {
6752
6793
  return null;
6753
6794
  }
6754
6795
  /**
6755
- * Return the currently active node or null.
6796
+ * Return the currently active node or null (alias for `tree.activeNode`).
6797
+ * Alias for {@link Wunderbaum.activeNode}.
6798
+ *
6756
6799
  * @see {@link WunderbaumNode.setActive}
6757
6800
  * @see {@link WunderbaumNode.isActive}
6758
- * @see {@link WunderbaumNode.getFocusNode}
6801
+ * @see {@link Wunderbaum.activeNode}
6802
+ * @see {@link Wunderbaum.focusNode}
6759
6803
  */
6760
6804
  getActiveNode() {
6761
6805
  return this.activeNode;
@@ -6768,7 +6812,11 @@ class Wunderbaum {
6768
6812
  }
6769
6813
  /**
6770
6814
  * Return the node that currently has keyboard focus or null.
6771
- * @see {@link WunderbaumNode.getActiveNode}
6815
+ * Alias for {@link Wunderbaum.focusNode}.
6816
+ * @see {@link WunderbaumNode.setFocus}
6817
+ * @see {@link WunderbaumNode.hasFocus}
6818
+ * @see {@link Wunderbaum.activeNode}
6819
+ * @see {@link Wunderbaum.focusNode}
6772
6820
  */
6773
6821
  getFocusNode() {
6774
6822
  return this.focusNode;
@@ -6874,19 +6922,30 @@ class Wunderbaum {
6874
6922
  }, true);
6875
6923
  return res;
6876
6924
  }
6877
- /** Log to console if opts.debugLevel >= 4 */
6878
- logDebug(...args) {
6925
+ /** Write to `console.log` with tree name as prefix if opts.debugLevel >= 4.
6926
+ * @see {@link Wunderbaum.logDebug}
6927
+ */
6928
+ log(...args) {
6879
6929
  if (this.options.debugLevel >= 4) {
6880
6930
  console.log(this.toString(), ...args); // eslint-disable-line no-console
6881
6931
  }
6882
6932
  }
6883
- /** Log error to console. */
6933
+ /** Write to `console.debug` with tree name as prefix if opts.debugLevel >= 4.
6934
+ * and browser console level includes debug/verbose messages.
6935
+ * @see {@link Wunderbaum.log}
6936
+ */
6937
+ logDebug(...args) {
6938
+ if (this.options.debugLevel >= 4) {
6939
+ console.debug(this.toString(), ...args); // eslint-disable-line no-console
6940
+ }
6941
+ }
6942
+ /** Write to `console.error` with tree name as prefix. */
6884
6943
  logError(...args) {
6885
6944
  if (this.options.debugLevel >= 1) {
6886
6945
  console.error(this.toString(), ...args); // eslint-disable-line no-console
6887
6946
  }
6888
6947
  }
6889
- /** Log to console if opts.debugLevel >= 3 */
6948
+ /** Write to `console.info` with tree name as prefix if opts.debugLevel >= 3. */
6890
6949
  logInfo(...args) {
6891
6950
  if (this.options.debugLevel >= 3) {
6892
6951
  console.info(this.toString(), ...args); // eslint-disable-line no-console
@@ -6905,7 +6964,7 @@ class Wunderbaum {
6905
6964
  console.timeEnd(this + ": " + label); // eslint-disable-line no-console
6906
6965
  }
6907
6966
  }
6908
- /** Log to console if opts.debugLevel >= 2 */
6967
+ /** Write to `console.warn` with tree name as prefix with if opts.debugLevel >= 2. */
6909
6968
  logWarn(...args) {
6910
6969
  if (this.options.debugLevel >= 2) {
6911
6970
  console.warn(this.toString(), ...args); // eslint-disable-line no-console
@@ -7043,6 +7102,10 @@ class Wunderbaum {
7043
7102
  }
7044
7103
  }
7045
7104
  }
7105
+ /* Set or remove keyboard focus to the tree container. @internal */
7106
+ _setActiveNode(node) {
7107
+ this._activeNode = node;
7108
+ }
7046
7109
  /** Set or remove keyboard focus to the tree container. */
7047
7110
  setActiveNode(key, flag = true, options) {
7048
7111
  var _a;
@@ -7057,6 +7120,10 @@ class Wunderbaum {
7057
7120
  this.element.blur();
7058
7121
  }
7059
7122
  }
7123
+ /* Set or remove keyboard focus to the tree container. @internal */
7124
+ _setFocusNode(node) {
7125
+ this._focusNode = node;
7126
+ }
7060
7127
  update(change, node, options) {
7061
7128
  // this.log(`update(${change}) node=${node}`);
7062
7129
  if (!(node instanceof WunderbaumNode)) {
@@ -7799,7 +7866,7 @@ class Wunderbaum {
7799
7866
  }
7800
7867
  Wunderbaum.sequence = 0;
7801
7868
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
7802
- Wunderbaum.version = "v0.8.0"; // Set to semver by 'grunt release'
7869
+ Wunderbaum.version = "v0.8.2"; // Set to semver by 'grunt release'
7803
7870
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
7804
7871
  Wunderbaum.util = util;
7805
7872