wunderbaum 0.5.1 → 0.5.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.
@@ -7,7 +7,7 @@
7
7
  /*!
8
8
  * Wunderbaum - util
9
9
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
10
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
10
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
11
11
  */
12
12
  /** @module util */
13
13
  /** Readable names for `MouseEvent.button` */
@@ -762,7 +762,7 @@
762
762
  /*!
763
763
  * Wunderbaum - types
764
764
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
765
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
765
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
766
766
  */
767
767
  /**
768
768
  * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
@@ -826,7 +826,7 @@
826
826
  /*!
827
827
  * Wunderbaum - wb_extension_base
828
828
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
829
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
829
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
830
830
  */
831
831
  class WunderbaumExtension {
832
832
  constructor(tree, id, defaults) {
@@ -1181,7 +1181,7 @@
1181
1181
  /*!
1182
1182
  * Wunderbaum - ext-filter
1183
1183
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1184
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
1184
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
1185
1185
  */
1186
1186
  const START_MARKER = "\uFFF7";
1187
1187
  const END_MARKER = "\uFFF8";
@@ -1348,7 +1348,6 @@
1348
1348
  p.setExpanded(true, {
1349
1349
  noAnimation: true,
1350
1350
  noEvents: true,
1351
- scrollIntoView: false,
1352
1351
  });
1353
1352
  p._filterAutoExpanded = true;
1354
1353
  }
@@ -1379,10 +1378,11 @@
1379
1378
  * [ext-filter] Re-apply current filter.
1380
1379
  */
1381
1380
  updateFilter() {
1381
+ var _a;
1382
1382
  let tree = this.tree;
1383
1383
  if (tree.filterMode &&
1384
1384
  this.lastFilterArgs &&
1385
- tree.options.filter.autoApply) {
1385
+ ((_a = tree.options.filter) === null || _a === void 0 ? void 0 : _a.autoApply)) {
1386
1386
  this._applyFilterNoUpdate.apply(this, this.lastFilterArgs);
1387
1387
  }
1388
1388
  else {
@@ -1412,15 +1412,14 @@
1412
1412
  delete node.match;
1413
1413
  delete node.subMatchCount;
1414
1414
  delete node.titleWithHighlight;
1415
- if (node.subMatchBadge) {
1416
- node.subMatchBadge.remove();
1417
- delete node.subMatchBadge;
1418
- }
1415
+ // if (node.subMatchBadge) {
1416
+ // node.subMatchBadge.remove();
1417
+ // delete node.subMatchBadge;
1418
+ // }
1419
1419
  if (node._filterAutoExpanded && node.expanded) {
1420
1420
  node.setExpanded(false, {
1421
1421
  noAnimation: true,
1422
1422
  noEvents: true,
1423
- scrollIntoView: false,
1424
1423
  });
1425
1424
  }
1426
1425
  delete node._filterAutoExpanded;
@@ -1474,7 +1473,7 @@
1474
1473
  /*!
1475
1474
  * Wunderbaum - ext-keynav
1476
1475
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1477
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
1476
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
1478
1477
  */
1479
1478
  const QUICKSEARCH_DELAY = 500;
1480
1479
  class KeynavExtension extends WunderbaumExtension {
@@ -1814,7 +1813,7 @@
1814
1813
  /*!
1815
1814
  * Wunderbaum - ext-logger
1816
1815
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1817
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
1816
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
1818
1817
  */
1819
1818
  class LoggerExtension extends WunderbaumExtension {
1820
1819
  constructor(tree) {
@@ -1855,7 +1854,7 @@
1855
1854
  /*!
1856
1855
  * Wunderbaum - common
1857
1856
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1858
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
1857
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
1859
1858
  */
1860
1859
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
1861
1860
  /**
@@ -2121,7 +2120,7 @@
2121
2120
  /*!
2122
2121
  * Wunderbaum - ext-dnd
2123
2122
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2124
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
2123
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
2125
2124
  */
2126
2125
  const nodeMimeType = "application/x-wunderbaum-node";
2127
2126
  class DndExtension extends WunderbaumExtension {
@@ -2142,6 +2141,7 @@
2142
2141
  preventRecursion: true,
2143
2142
  preventSameParent: false,
2144
2143
  preventVoidMoves: true,
2144
+ serializeClipboardData: true,
2145
2145
  scroll: true,
2146
2146
  scrollSensitivity: 20,
2147
2147
  // scrollnterval: 50, // Generste event every 50 ms
@@ -2150,13 +2150,13 @@
2150
2150
  sourceCopyHook: null,
2151
2151
  // Events (drag support)
2152
2152
  dragStart: null,
2153
- dragDrag: null,
2153
+ drag: null,
2154
2154
  dragEnd: null,
2155
2155
  // Events (drop support)
2156
2156
  dragEnter: null,
2157
2157
  dragOver: null,
2158
2158
  dragExpand: null,
2159
- dragDrop: null,
2159
+ drop: null,
2160
2160
  dragLeave: null, // Callback(targetNode, data)
2161
2161
  });
2162
2162
  // public dropMarkerElem?: HTMLElement;
@@ -2319,8 +2319,12 @@
2319
2319
  delete n.key;
2320
2320
  });
2321
2321
  nodeData._treeId = srcNode.tree.id;
2322
- const json = JSON.stringify(nodeData);
2323
- e.dataTransfer.setData(nodeMimeType, json);
2322
+ if (dndOpts.serializeClipboardData) {
2323
+ if (typeof dndOpts.serializeClipboardData === "function")
2324
+ e.dataTransfer.setData(nodeMimeType, dndOpts.serializeClipboardData(nodeData));
2325
+ else
2326
+ e.dataTransfer.setData(nodeMimeType, JSON.stringify(nodeData));
2327
+ }
2324
2328
  // e.dataTransfer!.setData("text/html", $(node.span).html());
2325
2329
  e.dataTransfer.setData("text/plain", srcNode.title);
2326
2330
  this.srcNode = srcNode;
@@ -2331,13 +2335,19 @@
2331
2335
  }, 0);
2332
2336
  // --- drag ---
2333
2337
  }
2334
- else if (e.type === "drag") ;
2338
+ else if (e.type === "drag") {
2339
+ if (dndOpts.drag)
2340
+ srcNode._callEvent("dnd.drag", { event: e });
2341
+ // --- dragend ---
2342
+ }
2335
2343
  else if (e.type === "dragend") {
2336
2344
  srcNode.setClass("wb-drag-source", false);
2337
2345
  this.srcNode = null;
2338
2346
  if (this.lastTargetNode) {
2339
2347
  this._leaveNode();
2340
2348
  }
2349
+ if (dndOpts.dragEnd)
2350
+ srcNode._callEvent("dnd.dragEnd", { event: e });
2341
2351
  }
2342
2352
  return true;
2343
2353
  }
@@ -2412,6 +2422,8 @@
2412
2422
  else if (e.type === "dragover") {
2413
2423
  const viewportY = e.clientY - this.tree.element.offsetTop;
2414
2424
  this.autoScroll(viewportY);
2425
+ if (dndOpts.dragOver)
2426
+ targetNode._callEvent("dnd.dragOver", { event: e });
2415
2427
  const region = this._calcDropRegion(e, this.lastAllowedDropRegions);
2416
2428
  this.lastDropRegion = region;
2417
2429
  if (dndOpts.autoExpandMS > 0 &&
@@ -2433,7 +2445,13 @@
2433
2445
  return false;
2434
2446
  // --- dragleave ---
2435
2447
  }
2436
- else if (e.type === "dragleave") ;
2448
+ else if (e.type === "dragleave") {
2449
+ // NOTE: we cannot trust this event, since it is always fired,
2450
+ // Instead we remove the marker on dragenter
2451
+ if (dndOpts.dragLeave)
2452
+ targetNode._callEvent("dnd.dragLeave", { event: e });
2453
+ // --- drop ---
2454
+ }
2437
2455
  else if (e.type === "drop") {
2438
2456
  e.stopPropagation(); // prevent browser from opening links?
2439
2457
  this._leaveNode();
@@ -2451,7 +2469,7 @@
2451
2469
  /*!
2452
2470
  * Wunderbaum - drag_observer
2453
2471
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2454
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
2472
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
2455
2473
  */
2456
2474
  /**
2457
2475
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2587,7 +2605,7 @@
2587
2605
  /*!
2588
2606
  * Wunderbaum - ext-grid
2589
2607
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2590
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
2608
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
2591
2609
  */
2592
2610
  class GridExtension extends WunderbaumExtension {
2593
2611
  constructor(tree) {
@@ -2624,7 +2642,7 @@
2624
2642
  /*!
2625
2643
  * Wunderbaum - deferred
2626
2644
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2627
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
2645
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
2628
2646
  */
2629
2647
  /**
2630
2648
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -2677,7 +2695,7 @@
2677
2695
  /*!
2678
2696
  * Wunderbaum - wunderbaum_node
2679
2697
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2680
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
2698
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
2681
2699
  */
2682
2700
  /** WunderbaumNode properties that can be passed with source data.
2683
2701
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -2982,7 +3000,7 @@
2982
3000
  async expandAll(flag = true, options) {
2983
3001
  const tree = this.tree;
2984
3002
  const minExpandLevel = this.tree.options.minExpandLevel;
2985
- let { depth = 99, loadLazy, force } = options !== null && options !== void 0 ? options : {};
3003
+ let { depth = 99, loadLazy, force, keepActiveNodeVisible = true, } = options !== null && options !== void 0 ? options : {};
2986
3004
  const expandOpts = {
2987
3005
  scrollIntoView: false,
2988
3006
  force: force,
@@ -3043,6 +3061,9 @@
3043
3061
  tree.enableUpdate(true);
3044
3062
  tree.logTimeEnd(tag);
3045
3063
  }
3064
+ if (tree.activeNode && keepActiveNodeVisible) {
3065
+ tree.activeNode.scrollIntoView();
3066
+ }
3046
3067
  }
3047
3068
  /**
3048
3069
  * Find all descendant nodes that match condition (excluding self).
@@ -3387,7 +3408,7 @@
3387
3408
  }
3388
3409
  /** Return true if this node has DOM representaion, i.e. is displayed in the viewport. */
3389
3410
  isRadio() {
3390
- return this.checkbox === "radio" || !!this.parent.radiogroup;
3411
+ return !!this.parent.radiogroup || this.getOption("checkbox") === "radio";
3391
3412
  }
3392
3413
  /** Return true if this node has DOM representaion, i.e. is displayed in the viewport. */
3393
3414
  isRendered() {
@@ -3482,7 +3503,7 @@
3482
3503
  for (const [key, value] of Object.entries(source)) {
3483
3504
  if (!RESERVED_TREE_SOURCE_KEYS.has(key)) {
3484
3505
  tree.data[key] = value;
3485
- tree.logDebug(`Add source.${key} to tree.data.${key}`);
3506
+ // tree.logDebug(`Add source.${key} to tree.data.${key}`);
3486
3507
  }
3487
3508
  }
3488
3509
  if (tree.options.selectMode === "hier") {
@@ -3670,7 +3691,6 @@
3670
3691
  */
3671
3692
  async makeVisible(options) {
3672
3693
  let i, dfd = new Deferred(), deferreds = [], parents = this.getParentList(false, false), len = parents.length, noAnimation = getOption(options, "noAnimation", false), scroll = getOption(options, "scrollIntoView", true);
3673
- // scroll = !(options && options.scrollIntoView === false);
3674
3694
  // Expand bottom-up, so only the top node is animated
3675
3695
  for (i = len - 1; i >= 0; i--) {
3676
3696
  // self.debug("pushexpand" + parents[i]);
@@ -3943,7 +3963,7 @@
3943
3963
  }
3944
3964
  else if (TEST_IMG.test(icon)) {
3945
3965
  // Image URL
3946
- iconSpan = elemFromHtml(`<img src="${icon}" class="wb-icon">`);
3966
+ iconSpan = elemFromHtml(`<i class="wb-icon" style="background-image: url('${icon}');">`);
3947
3967
  }
3948
3968
  else {
3949
3969
  // Class name
@@ -3991,7 +4011,6 @@
3991
4011
  const tree = this.tree;
3992
4012
  const treeOptions = tree.options;
3993
4013
  const checkbox = this.getOption("checkbox");
3994
- // const checkbox = this.getOption("checkbox") !== false;
3995
4014
  const columns = tree.columns;
3996
4015
  const level = this.getLevel();
3997
4016
  let elem;
@@ -4206,27 +4225,31 @@
4206
4225
  rowDiv.classList.add(...typeInfo.classes);
4207
4226
  }
4208
4227
  if (expanderSpan) {
4228
+ let image = null;
4209
4229
  if (this._isLoading) {
4210
- expanderSpan.className = "wb-expander " + iconMap.loading;
4230
+ image = iconMap.loading;
4211
4231
  }
4212
4232
  else if (this.isExpandable(false)) {
4213
4233
  if (this.expanded) {
4214
- expanderSpan.className = "wb-expander " + iconMap.expanderExpanded;
4234
+ image = iconMap.expanderExpanded;
4215
4235
  }
4216
4236
  else {
4217
- expanderSpan.className = "wb-expander " + iconMap.expanderCollapsed;
4237
+ image = iconMap.expanderCollapsed;
4218
4238
  }
4219
4239
  }
4220
4240
  else if (this.lazy && this.children == null) {
4221
- expanderSpan.className = "wb-expander " + iconMap.expanderLazy;
4241
+ image = iconMap.expanderLazy;
4222
4242
  }
4223
- else {
4243
+ if (image == null)
4224
4244
  expanderSpan.classList.add("wb-indent");
4225
- }
4245
+ else if (TEST_IMG.test(image))
4246
+ expanderSpan.style.backgroundImage = `url('${image}')`;
4247
+ else
4248
+ expanderSpan.className = "wb-expander " + image;
4226
4249
  }
4227
4250
  if (checkboxSpan) {
4228
4251
  let cbclass = "wb-checkbox ";
4229
- if (this.parent.radiogroup) {
4252
+ if (this.isRadio()) {
4230
4253
  cbclass += "wb-radio ";
4231
4254
  if (this.selected) {
4232
4255
  cbclass += iconMap.radioChecked;
@@ -4515,7 +4538,7 @@
4515
4538
  const updateOpts = { immediate: immediate };
4516
4539
  // const updateOpts = { immediate: !!util.getOption(options, "immediate") };
4517
4540
  this.tree.update(ChangeType.structure, updateOpts);
4518
- if (flag && scrollIntoView !== false) {
4541
+ if (flag && scrollIntoView) {
4519
4542
  const lastChild = this.getLastChild();
4520
4543
  if (lastChild) {
4521
4544
  this.tree.updatePendingModifications();
@@ -4988,7 +5011,7 @@
4988
5011
  /*!
4989
5012
  * Wunderbaum - ext-edit
4990
5013
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
4991
- * v0.5.1, Sat, 16 Sep 2023 19:08:55 GMT (https://github.com/mar10/wunderbaum)
5014
+ * v0.5.2, Mon, 09 Oct 2023 18:32:56 GMT (https://github.com/mar10/wunderbaum)
4992
5015
  */
4993
5016
  // const START_MARKER = "\uFFF7";
4994
5017
  class EditExtension extends WunderbaumExtension {
@@ -5284,8 +5307,8 @@
5284
5307
  * https://github.com/mar10/wunderbaum
5285
5308
  *
5286
5309
  * Released under the MIT license.
5287
- * @version v0.5.1
5288
- * @date Sat, 16 Sep 2023 19:08:55 GMT
5310
+ * @version v0.5.2
5311
+ * @date Mon, 09 Oct 2023 18:32:56 GMT
5289
5312
  */
5290
5313
  // import "./wunderbaum.scss";
5291
5314
  class WbSystemRoot extends WunderbaumNode {
@@ -5571,7 +5594,9 @@
5571
5594
  node.setActive(true, { event: e });
5572
5595
  }
5573
5596
  if (info.region === NodeRegion.expander) {
5574
- node.setExpanded(!node.isExpanded());
5597
+ node.setExpanded(!node.isExpanded(), {
5598
+ scrollIntoView: options.scrollIntoViewOnExpandClick !== false,
5599
+ });
5575
5600
  }
5576
5601
  else if (info.region === NodeRegion.checkbox) {
5577
5602
  node.toggleSelected();
@@ -7033,17 +7058,15 @@
7033
7058
  }
7034
7059
  else {
7035
7060
  this.log("_updateViewportImmediately():", pending);
7036
- let height = this.listContainerElement.clientHeight;
7037
- // We cannot get the height for absolute positioned parent, so look at first col
7038
- // let headerHeight = this.headerElement.clientHeight
7039
- // let headerHeight = this.headerElement.children[0].children[0].clientHeight;
7040
- // const headerHeight = this.options.headerHeightPx;
7041
- const headerHeight = this.headerElement.clientHeight; // May be 0
7042
- const wantHeight = this.element.clientHeight - headerHeight - FIX_ADJUST_HEIGHT;
7043
- if (Math.abs(height - wantHeight) > 1.0) {
7044
- // this.log("resize", height, wantHeight);
7045
- this.listContainerElement.style.height = wantHeight + "px";
7046
- height = wantHeight;
7061
+ if (this.options.adjustHeight !== false) {
7062
+ let height = this.listContainerElement.clientHeight;
7063
+ const headerHeight = this.headerElement.clientHeight; // May be 0
7064
+ const wantHeight = this.element.clientHeight - headerHeight - FIX_ADJUST_HEIGHT;
7065
+ if (Math.abs(height - wantHeight) > 1.0) {
7066
+ // this.log("resize", height, wantHeight);
7067
+ this.listContainerElement.style.height = wantHeight + "px";
7068
+ height = wantHeight;
7069
+ }
7047
7070
  }
7048
7071
  // console.profile(`_updateViewportImmediately()`)
7049
7072
  if (pending.has(RF.clearMarkup)) {
@@ -7419,7 +7442,7 @@
7419
7442
  }
7420
7443
  Wunderbaum.sequence = 0;
7421
7444
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
7422
- Wunderbaum.version = "v0.5.1"; // Set to semver by 'grunt release'
7445
+ Wunderbaum.version = "v0.5.2"; // Set to semver by 'grunt release'
7423
7446
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
7424
7447
  Wunderbaum.util = util;
7425
7448