wunderbaum 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@
294
294
  /*!
295
295
  * Wunderbaum - util
296
296
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
297
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
297
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
298
298
  */
299
299
  /** @module util */
300
300
  /** Readable names for `MouseEvent.button` */
@@ -1148,7 +1148,7 @@
1148
1148
  /*!
1149
1149
  * Wunderbaum - types
1150
1150
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1151
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
1151
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1152
1152
  */
1153
1153
  /**
1154
1154
  * Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
@@ -1212,7 +1212,7 @@
1212
1212
  /*!
1213
1213
  * Wunderbaum - wb_extension_base
1214
1214
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1215
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
1215
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1216
1216
  */
1217
1217
  class WunderbaumExtension {
1218
1218
  constructor(tree, id, defaults) {
@@ -1271,7 +1271,7 @@
1271
1271
  /*!
1272
1272
  * Wunderbaum - ext-filter
1273
1273
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1274
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
1274
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1275
1275
  */
1276
1276
  const START_MARKER = "\uFFF7";
1277
1277
  const END_MARKER = "\uFFF8";
@@ -1596,7 +1596,7 @@
1596
1596
  /*!
1597
1597
  * Wunderbaum - ext-keynav
1598
1598
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1599
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
1599
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1600
1600
  */
1601
1601
  const QUICKSEARCH_DELAY = 500;
1602
1602
  class KeynavExtension extends WunderbaumExtension {
@@ -1960,7 +1960,7 @@
1960
1960
  /*!
1961
1961
  * Wunderbaum - ext-logger
1962
1962
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1963
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
1963
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1964
1964
  */
1965
1965
  class LoggerExtension extends WunderbaumExtension {
1966
1966
  constructor(tree) {
@@ -2002,7 +2002,7 @@
2002
2002
  /*!
2003
2003
  * Wunderbaum - ext-dnd
2004
2004
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2005
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
2005
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2006
2006
  */
2007
2007
  const nodeMimeType = "application/x-wunderbaum-node";
2008
2008
  class DndExtension extends WunderbaumExtension {
@@ -2452,7 +2452,7 @@
2452
2452
  /*!
2453
2453
  * Wunderbaum - drag_observer
2454
2454
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2455
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
2455
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2456
2456
  */
2457
2457
  /**
2458
2458
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2601,7 +2601,7 @@
2601
2601
  /*!
2602
2602
  * Wunderbaum - common
2603
2603
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2604
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
2604
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2605
2605
  */
2606
2606
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
2607
2607
  /**
@@ -2941,7 +2941,7 @@
2941
2941
  /*!
2942
2942
  * Wunderbaum - ext-grid
2943
2943
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2944
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
2944
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2945
2945
  */
2946
2946
  class GridExtension extends WunderbaumExtension {
2947
2947
  constructor(tree) {
@@ -3032,7 +3032,7 @@
3032
3032
  /*!
3033
3033
  * Wunderbaum - deferred
3034
3034
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3035
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
3035
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
3036
3036
  */
3037
3037
  /**
3038
3038
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -3085,7 +3085,7 @@
3085
3085
  /*!
3086
3086
  * Wunderbaum - wunderbaum_node
3087
3087
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3088
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
3088
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
3089
3089
  */
3090
3090
  /** WunderbaumNode properties that can be passed with source data.
3091
3091
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -3417,54 +3417,65 @@
3417
3417
  startEditTitle() {
3418
3418
  this.tree._callMethod("edit.startEditTitle", this);
3419
3419
  }
3420
- /** Call `setExpanded()` on all descendant nodes. */
3420
+ /**
3421
+ * Call `setExpanded()` on all descendant nodes.
3422
+ *
3423
+ * @param flag true to expand, false to collapse.
3424
+ * @param options Additional options.
3425
+ * @see {@link Wunderbaum.expandAll}
3426
+ * @see {@link WunderbaumNode.setExpanded}
3427
+ */
3421
3428
  async expandAll(flag = true, options) {
3422
3429
  const tree = this.tree;
3423
- const minExpandLevel = this.tree.options.minExpandLevel;
3424
- const { depth = 99, loadLazy, force, keepActiveNodeVisible = true, } = options !== null && options !== void 0 ? options : {};
3430
+ const { collapseOthers, deep, depth, force, keepActiveNodeVisible = true, loadLazy, resetLazy, } = options !== null && options !== void 0 ? options : {};
3431
+ // limit expansion level to `depth` (or tree.minExpandLevel). Default: unlimited
3432
+ const treeLevel = this.tree.options.minExpandLevel || null; // 0 -> null
3433
+ const minLevel = depth !== null && depth !== void 0 ? depth : (force ? null : treeLevel);
3425
3434
  const expandOpts = {
3426
- scrollIntoView: false, // don't scroll very node on iteration
3435
+ deep: deep,
3427
3436
  force: force,
3428
3437
  loadLazy: loadLazy,
3438
+ resetLazy: resetLazy,
3439
+ scrollIntoView: false, // don't scroll every node while iterating
3429
3440
  };
3430
- // this.logInfo(`expandAll(${flag})`);
3441
+ this.logInfo(`expandAll(${flag}, depth=${depth}, minLevel=${minLevel})`);
3442
+ assert(!(flag && deep != null && !collapseOthers), "Expanding with `deep` option is not supported (implied by the `depth` option).");
3431
3443
  // Expand all direct children in parallel:
3432
3444
  async function _iter(n, level) {
3433
3445
  var _a;
3434
- // n.logInfo(` _iter(${level})`);
3435
- if (level === 0) {
3436
- return;
3437
- }
3438
- // if (!flag && minExpandLevel && !force && n.getLevel() <= minExpandLevel) {
3439
- // return; // Do not collapse until minExpandLevel
3440
- // }
3441
- const level_1 = level == null ? null : level - 1;
3446
+ // n.logInfo(` _iter(level=${level})`);
3442
3447
  const promises = [];
3443
3448
  (_a = n.children) === null || _a === void 0 ? void 0 : _a.forEach((cn) => {
3444
3449
  if (flag) {
3445
- if (!cn.expanded && (cn.children || (loadLazy && cn.lazy))) {
3450
+ if (!cn.expanded &&
3451
+ (minLevel == null || level < minLevel) &&
3452
+ (cn.children || (loadLazy && cn.lazy))) {
3446
3453
  // Node is collapsed and may be expanded (i.e. has children or is lazy)
3447
3454
  // Expanding may be async, so we store the promise.
3448
3455
  // Also the recursion is delayed until expansion finished.
3449
3456
  const p = cn.setExpanded(true, expandOpts);
3450
3457
  promises.push(p);
3451
- p.then(async () => {
3452
- await _iter(cn, level_1);
3453
- });
3458
+ if (depth == null) {
3459
+ p.then(async () => {
3460
+ await _iter(cn, level + 1);
3461
+ });
3462
+ }
3454
3463
  }
3455
3464
  else {
3456
3465
  // We don't expand the node, but still visit descendants.
3457
3466
  // There we may find lazy nodes, so we
3458
- promises.push(_iter(cn, level_1));
3467
+ promises.push(_iter(cn, level + 1));
3459
3468
  }
3460
3469
  }
3461
3470
  else {
3462
3471
  // Collapsing is always synchronous, so no promises required
3463
- if (!minExpandLevel || force || cn.getLevel() > minExpandLevel) {
3464
- // Do not collapse until minExpandLevel
3472
+ // Do not collapse until minExpandLevel
3473
+ if (minLevel == null || level >= minLevel) {
3465
3474
  cn.setExpanded(false, expandOpts);
3466
3475
  }
3467
- _iter(cn, level_1); // recursion, even if cn was already collapsed
3476
+ if ((minLevel != null && level < minLevel) || deep) {
3477
+ _iter(cn, level + 1); // recursion, even if cn was already collapsed
3478
+ }
3468
3479
  }
3469
3480
  });
3470
3481
  return new Promise((resolve) => {
@@ -3473,10 +3484,15 @@
3473
3484
  });
3474
3485
  });
3475
3486
  }
3476
- const tag = tree.logTime(`${this}.expandAll(${flag})`);
3487
+ const tag = tree.logTime(`${this}.expandAll(${flag}, depth=${depth})`);
3477
3488
  try {
3478
3489
  tree.enableUpdate(false);
3479
- await _iter(this, depth);
3490
+ await _iter(this, 0);
3491
+ if (collapseOthers) {
3492
+ assert(flag, "Option `collapseOthers` requires flag=true");
3493
+ assert(minLevel != null, "Option `collapseOthers` requires `depth` or `minExpandLevel`");
3494
+ this.expandAll(false, { depth: minLevel });
3495
+ }
3480
3496
  }
3481
3497
  finally {
3482
3498
  tree.enableUpdate(true);
@@ -4965,7 +4981,7 @@
4965
4981
  const orgEvent = options === null || options === void 0 ? void 0 : options.event; // Default: null
4966
4982
  const colIdx = options === null || options === void 0 ? void 0 : options.colIdx; // Default: null
4967
4983
  const edit = options === null || options === void 0 ? void 0 : options.edit; // Default: false
4968
- assert(!colIdx || tree.isCellNav(), "colIdx requires cellNav");
4984
+ // util.assert(!colIdx || tree.isCellNav(), "colIdx requires cellNav");
4969
4985
  assert(!edit || colIdx != null, "edit requires colIdx");
4970
4986
  if (!noEvents) {
4971
4987
  if (flag) {
@@ -5019,7 +5035,7 @@
5019
5035
  * Expand or collapse this node.
5020
5036
  */
5021
5037
  async setExpanded(flag = true, options) {
5022
- const { force, scrollIntoView, immediate } = options !== null && options !== void 0 ? options : {};
5038
+ const { force, scrollIntoView, immediate, resetLazy } = options !== null && options !== void 0 ? options : {};
5023
5039
  const sendEvents = !(options === null || options === void 0 ? void 0 : options.noEvents); // Default: send events
5024
5040
  if (!flag &&
5025
5041
  this.isExpanded() &&
@@ -5042,6 +5058,9 @@
5042
5058
  if (flag && this.lazy && this.children == null) {
5043
5059
  await this.loadLazy();
5044
5060
  }
5061
+ else if (!flag && resetLazy && this.lazy && this.children) {
5062
+ this.resetLazy();
5063
+ }
5045
5064
  this.expanded = flag;
5046
5065
  const updateOpts = { immediate: immediate };
5047
5066
  // const updateOpts = { immediate: !!util.getOption(options, "immediate") };
@@ -5612,7 +5631,7 @@
5612
5631
  /*!
5613
5632
  * Wunderbaum - ext-edit
5614
5633
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
5615
- * v0.11.1, Fri, 27 Dec 2024 22:58:06 GMT (https://github.com/mar10/wunderbaum)
5634
+ * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
5616
5635
  */
5617
5636
  // const START_MARKER = "\uFFF7";
5618
5637
  class EditExtension extends WunderbaumExtension {
@@ -5947,8 +5966,8 @@
5947
5966
  * https://github.com/mar10/wunderbaum
5948
5967
  *
5949
5968
  * Released under the MIT license.
5950
- * @version v0.11.1
5951
- * @date Fri, 27 Dec 2024 22:58:06 GMT
5969
+ * @version v0.12.0
5970
+ * @date Sun, 12 Jan 2025 10:51:41 GMT
5952
5971
  */
5953
5972
  // import "./wunderbaum.scss";
5954
5973
  class WbSystemRoot extends WunderbaumNode {
@@ -6281,7 +6300,10 @@
6281
6300
  false) {
6282
6301
  return false;
6283
6302
  }
6284
- if (node && info.colIdx === 0 && node.isExpandable()) {
6303
+ if (node &&
6304
+ info.colIdx === 0 &&
6305
+ node.isExpandable() &&
6306
+ info.region !== NodeRegion.expander) {
6285
6307
  this._callMethod("edit._stopEditTitle");
6286
6308
  node.setExpanded(!node.isExpanded());
6287
6309
  }
@@ -8270,7 +8292,7 @@
8270
8292
  }
8271
8293
  Wunderbaum.sequence = 0;
8272
8294
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
8273
- Wunderbaum.version = "v0.11.1"; // Set to semver by 'grunt release'
8295
+ Wunderbaum.version = "v0.12.0"; // Set to semver by 'grunt release'
8274
8296
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
8275
8297
  Wunderbaum.util = util;
8276
8298